summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Loibl <andreas@andreas-loibl.de>2012-02-16 02:39:34 +0100
committerAndreas Loibl <andreas@andreas-loibl.de>2012-02-16 02:39:34 +0100
commit0ff149fa625b4da1257f73d6534bd9f8e1562e38 (patch)
tree3f0650b940e9df4a63d39053347a311ccadf3b69
parent00e77c213ed52cbffd1b593e0f7e94c860cd5513 (diff)
downloadkanotix-0ff149fa625b4da1257f73d6534bd9f8e1562e38.zip
kanotix-0ff149fa625b4da1257f73d6534bd9f8e1562e38.tar.gz
added debpool feature
-rw-r--r--.gitignore5
-rw-r--r--auto/functions/debpool-hook25
-rw-r--r--config/chroot_debpool/packages2
-rwxr-xr-xconfig/chroot_local-hooks/Z_debpool107
4 files changed, 139 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 745bc82..55ae6e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,11 @@
/config/chroot_local-includes/etc/kanotix-version
/config/chroot_local-includes/root/build.conf
/config/chroot_local-includes/usr/local/bin
+/config/chroot_local-packages/
+/config/chroot_debpool/live-media-keyring.pub
+/config/chroot_debpool/live-media-keyring.sec
+/config/chroot_debpool/keep
+/debpool
/overlay*
/efi-*
/gfxoverlay
diff --git a/auto/functions/debpool-hook b/auto/functions/debpool-hook
new file mode 100644
index 0000000..c86a065
--- /dev/null
+++ b/auto/functions/debpool-hook
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+if [ "$(basename "$0")" = "lb_chroot_local-hooks" ]; then
+ echo "HOOK: debpool@chroot_local-hooks"
+ if [ -e config/chroot_debpool ]; then
+ mkdir -p chroot/live
+ cp config/chroot_debpool/* chroot/live/
+ fi
+fi
+
+if [ "$(basename "$0")" = "lb_binary_rootfs" ]; then
+ echo "HOOK: debpool@binary-rootfs"
+ for dir in chroot/chroot/live chroot/live
+ do
+ [ -d $dir ] || continue
+ rm -rf debpool
+ mv $dir debpool
+ mkdir -p binary
+ mv debpool/image/debian binary/
+ rmdir debpool/image
+ [ -e debpool/keep ] || rm -r debpool
+ break
+ done
+fi
+
diff --git a/config/chroot_debpool/packages b/config/chroot_debpool/packages
new file mode 100644
index 0000000..cb172d2
--- /dev/null
+++ b/config/chroot_debpool/packages
@@ -0,0 +1,2 @@
+openssh-server
+grub-efi
diff --git a/config/chroot_local-hooks/Z_debpool b/config/chroot_local-hooks/Z_debpool
new file mode 100755
index 0000000..ff59f8c
--- /dev/null
+++ b/config/chroot_local-hooks/Z_debpool
@@ -0,0 +1,107 @@
+#!/bin/bash
+[ ! -e /live/packages ] && exit 0
+
+[ -f /root/build.conf ] && . /root/build.conf
+[ -z "$LB_ARCHITECTURE" ] && LB_ARCHITECTURE=amd64
+[ -z "$LB_DISTRIBUTION" ] && LB_DISTRIBUTION=squeeze
+
+binary=/live/image/debian
+packages="$(cut -d'#' -f1 /live/packages | grep .)"
+[ -z "$packages" ] && exit 0
+
+rm -rf "$binary"
+mkdir -p "$binary"
+mkdir -p /binary.deb/archives/partial
+apt-get update
+apt-get --yes -o Dir::Cache=/binary.deb --download-only install $packages
+
+for FILE in /binary.deb/archives/*.deb
+do
+ SOURCE="$(dpkg -f ${FILE} Source | awk '{ print $1 }')"
+ SECTION="$(dpkg -f ${FILE} Section | awk '{ print $1 }')"
+
+ if [ -z "${SOURCE}" ]
+ then
+ SOURCE="$(basename ${FILE} | awk -F_ '{ print $1 }')"
+ fi
+
+ case "${SOURCE}" in
+ lib?*)
+ LETTER="$(echo ${SOURCE} | sed 's|\(....\).*|\1|')"
+ ;;
+
+ *)
+ LETTER="$(echo ${SOURCE} | sed 's|\(.\).*|\1|')"
+ ;;
+ esac
+
+ if echo "${SECTION}" | grep -qs contrib
+ then
+ SECTION="contrib"
+ elif echo "${SECTION}" | grep -qs non-free
+ then
+ SECTION="non-free"
+ else
+ SECTION="main"
+ fi
+
+ # Install directory
+ mkdir -p "$binary"/pool/${SECTION}/"${LETTER}"/"${SOURCE}"
+
+ # Move files
+ mv "${FILE}" "$binary"/pool/${SECTION}/"${LETTER}"/"${SOURCE}"
+done
+
+if [ ! -e /live/live-media-keyring.sec -o ! -e /live/live-media-keyring.pub ]; then
+ # Generate signing key for live-media repo
+ echo "Key-Type: RSA
+ Key-Length: 1024
+ Subkey-Type: ELG-E
+ Subkey-Length: 1024
+ Name-Real: live-media packages key
+ Name-Email: live-media-key@invalid
+ Expire-Date: 0
+ %secring /live/live-media-keyring.sec
+ %pubring /live/live-media-keyring.pub
+ %commit" | gpg --batch --gen-key
+fi
+
+cd "$binary"
+
+SECTIONS=
+for SECTION in pool/*
+do
+ SECTION="$(basename ${SECTION})"
+ SECTIONS+="$SECTION "
+ mkdir -p dists/${LB_DISTRIBUTION}/${SECTION}/binary-${LB_ARCHITECTURE}
+ apt-ftparchive packages pool/${SECTION} > dists/${LB_DISTRIBUTION}/${SECTION}/binary-${LB_ARCHITECTURE}/Packages
+ apt-ftparchive -o APT::FTPArchive::Release::Origin=live-media \
+ -o APT::FTPArchive::Release::Suite=stable \
+ -o APT::FTPArchive::Release::Codename=${LB_DISTRIBUTION} \
+ release dists/${LB_DISTRIBUTION} > dists/${LB_DISTRIBUTION}/Release
+ gzip -9 -c dists/${LB_DISTRIBUTION}/${SECTION}/binary-${LB_ARCHITECTURE}/Packages > dists/${LB_DISTRIBUTION}/${SECTION}/binary-${LB_ARCHITECTURE}/Packages.gz
+ # Sign release
+ gpg --no-default-keyring --secret-keyring /live/live-media-keyring.sec --keyring /live/live-media-keyring.pub -abs -o \
+ dists/${LB_DISTRIBUTION}/Release.gpg dists/${LB_DISTRIBUTION}/Release
+done
+
+cd -
+
+rm -rf /binary.deb
+
+# Add sources.list entry to the beginning of the file (above the first entry)
+if ! grep -q "^deb file:$binary" /etc/apt/sources.list; then
+line="$(grep -nm1 -B5 '^[[:space:]]*deb' /etc/apt/sources.list | tac | grep -vm1 ... | tr -d -)"
+((line++))
+sed -i "$line{i # Live Media
+i deb file:$binary $LB_DISTRIBUTION $SECTIONS
+x;p;x}" /etc/apt/sources.list
+fi
+
+# Import key
+gpg --no-default-keyring --secret-keyring /live/live-media-keyring.sec \
+--keyring /live/live-media-keyring.pub --armor \
+--export "live-media-key@invalid" | apt-key add -
+
+apt-get update
+