[2/3] postinst: fix and simplify the postinst test recipe

Message ID 20171122160414.14093-2-ross.burton@intel.com
State Accepted
Commit 228f5f072218823aa9d47f2fb1dcde584fde7a44
Headers show
Series
  • [1/3] oeqa/commands: don't break if get_bb_vars is passed a tuple
Related show

Commit Message

Ross Burton Nov. 22, 2017, 4:04 p.m.
Reduce the number of packages, and fix some syntax and logic errors in the
scripts.

Signed-off-by: Ross Burton <ross.burton@intel.com>

---
 .../recipes-test/postinst/postinst_1.0.bb          | 158 +++++++--------------
 1 file changed, 51 insertions(+), 107 deletions(-)

-- 
2.11.0

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Comments

Alexander Kanavin Nov. 22, 2017, 4:09 p.m. | #1
On 11/22/2017 06:04 PM, Ross Burton wrote:

> +    if [ -n "$D" ]; then

> +        echo "Delaying ${PN}-delayed-b until first boot"

>           exit 1

> -      fi


I still think this 'exit 1' madness should be fixed. But maybe some 
other time.

Alex
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Ross Burton Nov. 22, 2017, 4:09 p.m. | #2
On 22 November 2017 at 16:09, Alexander Kanavin <
alexander.kanavin@linux.intel.com> wrote:

> On 11/22/2017 06:04 PM, Ross Burton wrote:

>

> +    if [ -n "$D" ]; then

>> +        echo "Delaying ${PN}-delayed-b until first boot"

>>           exit 1

>> -      fi

>>

>

> I still think this 'exit 1' madness should be fixed. But maybe some other

> time.

>


Yes, agreed totally.

Ross
<div dir="ltr">On 22 November 2017 at 16:09, Alexander Kanavin <span dir="ltr">&lt;<a href="mailto:alexander.kanavin@linux.intel.com" target="_blank">alexander.kanavin@linux.intel.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 11/22/2017 06:04 PM, Ross Burton wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    if [ -n &quot;$D&quot; ]; then<br>
+        echo &quot;Delaying ${PN}-delayed-b until first boot&quot;<br>
          exit 1<br>
-      fi<br>
</blockquote>
<br></span>
I still think this &#39;exit 1&#39; madness should be fixed. But maybe some other time.<br></blockquote><div><br></div><div>Yes, agreed totally.</div><div><br></div><div>Ross </div></div></div></div>
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Alexander Kanavin Nov. 22, 2017, 4:13 p.m. | #3
On 11/22/2017 06:09 PM, Burton, Ross wrote:

>         +    if [ -n "$D" ]; then
>         +        echo "Delaying ${PN}-delayed-b until first boot"
>                    exit 1
>         -      fi
> 
> 
>     I still think this 'exit 1' madness should be fixed. But maybe some
>     other time.
> 
> 
> Yes, agreed totally.

In the meantime, I'll rebase my patchset that does it to these changes 
you made to the test :)

https://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=akanavin/dnf-rpm4-postinst-fix&id=a7f61bc88e5dd1668e0f8adee8ed5e06d2b4989c

from

https://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=akanavin/dnf-rpm4-postinst-fix


Alex

Patch

diff --git a/meta-selftest/recipes-test/postinst/postinst_1.0.bb b/meta-selftest/recipes-test/postinst/postinst_1.0.bb
index 6d497342779..112aa08c80f 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 @@ 
+SUMMARY = "Packages to exercise postinstall functions"
 LICENSE = "MIT"
-ALLOW_EMPTY_${PN}-at-rootfs = "1"
+
+inherit allarch
+
+PACKAGES = "${PN}-rootfs ${PN}-delayed-a ${PN}-delayed-b"
+
+ALLOW_EMPTY_${PN}-rootfs = "1"
 ALLOW_EMPTY_${PN}-delayed-a = "1"
 ALLOW_EMPTY_${PN}-delayed-b = "1"
-ALLOW_EMPTY_${PN}-delayed-d = "1"
-ALLOW_EMPTY_${PN}-delayed-p = "1"
-ALLOW_EMPTY_${PN}-delayed-t = "1"
-
-PACKAGES += "${PN}-at-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-delayed-d ${PN}-delayed-p ${PN}-delayed-t"
-PROVIDES += "${PN}-at-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-delayed-d ${PN}-delayed-p ${PN}-delayed-t"
-FILES_${PN}-delayed-a = ""
-FILES_${PN}-delayed-b = ""
-FILES_${PN}-delayed-d = ""
-FILES_${PN}-delayed-p = ""
-FILES_${PN}-delayed-t = ""
-
-# Runtime dependencies
-RDEPENDS_${PN}-delayed-a = "${PN}-at-rootfs"
+
+RDEPENDS_${PN}-delayed-a = "${PN}-rootfs"
 RDEPENDS_${PN}-delayed-b = "${PN}-delayed-a"
