summaryrefslogtreecommitdiffstats
path: root/share/scripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-03-02 10:06:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-03-02 10:39:04 +0000
commitcebe592fb5eb4c1625cf5dcab1968c27cbc25d3e (patch)
treeb4cc270e4a2c991ba207b2329c74d11412da2403 /share/scripts
parentAdding upstream version 20190222. (diff)
downloadopen-infrastructure-compute-tools-cebe592fb5eb4c1625cf5dcab1968c27cbc25d3e.tar.xz
open-infrastructure-compute-tools-cebe592fb5eb4c1625cf5dcab1968c27cbc25d3e.zip
Adding upstream version 20190301.upstream/20190301
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share/scripts')
-rwxr-xr-xshare/scripts/curl492
-rwxr-xr-xshare/scripts/curl.d/0001-debconf54
-rw-r--r--share/scripts/curl.d/0001-debconf.templates11
-rwxr-xr-xshare/scripts/debconf192
-rwxr-xr-xshare/scripts/debconf.d/0002-preseed-debconf2
-rwxr-xr-xshare/scripts/debconf.d/0003-debconf55
-rw-r--r--share/scripts/debconf.d/0003-debconf.templates2
-rwxr-xr-xshare/scripts/debootstrap24
8 files changed, 67 insertions, 765 deletions
diff --git a/share/scripts/curl b/share/scripts/curl
deleted file mode 100755
index 80ccde6..0000000
--- a/share/scripts/curl
+++ /dev/null
@@ -1,492 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
-#
-# SPDX-License-Identifier: GPL-3.0+
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-set -e
-
-PROJECT="open-infrastructure"
-SOFTWARE="compute-tools"
-PROGRAM="container"
-SCRIPT="${0}"
-
-HOOKS="/etc/${PROJECT}/${PROGRAM}/hooks"
-KEYS="/etc/${PROJECT}/${PROGRAM}/keys"
-MACHINES="/var/lib/machines"
-CACHE="/var/cache/${PROJECT}/${PROGRAM}/system"
-
-Parameters ()
-{
- GETOPT_LONGOPTIONS="bind:,bind-ro:,script:,name:,architecture:,clean,password:,server:,setup:,system:,"
- GETOPT_OPTIONS="b:,s:,n:,a:,p:"
-
- PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${SCRIPT} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
-
- if [ "${?}" != "0" ]
- then
- echo "'${SCRIPT}': getopt exit" >&2
- exit 1
- fi
-
- eval set -- "${PARAMETERS}"
-
- while true
- do
- case "${1}" in
- -b|--bind)
- # ignore
- shift 2
- ;;
-
- --bind-ro)
- # ignore
- shift 2
- ;;
-
- --cnt.auto)
- # ignore
- shift 2
- ;;
-
- --cnt.container-server)
- # ignore
- shift 2
- ;;
-
- -s|--script)
- # ignore
- shift 2
- ;;
-
- -n|--name)
- NAME="${2}"
- shift 2
- ;;
-
- -a|--architecture)
- ARCHITECTURE="${2}"
- shift 2
- ;;
-
- --clean)
- CLEAN="true"
- shift 1
- ;;
-
- -p|--password)
- PASSWORD="${2}"
- shift 2
- ;;
-
- --server)
- SERVER="${2}"
- shift 2
- ;;
-
- --setup)
- SETUP="${2}"
- shift 2
- ;;
-
- --system)
- SYSTEM="${2}"
- shift 2
- ;;
-
- --)
- shift 1
- break
- ;;
-
- *)
- echo "'${SCRIPT}': getopt error" >&2
- exit 1
- ;;
- esac
- done
-}
-
-Usage ()
-{
- echo "Usage: container create -n|--name NAME -s|--script ${SCRIPT} -- [--clean] [-p|--password PASSWORD] [--server SERVER] [--setup SETUP] [--system SYSTEM]" >&2
- exit 1
-}
-
-Parameters "${@}"
-
-if [ -z "${NAME}" ]
-then
- Usage
-fi
-
-if [ -e "${MACHINES}/${NAME}" ]
-then
- echo "'${NAME}': container already exists" >&2
- exit 1
-fi
-
-if [ ! -x /usr/bin/curl ]
-then
- echo "'${NAME}': /usr/bin/curl - no such file." >&2
- exit 1
-fi
-
-if [ "$(id -u)" -ne 0 ]
-then
- echo "'${NAME}': need root privileges" >&2
- exit 1
-fi
-
-COMPRESSIONS=""
-
-if [ -x /usr/bin/lzip ]
-then
- COMPRESSIONS="${COMPRESSIONS} lz"
-fi
-
-if [ -x /usr/bin/xz ]
-then
- COMPRESSIONS="${COMPRESSIONS} xz"
-fi
-
-if [ -x /bin/gzip ]
-then
- COMPRESSIONS="${COMPRESSIONS} gz"
-fi
-
-if [ -z "${COMPRESSIONS}" ]
-then
- echo "'${NAME}': no supported compressor available (lz, xz, gz)."
- exit 1
-fi
-
-SERVER="${SERVER:-https://get.open-infrastructure.net/system/container/debian}"
-PASSWORD="${PASSWORD:-$(dd if=/dev/urandom bs=12 count=1 2> /dev/null | base64)}"
-
-VERSION="$(container version)"
-
-export SERVER
-
-Debconf ()
-{
- # Configure local debconf
- mkdir -p "${DEBCONF_TMPDIR}/debconf"
-
-cat > "${DEBCONF_TMPDIR}/debconf.systemrc" << EOF
-Config: configdb
-Templates: templatedb
-
-Name: config
-Driver: File
-Mode: 644
-Reject-Type: password
-Filename: ${DEBCONF_TMPDIR}/debconf/config.dat
-
-Name: passwords
-Driver: File
-Mode: 600
-Backup: false
-Required: false
-Accept-Type: password
-Filename: ${DEBCONF_TMPDIR}/debconf/passwords.dat
-
-Name: configdb
-Driver: Stack
-Stack: config, passwords
-
-Name: templatedb
-Driver: File
-Mode: 644
-Filename: ${DEBCONF_TMPDIR}/debconf/templates.dat
-EOF
-
- DEBCONF_SYSTEMRC="${DEBCONF_TMPDIR}/debconf.systemrc"
- export DEBCONF_SYSTEMRC
-}
-
-# Pre hooks
-for FILE in "${HOOKS}/pre-${SCRIPT}".* "${HOOKS}/${NAME}.pre-${SCRIPT}"
-do
- if [ -x "${FILE}" ]
- then
- "${FILE}"
- fi
-done
-
-# Run
-
-# FIXME: default server via configuration file
-
-CURL_OPTIONS=""
-
-if curl -V | grep -qs http2
-then
- CURL_OPTIONS="${CURL_OPTIONS} --http2"
-fi
-
-if [ -z "${SYSTEM}" ]
-then
- # Downloading container list
- if curl --fail --head --output /dev/null --silent "${SERVER}/container-list.txt"
- then
- mkdir -p "/tmp/${SOFTWARE}"
- DEBCONF_TMPDIR="$(mktemp -d -p "/tmp/${SOFTWARE}" -t $(basename ${0}).XXXX)"
- export DEBCONF_TMPDIR
-
- if [ -z "${ARCHITECTURE}" ]
- then
- case "$(dpkg --print-architecture)" in
- amd64)
- GREP_PATTERN="(amd64|i386)"
- ;;
- esac
- fi
-
- GREP_PATTERN="${GREP_PATTERN:-${ARCHITECTURE}}"
-
- echo "Downloading $(echo ${SERVER} | awk -F/ '{ print $3 }') container list"
- curl --fail --location --progress-bar --user-agent ${SOFTWARE}/${VERSION} ${CURL_OPTIONS} \
- "${SERVER}/container-list.txt" | grep -E "${GREP_PATTERN}" > "${DEBCONF_TMPDIR}/container-list.txt"
-
- umask 0022
-
- Debconf
-
- # Run debconf parts
- for DEBCONF_SCRIPT in /usr/share/${PROJECT}/${PROGRAM}/scripts/curl.d/*
- do
- if [ -x "${DEBCONF_SCRIPT}" ]
- then
- # FIXME
- # debconf -o${SOFTWARE} "${DEBCONF_SCRIPT}"
- "${DEBCONF_SCRIPT}"
- fi
- done
-
- # Read-in configuration from debconf
- . "${DEBCONF_TMPDIR}/debconf.default"
-
- # Remove debconf temporary files
- rm --preserve-root --one-file-system -rf "${DEBCONF_TMPDIR}"
- rmdir --ignore-fail-on-non-empty "/tmp/${SOFTWARE}" 2>&1 || true
- fi
-fi
-
-for COMPRESSION in ${COMPRESSIONS}
-do
- if curl --fail --head --output /dev/null --silent "${SERVER}/${SYSTEM}.${COMPRESSION}"
- then
- SYSTEM="${SYSTEM}.${COMPRESSION}"
- break
- fi
-done
-
-# Downloading container files
-mkdir -p "${CACHE}"
-
-SETUP="${SETUP:-$(echo ${SYSTEM} | sed -e 's|.system.tar.|.setup.tar.|')}"
-
-for FILE in "${SYSTEM}" "${SYSTEM}.gpg" "${SYSTEM}.sha512" \
- "${SETUP}" "${SETUP}.gpg" "${SETUP}.sha512"
-do
- if curl --fail --head --output /dev/null --silent "${SERVER}/${FILE}"
- then
- case "${FILE}" in
- *.sha512)
- if [ -e "${CACHE}/$(basename ${FILE} .sha512).gpg" ]
- then
- continue
- fi
- ;;
- esac
-
- if [ -e "${CACHE}/${FILE}" ]
- then
- CURL_TIME_COND="--time-cond ${CACHE}/${FILE}"
- else
- CURL_TIME_COND=""
- fi
-
- echo "Downloading ${FILE}"
- curl --fail --location --progress-bar --user-agent ${SOFTWARE}/${VERSION} ${CURL_OPTIONS} ${CURL_TIME_COND} \
- "${SERVER}/${FILE}" -o "${CACHE}/${FILE}"
- fi
-done
-
-cd "${CACHE}"
-
-for FILE in "${SYSTEM}" "${SETUP}"
-do
- if [ ! -e "${FILE}" ]
- then
- continue
- fi
-
- if [ -e "${FILE}.gpg" ]
- then
- echo -n "Verifying ${FILE}:"
-
- set +e
- gpg --homedir "${KEYS}" --verify "${FILE}.gpg" "${FILE}" > /dev/null 2>&1
- GNUPG="${?}"
- set -e
-
- case "${GNUPG}" in
- 0)
- echo " gpg ok."
- continue
- ;;
-
- *)
- echo " gpg failed."
- exit 1
- ;;
- esac
- elif [ -e "${FILE}.sha512" ]
- then
- echo -n "Verifying ${FILE}:"
-
- set +e
- sha512sum --check "${FILE}.sha512" --status
- SHA512SUM="${?}"
- set -e
-
- case "${SHA512SUM}" in
- 0)
- echo " sha512 ok."
- ;;
-
- *)
- echo " sha512 failed."
- exit 1
- ;;
- esac
- fi
-done
-
-cd "${OLDPWD}"
-
-case "${SYSTEM}" in
- *.gz)
- TAR_OPTIONS="--gzip"
-
- if [ ! -e /bin/gzip ]
- then
- echo -en "\n"
- echo "'${NAME}': /bin/lzip - no such file." >&2
- exit 1
- fi
- ;;
-
- *.lz)
- TAR_OPTIONS="--lzip"
-
- if [ ! -e /usr/bin/lzip ]
- then
- echo -en "\n"
- echo "'${NAME}': /usr/bin/lzip - no such file." >&2
- exit 1
- fi
- ;;
-
- *.xz)
- TAR_OPTIONS="--xz"
-
- if [ ! -e /usr/bin/xz ]
- then
- echo -en "\n"
- echo "'${NAME}': /usr/bin/xz - no such file." >&2
- exit 1
- fi
- ;;
-
- *)
- TAR_OPTIONS=""
- ;;
-esac
-
-for FILE in "${SYSTEM}" "${SETUP}"
-do
- if [ ! -e "${CACHE}/${FILE}" ]
- then
- continue
- fi
-
- case "${FILE}" in
- *.system.tar.*)
- DIRECTORY="${MACHINES}/${NAME}"
- ;;
-
- *.setup.tar.*)
- DIRECTORY="${MACHINES}/${NAME}/setup"
- ;;
- esac
-
- mkdir -p "${DIRECTORY}"
-
- if [ -e /usr/bin/pv ]
- then
- echo "Unpacking ${FILE}"
- pv --format '%p' --width 77 "${CACHE}/${FILE}" | tar xf - ${TAR_OPTIONS} -C "${DIRECTORY}" --strip 1
- else
- echo -n "Unpacking ${FILE}:"
- tar xf "${CACHE}/${FILE}" ${TAR_OPTIONS} -C "${DIRECTORY}" --strip 1
- echo " ok."
- fi
-done
-
-if [ -x "${MACHINES}/${NAME}/setup/container" ]
-then
- chroot "${MACHINES}/${NAME}" /usr/bin/env -i \
- LC_ALL="C" PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games" TERM="${TERM}" \
- DEBIAN_FRONTEND="dialog" DEBIAN_PRIORITY="low" \
- DEBCONF_NONINTERACTIVE_SEEN="true" DEBCONF_NOWARNINGS="true" \
- NAME="${NAME}" \
- /setup/container
-
- rm -rf "${MACHINES}/${NAME}/setup"
-fi
-
-# Creating machine-id
-chroot "${MACHINES}/${NAME}" systemd-machine-id-setup > /dev/null 2>&1
-
-# Setting hostname
-echo "${NAME}" > "${MACHINES}/${NAME}/etc/hostname"
-
-# Copying resolv.conf
-cp -L /etc/resolv.conf "${MACHINES}/${NAME}/etc/resolv.conf"
-
-# Setting root password
-echo root:${PASSWORD} | chroot "${MACHINES}/${NAME}" chpasswd
-echo "${NAME}: root password set to '${PASSWORD}'."
-
-# Remove cache
-case "${CLEAN}" in
- true)
- rm -f "${CACHE}/${SYSTEM}" "${CACHE}/${SYSTEM}.sha512"
- rm -f "${CACHE}/${SETUP}" "${CACHE}/${SETUP}.sha512"
- ;;
-esac
-
-# Post hooks
-for FILE in "${HOOKS}/post-${SCRIPT}".* "${HOOKS}/${NAME}.post-${SCRIPT}"
-do
- if [ -x "${FILE}" ]
- then
- "${FILE}"
- fi
-done
diff --git a/share/scripts/curl.d/0001-debconf b/share/scripts/curl.d/0001-debconf
deleted file mode 100755
index 3f98f74..0000000
--- a/share/scripts/curl.d/0001-debconf
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2014-2019 Daniel Baumann <daniel.baumann@open-infrastructure.net>
-#
-# SPDX-License-Identifier: GPL-3.0+
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-set -e
-
-DEBCONF_NOWARNINGS="true"
-export DEBCONF_NOWARNINGS
-
-. /usr/share/debconf/confmodule
-
-System ()
-{
- TITLE="$(echo ${SERVER} | awk -F/ '{ print $3 }')"
-
- SYSTEMS="$(for SYSTEM in $(cat ${DEBCONF_TMPDIR}/container-list.txt | cut -d\| -f2 | sed -e 's| |#|g'); do echo -n "$(echo ${SYSTEM} | sed -e 's|#| |g'), "; done | sed -e 's|, $||')"
- SYSTEMS_C="$(for SYSTEM_C in $(cat ${DEBCONF_TMPDIR}/container-list.txt | cut -d\| -f1); do echo -n "${SYSTEM_C}, "; done | sed -e 's|, $||')"
-
- db_subst cnt-curl/title TITLE "${TITLE}"
-
- db_subst cnt-curl/system CHOICES "${SYSTEMS}"
- db_subst cnt-curl/system CHOICES_C "${SYSTEMS_C}"
-
- db_fset cnt-curl/system seen false
-
- db_settitle cnt-curl/title
- db_input high cnt-curl/system || true
- db_go
-
- db_get cnt-curl/system
- SYSTEM="${RET}" # select
-
- echo "SYSTEM=\"${SYSTEM}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
- export SYSTEM
-}
-
-System
-
-db_stop
diff --git a/share/scripts/curl.d/0001-debconf.templates b/share/scripts/curl.d/0001-debconf.templates
deleted file mode 100644
index c87e47e..0000000
--- a/share/scripts/curl.d/0001-debconf.templates
+++ /dev/null
@@ -1,11 +0,0 @@
-Template: cnt-curl/title
-Type: title
-Description: ${TITLE}
-
-Template: cnt-curl/system
-Type: select
-Default:
-Choices-C: ${CHOICES_C}
-Choices: ${CHOICES}
-Description: Container list:
- Select the system to use for creating the container.
diff --git a/share/scripts/debconf b/share/scripts/debconf
index fbb20fa..fbabab4 100755
--- a/share/scripts/debconf
+++ b/share/scripts/debconf
@@ -174,22 +174,22 @@ EOF
chmod 0755 "${DIRECTORY}/usr/sbin/policy-rc.d"
# Upgrade system
- Chroot "${DIRECTORY}" "apt-get update"
- Chroot "${DIRECTORY}" "apt-get --yes --option APT::Force-LoopBreak=true --option Dpkg::Options::=--force-confnew upgrade"
- Chroot "${DIRECTORY}" "apt-get --yes --option APT::Force-LoopBreak=true --option Dpkg::Options::=--force-confnew dist-upgrade"
+ Chroot "${DIRECTORY}" "apt update"
+ Chroot "${DIRECTORY}" "apt --yes --option Dpkg::Options::=--force-confnew upgrade"
+ Chroot "${DIRECTORY}" "apt --yes --option Dpkg::Options::=--force-confnew dist-upgrade"
# Install systemd support packages
- Chroot "${DIRECTORY}" "apt-get --yes install dbus libpam-systemd systemd-sysv"
+ Chroot "${DIRECTORY}" "apt --yes install dbus libpam-systemd systemd-sysv"
- Chroot "${DIRECTORY}" "apt-get clean"
+ Chroot "${DIRECTORY}" "apt clean"
}
Cleanup_system ()
{
DIRECTORY="${1}"
- Chroot "${DIRECTORY}" "apt-get --yes --purge autoremove"
- Chroot "${DIRECTORY}" "apt-get clean"
+ Chroot "${DIRECTORY}" "apt --yes --purge autoremove"
+ Chroot "${DIRECTORY}" "apt clean"
# Cleanup
rm -f "${DIRECTORY}/etc/dpkg/dpkg.cfg.d/${SOFTWARE}"
@@ -276,72 +276,26 @@ Configure_apt ()
PARENT_AREA="$(echo ${PARENT_ARCHIVE_AREAS} | sed -e 's|,| |g')"
PARENT_DIST="$(echo ${PARENT_DISTRIBUTION} | sed -e 's|-backports||')"
- echo "deb ${PARENT_MIRROR} ${PARENT_DIST} ${PARENT_AREA}" > "${DIRECTORY}/etc/apt/sources.list.d/debian.list"
+cat > "${DIRECTORY}/etc/apt/sources.list.d/debian.list" << EOF
+# /etc/apt/sources.list.d/debian.list
- case "${MODE}" in
- progress-linux)
- AREA="$(echo ${ARCHIVE_AREAS} | sed -e 's|,| |g')"
- DIST="$(echo ${DISTRIBUTION} | sed -e 's|-backports||')"
-
- echo "deb ${MIRROR} ${DIST} ${AREA}" > "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
-
- case "${DISTRIBUTION}" in
- *-backports)
- echo "deb ${MIRROR} ${DIST}-backports ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- ;;
- esac
-
-cat > "${DIRECTORY}/etc/apt/preferences.d/progress-linux.pref" << EOF
-Package: *
-Pin: release n=${DIST}
-Pin-Priority: 999
-
-Package: *
-Pin: release n=${DIST}-security
-Pin-Priority: 999
-
-Package: *
-Pin: release n=${DIST}-updates
-Pin-Priority: 999
-
-Package: *
-Pin: release n=${DIST}-extras
-Pin-Priority: 999
+deb ${PARENT_MIRROR} ${PARENT_DIST} ${PARENT_AREA}
EOF
- case "${DISTRIBUTION}" in
- *-backports)
-
-cat >> "${DIRECTORY}/etc/apt/preferences.d/progress-linux.pref" << EOF
-Package: *
-Pin: release n=${DIST}-backports
-Pin-Priority: 999
+ case "${MODE}" in
+ progress-linux)
-Package: *
-Pin: release n=${DIST}-backports-extras
-Pin-Priority: 999
+cat > "${DIRECTORY}/progress-linux.cfg" << EOF
+progress-linux progress-linux/archives multiselect ${ARCHIVES}
+progress-linux progress-linux/archive-areas multiselect $(echo ${ARCHIVE_AREAS} | sed -e 's|,| |g')
EOF
- ;;
-
- *)
+ Chroot "${DIRECTORY}" "debconf-set-selections progress-linux.cfg"
+ Chroot "${DIRECTORY}" "DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=criticial dpkg-reconfigure progress-linux"
-cat >> "${DIRECTORY}/etc/apt/preferences.d/progress-linux.pref" << EOF
+ rm -f "${DIRECTORY}/progress-linux.cfg"
-#Package: *
-#Pin: release n=${DIST}-backports
-#Pin-Priority: 999
-
-#Package: *
-#Pin: release n=${DIST}-backports-extras
-#Pin-Priority: 999
-EOF
-
- ;;
- esac
-
- Chroot "${DIRECTORY}" "apt-key add /usr/share/progress-linux/pgp-keys/apt.progress-linux.org.gpg"
- Chroot "${DIRECTORY}" "apt-get update"
+ Chroot "${DIRECTORY}" "apt update"
;;
esac
}
@@ -399,8 +353,6 @@ EOF
fi
# Removing resolv.conf
- #rm -f "${DIRECTORY}/etc/resolv.conf"
- # FIXME: needs to stay for the moment
rm -f "${DIRECTORY}/etc/resolv.conf"
cp /etc/resolv.conf "${DIRECTORY}/etc"
@@ -429,7 +381,11 @@ Configure_system ()
PARENT_AREA="$(echo ${PARENT_ARCHIVE_AREAS} | sed -e 's|,| |g')"
PARENT_DIST="$(echo ${PARENT_DISTRIBUTION} | sed -e 's|-backports||')"
- echo "deb ${PARENT_MIRROR} ${PARENT_DIST} ${PARENT_AREA}" > "${DIRECTORY}/etc/apt/sources.list.d/debian.list"
+cat > "${DIRECTORY}/etc/apt/sources.list.d/debian.list" << EOF
+# /etc/apt/sources.list.d/debian.list
+
+deb ${PARENT_MIRROR} ${PARENT_DIST} ${PARENT_AREA}
+EOF
for PARENT_REPO in ${PARENT_ARCHIVES}
do
@@ -458,79 +414,16 @@ Configure_system ()
case "${MODE}" in
progress-linux)
- AREA="$(echo ${ARCHIVE_AREAS} | sed -e 's|,| |g')"
- DIST="$(echo ${DISTRIBUTION} | sed -e 's|-backports||')"
- echo "deb ${MIRROR} ${DIST} ${AREA}" > "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
+cat > "${DIRECTORY}/progress-linux.cfg" << EOF
+progress-linux progress-linux/archives multiselect ${ARCHIVES}
+progress-linux progress-linux/archive-areas multiselect $(echo ${ARCHIVE_AREAS} | sed -e 's|,| |g')
+EOF
- for REPO in ${ARCHIVES}
- do
- case "${REPO}" in
- ${DIST}-staging)
- echo "deb ${MIRROR} ${DIST}-staging ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- ;;
-
- ${DIST}-security)
- echo "deb ${MIRROR_SECURITY} ${DIST}-security ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- ;;
-
- ${DIST}-security-staging)
- echo "deb ${MIRROR_SECURITY} ${DIST}-security-staging ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- ;;
-
- ${DIST}-updates)
- echo "deb ${MIRROR} ${DIST}-updates ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- ;;
-
- ${DIST}-updates-staging)
- echo "deb ${MIRROR} ${DIST}-updates-staging ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- ;;
-
- ${DIST}-extras)
- if echo "${AREA}" | grep -qs non-free
- then
- echo "deb ${MIRROR} ${DIST}-extras ${AREA} restricted" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- else
- echo "deb ${MIRROR} ${DIST}-extras ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- fi
- ;;
-
- ${DIST}-extras-staging)
- if echo "${AREA}" | grep -qs non-free
- then
- echo "deb ${MIRROR} ${DIST}-extras-staging ${AREA} restricted" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- else
- echo "deb ${MIRROR} ${DIST}-extras-staging ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- fi
- ;;
-
- ${DIST}-backports)
- echo "deb ${MIRROR} ${DIST}-backports ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- ;;
-
- ${DIST}-backports-staging)
- echo "deb ${MIRROR} ${DIST}-backports-staging ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- ;;
-
- ${DIST}-backports-extras)
- if echo "${AREA}" | grep -qs non-free
- then
- echo "deb ${MIRROR} ${DIST}-backports-extras ${AREA} restricted" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- else
- echo "deb ${MIRROR} ${DIST}-backports-extras ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- fi
- ;;
-
- ${DIST}-backports-extras-staging)
- if echo "${AREA}" | grep -qs non-free
- then
- echo "deb ${MIRROR} ${DIST}-backports-extras-staging ${AREA} restricted" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- else
- echo "deb ${MIRROR} ${DIST}-backports-extras-staging ${AREA}" >> "${DIRECTORY}/etc/apt/sources.list.d/progress-linux.list"
- fi
- ;;
- esac
- done
+ Chroot "${DIRECTORY}" "debconf-set-selections progress-linux.cfg"
+ Chroot "${DIRECTORY}" "DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=criticial dpkg-reconfigure progress-linux"
+
+ rm -f "${DIRECTORY}/progress-linux.cfg"
;;
esac
@@ -602,9 +495,6 @@ EOF
rm -f "${DIRECTORY}/preseed.cfg"
fi
- # FIXME: All packages of priority of essential need to be reconfigured to reflect choices from preseeding
- # -> fix: use two-stage bootstrap (foreign) and inject preseeds in between
-
# Manual hack to workaround broken preseeding in locales package
if [ -n "${PRESEED_FILE}" ]
then
@@ -659,19 +549,9 @@ EOF
fi
done
- # FIXME: Install additional packages after lxc-support has been run.
- # This is suboptimal, ideally we should install all packages but not run the maintainer scripts,
- # then run lxc-support, and run the maintainer scripts. This way, lxc-support would see
- # all the installed packages and could skip those scripts entirely when a certain package is not
- # installed. Unfortunately, that is not possible in any reasonable way with apt-get.
- # FTR: The only known workaround for now would be to first apt-get install --download-only all
- # packages, then unpack them with dpkg, run lxc-support, and dpkg --configure them.
- # For the time being, it's better to have lxc-support see no packages at all and be run before
- # packages are installed, than the other way around.
- # Workaround: We're running lxc-support at the end of the template again.
if [ -n "${PACKAGES}" ]
then
- Chroot "${DIRECTORY}" "apt-get --option APT::Force-LoopBreak=true --option Dpkg::Options::=--force-confnew --yes install ${PACKAGES}"
+ Chroot "${DIRECTORY}" "apt --option Dpkg::Options::=--force-confnew --yes install ${PACKAGES}"
fi
# Manual hack to regenerate ssh keys
@@ -898,8 +778,6 @@ Commands ()
{
DIRECTORY="${1}"
- # config (FIXME)
-
# maximum of 15 characters, prefix is 'veth-'
HOSTNAME_SHORT="$(echo ${NAME} | cut -c-8)"
HOST_INTERFACE_NAME="$(echo ${NETWORK1_VETH:-veth-${HOSTNAME_SHORT}-0})"
@@ -992,8 +870,6 @@ for DEBCONF_SCRIPT in "/usr/share/${PROJECT}/${PROGRAM}/scripts/debconf.d"/*
do
if [ -x "${DEBCONF_SCRIPT}" ]
then
- # FIXME
- # debconf -o${SOFTWARE} "${DEBCONF_SCRIPT}"
"${DEBCONF_SCRIPT}"
fi
done
@@ -1078,7 +954,7 @@ fi
Configure_system "${MACHINES}/${NAME}"
Configure_network "${MACHINES}/${NAME}"
-Configure_systemd_networkd "${MACHINES}/${NAME}" # FIXME
+Configure_systemd_networkd "${MACHINES}/${NAME}"
Cleanup_system "${MACHINES}/${NAME}"
Commands "${MACHINES}/${NAME}"
diff --git a/share/scripts/debconf.d/0002-preseed-debconf b/share/scripts/debconf.d/0002-preseed-debconf
index 086fffc..9aca6bf 100755
--- a/share/scripts/debconf.d/0002-preseed-debconf
+++ b/share/scripts/debconf.d/0002-preseed-debconf
@@ -58,7 +58,7 @@ do
# preseed file has includes
INCLUDE_PRESEED_FILES="$(grep '^ *compute-tools *container/include-preseed-files' ${PRESEED_FILE} | awk '{ $1=$2=$3=""; print $0 }' | sed -e 's|,| |g')"
- # FIXME: we're supporting only *ONE* include layer for now, so no nested/recursive includes just yet
+ # only one include layer is supported, no nested/recursive includes
for FILE in ${INCLUDE_PRESEED_FILES}
do
if [ -e "${FILE}" ]
diff --git a/share/scripts/debconf.d/0003-debconf b/share/scripts/debconf.d/0003-debconf
index 843d0b4..684261a 100755
--- a/share/scripts/debconf.d/0003-debconf
+++ b/share/scripts/debconf.d/0003-debconf
@@ -118,20 +118,8 @@ Architecture ()
arm64)
DEFAULT="arm64"
- CHOICES="Automatic, Rpi1 (armel), Rpi2 (armhf), Rpi3 (arm64)"
- CHOICES_C="auto, armel, armhf, arm64"
- ;;
-
- armel)
- DEFAULT="armel"
- CHOICES="Automatic, Rpi1 (armel)"
- CHOICES_C="auto, armel"
- ;;
-
- armhf)
- DEFAULT="armhf"
- CHOICES="Automatic, Rpi1 (armel), Rpi2 (armhf)"
- CHOICES_C="auto, armel, armhf"
+ CHOICES="Automatic, RaspberryPi 3 (arm64)"
+ CHOICES_C="auto, arm64"
;;
i386)
@@ -195,29 +183,22 @@ Archives ()
debian)
case "${PARENT_DISTRIBUTION}" in
sid)
- db_subst container/archives CHOICES "Experimental"
- db_subst container/archives CHOICES_C "experimental"
+ db_subst container/archives CHOICES "sid, experimental"
- db_set container/archives ""
+ db_set container/archives "sid"
db_fset container/archives seen false
;;
*)
- db_subst container/archives CHOICES "Security, Updates, Backports, Proposed Updates"
- db_subst container/archives CHOICES_C "${DISTRIBUTION}-security, ${DISTRIBUTION}-updates, ${DISTRIBUTION}-backports, ${DISTRIBUTION}-proposed-updates"
+ db_subst container/archives CHOICES "${DISTRIBUTION}, ${DISTRIBUTION}-security, ${DISTRIBUTION}-updates, ${DISTRIBUTION}-backports, ${DISTRIBUTION}-proposed-updates"
case "${PARENT_DISTRIBUTION}" in
sid)
- db_set container/archives ""
- ;;
-
- buster)
- db_set container/archives "${DISTRIBUTION}-security, ${DISTRIBUTION}-updates"
+ db_set container/archives "sid"
;;
*)
- #db_set container/archives "${DISTRIBUTION}-security, ${DISTRIBUTION}-updates, ${DISTRIBUTION}-backports"
- db_set container/archives "${DISTRIBUTION}-security, ${DISTRIBUTION}-updates"
+ db_set container/archives "${DISTRIBUTION}, ${DISTRIBUTION}-security, ${DISTRIBUTION}-updates"
;;
esac
@@ -229,10 +210,9 @@ Archives ()
progress-linux)
DIST="$(echo ${DISTRIBUTION} | sed -e 's|-backports||')"
- db_subst container/archives CHOICES "staging, Security, Security (staging), Updates, Updates (staging), Extras, Extras (staging), Backports, Backports (staging), Backports Extras, Backports Extras (staging)"
- db_subst container/archives CHOICES_C "${DIST}-staging, ${DIST}-security, ${DIST}-security-staging, ${DIST}-updates, ${DIST}-updates-staging, ${DIST}-extras, ${DIST}-extras-staging, ${DIST}-backports, ${DIST}-backports-staging, ${DIST}-backports-extras, ${DIST}-backports-extras-staging"
+ db_subst container/archives CHOICES "${DIST}, ${DIST}-security, ${DIST}-updates, ${DIST}-extras, ${DIST}-backports, ${DIST}-backports-extras"
- db_set container/archives "${DIST}-security, ${DIST}-updates, ${DIST}-extras, ${DIST}-backports, ${DIST}-backports-extras"
+ db_set container/archives "${DIST}, ${DIST}-security, ${DIST}-updates, ${DIST}-extras, ${DIST}-backports, ${DIST}-backports-extras"
db_fset container/archives seen false
;;
esac
@@ -260,13 +240,11 @@ Parent_archives ()
then
case "${MODE}" in
progress-linux)
- db_subst container/parent-archives CHOICES "Security, Updates, Backports, Proposed Updates"
- db_subst container/parent-archives CHOICES_C "${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates, ${PARENT_DISTRIBUTION}-backports, ${PARENT_DISTRIBUTION}-proposed-updates"
+ db_subst container/parent-archives CHOICES "${PARENT_DISTRIBUTION}, ${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates, ${PARENT_DISTRIBUTION}-backports, ${PARENT_DISTRIBUTION}-proposed-updates"
case "${PARENT_DISTRIBUTION}" in
*)
- #db_set container/parent-archives "${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates, ${PARENT_DISTRIBUTION}-backports"
- db_set container/parent-archives "${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates"
+ db_set container/parent-archives "${PARENT_DISTRIBUTION}, ${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates"
;;
esac
@@ -278,8 +256,7 @@ Parent_archives ()
;;
*)
- db_subst container/parent-archives CHOICES "Security, Updates, Backports, Proposed Updates"
- db_subst container/parent-archives CHOICES_C "${ARCHIVES}"
+ db_subst container/parent-archives CHOICES "${DISTRIBUTION}, ${DISTRIBUTION}-security, ${DISTRIBUTION}-updates, ${DISTRIBUTION}-backports, ${DISTRIBUTION}-proposed-updates"
db_set container/parent-archives "${ARCHIVES}"
db_fset container/parent-archives seen true
@@ -295,8 +272,7 @@ Parent_archives ()
progress-linux)
case "${PARENT_DISTRIBUTION}" in
*)
- #PARENT_ARCHIVES="${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates, ${PARENT_DISTRIBUTION}-backports"
- PARENT_ARCHIVES="${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates"
+ PARENT_ARCHIVES="${PARENT_DISTRIBUTION}, ${PARENT_DISTRIBUTION}-security, ${PARENT_DISTRIBUTION}-updates"
;;
esac
;;
@@ -693,11 +669,6 @@ EOF
Network_defaults ()
{
- # FIXME:
- # * use interfaces.d where possible
- # * respect pre-existing interfaces (or interfaces.d)
- # * add support for bridges (make interface configuration more generic?)
-
HOSTNAME_SHORT="$(echo veth-$(echo ${NAME} | cut -c-8)-0)"
VETH_NAME="${HOSTNAME_SHORT}"
diff --git a/share/scripts/debconf.d/0003-debconf.templates b/share/scripts/debconf.d/0003-debconf.templates
index 3d607a7..13899ef 100644
--- a/share/scripts/debconf.d/0003-debconf.templates
+++ b/share/scripts/debconf.d/0003-debconf.templates
@@ -37,7 +37,6 @@ Description: Architecture
Template: container/archives
Type: multiselect
Default:
-Choices-C: ${CHOICES_C}
Choices: ${CHOICES}
Description: Archives
Archives.
@@ -45,7 +44,6 @@ Description: Archives
Template: container/parent-archives
Type: multiselect
Default:
-Choices-C: ${CHOICES_C}
Choices: ${CHOICES}
Description: Parent Archives
Parent Archives.
diff --git a/share/scripts/debootstrap b/share/scripts/debootstrap
index 7910ac3..61f5e13 100755
--- a/share/scripts/debootstrap
+++ b/share/scripts/debootstrap
@@ -20,8 +20,10 @@
set -e
PROJECT="open-infrastructure"
+SOFTWARE="compute-tools"
PROGRAM="container"
-SCRIPT="${0}"
+
+SCRIPT="$(basename ${0})"
HOOKS="/etc/${PROJECT}/${PROGRAM}/hooks"
MACHINES="/var/lib/machines"
@@ -126,9 +128,21 @@ then
exit 1
fi
-if [ ! -x /usr/sbin/debootstrap ]
+case "${SCRIPT}" in
+ debootstrap)
+ BOOTSTRAP="/usr/sbin/debootstrap"
+ BOOTSTRAP_OPTIONS=""
+ ;;
+
+ mmdebstrap)
+ BOOTSTRAP="/usr/bin/mmdebstrap"
+ BOOTSTRAP_OPTIONS="--mode=root"
+ ;;
+esac
+
+if [ ! -x "${BOOTSTRAP}" ]
then
- echo "'${NAME}': /usr/sbin/debootstrap - no such file." >&2
+ echo "'${NAME}': ${BOOTSTRAP} - no such file." >&2
exit 1
fi
@@ -162,8 +176,8 @@ done
mkdir -p "${MACHINES}"
-debootstrap --arch=${ARCHITECTURE} --include=${INCLUDE} ${DISTRIBUTION} ${MACHINES}/${NAME} ${MIRROR}
-chroot "${MACHINES}/${NAME}" apt-get clean
+${BOOTSTRAP} ${BOOTSTRAP_OPTIONS} --arch=${ARCHITECTURE} --include=${INCLUDE} ${DISTRIBUTION} ${MACHINES}/${NAME} ${MIRROR}
+chroot "${MACHINES}/${NAME}" apt clean
# Setting hostname
echo "${NAME}" > "${MACHINES}/${NAME}/etc/hostname"