[SCM] live-debconfig branch, debian-next, updated. debian/4.0_a4-1-4-g00ee264

Daniel Baumann daniel at debian.org
Wed Aug 22 07:49:05 UTC 2012


The following commit has been merged in the debian-next branch:
commit 00ee2641a98d84a0e0bb1dd17146ba33fed64bc7
Author: Daniel Baumann <daniel at debian.org>
Date:   Wed Aug 22 09:48:54 2012 +0200

    Updating.

diff --git a/bin/live-debconfig b/bin/live-debconfig
index a4d2d40..ca75aa2 100755
--- a/bin/live-debconfig
+++ b/bin/live-debconfig
@@ -62,10 +62,15 @@ EOF
 
 fi
 
-if [ "${1}" = "--noscripts" ]
-then
-	exit
-fi
+case "${1}" in
+	--noscripts)
+		exit
+		;;
+
+	--preseed)
+		PRESEED="true"
+		;;
+esac
 
 # Run debconf scripts
 for _SCRIPT in /lib/live/debconfig/*
@@ -73,6 +78,6 @@ do
 	if [ -x "${_SCRIPT}" ]
 	then
 		# FIXME: make scripts a multiselect
-		"${_SCRIPT}"
+		PRESEED="${PRESEED}" "${_SCRIPT}"
 	fi
 done
diff --git a/scripts/debconfig.sh b/scripts/debconfig.sh
new file mode 100755
index 0000000..0474ec7
--- /dev/null
+++ b/scripts/debconfig.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+## live-debconfig(7) - System Configuration Scripts
+## Copyright (C) 2006-2012 Daniel Baumann <daniel at 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 ()
+{
+	DEBCONF_FIELD="${1}"
+	DEBCONF_TYPE="${2}"
+	DEBCONF_DEFAULT="${3}"
+
+	DEBCONF_RETURN="_$(basename ${DEBCONF_FIELD} | tr [a-z] [A-Z])"
+
+	# Read from database
+	db_get ${DEBCONF_FIELD}
+	DEBCONF_VARIABLE="${RET}"
+
+	# Read from user
+	if [ -z "${DEBCONF_VARIABLE}" ]
+	then
+		if [ -n "${DEBCONF_DEFAULT}" ]
+		then
+			db_set ${DEBCONF_FIELD} ${DEBCONF_DEFAULT}
+			db_fset ${DEBCONF_FIELD} seen false
+		fi
+
+		if [ "${PRESEED}" != true ]
+		then
+			case "${DEBCONF_TYPE}" in
+				external*)
+					db_settitle live-debconfig/title
+					db_input high ${DEBCONF_FIELD} || true
+					db_go
+
+					db_get ${DEBCONF_FIELD}
+					DEBCONF_VARIABLE="${RET}"
+
+					case "${DEBCONF_TYPE}" in
+						*non-empty)
+							if [ -z "${DEBCONF_VARIABLE}" ]
+							then
+								DEBCONF_VARIABLE="${DEBCONF_DEFAULT}"
+							fi
+							;;
+					esac
+					;;
+			esac
+		fi
+	fi
+
+	eval ${DEBCONF_RETURN}="\"${DEBCONF_VARIABLE}\""
+	export $(echo ${DEBCONF_RETURN})
+}
diff --git a/scripts/debconfig/0010-hostname b/scripts/debconfig/0010-hostname
index 17eb51c..fb2790a 100755
--- a/scripts/debconfig/0010-hostname
+++ b/scripts/debconfig/0010-hostname
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -x
 
 ## live-debconfig(7) - System Configuration Scripts
 ## Copyright (C) 2006-2012 Daniel Baumann <daniel at debian.org>
@@ -15,66 +15,40 @@ export DEBCONF_SYSTEMRC
 
 . /usr/share/debconf/confmodule
 
+#. /lib/live/debconfig.sh
+. ../debconfig.sh
+
 Hostname ()
 {
-	db_get live-debconfig/hostname/hostname
-	_HOSTNAME="${RET}" # string (w/o empty)
-
-	if [ -z "${_HOSTNAME}" ]
+	# Hostname: default
+	if [ -n "$(cat /etc/hostname 2> /dev/null)" ]
 	then
-		if [ -n "$(cat /etc/hostname 2> /dev/null)" ]
-		then
-			_HOSTNAME="$(cat /etc/hostname)"
-		elif [ -e /etc/os-release ]
-		then
-			. /etc/os-release
-			_HOSTNAME="${ID:-debian}"
-		elif [ -x /usr/bin/lsb_release ]
-		then
-			_HOSTNAME="$(lsb_release -is | tr [A-Z] [a-z])"
-		elif [ -e /etc/progress_version ]
-		then
-			_HOSTNAME="progress"
-		else
-			_HOSTNAME="debian"
-		fi
+		DEFAULT="$(cat /etc/hostname)"
+	elif [ -e /etc/os-release ]
+	then
+		. /etc/os-release
 
-		db_set live-debconfig/hostname/hostname "${_HOSTNAME}"
-		db_fset live-debconfig/hostname/hostname seen false
+		DEFAULT="${ID}"
+	elif [ -x /usr/bin/lsb_release ]
+	then
+		DEFAULT="$(lsb_release -is | tr [A-Z] [a-z])"
+	elif [ -e /etc/progress_version ]
+	then
+		DEFAULT="progress"
+	fi
 
-		db_settitle live-debconfig/title
-		db_input high live-debconfig/hostname/hostname || true
-		db_go
+	DEFAULT="${DEFAULT:-debian}"
+	db_set live-debconfig/hostname/hostname ${DEFAULT}
 
-		db_get live-debconfig/hostname/hostname
-		_HOSTNAME="${RET}" # string (w/o empty)
+	# Hostname: debconf
+	Debconf live-debconfig/hostname/hostname external-non-empty ${DEFAULT}
 
-		if [ -z "${_HOSTNAME}" ]
-		then
-			if [ -n "$(cat /etc/hostname 2> /dev/null)" ]
-			then
-				_HOSTNAME="$(cat /etc/hostname)"
-			elif [ -e /etc/os-release ]
-			then
-				. /etc/os-release
-				_HOSTNAME="${ID:-debian}"
-			elif [ -x /usr/bin/lsb_release ]
-			then
-				_HOSTNAME="$(lsb_release -is | tr [A-Z] [a-z])"
-			elif [ -e /etc/progress_version ]
-			then
-				_HOSTNAME="progress"
-			else
-				_HOSTNAME="debian"
-			fi
-		fi
-	fi
+	# Hostname: configuration
+	echo "${_HOSTNAME}" > /etc/hostname.tmp
+	mv /etc/hostname.tmp /etc/hostname
 }
 
 ## live-debconfig/hostname/hostname
 Hostname
 
-echo "${_HOSTNAME}" > /etc/hostname.tmp
-mv /etc/hostname.tmp /etc/hostname
-
 db_stop

-- 
live-debconfig



More information about the debian-live-changes mailing list