X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=Makefile;h=84c9221595f947f9196b53951fb96eed5193944a;hb=da277e4a51db02e38bd9c0cde11aa40bebaef5fc;hp=1b1af097d862457590177f90b7900e2d215e8992;hpb=cfeadc7b40fda3c80d5f7707e72f35834115e0d9;p=blast diff --git a/Makefile b/Makefile index 1b1af09..84c9221 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,8 @@ PACKAGES := ${PACKAGES} apt busybox-static debian-archive-keyring init systemd BOOT_MB := 62 ROOT_MB := 959 +fstype := ext4 + config.mk: cp "config.example" "$@" @@ -43,8 +45,6 @@ deb http://cdn.debian.net/debian ${release} main endef endif -fstype := ext4 - ifdef disk VOLUME := ${disk} PBOOT := ${disk}1 @@ -68,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 @@ -87,7 +87,7 @@ else ifdef image _mbr: _partcopy _bootloader_pc else ifdef subvol - SYSROOT := sys_root_${release}/ + SYSROOT := sys_root_${release}_${ARCH}/ CFGROOT := cfg_root/ _target: _install _config ${subvol} @@ -98,11 +98,11 @@ else ifdef subvol _config: _copy ${subvol}: _config - btrfs sub snap "${CFG_ROOT}" "$@" + btrfs sub snap "${CFGROOT}" "$@" else ifdef squash SQUASH := ${squash} - SYSROOT := sys_root_${release}/ + SYSROOT := sys_root_${release}_${ARCH}/ CFGROOT := cfg_root/ PACKAGES += squashfs-tools nbd-client @@ -118,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 @@ -136,13 +136,14 @@ else ifdef iso _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 @@ -151,8 +152,7 @@ else ifdef raspi deb http://archive.raspberrypi.org/debian ${release} main endef - PACKAGES += firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel initramfs-tools nilfs-tools - fstype := nilfs2 + PACKAGES += firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel initramfs-tools _target: _umount _config @@ -167,7 +167,7 @@ else ifdef raspi _copy: _install _img_mount _config: _copy _img_mount _bootloader_raspi: _img_mount - _umount: _img_mount _config _bootloader_raspi + _umount: _copy _config _bootloader_raspi else _target: @@ -180,7 +180,8 @@ ifdef modules include $(addsuffix .mk, $(addprefix modules/, $(subst ${comma_},${space_},${modules}))) endif -ifeq "${ARCH}" "amd64" +ifeq "$(findstring linux-image, ${PACKAGES})" "linux-image" +else ifeq "${ARCH}" "amd64" PACKAGES += linux-image-amd64 else ifeq "${ARCH}" "i386" PACKAGES += linux-image-686 @@ -188,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 "$@" @@ -240,6 +237,7 @@ ${SYSROOT}/etc/apt/apt.conf.d/10norecommends: ${SYSROOT} ${SYSROOT}/etc/apt/trusted.gpg.d/: ${SYSROOT} _bootstrap mkdir -p -m 755 "$@" cp keys/*.gpg "$@" + chmod 644 "$@"/*.gpg _install: ${SYSROOT} _aptkeys _norecommends printf '%s\n' "$${SOURCES}" |sort -u >"$${SYSROOT}/etc/apt/sources.list" @@ -259,6 +257,7 @@ _install: ${SYSROOT} _aptkeys _norecommends chroot "$${SYSROOT}" rm /usr/sbin/udevadm _copy: ${SYSROOT} ${CFGROOT} + sync cp -au "$${SYSROOT}/." "$${CFGROOT}/" _config: ${CFGROOT} @@ -309,15 +308,15 @@ _partition_gpt: ${VOLUME} _sparse: ${PBOOT} ${PROOT} -ifdef raspi -_format_root: ${PROOT} - -umount "$${CFGROOT}/boot" "$${CFGROOT}" "${PROOT}" - mkfs.nilfs2 -f -L FSROOT "$${PROOT}" +ifeq "${fstype}" "ext4" + fsflag:=-F else + fsflag:=-f +endif + _format_root: ${PROOT} -umount "$${CFGROOT}/boot" "$${CFGROOT}" "${PROOT}" - mkfs.ext4 -F -L FSROOT "$${PROOT}" -endif + mkfs.${fstype} ${fsflag} -L FSROOT "$${PROOT}" _format_boot: ${PBOOT} -umount "$${CFGROOT}/boot" "${PBOOT}" @@ -382,10 +381,12 @@ _bootloader_pc: ${CFGROOT} _grub_efi32 _grub_efi64 _syslinux_bios #_syslinux_efi _bootloader_iso: ${CFGROOT} ${ISOROOT} mkdir -p "$${ISOROOT}/boot/grub/" cp -L "$${CFGROOT}/vmlinuz" "$${CFGROOT}/initrd.img" "$${ISOROOT}" + printf '%s\n' "insmod all_video" "set gfxmode=auto" "load_video" "insmod gfxterm" \ + >"$${ISOROOT}/boot/grub/grub.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" + >>"$${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'" "}" \ @@ -397,6 +398,7 @@ _efi_mount: ${PBOOT} mount -t vfat -o loop "$${PBOOT}" "efi/" _efi_umount: _efi_mount + sync umount efi/ && rmdir efi/ .PHONY: _syslinux_mbr _grub_mbr @@ -440,10 +442,12 @@ _img_mount: ${CFGROOT} || mount -o loop,offset=2M,sizelimit=${BOOT_MB}M \ -t vfat "$${VOLUME}" "$${CFGROOT}/boot" -_umount_boot: ${CFGROOT} +_umount_boot: ${CFGROOT} _config + sync -umount "$${CFGROOT}/boot" -_umount_root: _umount_boot +_umount_root: _umount_boot _config + sync umount "$${CFGROOT}" && rmdir "$${CFGROOT}" _umount: _umount_boot _umount_root @@ -458,8 +462,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