X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=Makefile;h=274d1c7c79d35764edbc2b3dc630a0ed05979122;hb=3dad161953c83b6a23ac663933802701755426a2;hp=adec7d705cdb54597f062e3e7c4298c278fc0627;hpb=94825873e9d1651ddd885049306cb44319bf9f41;p=blast diff --git a/Makefile b/Makefile index adec7d7..274d1c7 100644 --- a/Makefile +++ b/Makefile @@ -5,13 +5,15 @@ comma_:= , space_:= ${nul_} ${nul_} .PHONY: clean .FORCE _target -.PHONY: _bootloader_raspi _bootloader_pc _partition_gpt _partition_raspi -.PHONY: _squash_modules -.PHONY: _qemu _bootstrap _install _copy _config _squash -.PHONY: _format _mount _sparse _umount _partcopy _mbr +.PHONY: _qemu _bootstrap _install _copy _config +.PHONY: _partition_gpt _partition_raspi _sparse _partcopy _mbr +.PHONY: _format _format_root _format_boot +.PHONY: _bootloader_raspi _bootloader_pc _bootloader_iso +.PHONY: _mount _mount_root _mount_boot _efi_mount +.PHONY: _umount _umount_root _umount_boot _efi_umount +.PHONY: _squash_modules _squash _isosquash _iso_image 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 @@ -28,15 +30,18 @@ else include ${config} endif -ifndef release +ifdef release + KEYRING := keys/debian-archive-${release}-stable.gpg +else release := stretch + KEYRING := keys/debian-archive-stretch-stable.gpg endif +ifndef SOURCES define SOURCES := -deb http://cdn.debian.net/debian stretch main -deb http://cdn.debian.net/debian buster main deb http://cdn.debian.net/debian ${release} main endef +endif ifdef disk VOLUME := ${disk} @@ -94,6 +99,30 @@ else ifdef squash _config: _copy _squash_modules _squash: _config +else ifdef iso + ISO := ${iso} + ISOROOT := iso_root/ + SYSROOT := sys_root_${release}/ + CFGROOT := cfg_root/ + BOOT_MB := 2 + PBOOT := ${ISOROOT}/efi.img + + PACKAGES += squashfs-tools + + _target: _iso_image _install _config + + _bootstrap: + _install: _bootstrap + _copy: _install + _config: _copy _squash_modules + _isosquash: _config +# ${PBOOT}: ${ISOROOT} +# _format_boot: ${PBOOT} +# _efi_mount: ${PBOOT} _format_boot +# _efi_umount: _config + _bootloader_iso: _config + _iso_image: _bootloader_iso _isosquash # _efi_umount + else ifdef raspi VOLUME := ${raspi} PBOOT := rpi_boot.img @@ -144,20 +173,26 @@ else ifeq "${ARCH}" "i386" PACKAGES += linux-image-686 endif -export SOURCES SYSROOT CFGROOT VOLUME PBOOT PROOT SQUASH ARCH KEYRING BOOTSTRAP +export SOURCES SYSROOT CFGROOT VOLUME PBOOT PROOT SQUASH ARCH KEYRING BOOTSTRAP ISOROOT ISO sys_root_${release}/: btrfs subvol create "$@" || mkdir "$@" chmod 755 "$@" +rpi_root_${release}/: + btrfs subvol create "$@" || mkdir "$@" + chmod 755 "$@" + cfg_root/: sys_root_${release}/ _install -btrfs sub del "$@" || rm -r "$@" btrfs sub snap "$<" "$@" || mkdir "$@" chmod 755 "$@" -rpi_root_${release}/: +${ISOROOT}: + -btrfs sub del "$@" || rm -r "$@" btrfs subvol create "$@" || mkdir "$@" - chmod 755 "$@" + mkdir "$@/live" + chmod 755 "$@" "$@/live" img_mount/: mkdir -p -m 755 "$@" @@ -186,24 +221,29 @@ _norecommends: ${SYSROOT}/etc/apt/apt.conf.d/10norecommends ${SYSROOT}/etc/apt/apt.conf.d/10norecommends: ${SYSROOT} mkdir -p -m 755 "$(dir $@)" - printf 'APT::Install-Recommends "false";\n' >"$@" + printf 'APT::%s "false";\n' "Install-Recommends" "Keep-Recommends" "Install-Suggests" "Keep-Suggests" >"$@" chmod 644 "$@" -${SYSROOT}/etc/apt/trusted.gpg.d/: ${SYSROOT} +${SYSROOT}/etc/apt/trusted.gpg.d/: ${SYSROOT} _bootstrap mkdir -p -m 755 "$@" cp keys/*.gpg "$@" _install: ${SYSROOT} _aptkeys _norecommends - printf '%s\n' "$${SOURCES}" >"$${SYSROOT}/etc/apt/sources.list" + printf '%s\n' "$${SOURCES}" |sort -u >"$${SYSROOT}/etc/apt/sources.list" -cp /etc/resolv.conf "$${SYSROOT}/etc/" -chroot "$${SYSROOT}" sh -c 'apt-mark showmanual |xargs apt-mark auto' -chroot "$${SYSROOT}" apt-get update chroot "$${SYSROOT}" ln -sf /bin/true /usr/local/sbin/invoke-rc.d + chroot "$${SYSROOT}" ln -sf /bin/true /usr/sbin/udevadm chroot "$${SYSROOT}" apt-get --yes install ${PACKAGES} + mkdir -p -m 755 "$${SYSROOT}/var/lib/deborphan/" + chroot "$${SYSROOT}" sh -c 'printf "%s\\n" ${PACKAGES} >/var/lib/deborphan/keep' + -chroot "$${SYSROOT}" sh -c 'apt-get --yes purge $$(deborphan -an |sed "s;^.* ;;g")' chroot "$${SYSROOT}" apt-get --yes --auto-remove purge -chroot "$${SYSROOT}" apt-get --yes --auto-remove upgrade chroot "$${SYSROOT}" apt-get clean chroot "$${SYSROOT}" rm /usr/local/sbin/invoke-rc.d + chroot "$${SYSROOT}" rm /usr/sbin/udevadm _copy: ${SYSROOT} ${CFGROOT} cp -au "$${SYSROOT}/." "$${CFGROOT}/" @@ -224,6 +264,11 @@ _squash_modules: ${CFGROOT} _squash: ${SQUASH} _squash_modules +_isosquash: ${ISOROOT}/live/live.squashfs +${ISOROOT}/live/live.squashfs: ${CFGROOT} ${ISOROOT} .FORCE + -rm "$@" + printf '%s\n' boot |mksquashfs "$${CFGROOT}" "$@" -comp xz -ef /dev/stdin + ${VOLUME}: .FORCE ! printf '%s\n' "$${VOLUME}" |grep -q '^/dev/' # abort if volume should be real device dd count=0 of="$${VOLUME}" # truncate @@ -250,11 +295,22 @@ _partition_gpt: ${VOLUME} _sparse: ${PBOOT} ${PROOT} -_format: ${PBOOT} ${PROOT} - -umount "$${CFGROOT}/boot" "$${CFGROOT}" - mkfs.fat -F 32 -n BOOT "$${PBOOT}" +_format_root: ${PROOT} + -umount "$${CFGROOT}/boot" "$${CFGROOT}" "${PROOT}" mkfs.ext4 -F -L FSROOT "$${PROOT}" +_format_boot: ${PBOOT} + -umount "$${CFGROOT}/boot" "${PBOOT}" + mkfs.fat -F 32 -n BOOT "$${PBOOT}" + +_format: _format_root _format_boot + +_iso_image: ${ISOROOT} # _efi_iso _efi_umount + xorriso -as mkisofs -o "$${ISO}" -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \ + -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \ + "$${ISOROOT}" + # -eltorito-alt-boot -e efi.img -no-emul-boot -isohybrid-gpt-basdat \ + .PHONY: _syslinux_efi32 _syslinux_efi64 _syslinux_bios .PHONY: _grub_efi32 _grub_efi64 @@ -306,6 +362,30 @@ _bootloader_pc: ${CFGROOT} _grub_efi32 _grub_efi64 _syslinux_bios #_syslinux_efi printf "menuentry 'Rescue' --id 'rescue' {\n linux '/%s' root=LABEL=FSROOT init=/bin/sh\n initrd '/%s'\n}\n" \ "$$k" "$$i" >>"$${CFGROOT}/boot/grub.cfg" +_bootloader_iso: ${CFGROOT} ${ISOROOT} + # grub-mkimage -p / -O i386-pc-eltorito biosdisk iso9660 normal linux all_video >"$${ISOROOT}/grub.bin" + cp -L "$${CFGROOT}/vmlinuz" "$${CFGROOT}/initrd.img" "$${ISOROOT}" + cp /usr/lib/ISOLINUX/isolinux.bin $(addprefix /usr/lib/syslinux/modules/bios/, ldlinux.c32 menu.c32 libutil.c32) "$${ISOROOT}" + # printf '%s\n' "set timeout=10" "default=buster" \ + # "menuentry 'Debian Buster' --id 'buster' {" \ + # "linux '/vmlinuz' boot=live" "initrd '/initrd.img'" "}" \ + # >"$${ISOROOT}/grub.cfg" + printf '%s\n' "UI menu.c32" "DEFAULT buster" "TIMEOUT 100" \ + "LABEL buster" " MENU LABEL Debian Buster 64bit" \ + " KERNEL /vmlinuz" " APPEND initrd=/initrd.img boot=live" \ + >"$${ISOROOT}/syslinux.cfg" + +_efi_mount: ${PBOOT} + -umount "efi/" + mkdir -p -m 755 "efi/" + mount -t vfat -o loop "$${PBOOT}" "efi/" + +_efi_umount: _efi_mount + umount efi/ && rmdir efi/ + +_efi_iso: _efi_mount _grub_efi32 _grub_efi64 + cp -r "$${CFGROOT}/boot/EFI/." "efi/EFI/" + .PHONY: _syslinux_mbr _grub_mbr _syslinux_mbr: ${VOLUME} @@ -321,12 +401,20 @@ _partcopy: ${VOLUME} ${PROOT} ${PBOOT} dd conv=notrunc,sparse bs=1M seek=2 if="$${PBOOT}" of="$${VOLUME}" dd conv=notrunc,sparse bs=1M seek=$$((2 + ${BOOT_MB})) if="$${PROOT}" of="$${VOLUME}" -_mount: ${PBOOT} ${PROOT} ${CFG_ROOT} +_mount_root: ${PROOT} ${CFGROOT} mount -t ext4 "$${PROOT}" "$${CFGROOT}" chmod 755 "$${CFGROOT}" + +_mount_boot: ${PBOOT} mkdir -p -m 755 "$${CFGROOT}/boot" mount -t vfat "$${PBOOT}" "$${CFGROOT}/boot" +ifdef disk + _mount_boot: _mount_root +endif + +_mount: _mount_root _mount_boot + _img_mount: mount -o loop,offset="$$((${BOOT_MB} + 2))"M,sizelimit=${ROOT_MB}M \ -t ext4 "$${VOLUME}" "$${CFGROOT}" @@ -335,10 +423,14 @@ _img_mount: mount -o loop,offset=2M,sizelimit=${BOOT_MB}M \ -t vfat "$${VOLUME}" "$${CFGROOT}/boot" -_umount: ${CFGROOT} +_umount_boot: ${CFGROOT} -umount "$${CFGROOT}/boot" + +_umount_root: _umount_boot umount "$${CFGROOT}" && rmdir "$${CFGROOT}" +_umount: _umount_boot _umount_root + clean: [ "$${SYSROOT#/}" ] && [ "$${CFGROOT#/}" ] || false # (abort receipe) -umount img_mount/boot @@ -347,12 +439,14 @@ clean: -umount hdd_mount/boot -umount hdd_mount -rmdir hdd_mount - 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_${release}/" ]; then btrfs sub del "rpi_root_${release}/" || echo rm -r "rpi_root_${release}/"; fi + if [ -d "cfg_root/" ]; then btrfs sub del "cfg_root/" || rm -r "cfg_root/"; fi + if [ -d "iso_root/" ]; then btrfs sub del "iso_root/" || rm -r "iso_root/"; fi + if [ -d "sys_root_${release}/" ]; then btrfs sub del "sys_root_${release}/" || rm -r "sys_root_${release}/"; fi + if [ -d "rpi_root_${release}/" ]; then btrfs sub del "rpi_root_${release}/" || rm -r "rpi_root_${release}/"; fi -rm part_boot.img -rm part_root.img -rm rpi_boot.img -rm rpi_root.img -[ -f "$${SQUASH}" ] && rm "$${SQUASH}" -[ -f "$${VOLUME}" ] && rm "$${VOLUME}" + -[ -f "$${ISO}" ] && rm "$${ISO}"