]> git.plutz.net Git - blast/blobdiff - Makefile
enable config selection, enable release switch
[blast] / Makefile
index fb0db2b294daf13a1dad2592c508f7cd22032343..c3309a2912ebc71823a073a498b1a8ba26d78c7d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,21 +13,29 @@ space_:= ${nul_} ${nul_}
 ARCH := amd64
 KEYRING := keys/debian-archive-stretch-stable.gpg
 BOOTSTRAP := http://cdn.debian.net/debian
+PACKAGES := ${PACKAGES} apt busybox-static debian-archive-keyring init systemd
 
 # Partition Table (2M) + Boot Partition (126M)+ Root Partition + Slack Space (1M) = 2048M
 BOOT_MB := 62
 ROOT_MB := 959
 
-define SOURCES = 
-deb    http://cdn.debian.net/debian stretch main
-endef
-
-PACKAGES := ${PACKAGES} apt busybox-static debian-archive-keyring init systemd
-
-include config.mk
 config.mk:
        cp "config.example" "$@"
 
+ifndef config
+  include config.mk
+else
+  include ${config}
+endif
+
+ifndef release
+  release := stretch
+endif
+
+define SOURCES := 
+deb    http://cdn.debian.net/debian ${release} main
+endef
+
 ifdef disk
   VOLUME := ${disk}
   PBOOT := ${disk}1
@@ -51,7 +59,7 @@ else ifdef image
   VOLUME := ${image}
   PBOOT := part_boot.img
   PROOT := part_root.img
-  SYSROOT := sys_root/
+  SYSROOT := sys_root_${release}/
   CFGROOT := img_mount/
   
   _target: _mbr _umount _partcopy _config _install
@@ -71,34 +79,36 @@ else ifdef image
 
 else ifdef squash
   SQUASH := ${squash}
-  SYSROOT := sys_root/
+  SYSROOT := sys_root_${release}/
   CFGROOT := cfg_root/
+
+  PACKAGES += squashfs-tools nbd-client
   
   _target: _squash _install _config
   
   _bootstrap:
   _install: _bootstrap
   _copy: _install
-  _config: _copy
-  _squash: _config _squash_modules
+  _config: _copy _squash_modules
+  _squash: _config
 
 else ifdef raspi
   VOLUME := ${raspi}
   PBOOT := rpi_boot.img
   PROOT := rpi_root.img
-  SYSROOT := rpi_root/
+  SYSROOT := rpi_root_${release}/
   CFGROOT := img_mount/
   
   ARCH := armhf
   KEYRING := keys/raspbian-archive-keyring.gpg
   BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian
 
-  define SOURCES =
-  deb  http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi
-  deb  http://archive.raspberrypi.org/debian stretch main
+  define SOURCES :=
+  deb  http://raspbian.raspberrypi.org/raspbian ${release} main non-free firmware rpi
+  deb  http://archive.raspberrypi.org/debian ${release} main
   endef
 
-PACKAGES := ${PACKAGES} firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel
+  PACKAGES += firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel
 
   _target: _umount _partcopy _config _install
   
@@ -134,16 +144,17 @@ endif
 
 export SOURCES SYSROOT CFGROOT VOLUME PBOOT PROOT SQUASH ARCH KEYRING BOOTSTRAP
 
-sys_root/:
-       btrfs subvol create "$@" || mkdir -p "$@"
+sys_root_${release}/:
+       btrfs subvol create "$@" || mkdir "$@"
        chmod 755 "$@"
 
-cfg_root/: sys_root/ _install
-       btrfs sub snap "$<" "$@" || mkdir -p "$@"
+cfg_root/: sys_root_${release}/ _install
+       -btrfs sub del "$@" || rm -r "$@"
+       btrfs sub snap "$<" "$@" || mkdir "$@"
        chmod 755 "$@"
 
-rpi_root/:
-       btrfs subvol create "$@" || mkdir -p "$@"
+rpi_root_${release}/:
+       btrfs subvol create "$@" || mkdir "$@"
        chmod 755 "$@"
 
 img_mount/:
@@ -163,7 +174,9 @@ _bootstrap: ${SYSROOT}/bin/sh
 ${SYSROOT}/bin/sh: | ${SYSROOT}
        debootstrap --variant=minbase --arch="$${ARCH}" \
                --keyring="$${KEYRING}" \
-               stretch "$${SYSROOT}" "$${BOOTSTRAP}"
+               "${release}" "$${SYSROOT}" "$${BOOTSTRAP}"
+       printf 'APT::Default-Release "%s";' "${release}" >"$${SYSROOT}/etc/apt/apt.conf.d/10release"
+
 
 .PHONY: _aptkeys _norecommends
 _aptkeys: ${SYSROOT}/etc/apt/trusted.gpg.d/
@@ -193,14 +206,14 @@ _install: ${SYSROOT} _aptkeys _norecommends
 _copy: ${SYSROOT} ${CFGROOT}
        cp -au "$${SYSROOT}/." "$${CFGROOT}/"
 
-.PHONY: _common_config
-_config: _common_config
-_common_config: ${CFGROOT}
+_config: ${CFGROOT}
        ln -sf /dev/null "$${CFGROOT}/etc/systemd/network/99-default.link"
+       printf '\nsession       optional        pam_mkhomedir.so umask=0027\n' >>"$${CFGROOT}/etc/pam.d/common-session"
        printf 'LABEL=FSROOT / ext4 auto,nofail,rw 0 0\nLABEL=BOOT /boot vfat auto,nofail,ro 0 0\n' \
                >"$${CFGROOT}/etc/fstab"
+       chroot "$${CFGROOT}" update-initramfs -u
 
-${SQUASH}: ${CFGROOT}
+${SQUASH}: ${CFGROOT} .FORCE
        -rm "$${SQUASH}"
        mksquashfs "$${CFGROOT}" "$${SQUASH}" -comp xz
 
@@ -324,9 +337,9 @@ clean:
        -umount hdd_mount/boot
        -umount hdd_mount
        -rmdir hdd_mount
-       if [ -d "sys_root/" ]; then btrfs sub del "sys_root/" || echo rm -r "sys_root/"; fi
+       if [ -d "sys_root_${release}/" ]; then btrfs sub del "sys_root_${release}/" || echo rm -r "sys_root_${release}/"; fi
        if [ -d "cfg_root/" ]; then btrfs sub del "cfg_root/" || echo rm -r "cfg_root/"; fi
-       if [ -d "rpi_root/" ]; then btrfs sub del "rpi_root/" || echo rm -r "rpi_root/"; fi
+       if [ -d "rpi_root_${release}/" ]; then btrfs sub del "rpi_root_${release}/" || echo rm -r "rpi_root_${release}/"; fi
        -rm part_boot.img
        -rm part_root.img
        -rm rpi_boot.img