-RDEPENDS_${PN}-delayed-d = "${PN}-delayed-b"
-RDEPENDS_${PN}-delayed-p = "${PN}-delayed-d"
-RDEPENDS_${PN}-delayed-t = "${PN}-delayed-p"
-
-# Main recipe post-install
-pkg_postinst_${PN}-at-rootfs () {
-    tfile="/etc/postinsta-test"
-    touch "$D"/this-was-created-at-rootfstime
-    if test "x$D" != "x" then
-        # Need to run on first boot
+
+TESTDIR = "${sysconfdir}/postinst-test"
+
+# At rootfs time touch $TESTDIR/rootfs.  Errors if the file already exists, or
+# if the function runs on first boot.
+pkg_postinst_${PN}-rootfs () {
+    set -e
+
+    if [ -z "$D" ]; then
+        echo "${PN}-rootfs should have finished at rootfs time"
+        exit 1
+    fi
+
+    if [ -e $D${TESTDIR}/rootfs ]; then
+        echo "$D${TESTDIR}/rootfs exists, but should not"
         exit 1
-    else
-        echo "lets write postinst" > $tfile
     fi
+
+    mkdir -p $D${TESTDIR}
+    touch $D${TESTDIR}/rootfs
 }
 
-# Dependency recipes post-installs
+# Depends on rootfs, delays until first boot, verifies that the rootfs file was
+# written.
 pkg_postinst_${PN}-delayed-a () {
-    efile="/etc/postinst-test"
-    tfile="/etc/postinsta-test"
-    rdeps="postinst"
-
-    if test "x$D" != "x"; then
-      # Need to run on first boot
-      exit 1
-    else
-      touch /etc/this-was-created-at-first-boot
-      if test -e $efile ; then
-        echo 'success' > $tfile
-      else
-        echo 'fail to install $rdeps first!' >&2
+    set -e
+
+    if [ -n "$D" ]; then
+        echo "Delaying ${PN}-delayed-a until first boot"
         exit 1
-      fi
-   fi
-}
+    fi
 
-pkg_postinst_${PN}-delayed-b () {
-    efile="/etc/postinsta-test"
-    tfile="/etc/postinstb-test"
-    rdeps="postinsta"
-
-    if test "x$D" != "x"; then
-      # Need to run on first boot
-      exit 1
-    else
-      if test -e $efile ; then
-        echo 'success' > $tfile
-      else
-        echo 'fail to install $rdeps first!' >&2
+    if [ ! -e ${TESTDIR}/rootfs ]; then
+        echo "${PN}-delayed-a: ${TESTDIR}/rootfs not found"
         exit 1
-      fi
-   fi
+    fi
+
+    touch ${TESTDIR}/delayed-a
 }
 
-pkg_postinst_${PN}-delayed-d () {
-    efile="/etc/postinstb-test"
-    tfile="/etc/postinstd-test"
-    rdeps="postinstb"
-
-    if test "x$D" != "x"; then
-      # Need to run on first boot
-      exit 1
-    else
-      if test -e $efile ; then
-        echo 'success' > $tfile
-      else
-        echo 'fail to install $rdeps first!' >&2
+# Depends on delayed-a, delays until first boot, verifies that the delayed-a file was
+# written. This verifies the ordering between delayed postinsts.
+pkg_postinst_${PN}-delayed-b () {
+    set -e
+
+    if [ -n "$D" ]; then
+        echo "Delaying ${PN}-delayed-b until first boot"
         exit 1
-      fi
-   fi
-}
+    fi
 
-pkg_postinst_${PN}-delayed-p () {
-    efile="/etc/postinstd-test"
-    tfile="/etc/postinstp-test"
-    rdeps="postinstd"
-
-    if test "x$D" != "x"; then
-      # Need to run on first boot
-      exit 1
-    else
-      if test -e $efile ; then
-        echo 'success' > $tfile
-      else
-        echo 'fail to install $rdeps first!' >&2
+    if [ ! -e ${TESTDIR}/delayed-a ]; then
+        echo "${PN}-delayed-b: ${TESTDIR}/delayed-a not found"
         exit 1
-      fi
-   fi
-}
+    fi
 
-pkg_postinst_${PN}-delayed-t () {
-    efile="/etc/postinstp-test"
-    tfile="/etc/postinstt-test"
-    rdeps="postinstp"
-
-    if test "x$D" != "x"; then
-      # Need to run on first boot
-      exit 1
-    else
-      if test -e $efile ; then
-          echo 'success' > $tfile
-      else
-          echo 'fail to install $rdeps first!' >&2
-          exit 1
-      fi
-   fi
+    touch ${TESTDIR}/delayed-b
 }