From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6560975164340699136 X-Received: by 2002:adf:e84b:: with SMTP id d11-v6mr877708wrn.24.1527596070850; Tue, 29 May 2018 05:14:30 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:7c18:: with SMTP id x24-v6ls2087757wmc.2.gmail; Tue, 29 May 2018 05:14:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJINncM6/E5SsyFg6Vc1IJ0D5EH7i6OzH0prVAvKPozL0B5ElK2jBn82NASZjsd8TuF84eu X-Received: by 2002:a1c:9855:: with SMTP id a82-v6mr1462303wme.4.1527596070418; Tue, 29 May 2018 05:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527596070; cv=none; d=google.com; s=arc-20160816; b=gpJTV8IflAPjDoi2BFUahCKwI1RIpTuVE+YAjpoMWlV7FI+o2xxV0dsP+bUfIh+n/B 1snekPzKr5nYVjRDO+S8ALjilvp29vGuxmjnCJD2T0BPUnRc7rbrylupEGohLlRQXlJK pEOzzIUyjR1sdXMUc5x+gmZ7jn1xIPGLDd4aDEVIrFihtBUyxZlY0dsOZUCOW/0fg/Z2 pgryNsU6ShEOiLqUzWsm6SawB2m6pgGfFkKY/JaHFh6SiglY1Y/Gjg/E06lcwGm8u+m2 GuZblB0HZHjbYWk8fVBbhkhD808wCaNhCBYiYc5NXZ6lBDYiTcZodwDwjPhp9K4eDc1r 5dlg== 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=WpdPVUJZ9FZPV4D2nVZYxkKAcOzkl9Wf8j5RyjPS/cI=; b=pP4xsBID6/pqyzwqxabMyL9V9qhuMKZ/M/WKv0AMY4Uk+lcZvo6KjWpN1iEGzfeU7O kpURoghtClBZN+hiVvdJTt2XYd8MaOL9SmBB7M6y0k8e2NrqJzX32QDmLr9VbaInrSoq hrrJu46ZIONEZo0JTUzS/bFognY0fADJhWIx80R81ODtUjJD9U0RqM8iuzReYW+s76FY NdgGtQxf87hDKbrt0AOXSszwMwcly761yHTq/XF6WOITCN6sWMwpSHTTOK5C6yEo3n/2 Ka7bJ90xqBn62J5Dv2EtnN5IfkV3/LyIWijPuWrdTC66WrnO7eqdJxburUMyWZN59JcH RLMw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id c18-v6si577872wrq.5.2018.05.29.05.14.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 05:14:30 -0700 (PDT) Received-SPF: pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w4TCETb8003366 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 May 2018 14:14:29 +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 w4TCET91025126; Tue, 29 May 2018 14:14:29 +0200 From: claudius.heine.ext@siemens.com To: isar-users@googlegroups.com Cc: Claudius Heine Subject: [PATCH v5 1/4] isar-bootstrap|configscript: implement one transient packages Date: Tue, 29 May 2018 14:14:22 +0200 Message-Id: <20180529121425.8783-2-claudius.heine.ext@siemens.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529121425.8783-1-claudius.heine.ext@siemens.com> References: <20180529121425.8783-1-claudius.heine.ext@siemens.com> X-TUID: 5VtIDG5A5j0Q 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..d6b2a26 100644 --- a/meta/classes/isar-bootstrap-helper.bbclass +++ b/meta/classes/isar-bootstrap-helper.bbclass @@ -5,15 +5,24 @@ # # SPDX-License-Identifier: MIT +IMAGE_TRANSIENT_PACKAGES ??= "" + +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_TRANSIENT_PACKAGES} + [ "clean" = ${CLEAN} ] && sudo rm -f ${CLEAN_FILES} sudo -E chroot "$ROOTFSDIR" \ /usr/bin/apt-get ${APT_ARGS} $PACKAGES + for pkg in ${IMAGE_TRANSIENT_PACKAGES}; do + sudo -E chroot "$ROOTFSDIR" \ + /usr/bin/apt-get ${APT_ARGS} $pkg + done + for pkg in ${@reverse_bb_array(d, "IMAGE_TRANSIENT_PACKAGES") 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