From 877d8dd14c0f97bf64db6ab21d23da98dd64fdd5 Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel@debian.org>
Date: Sun, 23 Sep 2007 10:04:35 +0200
Subject: Adding live-package 0.99.12-1.

---
 AUTHORS                    |  2 ++
 ChangeLog                  | 18 ++++++++++
 FIXME                      | 26 --------------
 debian/changelog           |  8 +++++
 debian/control             |  2 +-
 doc/man/make-live.1        | 16 ++++++++-
 doc/man/make-live.conf.5   |  4 +--
 src/config                 |  6 ++++
 src/main.sh                | 20 +++++++----
 src/scripts/02defaults.sh  | 63 +++++++++++++++++++--------------
 src/scripts/11bootstrap.sh | 20 +++++------
 src/scripts/13hack.sh      |  9 +++--
 src/scripts/14chroot.sh    | 10 ++----
 src/scripts/21image.sh     | 86 +++++++++++++++++++++++++---------------------
 src/scripts/22iso.sh       |  4 ++-
 src/scripts/23net.sh       |  4 ++-
 16 files changed, 170 insertions(+), 128 deletions(-)
 delete mode 100644 FIXME

diff --git a/AUTHORS b/AUTHORS
index 37156f1..cc8f0f1 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -9,3 +9,5 @@ Patches (alphabetical order):
 	* Bas Wijnen <wijnen@debian.org>
 	* Frederic Lehobey <Frederic.Lehobey@free.fr>
 	* Jason D. Clinton <me@jasonclinton.com>
+	* Marcelo D. Re <mdre@rectorado.unl.edu.ar>
+	* Otavio Salvador <otavio@debian.org>
diff --git a/ChangeLog b/ChangeLog
index 4e77760..f017bc2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2006-10-25 Daniel Baumann <daniel@debian.org>
+
+	* Applied patch from Marcelo D. Re <mdre@rectorado.unl.edu.ar>:
+	  - skip deb-src source-list entries when building images with
+	    --without-source.
+	* Applied patches from Otavio Salvador <otavio@debian.org>:
+	  - adding '--bootstrap-config' to support cdebootstraps
+	    '--suite-config'.
+	  - allowing override of ${BASE}.
+	  - adjust sourcing of scripts, so that only the real scripts are
+	    sourced and not other (backup) files.
+	  - allowing override of kernel-packages.
+	* Reverted mangling of LIVE_DISTRIBUTION for sources.list generation.
+
+2006-10-18 Daniel Baumann <daniel@debian.org>
+
+	* Autodetecting proxy now.
+
 2006-10-16 Daniel Baumann <daniel@debian.org>
 
 	* Readded and slightly changed --clone and --preseed.
