From patchwork Wed Nov 22 16:04:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 119497 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp355510qgn; Wed, 22 Nov 2017 08:04:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMZJ5EbmJF74zS1uTBARg9dFffg0rAjwurS3N3GU2H7THA1AkFA6o/t6BPzBoa857MIDnDSC X-Received: by 10.159.216.131 with SMTP id s3mr21598410plp.432.1511366672908; Wed, 22 Nov 2017 08:04:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511366672; cv=none; d=google.com; s=arc-20160816; b=sjV8pttY/rCCkthJpXazVzZm5YfNUPC2Le1G8Pz9eedqMTO1NoOdptbj55SzXBmOAe zRauKZ6lDulGfyQ9FmbOvHgFoP90N+9PnCTN1OQLX/PU/cJT8R2ky4b6tYdKIMv7lUOD RqUNML7PAyzlAOA+vH7Uq8ZO3fyh71EPczQhiVeG8ad4lvl4Y2fq0v3qN876gAbh3BZI 9auIDfVylXtTAKjEKqlUjh0z1sHMbQr08zbayoljACtXeu5iL2REmMxodMPwW/NSG/LV YyOIc4syaDyPcK64xtDhwhz9A+1+qkCQYIbq2LLf5yaa3mgl/smqu/poUmgH3iv+9yz/ 4owQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=0GT6vwiDLExKeRrwDhrUjvZIh/wGszoEkhaRcf7rCr4=; b=oXr3RyMCiE1MtkX0CDih6vqaafz+OBwl3fgwAm1GMdBOdMdlmKCYT/A/P8dUcWRB/l VrWgG3zVlmS6Gy+vZKZF1UXma2BvX4DRBZtowgGuwK/hpwKV60fe6Jg4p0jTpO/YYpc4 pLyhpVoK+igaJwWItdd1C0dV3lKihAK0/Bgee8WTkk7TLnWmoG7grffiNvfmAlUoortu 78S4NKd+NGTQrUMtz5CFsiGqBriQlxWM3Clljf8MXTU08hFnjQAZmAtek/92ITz2kw9i 2X2pp77gV/dK4ZZ+1m/xB3I1oYupvtUnN6xg4sNu/RRRZ+9slhFd7bAeXQrwLHLGkT90 4csw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=gFoNH55q; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id r22si4940563pgo.706.2017.11.22.08.04.32; Wed, 22 Nov 2017 08:04:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=gFoNH55q; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org Received: from review.yoctoproject.org (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id C85E37872A; Wed, 22 Nov 2017 16:04:29 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by mail.openembedded.org (Postfix) with ESMTP id 88F9378650 for ; Wed, 22 Nov 2017 16:04:18 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id r68so11309629wmr.1 for ; Wed, 22 Nov 2017 08:04:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=8sh5QGQfUJ4BwKz1TS2kb4UsFvJeJJ6se0J9LfxieFs=; b=gFoNH55qK/SVrgA5sWDgbcz1EFIZXxgu8XYYHjocn6BPZUYQj0DNjCFhVkHSOyzZw4 CPtF8iX8/PJxRXz8/c3ffu+sY0viQrjQCfstq3Ragmmwiq2CTR/CJsqHnEh0qbcswYVM HgW4bGHwuJuKYn1GH+5LS8IBcDJ3ZdDZ8AFQEteWds6Zfg3CbfJWts3c9pxKe878Fr1c HxWss8HdadygFh/cQLFP0h3ZJx0AhFgmxYl+GmJNGsZFIfkIIkTGoQRVR7avqLcDP8Mu U9E94LWpVESjvw/yq5DHV2i7mMPAlb+H4ifQ4puh6ccq4yARUsps5osMxwuZLoOR53EI CO6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8sh5QGQfUJ4BwKz1TS2kb4UsFvJeJJ6se0J9LfxieFs=; b=gUSHqDEw+xdqn8w8mMtky5bE3JzTuUOmxfFjcNeEIMy/dXOQ27TUliP3UU5p6BW6rP gWX5K66ZIDhcvty1tcAg5Fu8MYRa37ionsJQ7EcvzcNrQjaIH6ucAyGtFL4Mjvf05+Rw viB/7YuRp1+yryDAC/aJIrobffU1cAwdPw7YIGYsY9WUKSZyscyIBSPTNnt7bFRLyUik p/6eI/vhDYIvrzeNTPmCTwBTVN3EhLvpTAu9xKwjYHhWiVDkecHthKsoc7WnjQNiKcL5 JdKwbpxcfpUXrxTLuHnx6KEGW2PQKAt5sioCDVmFNc0KquCbWJNaf5QfDTTrLlEmWyYi VAEw== X-Gm-Message-State: AJaThX726kz9SNEQBo6a/oMQkGAGQ0Dpa9R+CEuU9AMS8z+9Kl2C913b 325Lob4d3vriIn8K7oylpRlyafa6 X-Received: by 10.28.157.7 with SMTP id g7mr4132444wme.99.1511366658985; Wed, 22 Nov 2017 08:04:18 -0800 (PST) Received: from flashheart.burtonini.com (home.burtonini.com. [81.2.106.35]) by smtp.gmail.com with ESMTPSA id k30sm28923728wrf.63.2017.11.22.08.04.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Nov 2017 08:04:18 -0800 (PST) From: Ross Burton To: openembedded-core@lists.openembedded.org Date: Wed, 22 Nov 2017 16:04:13 +0000 Message-Id: <20171122160414.14093-2-ross.burton@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171122160414.14093-1-ross.burton@intel.com> References: <20171122160414.14093-1-ross.burton@intel.com> Subject: [OE-core] [PATCH 2/3] postinst: fix and simplify the postinst test recipe X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org Reduce the number of packages, and fix some syntax and logic errors in the scripts. Signed-off-by: Ross Burton --- .../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 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 }