8 CACHE_FILE="$HELPER_DIR/cache.tar"
10 EXTRA_PKGS="linux-image-amd64,e2fsprogs,ntfs-3g,xmlstarlet"
12 helper_img=$(mktemp $HELPER_DIR/image.XXXXXXXX)
14 dd if=/dev/zero of=$helper_img bs=1k count=400000
15 blockdev=$(losetup -sf $helper_img)
16 CLEANUP+=("losetup -d $blockdev")
18 format_disk0 $blockdev "extdump"
20 root_dev=$(map_disk0 $blockdev)-1
21 CLEANUP+=("unmap_disk0 $blockdev")
26 CLEANUP+=("rmdir $TMPDIR")
28 mount $root_dev $TMPDIR
29 CLEANUP+=("umount $root_dev")
31 if [ -f "$CACHE_FILE" ]; then
32 tar xf "$CACHE_FILE" -C $TMPDIR
34 debootstrap --arch "$ARCH" --include $EXTRA_PKGS --variant=minbase \
37 # remove the downloaded debs, as they are no longer needed
38 find "$TMPDIR/var/cache/apt/archives" -type f -name '*.deb' -print0 | \
41 TMP_CACHE=$(mktemp "${CACHE_FILE}.XXXXXX")
42 tar cf "$TMP_CACHE" -C $TMPDIR .
43 mv -f "$TMP_CACHE" "$CACHE_FILE"
46 echo helper > $TMPDIR/etc/hostname
48 cat > $TMPDIR/etc/fstab <<EOF
49 # /etc/fstab: static file system information.
51 # <file system> <mount point> <type> <options> <dump> <pass>
52 /dev/sda1 / ext3 defaults 0 1
53 proc /proc proc defaults 0 0
56 if [ ! -L "$TMPDIR/vmlinuz" -o ! -L "$TMPDIR/vmlinuz" ]; then
58 log_error "vmlinuz or initrd.img link in root is missing."
59 log_error "I don't know how to find a usable kernel/initrd pair."
63 kernel=$(readlink -en $TMPDIR/vmlinuz)
64 initrd=$(readlink -en $TMPDIR/initrd.img)
66 echo "Moving $(basename $kernel) and $(basename $initrd) to $HELPER_DIR"
67 mv $kernel $initrd $HELPER_DIR
69 kernel=$(basename $kernel)
70 initrd=$(basename $initrd)
72 (cd $HELPER_DIR; ln -fs $kernel kernel; ln -fs $initrd initrd)
74 rm $TMPDIR/vmlinuz $TMPDIR/initrd.img
78 mv $helper_img $HELPER_DIR/image
84 # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :