]> git.plutz.net Git - bootimage/blob - Makefile
Modular config
[bootimage] / Makefile
1 .FORCE:
2
3 USER := user
4 PASS := user
5 GROUPS := sudo
6
7 ARCH := amd64
8 CONFIG := config_base/
9
10 PACKAGES := apt bilibop-lockfs btrfs-tools busybox-static bzip2 ca-certificates cron deborphan extlinux 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 systemd unace unrar-free unzip vim wget wireless-tools wpasupplicant xz-utils zip
11
12 Include *.mk
13
14 stretch_%_root/bin/sh:
15         btrfs subvolume create "$(subst bin/sh,,$@)" || mkdir "$(subst bin/sh,,$@)"
16         chmod 755 "$(subst bin/sh,,$@)"
17         debootstrap --arch=${ARCH} --variant=minbase stretch "$(subst bin/sh,,$@)"
18
19 stretch_%_root/: stretch_%_root/bin/sh ${CONFIG} .FORCE
20         for tree in ${CONFIG}; do for file in apt default timezone; do cp -av "$$tree/etc/$$file" "$@/etc/" || true; done; done
21         chroot "$@" ln -sf /bin/true /usr/local/sbin/invoke-rc.d
22         chroot "$@" sh -c 'apt-mark showmanual |xargs apt-mark auto || true'
23         chroot "$@" apt-get update
24         chroot "$@" umount /proc /dev || true
25         chroot "$@" mount -t devtmpfs udev /dev
26         chroot "$@" mount -t proc proc /proc
27         chroot "$@" apt-get --yes install ${PACKAGES}
28         chroot "$@" apt-get --yes --auto-remove purge
29         chroot "$@" apt-get --yes --auto-remove upgrade
30         chroot "$@" rm /usr/local/sbin/invoke-rc.d
31         chroot "$@" umount /proc /dev
32         chroot "$@" apt-get clean
33         touch "$@"
34
35 stretch_%_config/: stretch_%_root/ ${CONFIG} .FORCE
36         btrfs subvolume delete "$@" || rm -r "$@" || true
37         btrfs subvolume snapshot "$<" "$@" || cp -rlv "$<" "$@"
38         cp -av $(addsuffix /*, ${CONFIG}) "$@"
39         chroot "$@" locale-gen
40         chroot "$@" update-locale
41         chroot "$@" useradd -M -p "$$(printf %s\\n '${PASS}' |mkpasswd -m sha-256 -s)" '${USER}'
42         for g in ${GROUPS}; do chroot "$@" adduser '${USER}' "$$g"; done
43         touch "$@"
44
45 stretch_%.squashfs: stretch_%_config/
46         rm "$@" || true
47         mksquashfs "$<" "$@" -comp xz