From 2313d059f712fbe2f9465139d59ae7b8325cf221 Mon Sep 17 00:00:00 2001
From: Andreas Loibl <andreas@andreas-loibl.de>
Date: Wed, 29 Feb 2012 23:36:50 +0100
Subject: added compat for live-build 2/3

---
 auto/config           | 40 ++++++++++++++----------------
 auto/functions/compat | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 21 deletions(-)
 create mode 100644 auto/functions/compat

diff --git a/auto/config b/auto/config
index 2eda1e3..9cc1c44 100755
--- a/auto/config
+++ b/auto/config
@@ -10,6 +10,7 @@ MIRROR_BOOTSTRAP="$MIRROR_CHROOT"
 
 # preset kanotix defaults
 export LB_PACKAGES_LISTS="kanotix-master"
+export LB_DISTRIBUTION="squeeze"
 export LB_BOOTLOADER="syslinux"
 export LB_SYSLINUX_MENU_LIVE_ENTRY="Kanotix"
 export LB_LINUX_PACKAGES="linux-image linux-headers"
@@ -18,14 +19,14 @@ lb config noauto \
 	--iso-volume KANOTIX \
 	--iso-preparer kanotix.com \
 	--iso-publisher kanotix.com \
+	--binary-images iso-hybrid \
 	--chroot-filesystem squashfs \
 	--debian-installer false \
 	--apt apt \
 	--apt-recommends false \
 	--bootappend-live 'utc=no timezone=Europe/Berlin locales=de keyboard-layouts=de keyboard-variant=nodeadkeys splash' \
-	--distribution squeeze \
         --archive-areas "main contrib non-free" \
-	--repositories "live.debian.net acritox hellfire lo wine-ppa firefox" \
+	--repositories "live.debian.net acritox hellfire lo" \
 	--security true \
 	--checksums md5 \
 	--syslinux-timeout 5 \
@@ -38,8 +39,7 @@ lb config noauto \
 	--mirror-binary ${MIRROR_BINARY} \
 	--mirror-binary-security ${MIRROR_BINARY_SECURITY} \
 	--binary-indices true \
-	--backports true \
-	"${@}"
+	"${@}" || exit $?
 
 # hostname and username are configured in config/chroot_local-includes/etc/live/config.conf
 #lb config noauto \
@@ -50,23 +50,21 @@ lb config noauto \
 . config/bootstrap
 . config/chroot
 
-# architecture depending stuff (e.g. kernel)
-case $LB_ARCHITECTURE in
-"amd64")
-  lb config noauto \
-        --linux-flavours generic \
-	--linux-packages "linux-image-3.2.0-17 linux-headers-3.2.0-17"
-        #--linux-packages "linux-image linux-headers"
-        #--linux-flavours amd64 \
-        #--linux-packages "linux-image-2.6 linux-headers-2.6"
+# architecture and distribution depending stuff (e.g. kernel)
+case "$LB_DISTRIBUTION" in
+squeeze)
+	LB_REPOSITORIES+=" firefox wine-ppa squeeze-backports"
+	case $LB_ARCHITECTURE in
+	amd64) LB_LINUX_PACKAGES="linux-image-3.2.0-17 linux-headers-3.2.0-17"; LB_LINUX_FLAVOURS="generic";;
+	i386)  LB_LINUX_PACKAGES="linux-image-3.2.0-15 linux-headers-3.2.0-15"; LB_LINUX_FLAVOURS="generic";;
+	esac
 	;;
-"i386")
-  lb config noauto \
-        --linux-flavours generic \
-	--linux-packages "linux-image-3.2.0-15 linux-headers-3.2.0-15"
-        #--linux-packages "linux-image linux-headers"
-        #--linux-flavours 686-bigmem \
-        #--linux-packages "linux-image-2.6 linux-headers-2.6"
+wheezy)
+	LB_REPOSITORIES+=" dragonfire wine-ppa-oneiric"
+	case $LB_ARCHITECTURE in
+	amd64) LB_LINUX_PACKAGES="linux-image linux-headers"; LB_LINUX_FLAVOURS="amd64";;
+	i386)  LB_LINUX_PACKAGES="linux-image linux-headers"; LB_LINUX_FLAVOURS="686-pae";;
+	esac
 	;;
 esac
 
