From 93d59c3176876b0990b27375458cf6518459bb07 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 23 Feb 2019 16:36:10 +0100 Subject: Merging upstream version 20190222. Signed-off-by: Daniel Baumann --- share/scripts/debconf | 95 ++++++++++++++------------------------------------- 1 file changed, 26 insertions(+), 69 deletions(-) (limited to 'share/scripts/debconf') diff --git a/share/scripts/debconf b/share/scripts/debconf index 5325c11..fbb20fa 100755 --- a/share/scripts/debconf +++ b/share/scripts/debconf @@ -1,7 +1,6 @@ #!/bin/sh -# container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2018 Daniel Baumann +# Copyright (C) 2014-2019 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # @@ -20,11 +19,14 @@ set -e +PROJECT="open-infrastructure" +SOFTWARE="compute-tools" +PROGRAM="container" SCRIPT="${0}" export SCRIPT -CONFIG="/etc/container-tools/config" -HOOKS="/etc/container-tools/hooks" +CONFIG="/etc/${PROJECT}/${PROGRAM}/config" +HOOKS="/etc/${PROJECT}/${PROGRAM}/hooks" MACHINES="/var/lib/machines" Parameters () @@ -157,7 +159,7 @@ Upgrade_system () # Disable dpkg syncing -cat > "${DIRECTORY}/etc/dpkg/dpkg.cfg.d/container-tools" << EOF +cat > "${DIRECTORY}/etc/dpkg/dpkg.cfg.d/${SOFTWARE}" << EOF force-unsafe-io EOF @@ -190,7 +192,7 @@ Cleanup_system () Chroot "${DIRECTORY}" "apt-get clean" # Cleanup - rm -f "${DIRECTORY}/etc/dpkg/dpkg.cfg.d/container-tools" + rm -f "${DIRECTORY}/etc/dpkg/dpkg.cfg.d/${SOFTWARE}" rm -f "${DIRECTORY}/usr/sbin/policy-rc.d" # Unmount pseudo-filesystems @@ -202,8 +204,8 @@ Cleanup_system () Debconf () { # Configure local debconf - mkdir -p /tmp/container-tools - DEBCONF_TMPDIR="$(mktemp -d -p /tmp/container-tools -t $(basename ${0}).XXXX)" + mkdir -p "/tmp/${SOFTWARE}" + DEBCONF_TMPDIR="$(mktemp -d -p "/tmp/${SOFTWARE}" -t $(basename ${0}).XXXX)" export DEBCONF_TMPDIR mkdir -p "${DEBCONF_TMPDIR}/debconf" @@ -247,12 +249,18 @@ Debootstrap () EXCLUDE="ifupdown" INCLUDE="dbus" - if echo "${MIRROR}" | grep -qs '^https' || \ - echo "{PARENT_MIRROR}" | grep -qs '^https' + if ( echo "${MIRROR}" | grep -qs '^https' ) || \ + ( echo "${PARENT_MIRROR}" | grep -qs '^https' ) then INCLUDE="${INCLUDE},apt-transport-https,ca-certificates" fi + case "${MODE}" in + progress-linux) + INCLUDE="${INCLUDE},progress-linux,gnupg" + ;; + esac + mkdir -p "$(dirname ${DIRECTORY})" debootstrap --verbose --arch=${ARCHITECTURE} --components=${PARENT_ARCHIVE_AREAS} \ --exclude=${EXCLUDE} --include=${INCLUDE} ${PARENT_DISTRIBUTION} "${DIRECTORY}" ${PARENT_MIRROR} @@ -332,58 +340,7 @@ EOF ;; esac - # Import archive keys - KEYS="project/pgp/archive-key-${DIST}.asc" - - for KEY in ${KEYS} - do - KEY_NAME="$(basename ${KEY})" - echo "P: Fetching archive-key ${KEY_NAME}..." - - wget -q "${MIRROR}/${KEY}" -O "${DIRECTORY}/key.asc" - wget -q "${MIRROR}/${KEY}.gpg" -O "${DIRECTORY}/key.asc.gpg" - - if [ -e /usr/bin/gpgv ] - then - if [ -e /usr/share/keyrings/debian-keyring.gpg ] || [ -e /usr/share/keyrings/debian-maintainers.gpg ] - then - KEY_VALID="" - - for KEYRING in /usr/share/keyrings/debian-keyring.gpg /usr/share/keyrings/debian-maintainers.gpg - do - if [ -e "${KEYRING}" ] - then - echo -n "I: Verifying archive-key ${KEY_NAME} against $(basename ${KEYRING} .gpg | sed -e 's|-keyring||') keyring..." - - # FIXME: doesn't work anymore when the template eventually be run with 'set -e' - /usr/bin/gpgv --quiet --keyring ${KEYRING} "${DIRECTORY}/key.asc.gpg" "${DIRECTORY}/key.asc" > /dev/null 2>&1 && KEY_VALID="true" && break - fi - done - - case "${KEY_VALID}" in - true) - echo " successful." - ;; - - *) - echo " failed." - return 1 - ;; - esac - else - echo "W: Skipping archive-key ${KEY_NAME} verification, debian-keyring not available..." - fi - else - echo "W: Skipping archive-key ${KEY_NAME} verification, gpgv not available..." - fi - - echo "P: Importing archive-key ${KEY_NAME}..." - - Chroot "${DIRECTORY}" "apt-key add key.asc" - rm -f "${DIRECTORY}/key.asc" - rm -f "${DIRECTORY}/key.asc.gpg" - done - + Chroot "${DIRECTORY}" "apt-key add /usr/share/progress-linux/pgp-keys/apt.progress-linux.org.gpg" Chroot "${DIRECTORY}" "apt-get update" ;; esac @@ -898,7 +855,7 @@ EOF cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-up-eno${NUMBER}.service" << EOF [Unit] -Description=container-tools IPV4_POST_UP +Description=${SOFTWARE} IPV4_POST_UP After=network-online.target Wants=network-online.target @@ -918,7 +875,7 @@ EOF cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-down-eno${NUMBER}.service" << EOF [Unit] -Description=container-tools IPV4_POST_DOWN +Description=${SOFTWARE} IPV4_POST_DOWN After=network.target Wants=network.target @@ -1031,12 +988,12 @@ do done # Run debconf parts -for DEBCONF_SCRIPT in /usr/share/container-tools/scripts/debconf.d/* +for DEBCONF_SCRIPT in "/usr/share/${PROJECT}/${PROGRAM}/scripts/debconf.d"/* do if [ -x "${DEBCONF_SCRIPT}" ] then # FIXME - # debconf -ocontainer-tools "${DEBCONF_SCRIPT}" + # debconf -o${SOFTWARE} "${DEBCONF_SCRIPT}" "${DEBCONF_SCRIPT}" fi done @@ -1044,7 +1001,7 @@ done # Read-in configuration from debconf . "${DEBCONF_TMPDIR}/debconf.default" -CACHE="/var/cache/container-tools/${MODE}" +CACHE="/var/cache/${PROJECT}/${PROGRAM}/${MODE}" SYSTEM="${MACHINES}/${NAME}" ## Generic parts @@ -1057,7 +1014,7 @@ then mv "${CACHE}/${DISTRIBUTION}_${ARCHITECTURE}.tmp" "${CACHE}/${DISTRIBUTION}_${ARCHITECTURE}" fi -Upgrade_system "${CACHE}/${DISTRIBUTION}_${ARCHITECTURE}" || echo "W: If upgrading the system failed, try removing the cache for your distribution in /var/cache/container-tools" +Upgrade_system "${CACHE}/${DISTRIBUTION}_${ARCHITECTURE}" || echo "W: If upgrading the system failed, try removing the cache for your distribution in /var/cache/${PROJECT}/${PROGRAM}" Cleanup_system "${CACHE}/${DISTRIBUTION}_${ARCHITECTURE}" ## Specific parts @@ -1175,7 +1132,7 @@ fi # remove debconf temporary files rm --preserve-root --one-file-system -rf "${DEBCONF_TMPDIR}" -rmdir --ignore-fail-on-non-empty /tmp/container-tools 2>&1 || true +rmdir --ignore-fail-on-non-empty "/tmp/${SOFTWARE}" 2>&1 || true # Post hooks for FILE in "${HOOKS}/post-${SCRIPT}".* "${HOOKS}/${NAME}.post-${SCRIPT}" -- cgit v1.2.3