Adding multiselect debconf dialog for script selection when being used interactively.
authorDaniel Baumann <daniel@debian.org>
Thu, 6 Dec 2012 16:52:18 +0000 (17:52 +0100)
committerDaniel Baumann <daniel@debian.org>
Thu, 6 Dec 2012 17:23:23 +0000 (18:23 +0100)
bin/live-debconfig
scripts/debconfig/multiselect [new file with mode: 0755]
scripts/debconfig/multiselect.templates [new file with mode: 0644]

index 7cd74d0..df4b892 100755 (executable)
@@ -34,12 +34,12 @@ Cmdline ()
 
                        --debconfig)
                                # Run all scripts
-                               _SCRIPTS="$(ls /lib/live/debconfig/* | grep -v '\.templates$')"
+                               _SCRIPTS="$(ls /lib/live/debconfig/????-* | grep -v '\.templates$')"
                                ;;
 
                        --nodebconfig=*)
                                # Don't run requested scripts
-                               _SCRIPTS="$(ls /lib/live/debconfig/* | grep -v '\.templates$')"
+                               _SCRIPTS="$(ls /lib/live/debconfig/????-* | grep -v '\.templates$')"
                                LIVE_NODEBCONFIGS="${_PARAMETER#*nodebconfig=}"
                                ;;
 
@@ -52,6 +52,14 @@ Cmdline ()
                        --debug)
                                LIVE_DEBUG="true"
                                ;;
+
+                       *)
+                               echo "Usage: live-debconfig"
+                               echo "Usage: live-debconfig --debconfig|--debconfig=SCRIPT1,SCRIPT2,SCRIPT3"
+                               echo "Usage: live-debconfig --nodebconfig|--nodebconfig=SCRIPT1,SCRIPT2,SCRIPT3"
+                               echo "Usage: live-debconfig --debug"
+                               exit 1
+                               ;;
                esac
        done
 
@@ -123,16 +131,6 @@ EOF
 
 Main ()
 {
-       _CMDLINE="${@}"
-
-       if [ -z "${_CMDLINE}" ]
-       then
-               echo "Usage: live-debconfig --debconfig|--debconfig=SCRIPT1,SCRIPT2,SCRIPT3"
-               echo "Usage: live-debconfig --nodebconfig|--nodebconfig=SCRIPT1,SCRIPT2,SCRIPT3"
-               echo "Usage: live-debconfig --debug"
-               exit 1
-       fi
-
        # Reading configuration files
        for _FILE in /etc/live/debconfig.conf /etc/live/debconfig/*
        do
@@ -143,6 +141,8 @@ Main ()
        done
 
        # Processing command line
+       _CMDLINE="${@}"
+
        Cmdline
 
        case "${LIVE_DEBUG}" in
@@ -155,6 +155,14 @@ Main ()
 
        Setup_debconf
 
+       if [ -z "${_SCRIPTS}" ]
+       then
+               /lib/live/debconfig/multiselect
+
+               . /var/lib/live/debconfig/multiselect
+               rm -f /var/lib/live/debconfig/multiselect
+       fi
+
        # Configuring system
        _SCRIPTS="$(echo ${_SCRIPTS} | sed -e 's| |\n|g' | sort -u)"
 
diff --git a/scripts/debconfig/multiselect b/scripts/debconfig/multiselect
new file mode 100755 (executable)
index 0000000..1aae7cd
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+## live-debconfig(7) - System Configuration Scripts
+## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
+##
+## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
+## This is free software, and you are welcome to redistribute it
+## under certain conditions; see COPYING for details.
+
+
+set -e
+
+DEBCONF_SYSTEMRC="/var/lib/live/debconfig/systemrc"
+export DEBCONF_SYSTEMRC
+
+. /usr/share/debconf/confmodule
+
+_SCRIPTS="$(for _SCRIPT in $(ls /lib/live/debconfig/????-* | grep -v '\.templates$' | sed -e 's|[0-9][0-9][0-9][0-9]-||g'); do echo -n "$(basename ${_SCRIPT}), "; done | sed -e 's|, $||')"
+_SCRIPTS_C="$(for _SCRIPT in $(ls /lib/live/debconfig/????-* | grep -v '\.templates$'); do echo -n "${_SCRIPT}, "; done | sed -e 's|, $||')"
+
+if [ -n "${_SCRIPTS}" ]
+then
+       db_subst live-debconfig/scripts CHOICES "${_SCRIPTS}"
+       db_subst live-debconfig/scripts CHOICES_C "${_SCRIPTS_C}"
+
+       db_fset live-debconfig/scripts seen false
+
+       db_settitle live-debconfig/title
+       db_input high live-debconfig/scripts || true
+       db_go
+
+       db_get live-debconfig/scripts
+       _SCRIPTS="${RET}" # multiselect
+
+       echo "_SCRIPTS=\"${_SCRIPTS}\"" > /var/lib/live/debconfig/multiselect
+
+       db_stop
+fi
diff --git a/scripts/debconfig/multiselect.templates b/scripts/debconfig/multiselect.templates
new file mode 100644 (file)
index 0000000..5293976
--- /dev/null
@@ -0,0 +1,11 @@
+Template: live-debconfig/title
+Type: title
+Description: live-debconfig: System Configuration
+
+Template: live-debconfig/scripts
+Type: multiselect
+Default:
+Choices: ${CHOICES}
+Choices-C: ${CHOICES_C}
+Description: live-debconfig: Scripts?
+ Which scripts should be run to configure the current system?