add more status output, delete -x flag
This commit is contained in:
parent
dd54582e5e
commit
9e5a8aa62a
1 changed files with 28 additions and 15 deletions
43
polystrap.sh
43
polystrap.sh
|
@ -23,7 +23,7 @@
|
||||||
# FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
# FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
# IN THE SOFTWARE.
|
# IN THE SOFTWARE.
|
||||||
|
|
||||||
set -ex
|
set -e
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0: [-s suite] [-a arch] [-d directory] [-m mirror] [-p packages] platform\n" >&2
|
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
|
export PATH=$PATH:/usr/sbin:/sbin
|
||||||
|
|
||||||
if [ "$FAKEROOTKEY" = "" ]; then
|
if [ "$FAKEROOTKEY" = "" ]; then
|
||||||
echo "re-executing script inside fakeroot" >&2
|
echo "I: re-executing script inside fakeroot" >&2
|
||||||
fakeroot "$0" "$@";
|
fakeroot "$0" "$@";
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -82,18 +82,19 @@ fi
|
||||||
# binutils must always be installed for objdump for fake ldd
|
# binutils must always be installed for objdump for fake ldd
|
||||||
PACKAGES="$PACKAGES binutils"
|
PACKAGES="$PACKAGES binutils"
|
||||||
|
|
||||||
echo "--------------------------" >&2
|
echo "I: --------------------------" >&2
|
||||||
echo "suite: $SUITE" >&2
|
echo "I: suite: $SUITE" >&2
|
||||||
echo "arch: $ARCH" >&2
|
echo "I: arch: $ARCH" >&2
|
||||||
echo "rootdir: $ROOTDIR" >&2
|
echo "I: rootdir: $ROOTDIR" >&2
|
||||||
echo "mirror: $MIRROR" >&2
|
echo "I: mirror: $MIRROR" >&2
|
||||||
echo "pkgs: $PACKAGES" >&2
|
echo "I: pkgs: $PACKAGES" >&2
|
||||||
echo "--------------------------" >&2
|
echo "I: --------------------------" >&2
|
||||||
|
|
||||||
[ -e "$ROOTDIR.tar" ] && { echo "tarball still exists" >&2; exit 1; }
|
[ -e "$ROOTDIR.tar" ] && { echo "tarball still exists" >&2; exit 1; }
|
||||||
[ -e "$ROOTDIR" ] && { echo "root directory still exists" >&2; exit 1; }
|
[ -e "$ROOTDIR" ] && { echo "root directory still exists" >&2; exit 1; }
|
||||||
|
|
||||||
# create multistrap.conf
|
# create multistrap.conf
|
||||||
|
echo "I: create multistrap.conf" >&2
|
||||||
MULTISTRAPCONF=`tempfile -d . -p multistrap`
|
MULTISTRAPCONF=`tempfile -d . -p multistrap`
|
||||||
echo -n > "$MULTISTRAPCONF"
|
echo -n > "$MULTISTRAPCONF"
|
||||||
while read line; do
|
while read line; do
|
||||||
|
@ -101,32 +102,39 @@ while read line; do
|
||||||
done < $PLATFORM/multistrap.conf
|
done < $PLATFORM/multistrap.conf
|
||||||
|
|
||||||
# download and extract packages
|
# download and extract packages
|
||||||
|
echo "I: run multistrap" >&2
|
||||||
multistrap -f "$MULTISTRAPCONF"
|
multistrap -f "$MULTISTRAPCONF"
|
||||||
rm -f "$MULTISTRAPCONF"
|
rm -f "$MULTISTRAPCONF"
|
||||||
|
|
||||||
# backup ldconfig and ldd
|
# backup ldconfig and ldd
|
||||||
|
echo "I: backup ldconfig and ldd" >&2
|
||||||
mv $ROOTDIR/sbin/ldconfig $ROOTDIR/sbin/ldconfig.REAL
|
mv $ROOTDIR/sbin/ldconfig $ROOTDIR/sbin/ldconfig.REAL
|
||||||
mv $ROOTDIR/usr/bin/ldd $ROOTDIR/usr/bin/ldd.REAL
|
mv $ROOTDIR/usr/bin/ldd $ROOTDIR/usr/bin/ldd.REAL
|
||||||
|
|
||||||
# copy initial directory tree - dereference symlinks
|
# copy initial directory tree - dereference symlinks
|
||||||
|
echo "I: copy initial directory root tree $PLATFORM/root/ to $ROOTDIR/" >&2
|
||||||
if [ -r "$PLATFORM/root" ]; then
|
if [ -r "$PLATFORM/root" ]; then
|
||||||
cp --recursive --dereference $PLATFORM/root/* $ROOTDIR/
|
cp --recursive --dereference $PLATFORM/root/* $ROOTDIR/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# copy qemu usermode binary
|
# copy qemu usermode binary
|
||||||
|
QEMUARCH=
|
||||||
if [ $ARCH != "`dpkg --print-architecture`" ]; then
|
if [ $ARCH != "`dpkg --print-architecture`" ]; then
|
||||||
case $ARCH in
|
case $ARCH in
|
||||||
alpha|arm|armeb|i386|m68k|mips|mipsel|ppc64|sh4|sh4eb|sparc|sparc64)
|
alpha|i386|m68k|mips|mipsel|ppc64|sh4|sh4eb|sparc|sparc64)
|
||||||
cp `which qemu-$ARCH-static` $ROOTDIR/usr/bin;;
|
QEMUARCH=$ARCH;;
|
||||||
amd64) cp `which qemu-x86_64-static` $ROOTDIR/usr/bin;;
|
arm*) QEMUARCH=arm;; # for arm, armel, armeb, armhf
|
||||||
armel) cp `which qemu-arm-static` $ROOTDIR/usr/bin;;
|
amd64) QEMUARCH=x86_64;;
|
||||||
lpia) cp `which qemu-i386-static` $ROOTDIR/usr/bin;;
|
lpia) QEMUARCH=i386;;
|
||||||
powerpc) cp `which qemu-ppc-static` $ROOTDIR/usr/bin;;
|
powerpc) QEMUARCH=ppc;;
|
||||||
*) echo "unknown architecture: $ARCH" >&2; exit 1;;
|
*) echo "unknown architecture: $ARCH" >&2; exit 1;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
echo "I: copy qemu-$QEMUARCH-static into $ROOTDIR" >&2
|
||||||
|
cp `which qemu-$QEMUARCH-static` $ROOTDIR/usr/bin
|
||||||
|
|
||||||
# preseed debconf
|
# preseed debconf
|
||||||
|
echo "I: preseed debconf" >&2
|
||||||
if [ -r "$PLATFORM/debconfseed.txt" ]; then
|
if [ -r "$PLATFORM/debconfseed.txt" ]; then
|
||||||
cp "$PLATFORM/debconfseed.txt" $ROOTDIR/tmp/
|
cp "$PLATFORM/debconfseed.txt" $ROOTDIR/tmp/
|
||||||
fakechroot chroot $ROOTDIR debconf-set-selections /tmp/debconfseed.txt
|
fakechroot chroot $ROOTDIR debconf-set-selections /tmp/debconfseed.txt
|
||||||
|
@ -136,20 +144,24 @@ fi
|
||||||
# run preinst scripts
|
# run preinst scripts
|
||||||
for script in $ROOTDIR/var/lib/dpkg/info/*.preinst; do
|
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
|
done
|
||||||
|
|
||||||
# run dpkg --configure -a twice because of errors during the first run
|
# 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
|
fakechroot chroot $ROOTDIR /usr/bin/dpkg --configure -a || fakechroot chroot $ROOTDIR /usr/bin/dpkg --configure -a
|
||||||
|
|
||||||
# source hooks
|
# source hooks
|
||||||
if [ -r "$PLATFORM/hooks" ]; then
|
if [ -r "$PLATFORM/hooks" ]; then
|
||||||
for f in $PLATFORM/hooks/*; do
|
for f in $PLATFORM/hooks/*; do
|
||||||
|
echo "I: run hook $f" >&2
|
||||||
. $f
|
. $f
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#cleanup
|
#cleanup
|
||||||
|
echo "I: cleanup" >&2
|
||||||
rm $ROOTDIR/sbin/ldconfig $ROOTDIR/usr/bin/ldd
|
rm $ROOTDIR/sbin/ldconfig $ROOTDIR/usr/bin/ldd
|
||||||
mv $ROOTDIR/sbin/ldconfig.REAL $ROOTDIR/sbin/ldconfig
|
mv $ROOTDIR/sbin/ldconfig.REAL $ROOTDIR/sbin/ldconfig
|
||||||
mv $ROOTDIR/usr/bin/ldd.REAL $ROOTDIR/usr/bin/ldd
|
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
|
# 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
|
# 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 / .
|
fakechroot chroot $ROOTDIR tar -cf $ROOTDIR.tar -C / .
|
||||||
mv $ROOTDIR/$ROOTDIR.tar .
|
mv $ROOTDIR/$ROOTDIR.tar .
|
||||||
|
|
Loading…
Reference in a new issue