summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-07-22 10:48:59 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-07-22 22:28:22 +0000
commita886751a87e8831df47a7ce9c9952902e7a5623d (patch)
tree16bd3d0375e0612755783c68381e01ca9118d184
parentUpdating default url to download images from in curl container create script. (diff)
downloadcompute-tools-a886751a87e8831df47a7ce9c9952902e7a5623d.tar.xz
compute-tools-a886751a87e8831df47a7ce9c9952902e7a5623d.zip
Adding cnt-debconf/mode preseed field to allow embedding container create script within preseed file itself without relying on a specific default create script being set on the host system, thanks to David Kunz for the idea.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
-rw-r--r--share/doc/examples/dschinn-backports.cfg2
-rw-r--r--share/doc/examples/stretch.cfg2
-rwxr-xr-xshare/scripts/debconf28
-rwxr-xr-xshare/scripts/debconf.d/0003-debconf22
-rw-r--r--share/scripts/debconf.d/0003-debconf.templates8
5 files changed, 43 insertions, 19 deletions
diff --git a/share/doc/examples/dschinn-backports.cfg b/share/doc/examples/dschinn-backports.cfg
index 1cddcf2..367d874 100644
--- a/share/doc/examples/dschinn-backports.cfg
+++ b/share/doc/examples/dschinn-backports.cfg
@@ -3,6 +3,8 @@
# example for automated Progress Linux 4+ (dschinn-backports) container creation
# using: sudo container create -s progress-linux
+container-tools cnt-debconf/mode select progress-linux
+
#container-tools cnt-debconf/preseed-files string
#container-tools cnt-debconf/include-preseed-files string
diff --git a/share/doc/examples/stretch.cfg b/share/doc/examples/stretch.cfg
index 2af4b85..c355a80 100644
--- a/share/doc/examples/stretch.cfg
+++ b/share/doc/examples/stretch.cfg
@@ -3,6 +3,8 @@
# example for automated Debian 9 (stretch) based container creation
# using: sudo container create -s debian
+container-tools cnt-debconf/mode select debian
+
#container-tools cnt-debconf/preseed-files string
#container-tools cnt-debconf/include-preseed-files string
diff --git a/share/scripts/debconf b/share/scripts/debconf
index 38bf937..e97f41e 100755
--- a/share/scripts/debconf
+++ b/share/scripts/debconf
@@ -19,6 +19,7 @@
set -e
SCRIPT="${0}"
+export SCRIPT
CONFIG="/etc/container-tools/config"
HOOKS="/etc/container-tools/hooks"
@@ -971,24 +972,10 @@ Commands ()
umask 0022
-# Get distributor from template filename
-MODE="$(basename ${SCRIPT})"
-
-case "${MODE}" in
- debconf)
- MODE="debian"
- ;;
-esac
-
-export MODE
-
-CACHE="/var/cache/container-tools/${MODE}"
-SYSTEM="${MACHINES}/${NAME}"
+export NAME
Debconf
-export NAME
-
# Pre hooks
for FILE in "${HOOKS}/pre-${SCRIPT}".* "${HOOKS}/${NAME}.pre-${SCRIPT}"
do
@@ -999,19 +986,22 @@ do
done
# Run debconf parts
-for SCRIPT in /usr/share/container-tools/scripts/debconf.d/*
+for DEBCONF_SCRIPT in /usr/share/container-tools/scripts/debconf.d/*
do
- if [ -x "${SCRIPT}" ]
+ if [ -x "${DEBCONF_SCRIPT}" ]
then
# FIXME
- # debconf -ocontainer-tools "${SCRIPT}"
- "${SCRIPT}"
+ # debconf -ocontainer-tools "${DEBCONF_SCRIPT}"
+ "${DEBCONF_SCRIPT}"
fi
done
# Read-in configuration from debconf
. "${DEBCONF_TMPDIR}/debconf.default"
+CACHE="/var/cache/container-tools/${MODE}"
+SYSTEM="${MACHINES}/${NAME}"
+
## Generic parts
if [ ! -e "${CACHE}/${DISTRIBUTION}_${ARCHITECTURE}" ]
then
diff --git a/share/scripts/debconf.d/0003-debconf b/share/scripts/debconf.d/0003-debconf
index 8e78b3e..007ddfb 100755
--- a/share/scripts/debconf.d/0003-debconf
+++ b/share/scripts/debconf.d/0003-debconf
@@ -23,6 +23,26 @@ export DEBCONF_NOWARNINGS
. /usr/share/debconf/confmodule
+Mode ()
+{
+ db_get cnt-debconf/mode
+ MODE="${RET}" # select
+
+ if [ -z "${MODE}" ]
+ then
+ MODE="$(basename ${SCRIPT})"
+
+ case "${MODE}" in
+ debconf)
+ MODE="debian"
+ ;;
+ esac
+ fi
+
+ echo "MODE=\"${MODE}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+ export MODE
+}
+
Distribution ()
{
db_get cnt-debconf/distribution
@@ -1044,6 +1064,8 @@ Internal_options ()
echo "CNT_OVERLAY=\"${CNT_OVERLAY}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
}
+Mode
+
Distribution
Parent_distribution
diff --git a/share/scripts/debconf.d/0003-debconf.templates b/share/scripts/debconf.d/0003-debconf.templates
index e46fa88..61b8154 100644
--- a/share/scripts/debconf.d/0003-debconf.templates
+++ b/share/scripts/debconf.d/0003-debconf.templates
@@ -2,6 +2,14 @@ Template: cnt-debconf/title
Type: title
Description: container-tools
+Template: cnt-debconf/mode
+Type: select
+Default:
+Choices-C: ${CHOICES_C}
+Choices: ${CHOICES}
+Description: Mode
+ Mode.
+
Template: cnt-debconf/distribution
Type: select
Default: