X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=Makefile;h=31f844eef8ada7307a9c9b3c1d38ede53efd3fe5;hb=3365b381c0c1a811ac00a4337f063dbb65134fb0;hp=b683f13b895bf9a7a0050efac8ef05bf1e10995d;hpb=1f58768749ba34d6fbc1764d47d510a762077f54;p=blast diff --git a/Makefile b/Makefile index b683f13..31f844e 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,8 @@ deb http://cdn.debian.net/debian ${release} main endef endif +fstype := ext4 + ifdef disk VOLUME := ${disk} PBOOT := ${disk}1 @@ -66,7 +68,7 @@ else ifdef image VOLUME := ${image} PBOOT := part_boot.img PROOT := part_root.img - SYSROOT := sys_root_${release}/ + SYSROOT := sys_root_${release}_${ARCH}/ CFGROOT := img_mount/ _target: _mbr _umount _config _install @@ -84,9 +86,23 @@ else ifdef image _umount: _img_mount _config _bootloader_pc _mbr: _partcopy _bootloader_pc +else ifdef subvol + SYSROOT := sys_root_${release}_${ARCH}/ + CFGROOT := cfg_root/ + + _target: _install _config ${subvol} + + _bootstrap: + _install: _bootstrap + _copy: _install + _config: _copy + + ${subvol}: _config + btrfs sub snap "${CFG_ROOT}" "$@" + else ifdef squash SQUASH := ${squash} - SYSROOT := sys_root_${release}/ + SYSROOT := sys_root_${release}_${ARCH}/ CFGROOT := cfg_root/ PACKAGES += squashfs-tools nbd-client @@ -102,7 +118,7 @@ else ifdef squash else ifdef iso ISO := ${iso} ISOROOT := iso_root/ - SYSROOT := sys_root_${release}/ + SYSROOT := sys_root_${release}_${ARCH}/ CFGROOT := cfg_root/ BOOT_MB := 2 PBOOT := ${ISOROOT}/efi.img @@ -116,21 +132,18 @@ else ifdef iso _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 + ARCH := armhf + VOLUME := ${raspi} PBOOT := rpi_boot.img PROOT := rpi_root.img - SYSROOT := rpi_root_${release}/ + SYSROOT := sys_root_${release}_${ARCH}/ CFGROOT := img_mount/ - ARCH := armhf KEYRING := keys/raspbian-archive-keyring.gpg BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian @@ -139,7 +152,8 @@ else ifdef raspi deb http://archive.raspberrypi.org/debian ${release} main endef - PACKAGES += firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel + PACKAGES += firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel initramfs-tools nilfs-tools + fstype := nilfs2 _target: _umount _config @@ -175,15 +189,11 @@ endif 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}/: +sys_root_${release}_${ARCH}/: btrfs subvol create "$@" || mkdir "$@" chmod 755 "$@" -cfg_root/: sys_root_${release}/ _install +cfg_root/: sys_root_${release}_${ARCH}/ _install -btrfs sub del "$@" || rm -r "$@" btrfs sub snap "$<" "$@" || mkdir "$@" chmod 755 "$@" @@ -251,11 +261,11 @@ _copy: ${SYSROOT} ${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' \ + printf 'LABEL=FSROOT / ${fstype} 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} .FORCE +${SQUASH}: ${CFGROOT} -rm "$${SQUASH}" mksquashfs "$${CFGROOT}" "$${SQUASH}" -comp xz @@ -267,7 +277,8 @@ _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 + { cd "$${CFGROOT}"; 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 @@ -295,9 +306,15 @@ _partition_gpt: ${VOLUME} _sparse: ${PBOOT} ${PROOT} +ifdef raspi +_format_root: ${PROOT} + -umount "$${CFGROOT}/boot" "$${CFGROOT}" "${PROOT}" + mkfs.nilfs2 -f -L FSROOT "$${PROOT}" +else _format_root: ${PROOT} -umount "$${CFGROOT}/boot" "$${CFGROOT}" "${PROOT}" mkfs.ext4 -F -L FSROOT "$${PROOT}" +endif _format_boot: ${PBOOT} -umount "$${CFGROOT}/boot" "${PBOOT}" @@ -305,11 +322,8 @@ _format_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 \ +_iso_image: ${ISOROOT} + grub-mkrescue -o "$${ISO}" "$${ISOROOT}" .PHONY: _syslinux_efi32 _syslinux_efi64 _syslinux_bios .PHONY: _grub_efi32 _grub_efi64 @@ -344,7 +358,7 @@ _grub_efi64: ${CFGROOT} grub-mkimage -p / -O x86_64-efi fat part_gpt normal linux all_video >"$${CFGROOT}/boot/EFI/BOOT/BOOTX64.EFI" ${CFGROOT}/boot/cmdline.txt: ${CFGROOT} - printf 'root=/dev/mmcblk0p2 rootfstype=ext4 fsck.repair=yes rootwait' >"$@" + printf 'root=/dev/mmcblk0p2 rootfstype=${fstype} fsck.repair=yes rootwait' >"$@" _bootloader_raspi: ${CFGROOT} ${CFGROOT}/boot/cmdline.txt @@ -363,17 +377,16 @@ _bootloader_pc: ${CFGROOT} _grub_efi32 _grub_efi64 _syslinux_bios #_syslinux_efi "$$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" + mkdir -p "$${ISOROOT}/boot/grub/" 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" + printf '%s\n' "set timeout=10" "default=buster" \ + "menuentry 'Debian Buster' --id 'buster' {" \ + "linux '/vmlinuz' boot=live" "initrd '/initrd.img'" "}" \ + >"$${ISOROOT}/boot/grub/grub.cfg" + -[ -f "$${ISOROOT}/install/initrd.gz" -a -f "$${ISOROOT}/install/linux" ] && \ + printf '%s\n' "menuentry 'Install Debian' --id 'install' {" \ + "linux '/install/linux'" "initrd '/install/initrd.gz'" "}" \ + >>"$${ISOROOT}/boot/grub/grub.cfg" _efi_mount: ${PBOOT} -umount "efi/" @@ -383,9 +396,6 @@ _efi_mount: ${PBOOT} _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} @@ -402,12 +412,14 @@ _partcopy: ${VOLUME} ${PROOT} ${PBOOT} dd conv=notrunc,sparse bs=1M seek=$$((2 + ${BOOT_MB})) if="$${PROOT}" of="$${VOLUME}" _mount_root: ${PROOT} ${CFGROOT} - mount -t ext4 "$${PROOT}" "$${CFGROOT}" + mountpoint "$${CFGROOT}" \ + || mount -t ${fstype} "$${PROOT}" "$${CFGROOT}" chmod 755 "$${CFGROOT}" _mount_boot: ${PBOOT} mkdir -p -m 755 "$${CFGROOT}/boot" - mount -t vfat "$${PBOOT}" "$${CFGROOT}/boot" + mountpoint "$${CFGROOT}/boot" \ + || mount -t vfat "$${PBOOT}" "$${CFGROOT}/boot" ifdef disk _mount_boot: _mount_root @@ -416,12 +428,14 @@ endif _mount: _mount_root _mount_boot _img_mount: ${CFGROOT} - mount -o loop,offset="$$((${BOOT_MB} + 2))"M,sizelimit=${ROOT_MB}M \ - -t ext4 "$${VOLUME}" "$${CFGROOT}" + mountpoint "$${CFGROOT}" \ + || mount -o loop,offset="$$((${BOOT_MB} + 2))"M,sizelimit=${ROOT_MB}M \ + -t ${fstype} "$${VOLUME}" "$${CFGROOT}" chmod 755 "$${CFGROOT}" mkdir -p -m 755 "$${CFGROOT}/boot" - mount -o loop,offset=2M,sizelimit=${BOOT_MB}M \ - -t vfat "$${VOLUME}" "$${CFGROOT}/boot" + mountpoint "$${CFGROOT}/boot" \ + || mount -o loop,offset=2M,sizelimit=${BOOT_MB}M \ + -t vfat "$${VOLUME}" "$${CFGROOT}/boot" _umount_boot: ${CFGROOT} -umount "$${CFGROOT}/boot" @@ -441,8 +455,7 @@ clean: -rmdir hdd_mount 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 + if [ -d "sys_root_${release}_${ARCH}/" ]; then btrfs sub del "sys_root_${release}_${ARCH}/" || rm -r "sys_root_${release}_${ARCH}/"; fi -rm part_boot.img -rm part_root.img -rm rpi_boot.img