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
+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
-Include *.mk
+include *.mk
+
+.PRECIOUS: stretch_%_root/bin/sh
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
+stretch_%_root/: stretch_%_root/bin/sh ${CONFIG} permissions .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 "$@" apt-get update
chroot "$@" umount /proc /dev || true
chroot "$@" mount -t devtmpfs udev /dev
chroot "$@" mount -t proc proc /proc
chroot "$@" apt-get clean
touch "$@"
-stretch_%_config/: stretch_%_root/ ${CONFIG} .FORCE
- btrfs subvolume delete "$@" || rm -r "$@" || true
+stretch_%_config/: stretch_%_root/ ${CONFIG} permissions .FORCE
+ if [ -d "$@" ]; then btrfs subvolume delete "$@" || rm -r "$@"; else true; fi
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
+ -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
+ chmod a+r "$@"
+
+vmlinuz: stretch_*_root/
+ ln -fs '$<$@' ./
+
+initrd.img: stretch_*_root/
+ ln -fs '$<$@' ./
+
+/dev/sd%: partitions .FORCE
+ sfdisk ${@} <partitions
+ dd of=${@} if=/usr/lib/syslinux/mbr/gptmbr.bin
+
+/dev/sd%1: /dev/sd% vmlinuz initrd.img syslinux.cfg syslia32.cfg syslx64.cfg bootmenu.cfg .FORCE
+ mkdir -p mount
+ mkfs.vfat -n SQUASHBOOT ${@}
+ syslinux -i ${@}
+ mount -t vfat ${@} mount
+ mkdir -p $(addprefix mount/, EFI/BOOT efi32 efi64 bios)
+ cp /usr/lib/SYSLINUX.EFI/efi32/syslinux.efi mount/EFI/BOOT/BOOTIA32.EFI
+ cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi mount/EFI/BOOT/BOOTX64.EFI
+ cp $(addprefix /usr/lib/syslinux/modules/efi32/, ldlinux.e32 menu.c32 libutil.c32) mount/efi32/
+ cp $(addprefix /usr/lib/syslinux/modules/efi64/, ldlinux.e64 menu.c32 libutil.c32) mount/efi64/
+ cp $(addprefix /usr/lib/syslinux/modules/bios/, menu.c32 libutil.c32) mount/bios/
+ cp -L vmlinuz initrd.img *.squashfs Makefile partitions mount/
+ cp syslia32.cfg syslx64.cfg syslinux.cfg bootmenu.cfg mount/
+ # Temporary workaround, Uncomment for syslinux 6.04+
+ cp $(addprefix /usr/lib/syslinux/modules/, efi32/ldlinux.e32 efi64/ldlinux.e64) mount/EFI/BOOT/
+ cp syslx64.cfg mount/EFI/BOOT/syslinux.cfg
+ umount mount/
+ sync
+
+/dev/sd%2: /dev/sd% .FORCE
+ mkswap -L SWAP ${@}
+ sync
+
+/dev/sd%3: /dev/sd% .FORCE
+ mkdir -p mount
+ mkfs.btrfs -fL SQUASHCLIENT ${@}
+ mount -t btrfs ${@} mount
+ btrfs subvolume create mount/home
+ chmod 0755 mount/home
+ umount mount/
+ sync
--- /dev/null
+[base]
+## uncomment and set autologin username to enable autologin
+# autologin=dgod
+
+## uncomment and set timeout to enable timeout autologin,
+## the value should >=5
+# timeout=10
+
+## default session or desktop used when no systemwide config
+session=/usr/bin/startxfce4
+
+## uncomment and set to set numlock on your keyboard
+# numlock=0
+
+## set this if you don't want to put xauth file at ~/.Xauthority
+# xauth_path=/tmp
+
+# not ask password for users who have empty password
+# skip_password=1
+
+## greeter used to welcome the user
+greeter=/usr/lib/lxdm/lxdm-greeter-gtk
+
+[server]
+## arg used to start xserver, not fully function
+# arg=/usr/bin/X -background vt1
+# uncomment this if you really want xserver listen to tcp
+# tcp_listen=1
+
+[display]
+## gtk theme used by greeter
+gtk_theme=Clearlooks
+
+## background of the greeter
+#bg=/usr/share/backgrounds/default.png
+bg=/usr/share/images/desktop-base/login-background.svg
+
+## if show bottom pane
+bottom_pane=1
+
+## if show language select control
+lang=1
+
+## if show keyboard layout select control
+keyboard=0
+
+## the theme of greeter
+theme=Industrial
+
+[input]
+
+[userlist]
+## if disable the user list control at greeter
+disable=0
+
+## whitelist user
+white=
+
+## blacklist user
+black=
+
--- /dev/null
+.PHONY: permissions
+
+permissions: ${CONFIG} .FORCE
+ chown -R root:root config_*/
+ chmod 0755 config_*/
+ -chmod -R a+rX config_*/etc/
+ -chmod -R a+rX config_*/var/
+ -chmod -R a+rX config_*/lib/
+ -chmod -R a+rX config_*/usr/
+ -chmod -R a+rX config_*/opt/
+ -chmod 0700 config_*/var/lib/polkit-1/
+ -chgrp -R 107 config_*/var/spool/cron/crontabs/
+ -chmod 1730 config_*/var/spool/cron/crontabs/
+ -chmod 0600 config_*/var/spool/cron/crontabs/*
+ -chmod 0600 config_*/etc/NetworkManager/system-connections/*
+ -chmod 0750 config_*/root/
+ -chmod 0700 config_*/root/.ssh/
+ -chmod 0600 config_*/root/.ssh/authorized_keys
+ -chmod 0750 config_*/home/*/
+ -chmod 0700 config_*/home/*/.ssh/
+ -chmod 0600 config_*/home/*/.ssh/authorized_keys
+ -chown 1014:1014 config_*/home/guest