@@ -75,7 +73,7 @@ grep -wq trinity <<<"$LB_PACKAGES_LISTS" && LB_REPOSITORIES+=" trinity"
 grep -wq -e virtualbox -e vbox <<<"$LB_PACKAGES $LB_PACKAGES_LISTS" && LB_REPOSITORIES+=" vbox"
 grep -wq -e opera <<<"$LB_PACKAGES $LB_PACKAGES_LISTS" && LB_REPOSITORIES+=" opera"
 grep -wq chrome <<<"$LB_PACKAGES $LB_PACKAGES_LISTS" && LB_REPOSITORIES+=" chrome"
-lb config noauto --repositories "$LB_REPOSITORIES"
+lb config noauto --linux-packages "$LB_LINUX_PACKAGES" --linux-flavours "$LB_LINUX_FLAVOURS" --repositories "$LB_REPOSITORIES"
 
 # Fetch kanotix-scripts if necessary
 mkdir -p config/chroot_local-includes/usr/local/bin
diff --git a/auto/functions/compat b/auto/functions/compat
new file mode 100644
index 0000000..a2a965c
--- /dev/null
+++ b/auto/functions/compat
@@ -0,0 +1,68 @@
+#!/bin/bash
+export LB_VERSION=$VERSION
+
+Compat_arguments ()
+{
+	while [ "$#" -gt 0 ]
+	do
+		arg="$1"
+		shift
+		case "$arg" in
+		-r|--repositories) arg="--archives";;
+		--architecture) arg="--architectures";;
+		--packages-lists) arg="--package-lists";;
+		--syslinux-theme) ;;
+		# ignore other unsupported arguments
+		--syslinux-*|--bootstrap-config|-e|--encryption|-l|--language) shift; continue;;
+		--binary-indices|--packages|--symlinks|--sysvinit|--tasks|--virtual-root-size) shift; continue;;
+		esac
+		echo -n "$arg$IFS"
+	done
+}
+
+Compat_config ()
+{
+[ -e config/chroot ] && cat <<eof >> config/chroot
+
+# Compat (Live-build 2 -> 3)
+LB_REPOSITORIES="$LB_ARCHIVES"
+LB_PACKAGES_LISTS="$LB_PACKAGE_LISTS"
+eof
+[ -e config/bootstrap ] && cat <<eof >> config/bootstrap
+
+# Compat (Live-build 2 -> 3)
+LB_ARCHITECTURE="$LB_ARCHITECTURES"
+eof
+}
+
+case "$LB_VERSION" in
+3*)
+	case "$(basename "$0")" in
+	lb_config)
+		OIFS="$IFS"; IFS="$(printf \\a)"
+		set -- $(Compat_arguments "$@")
+		IFS="$OIFS"
+		[ -z "$LB_ARCHIVES" ] && LB_ARCHIVES="$LB_REPOSITORIES"
+		LB_REPOSITORIES="$LB_ARCHIVES" 
+		[ -z "$LB_PACKAGE_LISTS" ] && LB_PACKAGE_LISTS="$LB_PACKAGES_LISTS"
+		LB_PACKAGES_LISTS="$LB_PACKAGE_LISTS"
+		[ -z "$LB_ARCHITECTURES" ] && LB_ARCHITECTURES="$LB_ARCHITECTURE"
+		LB_ARCHITECTURE="$LB_ARCHITECTURES"
+		trap Compat_config EXIT
+		;;
+	lb_chroot_archives)
+		mkdir -p config/archives
+		for i in config/repositories/*
+		do
+			[ ! -e "$i" ] && break
+			case "$i" in
+			*.gpg) target="$(basename "$i" .gpg).key";;
+			*) target="$(basename "$i" .list).list";;
+			esac
+			cp "$i" config/archives/"$target"
+		done
+		;;
+	esac
+	;;
+esac
+
-- 
cgit v1.0