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

---
 ChangeLog                 |  6 +++++
 Makefile                  |  4 +++
 debian/changelog          |  6 +++++
 src/hooks/minimal         |  4 +++
 src/lists/minimal         |  2 +-
 src/main.sh               |  2 +-
 src/scripts/02defaults.sh |  2 +-
 src/scripts/12patch.sh    | 56 ++++++++++++++++++++++++++++++++-------
 src/scripts/14chroot.sh   | 31 +++++++++++++++-------
 src/scripts/21image.sh    | 24 ++++++++++++-----
 src/scripts/22iso.sh      | 65 ++++++++++++++++++++++++++++++++++++++++-----
 src/scripts/23net.sh      | 67 +++++++++++++++++++++++++++++++++++++++++------
 12 files changed, 226 insertions(+), 43 deletions(-)
 create mode 100644 src/hooks/minimal

diff --git a/ChangeLog b/ChangeLog
index b22c8cf..c699f06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-09-26 Daniel Baumann <daniel@debian.org>
+
+	* Added default flavour hooks.
+	* minimal flavour does not install debian-archive-keyring to save space.
+	* Adjusted network patch.
+
 2006-09-25 Daniel Baumann <daniel@debian.org>
 
 	* Removed now unused initramfs-tools hack.
diff --git a/Makefile b/Makefile
index 2ea7ec0..29ebd20 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,10 @@ install:
 	install -d -m 0755 $(DESTDIR)/usr/share/make-live/lists
 	install -m 0644 src/lists/* $(DESTDIR)/usr/share/make-live/lists
 
+	@# Install flavour hooks
+	install -d -m 0755 $(DESTDIR)/usr/share/make-live/hooks
+	install -m 0644 src/hooks/* $(DESTDIR)/usr/share/make-live/hooks
+
 	@# Install sub scripts
 	install -d -m 0755 $(DESTDIR)/usr/share/make-live/scripts
 	install -m 0755 src/scripts/*.sh $(DESTDIR)/usr/share/make-live/scripts
diff --git a/debian/changelog b/debian/changelog
index cce7f00..b8814e1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+live-package (0.99.8-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Daniel Baumann <daniel@debian.org>  Mon, 25 Sep 2006 00:00:00 +0200
+
 live-package (0.99.7-1) unstable; urgency=medium
 
   * New upstream release:
diff --git a/src/hooks/minimal b/src/hooks/minimal
new file mode 100644
index 0000000..de36a30
--- /dev/null
+++ b/src/hooks/minimal
@@ -0,0 +1,4 @@
+# /usr/share/make-live/hooks/minimal - hook list for make-live(8)
+
+# Remove unused packages
+#apt-get remove --purge --yes apt-utils libdb4.4
diff --git a/src/lists/minimal b/src/lists/minimal
index 1289107..d57bbc2 100644
--- a/src/lists/minimal
+++ b/src/lists/minimal
@@ -1,4 +1,4 @@
 # /usr/share/make-live/lists/minimal - package list for make-live(8)
 
 # Minimal
-eject sudo
+eject nvi sudo
diff --git a/src/main.sh b/src/main.sh
index 06ec1ac..a6ccf85 100755
--- a/src/main.sh
+++ b/src/main.sh
@@ -28,7 +28,7 @@ set -e
 BASE="/usr/share/make-live"
 CONFIG="/etc/make-live.conf"
 PROGRAM="`basename ${0}`"
-VERSION="0.99.7"
+VERSION="0.99.8"
 
 CODENAME_OLDSTABLE="woody"
 CODENAME_STABLE="sarge"
diff --git a/src/scripts/02defaults.sh b/src/scripts/02defaults.sh
index fd58883..d23c021 100644
--- a/src/scripts/02defaults.sh
+++ b/src/scripts/02defaults.sh
@@ -219,7 +219,7 @@ Defaults ()
 	fi
 
 	# Set package indices
-	if [ -z "${LIVE_GENERIC_INDICES}" ]
+	if [ -z "${LIVE_GENERIC_INDICES}" ] && [ "${LIVE_FLAVOUR}" != "minimal" ]
 	then
 		LIVE_GENERIC_INDICES="yes"
 	fi
diff --git a/src/scripts/12patch.sh b/src/scripts/12patch.sh
index 873865c..7f07241 100644
--- a/src/scripts/12patch.sh
+++ b/src/scripts/12patch.sh
@@ -58,16 +58,25 @@ Patch_network ()
 
 	case "${1}" in
 		apply)
-			# Save host lookup table
-			if [ -f "${LIVE_CHROOT}"/etc/hosts ]
+			# Save apt configuration
+			if [ -f "${LIVE_CHROOT}"/etc/apt/apt.conf ]
 			then
-				cp "${LIVE_CHROOT}"/etc/hosts "${LIVE_CHROOT}"/etc/hosts.orig
+				cp "${LIVE_CHROOT}"/etc/apt/apt.conf "${LIVE_CHROOT}"/etc/apt/apt.conf.orig
 			fi
 
-			# Save resolver configuration
-			if [ -f "${LIVE_CHROOT}"/etc/resolv.conf ]
+			# Configure apt.conf
+			if [ -n "${LIVE_PROXY_FTP}" ]
 			then
-				cp "${LIVE_CHROOT}"/etc/resolv.conf "${LIVE_CHROOT}"/etc/resolv.conf.orig
+				echo "Acquire::ftp::Proxy \"${LIVE_PROXY_FTP}\";" >> "${LIVE_CHROOT}"/etc/apt/apt.conf
+			elif [ -n "${LIVE_PROXY_HTTP}" ]
+			then
+				echo "Acquire::http::Proxy \"${LIVE_PROXY_HTTP}\";" >> "${LIVE_CHROOT}"/etc/apt/apt.conf
+			fi
+
+			# Save host lookup table
+			if [ -f "${LIVE_CHROOT}"/etc/hosts ]
+			then
+				cp "${LIVE_CHROOT}"/etc/hosts "${LIVE_CHROOT}"/etc/hosts.orig
 			fi
 
 			# Copy host lookup table
@@ -76,6 +85,12 @@ Patch_network ()
 				cp /etc/hosts "${LIVE_CHROOT}"/etc/hosts
 			fi
 
+			# Save resolver configuration
+			if [ -f "${LIVE_CHROOT}"/etc/resolv.conf ]
+			then
+				cp "${LIVE_CHROOT}"/etc/resolv.conf "${LIVE_CHROOT}"/etc/resolv.conf.orig
+			fi
+
 			# Copy resolver configuration
 			if [ -f /etc/resolv.conf ]
 			then
@@ -84,16 +99,28 @@ Patch_network ()
 			;;
 
 		deapply)
+			# Restore apt configuration
+			if [ -f "${LIVE_CHROOT}"/etc/apt/apt.conf.orig ]
+			then
+				mv "${LIVE_CHROOT}"/etc/apt/apt.conf.orig "${LIVE_CHROOT}"/etc/apt/apt.conf
+			else
+				rm -f "${LIVE_CHROOT}"/etc/apt/apt.conf
+			fi
+
 			# Restore host lookup table
 			if [ -f "${LIVE_CHROOT}"/etc/hosts.orig ]
 			then
 				mv "${LIVE_CHROOT}"/etc/hosts.orig "${LIVE_CHROOT}"/etc/hosts
+			else
+				rm -f "${LIVE_CHROOT}"/etc/hosts
 			fi
 
 			# Restore resolver configuration
 			if [ -f "${LIVE_CHROOT}"/etc/resolv.conf.orig ]
 			then
 				mv "${LIVE_CHROOT}"/etc/resolv.conf.orig "${LIVE_CHROOT}"/etc/resolv.conf
+			else
+				rm -f "${LIVE_CHROOT}"/etc/resolv.conf
 			fi
 			;;
 	esac
@@ -107,13 +134,24 @@ Patch_linux ()
 
 	case "${1}" in
 		apply)
-			# Write configuration option
+			# Save kernel configuration
+			if [ -f "${LIVE_CHROOT}"/etc/kernel-img.conf ]
+			then
+				cp "${LIVE_CHROOT}"/etc/kernel-img.conf "${LIVE_CHROOT}"/etc/kernel-img.conf.old
+			fi
+
+			# Configure kernel-img.conf
 			echo "do_initrd = Yes"  >> "${LIVE_CHROOT}"/etc/kernel-img.conf
 			;;
 
 		deapply)
-			# Remove configuration file
-			rm -f "${LIVE_CHROOT}"/etc/kernel-img.conf
+			# Restore kernel configuration
+			if [ -f "${LIVE_CHROOT}"/etc/kernel-img.conf.old ]
+			then
+				mv "${LIVE_CHROOT}"/etc/kernel-img.conf.old "${LIVE_CHROOT}"/etc/kernel-img.conf
+			else
+				rm -f "${LIVE_CHROOT}"/etc/kernel-img.conf
+			fi
 			;;
 	esac
 }
diff --git a/src/scripts/14chroot.sh b/src/scripts/14chroot.sh
index 918e09a..356c1a2 100644
--- a/src/scripts/14chroot.sh
+++ b/src/scripts/14chroot.sh
@@ -33,7 +33,10 @@ Chroot ()
 		# Install secure apt
 		if [ "${LIVE_DISTRIBUTION}" = "testing" ] || [ "${LIVE_DISTRIBUTION}" = "unstable" ]
 		then
-			Chroot_exec "apt-get install --yes --force-yes debian-archive-keyring"
+			if [ "${LIVE_FLAVOUR}" != "minimal" ]
+			then
+				Chroot_exec "apt-get install --yes --force-yes debian-archive-keyring"
+			fi
 		fi
 
 		# Update indices
@@ -43,7 +46,7 @@ Chroot ()
 		Patch_linux apply
 
 		# Install linux-image, modules and casper
-		Chroot_exec "apt-get install --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 linux-image-2.6-${LIVE_KERNEL} squashfs-modules-2.6-${LIVE_KERNEL} unionfs-modules-2.6-${LIVE_KERNEL} casper"
 
 		# Deconfigure linux-image
 		Patch_linux deapply
@@ -52,14 +55,14 @@ Chroot ()
 		if [ -n "${LIVE_PACKAGE_LIST}" ]
 		then
 			grep -v "^#" "${LIVE_PACKAGE_LIST}" > "${LIVE_CHROOT}"/root/"`basename ${LIVE_PACKAGE_LIST}`"
-			Chroot_exec "xargs --arg-file=/root/`basename ${LIVE_PACKAGE_LIST}` apt-get install --yes"
+			Chroot_exec "xargs --arg-file=/root/`basename ${LIVE_PACKAGE_LIST}` apt-get install --yes --force-yes"
 			rm -f "${LIVE_CHROOT}"/root/"`basename ${LIVE_PACKAGE_LIST}`"
 		fi
 
 		# Install extra packages
 		if [ -n "${LIVE_PACKAGES}" ]
 		then
-			Chroot_exec "apt-get install --yes ${LIVE_PACKAGES}"
+			Chroot_exec "apt-get install --yes --force-yes ${LIVE_PACKAGES}"
 		fi
 
 		# Copy external directory into the chroot
@@ -70,6 +73,14 @@ Chroot ()
 			cd "${OLDPWD}"
 		fi
 
+		# Process flavour specific hooks
+		if [ -r "${BASE}"/hooks/"${LIVE_FLAVOUR}" ]
+		then
+			grep -v "^#" "${BASE}"/hooks/"${LIVE_FLAVOUR}" > "${LIVE_CHROOT}"/root/"${LIVE_FLAVOUR}"
+			Chroot_exec "sh /root/${LIVE_FLAVOUR}"
+			rm -f "${LIVE_CHROOT}"/root/"${LIVE_FLAVOUR}"
+		fi
+
 		# Execute extra command in the chroot
 		if [ -r "${LIVE_HOOK}" ]
 		then
@@ -88,16 +99,16 @@ Chroot ()
 
 		if [ ! -z "${LIVE_MANIFEST}" ]
 		then
-			Chroot_exec "apt-get install --yes ${LIVE_MANIFEST}"
+			Chroot_exec "apt-get install --yes --force-yes ${LIVE_MANIFEST}"
 			Chroot_exec "dpkg-query -W \*" | awk '$2 ~ /./ {print $1 " " $2 }' > "${LIVE_ROOT}"/filesystem.manifest-desktop
 		fi
 
-		# Clean apt packages cache
-		rm -f "${LIVE_CHROOT}"/var/cache/apt/archives/*.deb
-		rm -f "${LIVE_CHROOT}"/var/cache/apt/archives/partial/*.deb
+		# Remove unused packages
+		Chroot_exec "apt-get remove --purge --yes cdebootstrap-helper-diverts"
 
-		# Clean apt indices cache
-		rm -f "${LIVE_CHROOT}"/var/cache/apt/*pkgcache.bin
+		# 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
diff --git a/src/scripts/21image.sh b/src/scripts/21image.sh
index 930315c..7258b6a 100644
--- a/src/scripts/21image.sh
+++ b/src/scripts/21image.sh
@@ -138,7 +138,7 @@ Syslinux ()
 	then
 		# Install syslinux
 		Patch_network apply
-		Chroot_exec "apt-get install --yes syslinux"
+		Chroot_exec "apt-get install --yes --force-yes syslinux"
 
 		case "${1}" in
 			iso)
@@ -188,14 +188,26 @@ Linuximage ()
 	case "${1}" in
 		iso)
 			# Copy linux-image
-			cp "${LIVE_CHROOT}"/boot/vmlinuz-* "${LIVE_ROOT}"/binary/isolinux/vmlinuz
-			cp "${LIVE_CHROOT}"/boot/initrd.img-* "${LIVE_ROOT}"/binary/isolinux/initrd.gz
+			if [ "${LIVE_FLAVOUR}" = "minimal" ]
+			then
+				mv "${LIVE_CHROOT}"/boot/vmlinuz-* "${LIVE_ROOT}"/binary/isolinux/vmlinuz
+				mv "${LIVE_CHROOT}"/boot/initrd.img-* "${LIVE_ROOT}"/binary/isolinux/initrd.gz
+			else
+				cp "${LIVE_CHROOT}"/boot/vmlinuz-* "${LIVE_ROOT}"/binary/isolinux/vmlinuz
+				cp "${LIVE_CHROOT}"/boot/initrd.img-* "${LIVE_ROOT}"/binary/isolinux/initrd.gz
+			fi
 			;;
 
 		net)
 			# Copy linux-image
-			cp "${LIVE_ROOT}"/chroot/boot/vmlinuz-* "${LIVE_ROOT}"/tftpboot/vmlinuz
-			cp "${LIVE_ROOT}"/chroot/boot/initrd.img-* "${LIVE_ROOT}"/tftpboot/initrd.gz
+			if [ "${LIVE_FLAVOUR}" = "minimal" ]
+			then
+				mv "${LIVE_ROOT}"/chroot/boot/vmlinuz-* "${LIVE_ROOT}"/tftpboot/vmlinuz
+				mv "${LIVE_ROOT}"/chroot/boot/initrd.img-* "${LIVE_ROOT}"/tftpboot/initrd.gz
+			else
+				cp "${LIVE_ROOT}"/chroot/boot/vmlinuz-* "${LIVE_ROOT}"/tftpboot/vmlinuz
+				cp "${LIVE_ROOT}"/chroot/boot/initrd.img-* "${LIVE_ROOT}"/tftpboot/initrd.gz
+			fi
 			;;
 	esac
 }
@@ -206,7 +218,7 @@ Memtest ()
 	then
 		# Install memtest
 		Patch_network apply
-		Chroot_exec "apt-get install --yes memtest86+"
+		Chroot_exec "apt-get install --yes --force-yes memtest86+"
 
 		case "$1" in
 			iso)
diff --git a/src/scripts/22iso.sh b/src/scripts/22iso.sh
index d990e24..5088768 100644
--- a/src/scripts/22iso.sh
+++ b/src/scripts/22iso.sh
@@ -13,26 +13,56 @@ Iso ()
 {
 	if [ ! -f "${LIVE_ROOT}"/.stage/image_binary ]
 	then
+		# Configure chroot
+		Patch_chroot apply
+		Patch_runlevel apply
+
+		# Configure network
+		Patch_network apply
+
 		mkdir -p "${LIVE_ROOT}"/binary/casper
-		for manifest in "${LIVE_ROOT}"/filesystem.manifest*
+		for MANIFEST in "${LIVE_ROOT}"/filesystem.manifest*
 		do
-			mv "${manifest}" "${LIVE_ROOT}"/binary/casper/
+			mv "${MANIFEST}" "${LIVE_ROOT}"/binary/casper/
 		done
 
+		# Remove indices
+		rm -rf "${LIVE_CHROOT}"/var/cache/apt
+		mkdir -p "${LIVE_CHROOT}"/var/cache/apt/archives/partial
+		rm -rf "${LIVE_CHROOT}"/var/lib/apt/lists
+		mkdir -p "${LIVE_CHROOT}"/var/lib/apt/lists/partial
+
 		# Switching package indices to default
 		if [ "${LIVE_GENERIC_INDICES}" = "yes" ]
 		then
 			Indices default
 		fi
-	
+
+		# Deconfigure network
+		Patch_network deapply
+
+		# Deconfigure chroot
+		Patch_runlevel deapply
+		Patch_chroot deapply
+
 		# Generating rootfs image
 		Genrootfs
 
+		# Configure chroot
+		Patch_chroot apply
+		Patch_runlevel apply
+
+		# Configure network
+		Patch_network apply
+
+		# Remove indices
+		rm -rf "${LIVE_CHROOT}"/var/cache/apt
+		mkdir -p "${LIVE_CHROOT}"/var/cache/apt/archives/partial
+		rm -rf "${LIVE_CHROOT}"/var/lib/apt/lists
+		mkdir -p "${LIVE_CHROOT}"/var/lib/apt/lists/partial
+
 		# Switching package indices to custom
-		if [ "${LIVE_GENERIC_INDICES}" = "yes" ]
-		then
-			Indices custom
-		fi
+		Indices custom
 
 		# Installing syslinux
 		Syslinux iso
@@ -43,6 +73,13 @@ Iso ()
 		# Installing memtest
 		Memtest iso
 
+		# Deconfigure network
+		Patch_network deapply
+
+		# Deconfigure chroot
+		Patch_runlevel deapply
+		Patch_chroot deapply
+
 		# Installing templates
 		if [ "${LIVE_FLAVOUR}" != "minimal" ]
 		then
@@ -62,9 +99,23 @@ Iso ()
 
 	if [ ! -f "${LIVE_ROOT}"/.stage/image_source ] && [ "${LIVE_SOURCE}" = "yes" ]
 	then
+		# Configure chroot
+		Patch_chroot apply
+		Patch_runlevel apply
+
+		# Configure network
+		Patch_network apply
+
 		# Downloading sources
 		Sources
 
+		# Deconfigure network
+		Patch_network deapply
+
+		# Deconfigure chroot
+		Patch_runlevel deapply
+		Patch_chroot deapply
+
 		# Creating image
 		Mkisofs source
 
diff --git a/src/scripts/23net.sh b/src/scripts/23net.sh
index c4169ec..02869dd 100644
--- a/src/scripts/23net.sh
+++ b/src/scripts/23net.sh
@@ -13,16 +13,23 @@ Net ()
 {
 	if [ ! -f "${LIVE_ROOT}"/.stage/image_binary ]
 	then
+		# Configure chroot
+		Patch_chroot apply
+		Patch_runlevel apply
+
+		# Configure network
+		Patch_network apply
+
 		mkdir -p "${LIVE_ROOT}"/binary/casper
 		cp -r "${LIVE_TEMPLATES}"/common/* "${LIVE_ROOT}"/binary
 		
-		for manifest in "${LIVE_ROOT}"/filesystem.manifest*
+		for MANIFEST in "${LIVE_ROOT}"/filesystem.manifest*
 		do
-			mv "${manifest}" "${LIVE_ROOT}"/binary/casper/
+			mv "${MANIFEST}" "${LIVE_ROOT}"/binary/casper/
 		done
 
 		# Installing smbfs
-		Chroot_exec "apt-get install --yes smbfs"
+		Chroot_exec "apt-get install --yes --force-yes smbfs"
 
 		if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ]
 		then
@@ -40,20 +47,43 @@ EOF
 			Chroot_exec "update-initramfs -tu"
 		fi
 
+		# Remove indices
+		rm -rf "${LIVE_CHROOT}"/var/cache/apt
+		mkdir -p "${LIVE_CHROOT}"/var/cache/apt/archives/partial
+		rm -rf "${LIVE_CHROOT}"/var/lib/apt/lists
+		mkdir -p "${LIVE_CHROOT}"/var/lib/apt/lists/partial
+
 		# Switching package indices to default
 		if [ "${LIVE_GENERIC_INDICES}" = "yes" ]
 		then
 			Indices default
 		fi
-	
+
+		# Deconfigure network
+		Patch_network deapply
+
+		# Deconfigure chroot
+		Patch_runlevel deapply
+		Patch_chroot deapply
+
 		# Generating rootfs image
 		Genrootfs
 
+		# Configure chroot
+		Patch_chroot apply
+		Patch_runlevel apply
+
+		# Configure network
+		Patch_network apply
+
+		# Remove indices
+		rm -rf "${LIVE_CHROOT}"/var/cache/apt
+		mkdir -p "${LIVE_CHROOT}"/var/cache/apt/archives/partial
+		rm -rf "${LIVE_CHROOT}"/var/lib/apt/lists
+		mkdir -p "${LIVE_CHROOT}"/var/lib/apt/lists/partial
+
 		# Switching package indices to custom
-		if [ "${LIVE_GENERIC_INDICES}" = "yes" ]
-		then
-			Indices custom
-		fi
+		Indices custom
 
 		# Installing syslinux
 		Syslinux net
@@ -64,6 +94,13 @@ EOF
 		# Installing memtest
 		Memtest net
 
+		# Deconfigure network
+		Patch_network deapply
+
+		# Deconfigure chroot
+		Patch_runlevel deapply
+		Patch_chroot deapply
+
 		# Creating tarball
 		cd "${LIVE_ROOT}" && \
 		mv binary "`basename ${LIVE_SERVER_PATH}`" && \
@@ -79,9 +116,23 @@ EOF
 
 	if [ ! -f "${LIVE_ROOT}"/.stage/image_source ] && [ "${LIVE_SOURCE}" = "yes" ]
 	then
+		# Configure chroot
+		Patch_chroot apply
+		Patch_runlevel apply
+
+		# Configure network
+		Patch_network apply
+
 		# Downloading sources
 		Sources
 
+		# Deconfigure network
+		Patch_network deapply
+
+		# Deconfigure chroot
+		Patch_runlevel deapply
+		Patch_chroot deapply
+
 		# Creating tarball
 		tar cfz source.tar.gz "${LIVE_ROOT}"/source
 
-- 
cgit v1.0