diff --git a/FIXME b/FIXME
deleted file mode 100644
index 54d350b..0000000
--- a/FIXME
+++ /dev/null
@@ -1,26 +0,0 @@
-14chroot.sh
-
-        # Add splashy and conditionally a theme
-        if [ ! -z "${LIVE_SPLASHY}" ]
-        then
-                chroots "apt-get install --yes splashy splashy-themes"
-
-                if [ ! -z "${LIVE_SPLASHY_THEME}" ]
-                then
-                        # not already installed ? Then its a new theme to install!
-                        if [ ! -d "${LIVE_CHROOT}"/etc/splashy/themes/"${LIVE_SPLASHY_THEME}" ]
-                        then
-                                if [ -f "${LIVE_SPLASHY_THEME}".tar.gz ]
-                                then
-                                        cp "${LIVE_SPLASHY_THEME}".tar.gz "${LIVE_CHROOT}"/tmp/"${LIVE_SPLASHY_THEME}".tar.gz # this permits simlink to theme
-                                        chroots "splashy_config -i /tmp/${LIVE_SPLASHY_THEME}.tar.gz"
-                                        rm "${LIVE_CHROOT}"/tmp/"${LIVE_SPLASHY_THEME}".tar.gz
-                                        chroots "splashy_config -s ${LIVE_SPLASHY_THEME}"
-                                else
-                                        echo "Specify the local splashy theme without extension, it also must be in the cwd"
-                                fi
-                        else
-                                chroots "splashy_config -s ${LIVE_SPLASHY_THEME}"
-                        fi
-                fi
-        fi
diff --git a/debian/changelog b/debian/changelog
index 10d17a7..6b7c60e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+live-package (0.99.12-1) unstable; urgency=medium
+
+  * New upstream release.
+    - Reverted mangling of LIVE_DISTRIBUTION for sources.list generation
+      (Closes: #394226).
+
+ -- Daniel Baumann <daniel@debian.org>  Mon, 23 Oct 2006 00:00:00 +0200
+
 live-package (0.99.11-1) unstable; urgency=medium
 
   * New upstream release.
diff --git a/debian/control b/debian/control
index 3d4691d..7beaed0 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Standards-Version: 3.7.2
 
 Package: live-package
 Architecture: all
-Depends: cdebootstrap (>= 0.3.10), genext2fs, mkisofs, squashfs-tools
+Depends: cdebootstrap (>= 0.3.15), genext2fs, mkisofs, squashfs-tools
 Provides: make-live
 Description: utility to build Debian Live systems
  make-live is a utility to build Debian Live systems. It takes a Debian mirror
diff --git a/doc/man/make-live.1 b/doc/man/make-live.1
index 5ffb449..10d156a 100644
--- a/doc/man/make-live.1
+++ b/doc/man/make-live.1
@@ -11,6 +11,8 @@ make-live \- utility to build Debian Live systems
 .IR KERNEL_PARAMETER \||\| \|"KERNEL_PARAMETERS\|" \|]
 .RB [\| \-\-config
 .IR FILE \|]
+.RB [\| \-\-clone
+.IR DIRECTORY \|]
 .RB [\| \-c \||\| \-\-chroot
 .IR DIRECTORY \|]
 .RB [\| \-d \||\| \-\-distribution
@@ -35,6 +37,8 @@ make-live \- utility to build Debian Live systems
 .IR URL \|]
 .RB [\| \-\-packages
 .IR PACKAGE \||\| \|"PACKAGES\|" \|]
