summaryrefslogtreecommitdiffstats
path: root/meta-selftest
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2017-11-22 15:59:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-12-02 11:25:33 +0000
commitd39a30177842e07a1c5037308a01d5e7dbc573a5 (patch)
treed7f951f29ff3b5568a884a614b362900e4e0ecab /meta-selftest
parent6436ffbb0236964f47fa2301feb1a7465e16aaff (diff)
downloadpoky-d39a30177842e07a1c5037308a01d5e7dbc573a5.tar.gz
postinst: fix and simplify the postinst test recipe
Reduce the number of packages, and fix some syntax and logic errors in the scripts. (From OE-Core rev: 228f5f072218823aa9d47f2fb1dcde584fde7a44) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta-selftest')
-rw-r--r--meta-selftest/recipes-test/postinst/postinst_1.0.bb158
1 files changed, 51 insertions, 107 deletions
diff --git a/meta-selftest/recipes-test/postinst/postinst_1.0.bb b/meta-selftest/recipes-test/postinst/postinst_1.0.bb
index 6d49734277..112aa08c80 100644
--- a/meta-selftest/recipes-test/postinst/postinst_1.0.bb
+++ b/meta-selftest/recipes-test/postinst/postinst_1.0.bb
@@ -1,126 +1,70 @@
1SUMMARY = "Packages to exercise postinstall functions"
1LICENSE = "MIT" 2LICENSE = "MIT"
2ALLOW_EMPTY_${PN}-at-rootfs = "1" 3
4inherit allarch
5
6PACKAGES = "${PN}-rootfs ${PN}-delayed-a ${PN}-delayed-b"
7
8ALLOW_EMPTY_${PN}-rootfs = "1"
3ALLOW_EMPTY_${PN}-delayed-a = "1" 9ALLOW_EMPTY_${PN}-delayed-a = "1"
4ALLOW_EMPTY_${PN}-delayed-b = "1" 10ALLOW_EMPTY_${PN}-delayed-b = "1"
5ALLOW_EMPTY_${PN}-delayed-d = "1" 11
6ALLOW_EMPTY_${PN}-delayed-p = "1" 12RDEPENDS_${PN}-delayed-a = "${PN}-rootfs"
7ALLOW_EMPTY_${PN}-delayed-t = "1"
8
9PACKAGES += "${PN}-at-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-delayed-d ${PN}-delayed-p ${PN}-delayed-t"
10PROVIDES += "${PN}-at-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-delayed-d ${PN}-delayed-p ${PN}-delayed-t"
11FILES_${PN}-delayed-a = ""
12FILES_${PN}-delayed-b = ""
13FILES_${PN}-delayed-d = ""
14FILES_${PN}-delayed-p = ""
15FILES_${PN}-delayed-t = ""
16
17# Runtime dependencies
18RDEPENDS_${PN}-delayed-a = "${PN}-at-rootfs"
19RDEPENDS_${PN}-delayed-b = "${PN}-delayed-a" 13RDEPENDS_${PN}-delayed-b = "${PN}-delayed-a"
20RDEPENDS_${PN}-delayed-d = "${PN}-delayed-b" 14
21RDEPENDS_${PN}-delayed-p = "${PN}-delayed-d" 15TESTDIR = "${sysconfdir}/postinst-test"
22RDEPENDS_${PN}-delayed-t = "${PN}-delayed-p" 16
23 17# At rootfs time touch $TESTDIR/rootfs. Errors if the file already exists, or
24# Main recipe post-install 18# if the function runs on first boot.
25pkg_postinst_${PN}-at-rootfs () { 19pkg_postinst_${PN}-rootfs () {
26 tfile="/etc/postinsta-test" 20 set -e
27 touch "$D"/this-was-created-at-rootfstime 21
28 if test "x$D" != "x" then 22 if [ -z "$D" ]; then
29 # Need to run on first boot 23 echo "${PN}-rootfs should have finished at rootfs time"
24 exit 1
25 fi
26
27 if [ -e $D${TESTDIR}/rootfs ]; then
28 echo "$D${TESTDIR}/rootfs exists, but should not"
30 exit 1 29 exit 1
31 else
32 echo "lets write postinst" > $tfile
33 fi 30 fi
31
32 mkdir -p $D${TESTDIR}
33 touch $D${TESTDIR}/rootfs
34} 34}
35 35
36# Dependency recipes post-installs 36# Depends on rootfs, delays until first boot, verifies that the rootfs file was
37# written.
37pkg_postinst_${PN}-delayed-a () { 38pkg_postinst_${PN}-delayed-a () {
38 efile="/etc/postinst-test" 39 set -e
39 tfile="/etc/postinsta-test" 40
40 rdeps="postinst" 41 if [ -n "$D" ]; then
41 42 echo "Delaying ${PN}-delayed-a until first boot"
42 if test "x$D" != "x"; then
43 # Need to run on first boot
44 exit 1
45 else
46 touch /etc/this-was-created-at-first-boot
47 if test -e $efile ; then
48 echo 'success' > $tfile
49 else
50 echo 'fail to install $rdeps first!' >&2
51 exit 1 43 exit 1
52 fi 44 fi
53 fi
54}
55 45
56pkg_postinst_${PN}-delayed-b () { 46 if [ ! -e ${TESTDIR}/rootfs ]; then
57 efile="/etc/postinsta-test" 47 echo "${PN}-delayed-a: ${TESTDIR}/rootfs not found"
58 tfile="/etc/postinstb-test"
59 rdeps="postinsta"
60
61 if test "x$D" != "x"; then
62 # Need to run on first boot
63 exit 1
64 else
65 if test -e $efile ; then
66 echo 'success' > $tfile
67 else
68 echo 'fail to install $rdeps first!' >&2
69 exit 1 48 exit 1
70 fi 49 fi
71 fi 50
51 touch ${TESTDIR}/delayed-a
72} 52}
73 53
74pkg_postinst_${PN}-delayed-d () { 54# Depends on delayed-a, delays until first boot, verifies that the delayed-a file was
75 efile="/etc/postinstb-test" 55# written. This verifies the ordering between delayed postinsts.
76 tfile="/etc/postinstd-test" 56pkg_postinst_${PN}-delayed-b () {
77 rdeps="postinstb" 57 set -e
78 58
79 if test "x$D" != "x"; then 59 if [ -n "$D" ]; then
80 # Need to run on first boot 60 echo "Delaying ${PN}-delayed-b until first boot"
81 exit 1
82 else
83 if test -e $efile ; then
84 echo 'success' > $tfile
85 else
86 echo 'fail to install $rdeps first!' >&2
87 exit 1 61 exit 1
88 fi 62 fi
89 fi
90}
91 63
92pkg_postinst_${PN}-delayed-p () { 64 if [ ! -e ${TESTDIR}/delayed-a ]; then
93 efile="/etc/postinstd-test" 65 echo "${PN}-delayed-b: ${TESTDIR}/delayed-a not found"
94 tfile="/etc/postinstp-test"
95 rdeps="postinstd"
96
97 if test "x$D" != "x"; then
98 # Need to run on first boot
99 exit 1
100 else
101 if test -e $efile ; then
102 echo 'success' > $tfile
103 else
104 echo 'fail to install $rdeps first!' >&2
105 exit 1 66 exit 1
106 fi 67 fi
107 fi
108}
109 68
110pkg_postinst_${PN}-delayed-t () { 69 touch ${TESTDIR}/delayed-b
111 efile="/etc/postinstp-test"
112 tfile="/etc/postinstt-test"
113 rdeps="postinstp"
114
115 if test "x$D" != "x"; then
116 # Need to run on first boot
117 exit 1
118 else
119 if test -e $efile ; then
120 echo 'success' > $tfile
121 else
122 echo 'fail to install $rdeps first!' >&2
123 exit 1
124 fi
125 fi
126} 70}