From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6558749580291211264 X-Received: by 2002:a50:fb0e:: with SMTP id d14-v6mr693027edq.1.1527505009882; Mon, 28 May 2018 03:56:49 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:aa7:d351:: with SMTP id m17-v6ls16998366edr.3.gmail; Mon, 28 May 2018 03:56:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpI2o2m+MIPvV0aNu3PVWyysctlQuAZSm2nKTD6rcmh+X18Ze33YERGGEAHbh47Ag8A0xCu X-Received: by 2002:aa7:c0cd:: with SMTP id j13-v6mr3702148edp.12.1527505009484; Mon, 28 May 2018 03:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527505009; cv=none; d=google.com; s=arc-20160816; b=oVG0dN5DPFFFidCECe647NLsC+Sf1bR6OdCyZ9sXgfcZRnCOt03fn0ElTh/C4L9fJz +y6H2y24npUpV3pjkujTSjc6NJXXGS6K3KvMrYN7Ju/R37lMcnFpwzSpiYF+kvW60DfY 0V/XUxoDzBzokDqEW6uSIpPzNhR98ApWA94nTu3qPz1oDaMUP/vCQXNBQh3EwkUtZC07 YAQ+/ftF8zF9Cnh5R3AhpGv2Mzanel0pMlSfMvFy0oAo1nJ2F+JJfJrk04POOxdV0Xdo s+yTeKjC2PZzXr5Q9yKsRmef+4rThL9YXY6SWgdjXQG7ThnWgaDQhD3K+y8Fyhp/HY/a oe8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=A6Rcb4XmweSbs/N5XnQA/M2GRMt4k+LJljVULtOX+9A=; b=bqZbxP9J35uhtxPA9fLsO722s0+PLeSrUBdqGfWflLBCHSA/uUm6VyyV1pODsK7h7E yBPNk2ea9NPXpFS54nKluyoR7CEN+xRhHutJDiwXy7lhJriY+uj6XTVAYfiR21frL/kn obG8bTeJz7O0CoHtgZM0XAQJueWDDtl9547Skvg7qqEYNxNV+YDOD2GEfTSHph78Dih0 IC1I+YH/Ar4kkt5AFdHQK5/5zu/DS9xxoa6kkuQd8310CAV7RQgSv83mSPHPEnD2sinx hCGcw73pcs8wDK09L6P4DcCtpFP5JigAOaSwr4yKePXxNEQwsBg+h0gUZ5RoA2omNYlv sivA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id d24-v6si1067784eds.0.2018.05.28.03.56.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 03:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w4SAumvs023608 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 May 2018 12:56:48 +0200 Received: from ring.ppmd.siemens.net (linux-ses-ext02.ppmd.siemens.net [139.25.69.69]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id w4SAumAg019491; Mon, 28 May 2018 12:56:48 +0200 From: claudius.heine.ext@siemens.com To: isar-users@googlegroups.com Cc: Claudius Heine Subject: [PATCH v4 1/3] isar-bootstrap|configscript: implement one shot config option Date: Mon, 28 May 2018 12:56:41 +0200 Message-Id: <20180528105643.23518-2-claudius.heine.ext@siemens.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528105643.23518-1-claudius.heine.ext@siemens.com> References: <20180528105643.23518-1-claudius.heine.ext@siemens.com> X-TUID: B2htYRJeplSG From: Claudius Heine Some configuration tasks on the image require certain other packages, but those packages might not be required on the final image. One way to solve this is use a special package that is installed to the image and then removed again. When installing it makes certain that all required packages are installed to the image as well. Then the image can be configured in the postinst hook. When this package is removed and all unused dependencies are removed as well, no not required packages used by this package should remain on the image. Signed-off-by: Claudius Heine --- .../images/files/debian-configscript.sh | 1 - .../images/files/raspbian-configscript.sh | 1 - meta/classes/isar-bootstrap-helper.bbclass | 32 ++++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh index 7ca0562..9b3ff30 100755 --- a/meta-isar/recipes-core/images/files/debian-configscript.sh +++ b/meta-isar/recipes-core/images/files/debian-configscript.sh @@ -40,4 +40,3 @@ fi # Purge unused locale and installed packages' .deb files localepurge -apt-get clean diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh index b240de9..448dea5 100644 --- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh +++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh @@ -40,4 +40,3 @@ kernel=$KERNEL_IMAGE EOF localepurge -apt-get clean diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass index 4284d02..b87c94e 100644 --- a/meta/classes/isar-bootstrap-helper.bbclass +++ b/meta/classes/isar-bootstrap-helper.bbclass @@ -5,15 +5,24 @@ # # SPDX-License-Identifier: MIT +IMAGE_CFG_PACKAGE ??= "" + +def reverse_bb_array(d, varname): + array = d.getVar(varname, True) + if array is None: + return None + array = reversed(array.split()) + return " ".join(i for i in array) + setup_root_file_system() { ROOTFSDIR="$1" - CLEANHOSTLEAK="$2" + CLEAN="$2" shift shift PACKAGES="$@" APT_ARGS="install --yes --allow-unauthenticated \ -o Debug::pkgProblemResolver=yes" - CLEANHOSTLEAK_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf" + CLEAN_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf" sudo cp -Trpfx \ "${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/" \ @@ -41,8 +50,23 @@ setup_root_file_system() { -o Dir::Etc::sourceparts="-" \ -o APT::Get::List-Cleanup="0" sudo -E chroot "$ROOTFSDIR" \ - /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES - [ "clean" = ${CLEANHOSTLEAK} ] && sudo rm -f ${CLEANHOSTLEAK_FILES} + /usr/bin/apt-get ${APT_ARGS} --download-only $PACKAGES \ + ${IMAGE_CFG_PACKAGE} + [ "clean" = ${CLEAN} ] && sudo rm -f ${CLEAN_FILES} sudo -E chroot "$ROOTFSDIR" \ /usr/bin/apt-get ${APT_ARGS} $PACKAGES + for pkg in ${IMAGE_CFG_PACKAGE}; do + sudo -E chroot "$ROOTFSDIR" \ + /usr/bin/apt-get ${APT_ARGS} $pkg + done + for pkg in ${@reverse_bb_array(d, "IMAGE_CFG_PACKAGE") or ""}; do + sudo -E chroot "$ROOTFSDIR" \ + /usr/bin/apt-get purge --yes $pkg + done + if [ "clean" = ${CLEAN} ]; then + sudo -E chroot "$ROOTFSDIR" \ + /usr/bin/apt-get autoremove --purge --yes + sudo -E chroot "$ROOTFSDIR" \ + /usr/bin/apt-get clean + fi } -- 2.17.0