+.RB [\| \-\-preseed
+.IR FILE \|]
 .RB [\| \-p \||\| \-\-package-list
 .IR LIST \||\| FILE \|]
 .RB [\| \-\-proxy-ftp
@@ -81,6 +85,12 @@ passes kernel parameters to the bootloader, e.g. 'quiet' or 'vga=792' etc. Inste
 .BI "\-\-config " FILE
 uses another configuration file in addition to the default one. Settings in the additional configuration file do overwrite the settings from /etc/make-live.conf. Instead of this flag, the environment variable LIVE_CONFIG can be used (Default: /etc/make-live.conf).
 .TP
+.BI "\-\-clone " DIRECTORY
+Clones the package selection and configuration from a given root directory. It
+will output the settings to $LIVE_ROOT/preseed.cloned and $LIVE_ROOT/plist.clone
+for easy reuse with \-\-preseed and \-\-package-list. Instead of this flag, the
+environment variable LIVE_CLONE can be used.
+.TP
 .BI "\-c, \-\-chroot " DIRECTORY
 specifies the chroot directory. Instead of this flag, the environment variable LIVE_CHROOT (Default: $LIVE_ROOT/chroot").
 .TP
@@ -120,6 +130,10 @@ specifies a list of packages to install into the chroot. Instead of this flag, t
 .BI "\-p, \-\-package-list " FILE
 specifies an external package list file, one package for each line. It overrides list option. Instead of this flag, the environment variable LIVE_PACKAGE_LIST can be used (Default: standard).
 .TP
+.BI "\-\-preseed " FILE
+clone the packages selection and configuration from the provided
+root directory.
+.TP
 .BI "\-\-proxy-ftp " URL
 specifies the value of ftp_proxy inside the chrooted environment. Instead of this flag, the environment variable LIVE_PROXY_FTP can be used (Default: empty).
 .TP
@@ -189,7 +203,7 @@ works fully on amd64 and i386, partially on alpha, hppa, ia64, mips, mipsel, pow
 Debian Live project <http://live.debian.net/>
 
 .SH SEE ALSO
-.BR make-live.conf(8)
+.BR make-live.conf(5)
 
 .SH AUTHOR
 make-live was written by Daniel Baumann <daniel@debian.org> and Marco Amadori
diff --git a/doc/man/make-live.conf.5 b/doc/man/make-live.conf.5
index 27c8e43..f44351d 100644
--- a/doc/man/make-live.conf.5
+++ b/doc/man/make-live.conf.5
@@ -1,7 +1,7 @@
 .TH MAKE-LIVE.CONF 5 "Mon,  4 Sep 2006" "0.99" "Debian Live framework"
 
 .SH NAME
-make-live.conf \- configuration file for make-live(8)
+make-live.conf \- configuration file for make-live(1)
 
 .SH DESCRIPTION
 make-live is a utility to build Debian Live systems. It takes a Debian mirror as an input and outputs a live system image (ISO image for CDs and DVDs, or tarball for netboot). make-live is still in the early stage of development, but has basic functionality and can be run successfully.
@@ -87,7 +87,7 @@ works fully on amd64 and i386, partially on alpha, hppa, ia64, mips, mipsel, pow
 Debian Live project <http://live.debian.net/>
 
 .SH SEE ALSO
-.BR make-live(8)
+.BR make-live(1)
 
 .SH AUTHOR
 make-live was written by Daniel Baumann <daniel@debian.org> and Marco Amadori
diff --git a/src/config b/src/config
index 3cabd6f..4eecb36 100644
--- a/src/config
+++ b/src/config
@@ -30,6 +30,9 @@
 # Bootstrap flavour		(Default: standard)
 #LIVE_FLAVOUR="standard"
 
+# Bootstrap config      (Default: empty)
+#LIVE_BOOTSTRAP_CONFIG=""
+
 # User command			(Default: empty)
 #LIVE_HOOK=""
 
@@ -42,6 +45,9 @@
 # Kernel flavour		(Default: auto-detected)
 #LIVE_KERNEL=""
 
+# Kernel packages       (Default: auto-detected)
+#LIVE_KERNEL_PACKAGES=""
+
 # Desktop package manifest	(Default: empty)
 #LIVE_MANIFEST=""
 
diff --git a/src/main.sh b/src/main.sh
index d248961..1c97680 100755
--- a/src/main.sh
+++ b/src/main.sh
@@ -25,10 +25,10 @@
 set -e
 
 # Set static variables
-BASE="/usr/share/make-live"
+BASE=${LIVE_BASE:-"/usr/share/make-live"}
 CONFIG="/etc/make-live.conf"
 PROGRAM="`basename ${0}`"
-VERSION="0.99.11"
+VERSION="0.99.12"
 
 CODENAME_OLDSTABLE="woody"
 CODENAME_STABLE="sarge"
@@ -36,12 +36,12 @@ CODENAME_TESTING="etch"
 CODENAME_UNSTABLE="sid"
 
 # Source sub scripts
-for SCRIPT in "${BASE}"/scripts/*
+for SCRIPT in `find ${BASE}/scripts/ -not -name '*~' -and -type f`
 do
 	. "${SCRIPT}"
 done
 
-USAGE="Usage: ${PROGRAM} [-a|--architecture ARCHITECTURE] [-b|--bootappend KERNEL_PARAMETER|\"KERNEL_PARAMETERS\"] [--clone DIRECTORY] [--config FILE] [-c|--chroot DIRECTORY] [-d|--distribution DISTRIBUTION] [--disable-generic-indices] [--enable-generic-indices] [--filesystem FILESYSTEM] [-f|--flavour BOOTSTRAP_FLAVOUR] [--hook COMMAND|\"COMMANDS\"] [--include-chroot FILE|DIRECTORY] [--include-image FILE|DIRECTORY] [-k|--kernel KERNEL_FLAVOUR] [--manifest PACKAGE] [-m|--mirror URL] [--mirror-security URL] [--packages PACKAGE|\"PACKAGES\"] [-p|--package-list LIST|FILE] [--preseed FILE] [--proxy-ftp URL] [--proxy-http URL] [--repositories NAME] [-r|--root DIRECTORY] [-s|--section SECTION|\"SECTIONS\"] [--server-address HOSTNAME|IP] [--server-path DIRECTORY] [--templates DIRECTORY] [-t|--type TYPE]"
+USAGE="Usage: ${PROGRAM} [-a|--architecture ARCHITECTURE] [-b|--bootappend KERNEL_PARAMETER|\"KERNEL_PARAMETERS\"] [--clone DIRECTORY] [--config FILE] [-c|--chroot DIRECTORY] [-d|--distribution DISTRIBUTION] [--with-generic-indices] [--without-generic-indices] [--filesystem FILESYSTEM] [-f|--flavour BOOTSTRAP_FLAVOUR] [--hook COMMAND|\"COMMANDS\"] [--include-chroot FILE|DIRECTORY] [--include-image FILE|DIRECTORY] [-k|--kernel KERNEL_FLAVOUR] [--manifest PACKAGE] [-m|--mirror URL] [--mirror-security URL] [--packages PACKAGE|\"PACKAGES\"] [-p|--package-list LIST|FILE] [--preseed FILE] [--proxy-ftp URL] [--proxy-http URL] [--repositories NAME] [-r|--root DIRECTORY] [-s|--section SECTION|\"SECTIONS\"] [--server-address HOSTNAME|IP] [--server-path DIRECTORY] [--templates DIRECTORY] [-t|--type TYPE]"
 
 Help ()
 {
@@ -67,11 +67,11 @@ Help ()
 	echo "  -b, --bootappend: specifies the kernel parameter(s)."
 	echo "  --config: specifies an alternate configuration file."
 	echo "  -c, --chroot: specifies the chroot directory."
+	echo "  --clone: specifies a chroot directory to clone."
 	echo "  -d, --distribution: specifies the debian distribution."
-	echo "  --disable-generic-indices: disables generic debian package indices."
-	echo "  --enable-generic-indices: enables generic debian package indices (default)."
 	echo "  --filesystem: specifies the chroot filesystem."
 	echo "  -f, --flavour: specifies the bootstrap flavour."
+	echo "  --bootstrap-config: specifies the suite configuration to be used for bootstraping."
 	echo "  --hook: specifies extra command(s)."
 	echo "  --include-chroot: specifies file or directory for chroot inclusion."
 	echo "  --include-image: specifies file or directory for image inclusion."
@@ -83,6 +83,7 @@ Help ()
 	echo "  -p, --package-list: specifies additonal package list."
 	echo "  --repositories: specifies custom repositories."
 	echo "  -r, --root: specifies build root."
+	echo "  --preseed: specifies a debconf preseeding file."
 	echo "  --proxy-ftp: specifies \${ftp_proxy}."
 	echo "  --proxy-http: specifies \${http_proxy}."
 	echo "  -s, --section: specifies the debian sections."
@@ -90,6 +91,8 @@ Help ()
 	echo "  --server-path: specifies the netboot server path for chroot."
 	echo "  --templates: specifies location of the templates."
 	echo "  -t, --type: specifies live system type."
+	echo "  --with-generic-indices: enables generic debian package indices (default)."
+	echo "  --without-generic-indices: disables generic debian package indices."
 	echo
 	echo "Environment:"
 	echo "  All settings can be also specified trough environment variables. Please see make-live.conf(8) for more information."
@@ -159,7 +162,7 @@ Configuration ()
 
 Main ()
 {
-	ARGUMENTS="`getopt --longoptions root:,type:,architecture:,bootappend:,clone:,config:,chroot:,distribution:,filesystem:,flavour:,hook:,include-chroot:,include-image:,kernel:,manifest:,mirror:,mirror-security:,output:,packages:,package-list:,proxy-ftp:,preseed:,proxy-http:,repositories:,section:,server-address:,server-path:,templates:,with-generic-indices,without-generic-indices,with-source,without-source,help,usage,version --name=${PROGRAM} --options r:t:a:b:c:d:f:k:m:o:p:s:huv --shell sh -- "${@}"`"
+	ARGUMENTS="`getopt --longoptions root:,type:,architecture:,bootappend:,clone:,config:,chroot:,distribution:,filesystem:,flavour:,bootstrap-config:,hook:,include-chroot:,include-image:,kernel:,manifest:,mirror:,mirror-security:,output:,packages:,package-list:,proxy-ftp:,preseed:,proxy-http:,repositories:,section:,server-address:,server-path:,templates:,with-generic-indices,without-generic-indices,with-source,without-source,help,usage,version --name=${PROGRAM} --options r:t:a:b:c:d:f:k:m:o:p:s:huv --shell sh -- "${@}"`"
 
 	if [ "${?}" != "0" ]
 	then
@@ -211,6 +214,9 @@ Main ()
 			-f|--flavour)
 				LIVE_FLAVOUR="${2}"; shift 2
 				;;
+			--bootstrap-config)
+				LIVE_BOOTSTRAP_CONFIG="${2}"; shift 2
+				;;
 			--hook)
 				LIVE_HOOK="${2}"; shift 2
 				;;
diff --git a/src/scripts/02defaults.sh b/src/scripts/02defaults.sh
index dffa490..f0ef328 100644
--- a/src/scripts/02defaults.sh
+++ b/src/scripts/02defaults.sh
@@ -54,33 +54,12 @@ Defaults ()
 	if [ -z "${LIVE_DISTRIBUTION}" ]
 	then
 		LIVE_DISTRIBUTION="testing"
-	else
-		case "${LIVE_DISTRIBUTION}" in
-			"${CODENAME_OLDSTABLE}")
-				LIVE_DISTRIBUTION="oldstable"
-				;;
-
-			"${CODENAME_STABLE}")
-				LIVE_DISTRIBUTION="stable"
-				;;
-
-			"${CODENAME_TESTING}")
-				LIVE_DISTRIBUTION="testing"
-				;;
-
-			"${CODENAME_UNSTABLE}")
-				LIVE_DISTRIBUTION="unstable"
-				;;
-
-			experimental)
-				LIVE_DISTRIBUTION="unstable"
-				LIVE_DISTRIBUTION_EXPERIMENTAL="yes"
-				;;
+	fi
 
-			*)
-				LIVE_DISTRIBUTION="unstable"
-				;;
-		esac
+	if [ "${LIVE_DISTRIBUTION}" = "experimental" ]
+	then
+		LIVE_DISTRIBUTION="unstable"
+		LIVE_DISTRIBUTION_EXPERIMENTAL="yes"
 	fi
 
 	# Set bootstrap flavour
@@ -161,6 +140,12 @@ Defaults ()
 		esac
 	fi
 
+	# Set kernel packages
+	if [ -z "${LIVE_KERNEL_PACKAGES}" ]
+	then
+		LIVE_KERNEL_PACKAGES="linux-image-2.6-${LIVE_KERNEL} squashfs-modules-2.6-${LIVE_KERNEL} unionfs-modules-2.6-${LIVE_KERNEL}"
+	fi
+
 	# Set debian mirror
 	if [ -z "${LIVE_MIRROR}" ]
 	then
@@ -194,6 +179,32 @@ Defaults ()
 		fi
 	fi
 
+	# Set FTP proxy
+	if [ -z "${LIVE_PROXY_FTP}" ] && [ -n "${ftp_proxy}" ]
+	then
+		LIVE_PROXY_FTP="${ftp_proxy}"
+		export LIVE_PROXY_FTP
+	else
+		if [ -n "${LIVE_PROXY_FTP}" ] && [ "${LIVE_PROXY_FTP}" != "${ftp_proxy}" ]
+		then
+			ftp_proxy="${LIVE_PROXY_FTP}"
+			export ftp_proxy
+		fi
+	fi
+
+	# Set HTTP proxy
+	if [ -z "${LIVE_PROXY_HTTP}" ] && [ -n "${http_proxy}" ]
+	then
+		LIVE_PROXY_HTTP="${http_proxy}"
+		export LIVE_PROXY_HTTP
+	else
+		if [ -n "${LIVE_PROXY_HTTP}" ] && [ "${LIVE_PROXY_HTTP}" != "${http_proxy}" ]
+		then
+			http_proxy="${LIVE_PROXY_HTTP}"
+			export http_proxy
+		fi
+	fi
+
 	# Set debian sections
 	if [ -z "${LIVE_SECTION}" ]
 	then
diff --git a/src/scripts/11bootstrap.sh b/src/scripts/11bootstrap.sh
index f2f6c0a..9aee5ec 100644
--- a/src/scripts/11bootstrap.sh
+++ b/src/scripts/11bootstrap.sh
@@ -13,25 +13,21 @@ Bootstrap ()
 {
 	if [ ! -f "${LIVE_ROOT}"/.stage/bootstrap ]
 	then
-		# Use proxy
-		if [ -n "${LIVE_PROXY_FTP}" ] && [ -z "${ftp_proxy}" ]
-		then
-			export ftp_proxy="${LIVE_PROXY_FTP}"
-		fi
-
-		if [ -n "${LIVE_PROXY_HTTP}" ] && [ -z "${http_proxy}" ]
-		then
-			export http_proxy="${LIVE_PROXY_HTTP}"
-		fi
-
 		# Create chroot directory
 		if [ ! -d "${LIVE_CHROOT}" ]
 		then
 			mkdir -p "${LIVE_CHROOT}"
 		fi
 
+		if [ -n "${LIVE_BOOTSTRAP_CONFIG}" ]; then
+			SUITE_CONFIG="--suite-config ${LIVE_BOOTSTRAP_CONFIG}"
+		fi 
+
 		# Bootstrap system
-		cdebootstrap --arch="${LIVE_ARCHITECTURE}" --flavour="${LIVE_FLAVOUR}" "${LIVE_DISTRIBUTION}" "${LIVE_CHROOT}" "${LIVE_MIRROR}"
+		cdebootstrap --arch="${LIVE_ARCHITECTURE}" --flavour="${LIVE_FLAVOUR}" ${SUITE_CONFIG} "${LIVE_DISTRIBUTION}" "${LIVE_CHROOT}" "${LIVE_MIRROR}"
+
+		# Remove unused packages
+		Chroot_exec "apt-get remove --purge --yes cdebootstrap-helper-diverts"
 
 		# Remove package cache
 		rm -rf "${LIVE_CHROOT}"/var/cache/bootstrap
diff --git a/src/scripts/13hack.sh b/src/scripts/13hack.sh
index bd3a335..1f7b57a 100644
--- a/src/scripts/13hack.sh
+++ b/src/scripts/13hack.sh
@@ -12,9 +12,12 @@
 Hack_xorg ()
 {
 	# xserver-xorg << 7.1
-	if [ -f "${LIVE_CHROOT}/etc/X11/xorg.conf" ] && [ "${LIVE_DISTRIBUTION}" = "testing" ]
+	if [ -f "${LIVE_CHROOT}/etc/X11/xorg.conf" ]
 	then
-		# Comment "BusID" line and set driver to "vesa"
-		sed -i -e 's/\(^.*BusID.*\)/#\1/g' -e '/Section "Device"/,/EndSection/ s/\(.*Driver.*"\).*\(".*\)/\1vesa\2/g' "${LIVE_CHROOT}"/etc/X11/xorg.conf
+		if [ "${LIVE_DISTRIBUTION}" = "testing" ] || [ "${LIVE_DISTRIBUTION}" = "${CODENAME_TESTING}" ]
+		then
+			# Comment "BusID" line and set driver to "vesa"
+			sed -i -e 's/\(^.*BusID.*\)/#\1/g' -e '/Section "Device"/,/EndSection/ s/\(.*Driver.*"\).*\(".*\)/\1vesa\2/g' "${LIVE_CHROOT}"/etc/X11/xorg.conf
+		fi
 	fi
 }
diff --git a/src/scripts/14chroot.sh b/src/scripts/14chroot.sh
index b650712..5b226e1 100644
--- a/src/scripts/14chroot.sh
+++ b/src/scripts/14chroot.sh
@@ -34,7 +34,7 @@ Chroot ()
 		Indices custom
 
 		# Install secure apt
-		if [ "${LIVE_DISTRIBUTION}" = "testing" ] || [ "${LIVE_DISTRIBUTION}" = "unstable" ]
+		if [ "${LIVE_DISTRIBUTION}" = "testing" ] || [ "${LIVE_DISTRIBUTION}" = "${CODENAME_TESTING}" ] || [ "${LIVE_DISTRIBUTION}" = "unstable" ] || [ "${LIVE_DISTRIBUTION}" = "${CODENAME_UNSTABLE}" ]
 		then
 			if [ "${LIVE_FLAVOUR}" != "minimal" ]
 			then
@@ -65,7 +65,7 @@ Chroot ()
 		Patch_linux apply
 
 		# Install linux-image, modules and casper
-		Chroot_exec "apt-get install --yes --force-yes linux-image-2.6-${LIVE_KERNEL} squashfs-modules-2.6-${LIVE_KERNEL} unionfs-modules-2.6-${LIVE_KERNEL} casper"
+		Chroot_exec "apt-get install --yes --force-yes ${LIVE_KERNEL_PACKAGES} casper"
 
 		# Deconfigure linux-image
 		Patch_linux deapply
@@ -159,16 +159,10 @@ Chroot ()
 			Chroot_exec "dpkg-query -W \*" | awk '$2 ~ /./ {print $1 " " $2 }' > "${LIVE_ROOT}"/filesystem.manifest-desktop
 		fi
 
-		# Remove unused packages
-		Chroot_exec "apt-get remove --purge --yes cdebootstrap-helper-diverts"
-
 		# Clean apt packages cache
 		rm -rf "${LIVE_CHROOT}"/var/cache/apt
 		mkdir -p "${LIVE_CHROOT}"/var/cache/apt/archives/partial
 
-		# Remove cdebootstrap packages cache
-		rm -rf "${LIVE_CHROOT}"/var/cache/bootstrap
-
 		# Unmount proc
 		umount "${LIVE_CHROOT}"/proc
 
diff --git a/src/scripts/21image.sh b/src/scripts/21image.sh
index 1bab3e1..57c3d9f 100644
--- a/src/scripts/21image.sh
+++ b/src/scripts/21image.sh
@@ -15,35 +15,38 @@ Indices ()
 		custom)
 			# Configure custom sources.list
 			case "${LIVE_DISTRIBUTION}" in
-				oldstable)
-					echo "deb ${LIVE_MIRROR} oldstable ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src ${LIVE_MIRROR} oldstable ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb ${LIVE_MIRROR_SECURITY} oldstable/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src ${LIVE_MIRROR_SECURITY} oldstable/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					;;
+				oldstable|"${CODENAME_OLDSTABLE}"|stable|"${CODENAME_STABLE}"|testing|"${CODENAME_TESTING}")
+					echo "deb ${LIVE_MIRROR} ${LIVE_DISTRIBUTION} ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
 
-				stable)
-					echo "deb ${LIVE_MIRROR} stable ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src ${LIVE_MIRROR} stable ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb ${LIVE_MIRROR_SECURITY} stable/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src ${LIVE_MIRROR_SECURITY} stable/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					;;
+					if [ "${LIVE_SOURCE}" = "yes" ]
+					then
+						echo "deb-src ${LIVE_MIRROR} ${LIVE_DISTRIBUTION} ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+					fi
+
+					echo "deb ${LIVE_MIRROR_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
 
-				testing)
-					echo "deb ${LIVE_MIRROR} testing ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src ${LIVE_MIRROR} testing ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb ${LIVE_MIRROR_SECURITY} testing/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src ${LIVE_MIRROR_SECURITY} testing/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+					if [ "${LIVE_SOURCE}" = "yes" ]
+					then
+						echo "deb-src ${LIVE_MIRROR_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+					fi
 					;;
 
-				unstable)
+				unstable|"${CODENAME_UNSTABLE}")
 					echo "deb ${LIVE_MIRROR} unstable ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src ${LIVE_MIRROR} unstable ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+
+					if [ "${LIVE_SOURCE}" = "yes" ]
+					then
+						echo "deb-src ${LIVE_MIRROR} unstable ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+					fi
 
 					if [ "${LIVE_DISTRIBUTION_EXPERIMENTAL}" = "yes" ]
 					then
 						echo "deb ${LIVE_MIRROR} experimental ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-						echo "deb-src ${LIVE_MIRROR} experimental ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+
+						if [ "${LIVE_SOURCE}" = "yes" ]
+						then
+							echo "deb-src ${LIVE_MIRROR} experimental ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+						fi
 
 cat > "${LIVE_CHROOT}"/etc/apt/preferences << EOF
 Package: *
@@ -58,35 +61,38 @@ EOF
 		default)
 			# Configure default sources.list
 			case "${LIVE_DISTRIBUTION}" in
-				oldstable)
-					echo "deb http://ftp.debian.org/debian/ oldstable ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src http://ftp.debian.org/debian/ oldstable ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb http://security.debian.org/ oldstable/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src http://security.debian.org/ oldstable/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					;;
+				oldstable|"${CODENAME_OLDSTABLE}"|stable|"${CODENAME_STABLE}"|testing|"${CODENAME_TESTING}")
+					echo "deb http://ftp.debian.org/debian/ ${LIVE_DISTRIBUTION} ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
 
-				stable)
-					echo "deb http://ftp.debian.org/debian/ stable ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src http://ftp.debian.org/debian/ stable ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb http://security.debian.org/ stable/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src http://security.debian.org/ stable/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					;;
+					if [ "${LIVE_SOURCE}" = "yes" ]
+					then
+						echo "deb-src http://ftp.debian.org/debian/ ${LIVE_DISTRIBUTION} ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+					fi
+
+					echo "deb http://security.debian.org/ ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
 
-				testing)
-					echo "deb http://ftp.debian.org/debian/ testing ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src http://ftp.debian.org/debian/ testing ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb http://security.debian.org/ testing/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src http://security.debian.org/ testing/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+					if [ "${LIVE_SOURCE}" = "yes" ]
+					then
+						echo "deb-src http://security.debian.org/ ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+					fi
 					;;
 
-				unstable)
+				unstable|"${CODENAME_UNSTABLE}")
 					echo "deb http://ftp.debian.org/debian/ unstable ${LIVE_SECTION}" > "${LIVE_CHROOT}"/etc/apt/sources.list
-					echo "deb-src http://ftp.debian.org/debian/ unstable ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+
+					if [ "${LIVE_SOURCE}" = "yes" ]
+					then
+						echo "deb-src http://ftp.debian.org/debian/ unstable ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+					fi
 
 					if [ "${LIVE_DISTRIBUTION_EXPERIMENTAL}" = "yes" ]
 					then
 						echo "deb http://ftp.debian.org/debian/ experimental ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
-						echo "deb-src http://ftp.debian.org/debian/ experimental ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+
+						if [ "${LIVE_SOURCE}" = "yes" ]
+						then
+							echo "deb-src http://ftp.debian.org/debian/ experimental ${LIVE_SECTION}" >> "${LIVE_CHROOT}"/etc/apt/sources.list
+						fi
 					fi
 					;;
 			esac
diff --git a/src/scripts/22iso.sh b/src/scripts/22iso.sh
index 5088768..6f60a5f 100644
--- a/src/scripts/22iso.sh
+++ b/src/scripts/22iso.sh
@@ -23,7 +23,9 @@ Iso ()
 		mkdir -p "${LIVE_ROOT}"/binary/casper
 		for MANIFEST in "${LIVE_ROOT}"/filesystem.manifest*
 		do
-			mv "${MANIFEST}" "${LIVE_ROOT}"/binary/casper/
+			if [ -e "${MANIFEST}" ]; then
+				mv "${MANIFEST}" "${LIVE_ROOT}"/binary/casper/
+			fi
 		done
 
 		# Remove indices
diff --git a/src/scripts/23net.sh b/src/scripts/23net.sh
index 78a0361..3f973e0 100644
--- a/src/scripts/23net.sh
+++ b/src/scripts/23net.sh
@@ -25,7 +25,9 @@ Net ()
 		
 		for MANIFEST in "${LIVE_ROOT}"/filesystem.manifest*
 		do
-			mv "${MANIFEST}" "${LIVE_ROOT}"/binary/casper/
+			if [ -e "${MANIFEST}" ]; then
+				mv "${MANIFEST}" "${LIVE_ROOT}"/binary/casper/
+			fi
 		done
 
 		# Mount proc
-- 
cgit v1.0