From 261580507a28b41de5aebe1cb6ba7e2ca32af32e Mon Sep 17 00:00:00 2001 From: josch Date: Sat, 25 Jun 2011 00:07:21 +0200 Subject: [PATCH 01/13] make temporary multistrap file unique --- polystrap.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/polystrap.sh b/polystrap.sh index 8f2e64d..d3f3694 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -93,13 +93,14 @@ echo "--------------------------" [ -e "$ROOTDIR" ] && { echo "root directory still exists"; exit; } # create multistrap.conf -echo -n > /tmp/multistrap.conf +echo -n > /tmp/multistrap.conf.$$ while read line; do - eval echo $line >> /tmp/multistrap.conf + eval echo $line >> /tmp/multistrap.conf.$$ done < $PLATFORM/multistrap.conf # download and extract packages -multistrap -f /tmp/multistrap.conf +multistrap -f /tmp/multistrap.conf.$$ +rm -f /tmp/multistrap.conf.$$ # backup ldconfig and ldd mv $ROOTDIR/sbin/ldconfig $ROOTDIR/sbin/ldconfig.REAL From 792d15f483769fa20fbfeccbb2f407d30d424f56 Mon Sep 17 00:00:00 2001 From: josch Date: Sat, 25 Jun 2011 19:52:20 +0200 Subject: [PATCH 02/13] put temporary config file in working directory --- polystrap.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/polystrap.sh b/polystrap.sh index d3f3694..b051a7c 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -93,14 +93,15 @@ echo "--------------------------" [ -e "$ROOTDIR" ] && { echo "root directory still exists"; exit; } # create multistrap.conf -echo -n > /tmp/multistrap.conf.$$ +MULTISTRAPCONF=`tempfile -d . -p multistrap` +echo -n > "$MULTISTRAPCONF" while read line; do - eval echo $line >> /tmp/multistrap.conf.$$ + eval echo $line >> "$MULTISTRAPCONF" done < $PLATFORM/multistrap.conf # download and extract packages -multistrap -f /tmp/multistrap.conf.$$ -rm -f /tmp/multistrap.conf.$$ +multistrap -f "$MULTISTRAPCONF" +rm -f "$MULTISTRAPCONF" # backup ldconfig and ldd mv $ROOTDIR/sbin/ldconfig $ROOTDIR/sbin/ldconfig.REAL From 91a4778e2da4f58f3c75af5bce7c9510b46a5d87 Mon Sep 17 00:00:00 2001 From: josch Date: Wed, 29 Jun 2011 10:41:44 +0200 Subject: [PATCH 03/13] add date in default config rootdir --- default/config | 2 +- kirkwood/config | 2 +- notioninkadam/config | 2 +- om-gta02/config | 2 +- touchbook/config | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/default/config b/default/config index a94421a..01b0692 100644 --- a/default/config +++ b/default/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" -ROOTDIR="debian-$SUITE-$ARCH" +ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" diff --git a/kirkwood/config b/kirkwood/config index a94421a..01b0692 100644 --- a/kirkwood/config +++ b/kirkwood/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" -ROOTDIR="debian-$SUITE-$ARCH" +ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" diff --git a/notioninkadam/config b/notioninkadam/config index a94421a..01b0692 100644 --- a/notioninkadam/config +++ b/notioninkadam/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" -ROOTDIR="debian-$SUITE-$ARCH" +ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" diff --git a/om-gta02/config b/om-gta02/config index a94421a..01b0692 100644 --- a/om-gta02/config +++ b/om-gta02/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" -ROOTDIR="debian-$SUITE-$ARCH" +ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" diff --git a/touchbook/config b/touchbook/config index a94421a..01b0692 100644 --- a/touchbook/config +++ b/touchbook/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" -ROOTDIR="debian-$SUITE-$ARCH" +ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" From 4ac98ea19e8dd204eed218b5c542b8abbbca96a1 Mon Sep 17 00:00:00 2001 From: josch Date: Wed, 29 Jun 2011 10:42:16 +0200 Subject: [PATCH 04/13] add proper exit status --- polystrap.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/polystrap.sh b/polystrap.sh index b051a7c..c5af8f8 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -49,12 +49,12 @@ while getopts s:a:d:m:p: opt; do done shift $(($OPTIND - 1)) -[ "$#" -ne 1 ] && { echo "too many positional arguments"; usage; exit; } +[ "$#" -ne 1 ] && { echo "too many positional arguments"; usage; exit 1; } PLATFORM="$1" -[ ! -r "$PLATFORM" ] && { echo "cannot find target directory: $PLATFORM"; exit; } -[ ! -r "$PLATFORM/multistrap.conf" ] && { echo "cannot read multistrap config: $PLATFORM/multistrap.conf"; exit; } +[ ! -r "$PLATFORM" ] && { echo "cannot find target directory: $PLATFORM"; exit 1; } +[ ! -r "$PLATFORM/multistrap.conf" ] && { echo "cannot read multistrap config: $PLATFORM/multistrap.conf"; exit 1; } # source default options . "default/config" @@ -89,8 +89,8 @@ echo "mirror: $MIRROR" echo "pkgs: $PACKAGES" echo "--------------------------" -[ -e "$ROOTDIR.tar" ] && { echo "tarball still exists"; exit; } -[ -e "$ROOTDIR" ] && { echo "root directory still exists"; exit; } +[ -e "$ROOTDIR.tar" ] && { echo "tarball still exists"; exit 1; } +[ -e "$ROOTDIR" ] && { echo "root directory still exists"; exit 1; } # create multistrap.conf MULTISTRAPCONF=`tempfile -d . -p multistrap` From eb03afb5ce946c1c76fb0ebf84a6bc903bc8fa46 Mon Sep 17 00:00:00 2001 From: josch Date: Wed, 29 Jun 2011 10:45:57 +0200 Subject: [PATCH 05/13] output messages to stderr --- polystrap.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/polystrap.sh b/polystrap.sh index c5af8f8..959845d 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -26,13 +26,13 @@ set -ex usage() { - echo "Usage: $0: [-s suite] [-a arch] [-d directory] [-m mirror] [-p packages] platform\n" + echo "Usage: $0: [-s suite] [-a arch] [-d directory] [-m mirror] [-p packages] platform\n" >&2 } export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C if [ "$FAKEROOTKEY" = "" ]; then - echo "re-executing script inside fakeroot" + echo "re-executing script inside fakeroot" >&2 fakeroot "$0" "$@"; exit fi @@ -49,12 +49,12 @@ while getopts s:a:d:m:p: opt; do done shift $(($OPTIND - 1)) -[ "$#" -ne 1 ] && { echo "too many positional arguments"; usage; exit 1; } +[ "$#" -ne 1 ] && { echo "too many positional arguments" >&2; usage; exit 1; } PLATFORM="$1" -[ ! -r "$PLATFORM" ] && { echo "cannot find target directory: $PLATFORM"; exit 1; } -[ ! -r "$PLATFORM/multistrap.conf" ] && { echo "cannot read multistrap config: $PLATFORM/multistrap.conf"; exit 1; } +[ ! -r "$PLATFORM" ] && { echo "cannot find target directory: $PLATFORM" >&2; exit 1; } +[ ! -r "$PLATFORM/multistrap.conf" ] && { echo "cannot read multistrap config: $PLATFORM/multistrap.conf" >&2; exit 1; } # source default options . "default/config" @@ -81,16 +81,16 @@ fi # binutils must always be installed for objdump for fake ldd PACKAGES="$PACKAGES binutils" -echo "--------------------------" -echo "suite: $SUITE" -echo "arch: $ARCH" -echo "rootdir: $ROOTDIR" -echo "mirror: $MIRROR" -echo "pkgs: $PACKAGES" -echo "--------------------------" +echo "--------------------------" >&2 +echo "suite: $SUITE" >&2 +echo "arch: $ARCH" >&2 +echo "rootdir: $ROOTDIR" >&2 +echo "mirror: $MIRROR" >&2 +echo "pkgs: $PACKAGES" >&2 +echo "--------------------------" >&2 -[ -e "$ROOTDIR.tar" ] && { echo "tarball still exists"; exit 1; } -[ -e "$ROOTDIR" ] && { echo "root directory still exists"; exit 1; } +[ -e "$ROOTDIR.tar" ] && { echo "tarball still exists" >&2; exit 1; } +[ -e "$ROOTDIR" ] && { echo "root directory still exists" >&2; exit 1; } # create multistrap.conf MULTISTRAPCONF=`tempfile -d . -p multistrap` @@ -121,7 +121,7 @@ if [ $ARCH != "`dpkg --print-architecture`" ]; then armel) cp `which qemu-arm-static` $ROOTDIR/usr/bin;; lpia) cp `which qemu-i386-static` $ROOTDIR/usr/bin;; powerpc) cp `which qemu-ppc-static` $ROOTDIR/usr/bin;; - *) echo "unknown architecture: $ARCH"; exit 1;; + *) echo "unknown architecture: $ARCH" >&2; exit 1;; esac fi From dd54582e5e0ecee205fb91c176ec314a905d7dc7 Mon Sep 17 00:00:00 2001 From: josch Date: Wed, 29 Jun 2011 10:47:48 +0200 Subject: [PATCH 06/13] make sure sbin binaries are in PATH --- polystrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/polystrap.sh b/polystrap.sh index 959845d..e835906 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -30,6 +30,7 @@ usage() { } export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C +export PATH=$PATH:/usr/sbin:/sbin if [ "$FAKEROOTKEY" = "" ]; then echo "re-executing script inside fakeroot" >&2 From 9e5a8aa62adb6ca9b948c12d4458ac09aa61c031 Mon Sep 17 00:00:00 2001 From: josch Date: Wed, 29 Jun 2011 11:03:43 +0200 Subject: [PATCH 07/13] add more status output, delete -x flag --- polystrap.sh | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/polystrap.sh b/polystrap.sh index e835906..6e9c9a3 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -23,7 +23,7 @@ # FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -set -ex +set -e usage() { echo "Usage: $0: [-s suite] [-a arch] [-d directory] [-m mirror] [-p packages] platform\n" >&2 @@ -33,7 +33,7 @@ export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C export PATH=$PATH:/usr/sbin:/sbin if [ "$FAKEROOTKEY" = "" ]; then - echo "re-executing script inside fakeroot" >&2 + echo "I: re-executing script inside fakeroot" >&2 fakeroot "$0" "$@"; exit fi @@ -82,18 +82,19 @@ fi # binutils must always be installed for objdump for fake ldd PACKAGES="$PACKAGES binutils" -echo "--------------------------" >&2 -echo "suite: $SUITE" >&2 -echo "arch: $ARCH" >&2 -echo "rootdir: $ROOTDIR" >&2 -echo "mirror: $MIRROR" >&2 -echo "pkgs: $PACKAGES" >&2 -echo "--------------------------" >&2 +echo "I: --------------------------" >&2 +echo "I: suite: $SUITE" >&2 +echo "I: arch: $ARCH" >&2 +echo "I: rootdir: $ROOTDIR" >&2 +echo "I: mirror: $MIRROR" >&2 +echo "I: pkgs: $PACKAGES" >&2 +echo "I: --------------------------" >&2 [ -e "$ROOTDIR.tar" ] && { echo "tarball still exists" >&2; exit 1; } [ -e "$ROOTDIR" ] && { echo "root directory still exists" >&2; exit 1; } # create multistrap.conf +echo "I: create multistrap.conf" >&2 MULTISTRAPCONF=`tempfile -d . -p multistrap` echo -n > "$MULTISTRAPCONF" while read line; do @@ -101,32 +102,39 @@ while read line; do done < $PLATFORM/multistrap.conf # download and extract packages +echo "I: run multistrap" >&2 multistrap -f "$MULTISTRAPCONF" rm -f "$MULTISTRAPCONF" # backup ldconfig and ldd +echo "I: backup ldconfig and ldd" >&2 mv $ROOTDIR/sbin/ldconfig $ROOTDIR/sbin/ldconfig.REAL mv $ROOTDIR/usr/bin/ldd $ROOTDIR/usr/bin/ldd.REAL # copy initial directory tree - dereference symlinks +echo "I: copy initial directory root tree $PLATFORM/root/ to $ROOTDIR/" >&2 if [ -r "$PLATFORM/root" ]; then cp --recursive --dereference $PLATFORM/root/* $ROOTDIR/ fi # copy qemu usermode binary +QEMUARCH= if [ $ARCH != "`dpkg --print-architecture`" ]; then case $ARCH in - alpha|arm|armeb|i386|m68k|mips|mipsel|ppc64|sh4|sh4eb|sparc|sparc64) - cp `which qemu-$ARCH-static` $ROOTDIR/usr/bin;; - amd64) cp `which qemu-x86_64-static` $ROOTDIR/usr/bin;; - armel) cp `which qemu-arm-static` $ROOTDIR/usr/bin;; - lpia) cp `which qemu-i386-static` $ROOTDIR/usr/bin;; - powerpc) cp `which qemu-ppc-static` $ROOTDIR/usr/bin;; + alpha|i386|m68k|mips|mipsel|ppc64|sh4|sh4eb|sparc|sparc64) + QEMUARCH=$ARCH;; + arm*) QEMUARCH=arm;; # for arm, armel, armeb, armhf + amd64) QEMUARCH=x86_64;; + lpia) QEMUARCH=i386;; + powerpc) QEMUARCH=ppc;; *) echo "unknown architecture: $ARCH" >&2; exit 1;; esac fi +echo "I: copy qemu-$QEMUARCH-static into $ROOTDIR" >&2 +cp `which qemu-$QEMUARCH-static` $ROOTDIR/usr/bin # preseed debconf +echo "I: preseed debconf" >&2 if [ -r "$PLATFORM/debconfseed.txt" ]; then cp "$PLATFORM/debconfseed.txt" $ROOTDIR/tmp/ fakechroot chroot $ROOTDIR debconf-set-selections /tmp/debconfseed.txt @@ -136,20 +144,24 @@ fi # run preinst scripts for script in $ROOTDIR/var/lib/dpkg/info/*.preinst; do [ "$script" = "$ROOTDIR/var/lib/dpkg/info/bash.preinst" ] && continue + echo "I: run preinst script ${script##$ROOTDIR}" >&2 fakechroot chroot $ROOTDIR ${script##$ROOTDIR} install done # run dpkg --configure -a twice because of errors during the first run +echo "I: configure packages" >&2 fakechroot chroot $ROOTDIR /usr/bin/dpkg --configure -a || fakechroot chroot $ROOTDIR /usr/bin/dpkg --configure -a # source hooks if [ -r "$PLATFORM/hooks" ]; then for f in $PLATFORM/hooks/*; do + echo "I: run hook $f" >&2 . $f done fi #cleanup +echo "I: cleanup" >&2 rm $ROOTDIR/sbin/ldconfig $ROOTDIR/usr/bin/ldd mv $ROOTDIR/sbin/ldconfig.REAL $ROOTDIR/sbin/ldconfig mv $ROOTDIR/usr/bin/ldd.REAL $ROOTDIR/usr/bin/ldd @@ -157,5 +169,6 @@ rm $ROOTDIR/usr/sbin/policy-rc.d # need to generate tar inside fakechroot so that absolute symlinks are correct # tar is clever enough to not try and put the archive inside itself +echo "I: create tarball $ROOTDIR.tar" >&2 fakechroot chroot $ROOTDIR tar -cf $ROOTDIR.tar -C / . mv $ROOTDIR/$ROOTDIR.tar . From b1f4e66ec18553f68e65e51c4945c020479f18f2 Mon Sep 17 00:00:00 2001 From: josch Date: Thu, 30 Jun 2011 08:11:28 +0200 Subject: [PATCH 08/13] add cdn.debian.net as default mirror --- default/config | 2 +- default/config.armhf | 2 +- default/multistrap.conf | 2 +- default/multistrap.conf.armhf | 2 +- kirkwood/config | 2 +- kirkwood/multistrap.conf | 2 +- notioninkadam/config | 2 +- notioninkadam/multistrap.conf | 2 +- om-gta02/config | 2 +- om-gta02/multistrap.conf | 2 +- touchbook/config | 2 +- touchbook/multistrap.conf | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/default/config b/default/config index 01b0692..78873f4 100644 --- a/default/config +++ b/default/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" -MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" +MIRROR="http://cdn.debian.net/debian" diff --git a/default/config.armhf b/default/config.armhf index 2fb40d4..0e88e96 100644 --- a/default/config.armhf +++ b/default/config.armhf @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armhf" ROOTDIR="debian-$DIST-$ARCH" -MIRROR="http://127.0.0.1:3142/ftp.debian-ports.org/debian" +MIRROR="http://ftp.debian-ports.org/debian" diff --git a/default/multistrap.conf b/default/multistrap.conf index fda0a51..e914a7b 100644 --- a/default/multistrap.conf +++ b/default/multistrap.conf @@ -16,7 +16,7 @@ suite=$SUITE omitdebsrc=true [Debian] -source=http://ftp.de.debian.org/debian +source=http://cdn.debian.net/debian keyring=debian-archive-keyring suite=$SUITE omitdebsrc=true diff --git a/default/multistrap.conf.armhf b/default/multistrap.conf.armhf index e2dccf0..9fffcf1 100644 --- a/default/multistrap.conf.armhf +++ b/default/multistrap.conf.armhf @@ -22,7 +22,7 @@ suite=unreleased omitdebsrc=true [Debian] -source=http://ftp.de.debian.org/debian +source=$MIRROR keyring=debian-archive-keyring suite=$SUITE omitdebsrc=true diff --git a/kirkwood/config b/kirkwood/config index 01b0692..78873f4 100644 --- a/kirkwood/config +++ b/kirkwood/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" -MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" +MIRROR="http://cdn.debian.net/debian" diff --git a/kirkwood/multistrap.conf b/kirkwood/multistrap.conf index fda0a51..e914a7b 100644 --- a/kirkwood/multistrap.conf +++ b/kirkwood/multistrap.conf @@ -16,7 +16,7 @@ suite=$SUITE omitdebsrc=true [Debian] -source=http://ftp.de.debian.org/debian +source=http://cdn.debian.net/debian keyring=debian-archive-keyring suite=$SUITE omitdebsrc=true diff --git a/notioninkadam/config b/notioninkadam/config index 01b0692..78873f4 100644 --- a/notioninkadam/config +++ b/notioninkadam/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" -MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" +MIRROR="http://cdn.debian.net/debian" diff --git a/notioninkadam/multistrap.conf b/notioninkadam/multistrap.conf index fda0a51..e914a7b 100644 --- a/notioninkadam/multistrap.conf +++ b/notioninkadam/multistrap.conf @@ -16,7 +16,7 @@ suite=$SUITE omitdebsrc=true [Debian] -source=http://ftp.de.debian.org/debian +source=http://cdn.debian.net/debian keyring=debian-archive-keyring suite=$SUITE omitdebsrc=true diff --git a/om-gta02/config b/om-gta02/config index 01b0692..78873f4 100644 --- a/om-gta02/config +++ b/om-gta02/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" -MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" +MIRROR="http://cdn.debian.net/debian" diff --git a/om-gta02/multistrap.conf b/om-gta02/multistrap.conf index 220d949..4e748fd 100644 --- a/om-gta02/multistrap.conf +++ b/om-gta02/multistrap.conf @@ -22,7 +22,7 @@ suite=unstable omitdebsrc=true [Debian] -source=http://ftp.de.debian.org/debian +source=http://cdn.debian.net/debian keyring=debian-archive-keyring suite=$SUITE omitdebsrc=true diff --git a/touchbook/config b/touchbook/config index 01b0692..78873f4 100644 --- a/touchbook/config +++ b/touchbook/config @@ -1,4 +1,4 @@ SUITE="sid" ARCH="armel" ROOTDIR="debian-$SUITE-$ARCH-`date +%F`" -MIRROR="http://127.0.0.1:3142/ftp.de.debian.org/debian" +MIRROR="http://cdn.debian.net/debian" diff --git a/touchbook/multistrap.conf b/touchbook/multistrap.conf index fda0a51..e914a7b 100644 --- a/touchbook/multistrap.conf +++ b/touchbook/multistrap.conf @@ -16,7 +16,7 @@ suite=$SUITE omitdebsrc=true [Debian] -source=http://ftp.de.debian.org/debian +source=http://cdn.debian.net/debian keyring=debian-archive-keyring suite=$SUITE omitdebsrc=true From c1286dae35fd30f3f7fe00ac50492af81f2eee33 Mon Sep 17 00:00:00 2001 From: josch Date: Thu, 30 Jun 2011 08:49:28 +0200 Subject: [PATCH 09/13] solve some whitespace issues --- polystrap.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/polystrap.sh b/polystrap.sh index 6e9c9a3..6b061dc 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -33,9 +33,9 @@ export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C export PATH=$PATH:/usr/sbin:/sbin if [ "$FAKEROOTKEY" = "" ]; then - echo "I: re-executing script inside fakeroot" >&2 - fakeroot "$0" "$@"; - exit + echo "I: re-executing script inside fakeroot" >&2 + fakeroot "$0" "$@"; + exit fi while getopts s:a:d:m:p: opt; do @@ -98,7 +98,7 @@ echo "I: create multistrap.conf" >&2 MULTISTRAPCONF=`tempfile -d . -p multistrap` echo -n > "$MULTISTRAPCONF" while read line; do - eval echo $line >> "$MULTISTRAPCONF" + eval echo $line >> "$MULTISTRAPCONF" done < $PLATFORM/multistrap.conf # download and extract packages @@ -143,9 +143,9 @@ fi # run preinst scripts for script in $ROOTDIR/var/lib/dpkg/info/*.preinst; do - [ "$script" = "$ROOTDIR/var/lib/dpkg/info/bash.preinst" ] && continue + [ "$script" = "$ROOTDIR/var/lib/dpkg/info/bash.preinst" ] && continue echo "I: run preinst script ${script##$ROOTDIR}" >&2 - fakechroot chroot $ROOTDIR ${script##$ROOTDIR} install + fakechroot chroot $ROOTDIR ${script##$ROOTDIR} install done # run dpkg --configure -a twice because of errors during the first run From e46ec0cf5aa115b9c34f61804a0ac28bd0d33e18 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Thu, 30 Jun 2011 08:52:44 +0200 Subject: [PATCH 10/13] Multistrap's include mechanism is hairy enough that users may need some support to debug their configs. --- polystrap.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/polystrap.sh b/polystrap.sh index 6b061dc..5564854 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -26,7 +26,7 @@ set -e usage() { - echo "Usage: $0: [-s suite] [-a arch] [-d directory] [-m mirror] [-p packages] platform\n" >&2 + echo "Usage: $0: [-n] [-s suite] [-a arch] [-d directory] [-m mirror] [-p packages] platform\n" >&2 } export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C @@ -38,13 +38,15 @@ if [ "$FAKEROOTKEY" = "" ]; then exit fi -while getopts s:a:d:m:p: opt; do +MSTRAP_SIM= +while getopts s:a:d:m:p:n opt; do case $opt in s) _SUITE="$OPTARG";; a) _ARCH="$OPTARG";; d) _ROOTDIR="$OPTARG";; m) _MIRROR="$OPTARG";; p) _PACKAGES="$OPTARG";; + n) MSTRAP_SIM="--simulate";; ?) usage; exit 1;; esac done @@ -103,7 +105,9 @@ done < $PLATFORM/multistrap.conf # download and extract packages echo "I: run multistrap" >&2 -multistrap -f "$MULTISTRAPCONF" +multistrap $MSTRAP_SIM -f "$MULTISTRAPCONF" +[ -z "$MSTRAP_SIM" ] || exit 0 + rm -f "$MULTISTRAPCONF" # backup ldconfig and ldd From 34f638595ad780b83dd128a64af9659f90e0bbb1 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Thu, 30 Jun 2011 08:56:36 +0200 Subject: [PATCH 11/13] Advertize qemu-user-static and binfmt-support, and warn about essential config items. --- README | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README b/README index 65434d2..0614c56 100644 --- a/README +++ b/README @@ -1,6 +1,12 @@ -Polystrap is a tool to create a foreign architecture rootfs without needing -superuser privileges by using multistrap, fakeroot, fakechroot and qemu user -mode emulation. +Polystrap is a tool to create a foreign architecture rootfs without +needing superuser privileges by using multistrap, fakeroot, fakechroot +and qemu user mode emulation from the qemu-user-static package. + +The proper qemu-*-static binary must be properly configured +(eg. /etc/qemu-binfmt/arm pointing to /usr/arm-linux-gnueabi/ with +xapt-installed libc and possibly other packages); package +binfmt-support (which is only a "Recommends" of qemu-user-static) must +also be installed. While I wanted to build without superuser privileges, multistrap would never offer mechanisms that would allow me to do so. Hence I wrote this script which @@ -29,6 +35,9 @@ In the normal case PLATFORM will contain some additional bits. The file is not strictly needed because the options can also be set by commandline arguments and the script will fall back to ./default/config. + Correct settings for ARCH and ROOTDIR are necessary + for proper operation, whereas other parameters are + only used if your multistrap.conf references them. PLATFORM/debconfseed.txt - as the name suggests PLATFORM/hooks - A directory that contains files that are sourced by polystrap after packages are installed. From c0e5a61eb93952488d9347dc8b66d37c7b676c66 Mon Sep 17 00:00:00 2001 From: josch Date: Thu, 30 Jun 2011 21:03:41 +0200 Subject: [PATCH 12/13] copying qemu-user-static into rootfs is a relic from the days of a real chroot - no idea how it survived the change for so long... --- polystrap.sh | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/polystrap.sh b/polystrap.sh index 5564854..e89d58c 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -121,22 +121,6 @@ if [ -r "$PLATFORM/root" ]; then cp --recursive --dereference $PLATFORM/root/* $ROOTDIR/ fi -# copy qemu usermode binary -QEMUARCH= -if [ $ARCH != "`dpkg --print-architecture`" ]; then - case $ARCH in - alpha|i386|m68k|mips|mipsel|ppc64|sh4|sh4eb|sparc|sparc64) - QEMUARCH=$ARCH;; - arm*) QEMUARCH=arm;; # for arm, armel, armeb, armhf - amd64) QEMUARCH=x86_64;; - lpia) QEMUARCH=i386;; - powerpc) QEMUARCH=ppc;; - *) echo "unknown architecture: $ARCH" >&2; exit 1;; - esac -fi -echo "I: copy qemu-$QEMUARCH-static into $ROOTDIR" >&2 -cp `which qemu-$QEMUARCH-static` $ROOTDIR/usr/bin - # preseed debconf echo "I: preseed debconf" >&2 if [ -r "$PLATFORM/debconfseed.txt" ]; then From da509267c7dfa5bfdec1649bf3a284395131e4dd Mon Sep 17 00:00:00 2001 From: Geert Stappers Date: Sun, 3 Jul 2011 09:41:01 +0200 Subject: [PATCH 13/13] polystrap [PATCH] Informational messages to standard out In good UNIX tradition is it possible to do foo > /dev/null to make foo silent and get only the error messages of foo For polystrap should that also be possible. --- polystrap.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/polystrap.sh b/polystrap.sh index e89d58c..1c59c4a 100755 --- a/polystrap.sh +++ b/polystrap.sh @@ -33,7 +33,7 @@ export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C export PATH=$PATH:/usr/sbin:/sbin if [ "$FAKEROOTKEY" = "" ]; then - echo "I: re-executing script inside fakeroot" >&2 + echo "I: re-executing script inside fakeroot" fakeroot "$0" "$@"; exit fi @@ -84,19 +84,19 @@ fi # binutils must always be installed for objdump for fake ldd PACKAGES="$PACKAGES binutils" -echo "I: --------------------------" >&2 -echo "I: suite: $SUITE" >&2 -echo "I: arch: $ARCH" >&2 -echo "I: rootdir: $ROOTDIR" >&2 -echo "I: mirror: $MIRROR" >&2 -echo "I: pkgs: $PACKAGES" >&2 -echo "I: --------------------------" >&2 +echo "I: --------------------------" +echo "I: suite: $SUITE" +echo "I: arch: $ARCH" +echo "I: rootdir: $ROOTDIR" +echo "I: mirror: $MIRROR" +echo "I: pkgs: $PACKAGES" +echo "I: --------------------------" [ -e "$ROOTDIR.tar" ] && { echo "tarball still exists" >&2; exit 1; } [ -e "$ROOTDIR" ] && { echo "root directory still exists" >&2; exit 1; } # create multistrap.conf -echo "I: create multistrap.conf" >&2 +echo "I: create multistrap.conf" MULTISTRAPCONF=`tempfile -d . -p multistrap` echo -n > "$MULTISTRAPCONF" while read line; do @@ -111,18 +111,18 @@ multistrap $MSTRAP_SIM -f "$MULTISTRAPCONF" rm -f "$MULTISTRAPCONF" # backup ldconfig and ldd -echo "I: backup ldconfig and ldd" >&2 +echo "I: backup ldconfig and ldd" mv $ROOTDIR/sbin/ldconfig $ROOTDIR/sbin/ldconfig.REAL mv $ROOTDIR/usr/bin/ldd $ROOTDIR/usr/bin/ldd.REAL # copy initial directory tree - dereference symlinks -echo "I: copy initial directory root tree $PLATFORM/root/ to $ROOTDIR/" >&2 +echo "I: copy initial directory root tree $PLATFORM/root/ to $ROOTDIR/" if [ -r "$PLATFORM/root" ]; then cp --recursive --dereference $PLATFORM/root/* $ROOTDIR/ fi # preseed debconf -echo "I: preseed debconf" >&2 +echo "I: preseed debconf" if [ -r "$PLATFORM/debconfseed.txt" ]; then cp "$PLATFORM/debconfseed.txt" $ROOTDIR/tmp/ fakechroot chroot $ROOTDIR debconf-set-selections /tmp/debconfseed.txt @@ -132,24 +132,24 @@ fi # run preinst scripts for script in $ROOTDIR/var/lib/dpkg/info/*.preinst; do [ "$script" = "$ROOTDIR/var/lib/dpkg/info/bash.preinst" ] && continue - echo "I: run preinst script ${script##$ROOTDIR}" >&2 + echo "I: run preinst script ${script##$ROOTDIR}" fakechroot chroot $ROOTDIR ${script##$ROOTDIR} install done # run dpkg --configure -a twice because of errors during the first run -echo "I: configure packages" >&2 +echo "I: configure packages" fakechroot chroot $ROOTDIR /usr/bin/dpkg --configure -a || fakechroot chroot $ROOTDIR /usr/bin/dpkg --configure -a # source hooks if [ -r "$PLATFORM/hooks" ]; then for f in $PLATFORM/hooks/*; do - echo "I: run hook $f" >&2 + echo "I: run hook $f" . $f done fi #cleanup -echo "I: cleanup" >&2 +echo "I: cleanup" rm $ROOTDIR/sbin/ldconfig $ROOTDIR/usr/bin/ldd mv $ROOTDIR/sbin/ldconfig.REAL $ROOTDIR/sbin/ldconfig mv $ROOTDIR/usr/bin/ldd.REAL $ROOTDIR/usr/bin/ldd @@ -157,6 +157,6 @@ rm $ROOTDIR/usr/sbin/policy-rc.d # need to generate tar inside fakechroot so that absolute symlinks are correct # tar is clever enough to not try and put the archive inside itself -echo "I: create tarball $ROOTDIR.tar" >&2 +echo "I: create tarball $ROOTDIR.tar" fakechroot chroot $ROOTDIR tar -cf $ROOTDIR.tar -C / . mv $ROOTDIR/$ROOTDIR.tar .