10 PACKAGES := apt bilibop-lockfs btrfs-tools busybox-static bzip2 ca-certificates cron deborphan efibootmgr firmware-linux-free gzip htop ifupdown init iputils-ping irqbalance isc-dhcp-client less live-boot live-boot-initramfs-tools make man-db nbd-client net-tools nmap ntpdate openssh-client openssh-server p7zip-full pciutils rsync squashfs-tools sshfs sudo syslinux syslinux-common syslinux-efi systemd unace unrar-free unzip vim wget wireless-tools wpasupplicant xz-utils zip
14 .PRECIOUS: stretch_%_root/bin/sh
16 stretch_%_root/bin/sh:
17 btrfs subvolume create "$(subst bin/sh,,$@)" || mkdir "$(subst bin/sh,,$@)"
18 chmod 755 "$(subst bin/sh,,$@)"
19 debootstrap --arch=${ARCH} --variant=minbase stretch "$(subst bin/sh,,$@)"
21 stretch_%_root/: stretch_%_root/bin/sh ${CONFIG} permissions .FORCE
22 for tree in ${CONFIG}; do for file in apt default timezone; do cp -av "$$tree/etc/$$file" "$@/etc/" || true; done; done
23 chroot "$@" ln -sf /bin/true /usr/local/sbin/invoke-rc.d
24 chroot "$@" sh -c 'apt-mark showmanual |xargs apt-mark auto || true'
25 -chroot "$@" apt-get update
26 chroot "$@" umount /proc /dev || true
27 chroot "$@" mount -t devtmpfs udev /dev
28 chroot "$@" mount -t proc proc /proc
29 chroot "$@" apt-get --yes install ${PACKAGES}
30 chroot "$@" apt-get --yes --auto-remove purge
31 chroot "$@" apt-get --yes --auto-remove upgrade
32 chroot "$@" rm /usr/local/sbin/invoke-rc.d
33 chroot "$@" umount /proc /dev
34 chroot "$@" apt-get clean
37 stretch_%_config/: stretch_%_root/ ${CONFIG} permissions .FORCE
38 if [ -d "$@" ]; then btrfs subvolume delete "$@" || rm -r "$@"; else true; fi
39 btrfs subvolume snapshot "$<" "$@" || cp -rlv "$<" "$@"
40 cp -av $(addsuffix /*, ${CONFIG}) "$@"
41 -chroot "$@" locale-gen
42 -chroot "$@" update-locale
43 -chroot "$@" useradd -M -p "$$(printf %s\\n '${PASS}' |mkpasswd -m sha-256 -s)" '${USER}'
44 -for g in ${GROUPS}; do chroot "$@" adduser '${USER}' "$$g"; done
47 stretch_%.squashfs: stretch_%_config/
49 mksquashfs "$<" "$@" -comp xz
51 vmlinuz: stretch_*_root/
54 initrd.img: stretch_*_root/
57 /dev/sd%: partitions .FORCE
58 sfdisk ${@} <partitions
59 dd of=${@} if=/usr/lib/syslinux/mbr/gptmbr.bin
61 /dev/sd%1: /dev/sd% vmlinuz initrd.img syslinux.cfg syslia32.cfg syslx64.cfg bootmenu.cfg .FORCE
63 mkfs.vfat -n SQUASHBOOT ${@}
65 mount -t vfat ${@} mount
66 mkdir -p $(addprefix mount/, EFI/BOOT efi32 efi64 bios)
67 cp /usr/lib/SYSLINUX.EFI/efi32/syslinux.efi mount/EFI/BOOT/BOOTIA32.EFI
68 cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi mount/EFI/BOOT/BOOTX64.EFI
69 cp $(addprefix /usr/lib/syslinux/modules/efi32/, ldlinux.e32 menu.c32 libutil.c32) mount/efi32/
70 cp $(addprefix /usr/lib/syslinux/modules/efi64/, ldlinux.e64 menu.c32 libutil.c32) mount/efi64/
71 cp $(addprefix /usr/lib/syslinux/modules/bios/, menu.c32 libutil.c32) mount/bios/
72 cp -L vmlinuz initrd.img *.squashfs Makefile partitions mount/
73 cp syslia32.cfg syslx64.cfg syslinux.cfg bootmenu.cfg mount/
74 # Temporary workaround, Uncomment for syslinux 6.04+
75 cp $(addprefix /usr/lib/syslinux/modules/, efi32/ldlinux.e32 efi64/ldlinux.e64) mount/EFI/BOOT/
76 cp syslx64.cfg mount/EFI/BOOT/syslinux.cfg
80 /dev/sd%2: /dev/sd% .FORCE
84 /dev/sd%3: /dev/sd% .FORCE
86 mkfs.btrfs -fL SQUASHCLIENT ${@}
87 mount -t btrfs ${@} mount
88 btrfs subvolume create mount/home