# This is the boot system build script.
: ${REPO_URL:=http://deb.devuan.org/merged}
: ${ARCH:=arm64}
-: ${CODENAME:=daedalus}
+: ${CODENAME:=ceres}
: ${BUILD:=$ARCH/build}
: ${SOURCES:=$ARCH/sources}
: ${INITRD:=$ARCH/build/initrd}
while read D ; do [ -z "$D" ] || unpack $D $3 || exit 1 ; done
}
+typeset -A SKIP
+
unpack() { # package directory
local F="$(debattr $1 Filename)"
local URL="${REPO_URL%/*}/$F"
local DST="$MEDIA/$F"
+ [ -z "${SKIP[$1]}" ] || return 0
[ -z "$F" ] && die "Unknown package $1"
[ -f "$DST" ] && return 0
local URL="${REPO_URL}/$F"
note "${INDENT}Get $1"
if ! wget -q -O $DST $URL ; then rm "$DST" ; exit 1 ; fi
mkdir -p "$2"
- ar p $DST data.tar.xz | tar -xJf - -C $2
+ if ar t $DST | grep -q data.tar.xz ; then
+ ar p $DST data.tar.xz | tar -xJf - --keep-directory-symlink -C $2
+ elif ar t $DST | grep -q data.tar.gz ; then
+ ar p $DST data.tar.gz | tar -xzf - --keep-directory-symlink -C $2
+ else
+ die unknow format $DST
+ fi
INDENT="$INDENT " do_depends "$1" Pre-Depends "$2" || exit 1
INDENT="$INDENT " do_depends "$1" Depends "$2" || exit 1
}
+sillylinks() {
+ for D in bin sbin lib lib64 ; do
+ mkdir -p $INITRD/usr/$D
+ ln -s usr/$D $INITRD/$d
+ done
+}
#=================================================================
SECTIONS="main main/debian-installer"
for S in $SECTIONS ; do get_source $S || die $S ; done
+sillylinks
LINUX="$(debattr linux-image-$ARCH Depends | sed 's| .*||' )"
VERSION="${LINUX#linux-image-}"
KERNEL="kernel-image-$VERSION-di"
for P in $($INITRD/bin/busybox --list) ; do
[ -e "$INITRD/bin/$P" ] || ln -sTf busybox "$INITRD/bin/$P"
done
-
note "Prepare modules.dep for ${LINUX#linux-image-}"
+find $INITRD/lib/modules/$VERSION -name '*.xz' -exec unxz '{}' ';'
( cd $INITRD; bin/depmod -b . ${LINUX#linux-image-} )
-# root:toor
+# root:toor login
heredoc $INITRD/etc/passwd <<EOF
root:\$5\$2GEhUQzfYu.hsf7H\$b8AIIGkhToQx.VFH77MGVNcQRkPjMgYJ90.h6dqmz.7:0:0:root:/root:/bin/sh
EOF
-heredoc $INITRD/etc/hostname <<EOF
-tiniest
-EOF
+echo tiniest > $INITRD/etc/hostname
herescript $INITRD/sbin/boot-modules-probe <<EOF
#!/bin/sh
exec /bin/setsid /bin/cttyhack /bin/sh
EOF
+#======================================================================
+# Install on vda1 as ext4
+SKIP[busybox-udeb]=true # stay with busybox-static
+SKIP[rootskel]=true # not to install
+SKIP[mounted-partitions]=true # Provided by partman-base (not to install)
+SKIP[created-fstab]=true # Provided by partman-base (not to install)
+
+for M in $(sed 's/#.*//') ; do unpack $M $INITRD || exit 1 ; done <<EOF
+e2fsprogs-udeb bootstrap-base devuan-keyring-udeb
+EOF
+
+sed '/fsys-tarfile/s|dpkg-deb|dpkg-debfix|' \
+ -i $INITRD/usr/share/debootstrap/functions
+herescript $INITRD/bin/dpkg-debfix <<EOF
+#/bin/sh
+if ar t "\$2" | grep -q data.tar.xz ; then
+ ar p "\$2" data.tar.xz | unxz
+elif ar t "\$2" | grep -q data.tar.gz ; then
+ ar p "\$2" data.tar.gz | gunzip
+else
+ ar t "\$2" >&2
+ echo "unknown format: \$*" >&2
+ exit 1
+fi
+EOF
+
+herescript $INITRD/install <<EOF
+#!/bin/sh
+set -x
+modprobe -a ext4 crc32c
+mkfs.ext4 -F -m0 /dev/vda1
+mkdir -p /target
+mount -t ext4 /dev/vda1 /target
+
+ifconfig lo up
+ifconfig eth0 10.10.10.64 netmask 255.255.255.0 up
+ip route add default via 10.10.10.100 dev eth0
+
+export http_proxy=$http_proxy
+debootstrap --foreign --arch=$ARCH $CODENAME /target $REPO_URL
+chroot /target debootstrap/debootstrap --second-stage
+EOF
+
+#======================================================================
note "Prepare $ARCH/initrd.gz"
cp $INITRD/boot/vmlinuz* $ARCH/vmlinuz
( cd $INITRD ; find . | fakeroot cpio -o -H newc ) | gzip > $ARCH/initrd.gz