]> git.plutz.net Git - bootimage/blobdiff - Makefile
Modular config
[bootimage] / Makefile
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..a80a8a7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,47 @@
+.FORCE:
+
+USER := user
+PASS := user
+GROUPS := sudo
+
+ARCH := amd64
+CONFIG := config_base/
+
+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
+
+Include *.mk
+
+stretch_%_root/bin/sh:
+       btrfs subvolume create "$(subst bin/sh,,$@)" || mkdir "$(subst bin/sh,,$@)"
+       chmod 755 "$(subst bin/sh,,$@)"
+       debootstrap --arch=${ARCH} --variant=minbase stretch "$(subst bin/sh,,$@)"
+
+stretch_%_root/: stretch_%_root/bin/sh ${CONFIG} .FORCE
+       for tree in ${CONFIG}; do for file in apt default timezone; do cp -av "$$tree/etc/$$file" "$@/etc/" || true; done; done
+       chroot "$@" ln -sf /bin/true /usr/local/sbin/invoke-rc.d
+       chroot "$@" sh -c 'apt-mark showmanual |xargs apt-mark auto || true'
+       chroot "$@" apt-get update
+       chroot "$@" umount /proc /dev || true
+       chroot "$@" mount -t devtmpfs udev /dev
+       chroot "$@" mount -t proc proc /proc
+       chroot "$@" apt-get --yes install ${PACKAGES}
+       chroot "$@" apt-get --yes --auto-remove purge
+       chroot "$@" apt-get --yes --auto-remove upgrade
+       chroot "$@" rm /usr/local/sbin/invoke-rc.d
+       chroot "$@" umount /proc /dev
+       chroot "$@" apt-get clean
+       touch "$@"
+
+stretch_%_config/: stretch_%_root/ ${CONFIG} .FORCE
+       btrfs subvolume delete "$@" || rm -r "$@" || true
+       btrfs subvolume snapshot "$<" "$@" || cp -rlv "$<" "$@"
+       cp -av $(addsuffix /*, ${CONFIG}) "$@"
+       chroot "$@" locale-gen
+       chroot "$@" update-locale
+       chroot "$@" useradd -M -p "$$(printf %s\\n '${PASS}' |mkpasswd -m sha-256 -s)" '${USER}'
+       for g in ${GROUPS}; do chroot "$@" adduser '${USER}' "$$g"; done
+       touch "$@"
+
+stretch_%.squashfs: stretch_%_config/
+       rm "$@" || true
+       mksquashfs "$<" "$@" -comp xz