X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=Makefile;h=03fd52b38bfc8c23846ed89a43f94464b3c92667;hb=7251742b7cfa1490d0a021974482d08bdf4acadd;hp=03a66ae2432f1a1cc738d660c7ec2a7b4c4ff02c;hpb=9fd67c85227b727824340a7552eec17fd460bb51;p=blast diff --git a/Makefile b/Makefile index 03a66ae..03fd52b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,12 @@ - DEFAULT: _target + +nul_:= +comma_:= , +space_:= ${nul_} ${nul_} + .PHONY: clean .FORCE -.PHONY: _qemu _bootstrap _install _copy _config _bootloader _squash +.PHONY: _config_raspi _partition_raspi +.PHONY: _qemu _bootstrap _install _copy _config_raspi _config _bootloader _squash .PHONY: _target _partition _format _mount _sparse _umount _partcopy _mbr ARCH := amd64 @@ -16,7 +21,12 @@ define SOURCES = deb http://cdn.debian.net/debian stretch main endef -PACKAGES := ${PACKAGES} apt btrfs-tools busybox-static bzip2 ca-certificates cron debian-archive-keyring deborphan firmware-linux-free gzip htop ifupdown init iputils-ping irqbalance isc-dhcp-client less make net-tools nmap ntpdate openssh-client psmisc rsync sshfs sudo systemd traceroute unzip vim wget wireless-tools wpasupplicant xz-utils zip +PACKAGES := ${PACKAGES} apt busybox-static debian-archive-keyring init systemd + +config.mk: + cp "config.example" "$@" + +include config.mk ifdef disk VOLUME := ${disk} @@ -87,7 +97,8 @@ define SOURCES = deb http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi deb http://archive.raspberrypi.org/debian stretch main endef -PACKAGES := ${PACKAGES} firmware-brcm8011 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel + +PACKAGES := ${PACKAGES} firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel _target: _umount _partcopy _config _install @@ -98,10 +109,11 @@ _sparse: _format: _sparse _mount: _format _copy: _install _mount -_config: _copy _mount +_config_raspi: _copy _mount +_config: _copy _mount _config_raspi _umount: _mount _config -_partition: -_partcopy: _partition _umount +_partition_raspi: +_partcopy: _partition_raspi _umount else _target: @@ -109,6 +121,11 @@ _target: endif +include modules/default.mk +ifdef modules +include $(addsuffix .mk, $(addprefix modules/, $(subst ${comma_},${space_},${modules}))) +endif + ifeq "${ARCH}" "amd64" PACKAGES := ${PACKAGES} linux-image-amd64 else ifeq "${ARCH}" "i386" @@ -125,18 +142,21 @@ cfg_root/: sys_root/ _install btrfs sub snap "$<" "$@" || mkdir -p "$@" chmod 755 "$@" +rpi_root/: + btrfs subvol create "$@" || mkdir -p "$@" + chmod 755 "$@" + img_mount/: - mkdir -p "$@" + mkdir -p -m 755 "$@" chmod 755 "$@" hdd_mount/: - mkdir -p "$@" - chmod 755 "$@" + mkdir -p -m 755 "$@" _qemu: ${SYSROOT}/usr/bin/qemu-arm-static ${SYSROOT}/usr/bin/qemu-arm-static: /usr/bin/qemu-arm-static ${SYSROOT} - mkdir -p "$${SYSROOT}"/usr/bin - chmod 755 "$${SYSROOT}/usr" "$${SYSROOT}/usr/bin" + mkdir -p -m 755 "$${SYSROOT}"/usr/bin + chmod 755 "$${SYSROOT}"/usr cp -p "$<" "$@" _bootstrap: ${SYSROOT}/bin/sh @@ -150,16 +170,16 @@ _aptkeys: ${SYSROOT}/etc/apt/trusted.gpg.d/ _norecommends: ${SYSROOT}/etc/apt/apt.conf.d/10norecommends ${SYSROOT}/etc/apt/apt.conf.d/10norecommends: ${SYSROOT} - mkdir -p "$(dir $@)" + mkdir -p -m 755 "$(dir $@)" printf 'APT::Install-Recommends "false";\n' >"$@" chmod 644 "$@" ${SYSROOT}/etc/apt/trusted.gpg.d/: ${SYSROOT} - mkdir -p "$@" + mkdir -p -m 755 "$@" cp keys/*.gpg "$@" _install: ${SYSROOT} _aptkeys _norecommends - printf %s "$${SOURCES}" >"$${SYSROOT}/etc/apt/sources.list" + printf '%s\n' "$${SOURCES}" >"$${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 @@ -173,10 +193,16 @@ _install: ${SYSROOT} _aptkeys _norecommends _copy: ${SYSROOT} ${CFGROOT} cp -au "$${SYSROOT}/." "$${CFGROOT}/" -.PHONY: _main_config -_config: _main_config -_main_config: ${CFGROOT} cfg_seed/ - cp -au cfg_seed/. "$${CFGROOT}" +_config_raspi: ${CFGROOT}/boot/cmdline.txt +${CFGROOT}/boot/cmdline.txt: ${CFGROOT} + printf 'dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet' >"$@" + +.PHONY: _common_config +_config: _common_config +_common_config: ${CFGROOT} + ln -sf /dev/null "$${CFGROOT}/etc/systemd/network/99-default.link" + printf 'LABEL=FSROOT / ext4 auto,nofail,rw 0 0\nLABEL=BOOT /boot vfat auto,nofail,ro 0 0\n' \ + >"$${CFGROOT}/etc/fstab" ${SQUASH}: ${CFGROOT} -rm "$${SQUASH}" @@ -188,6 +214,7 @@ ${VOLUME}: .FORCE ! printf '%s\n' "$${VOLUME}" |grep -q '^/dev/' # abort if volume should be real device dd count=0 of="$${VOLUME}" # truncate dd bs=1M count=0 seek=$$((3 + ${BOOT_MB} + ${ROOT_MB})) of="$${VOLUME}" + chmod g+w "$${VOLUME}" ${PBOOT}: .FORCE ! printf '%s\n' "$${PBOOT}" |grep -q '^/dev/' # abort if volume should be real device @@ -199,6 +226,10 @@ ${PROOT}: .FORCE dd count=0 of="$${PROOT}" # truncate dd bs=1M count=0 seek=${ROOT_MB} of="$${PROOT}" +_partition_raspi: ${VOLUME} + printf 'label: dos\n\n: start=2MiB, size=%iMiB, type=c\n: start=%iMiB, size=%iMiB, type=83\n' \ + ${BOOT_MB} "$$((${BOOT_MB} + 2))" ${ROOT_MB} | sfdisk "$${VOLUME}" + _partition: ${VOLUME} printf 'label: gpt\n\n: start=2MiB, size=%iMiB, type=1, attrs="LegacyBIOSBootable"\n: size=%iMiB, type=20\n' \ ${BOOT_MB} ${ROOT_MB} | sfdisk "$${VOLUME}" @@ -243,8 +274,6 @@ _grub_efi64: ${CFGROOT} grub-mkimage -p / -O x86_64-efi fat part_gpt normal linux all_video >"$${CFGROOT}/boot/EFI/BOOT/BOOTX64.EFI" _bootloader: ${CFGROOT} _grub_efi32 _grub_efi64 _syslinux_bios #_syslinux_efi32 _syslinux_efi64 - # cp -L "$${CFGROOT}/vmlinuz" "$${CFGROOT}/initrd.img" "$${CFGROOT}/boot/" - # cp -r cfg_syslinux/. "$${CFGROOT}/" printf 'UI menu.c32\nDEFAULT stretch\nTIMEOUT 30\n' >"$${CFGROOT}/boot/bootmenu.cfg" printf 'set timeout=3\ndefault=stretch\n\n' >"$${CFGROOT}/boot/grub.cfg" k="$$(printf ' %s' "$${CFGROOT}/boot/"vmlinuz-*)"; k="$${k##*/}"; \ @@ -276,10 +305,8 @@ _partcopy: ${VOLUME} ${PROOT} ${PBOOT} _mount: ${PBOOT} ${PROOT} ${CFG_ROOT} mount -t ext4 "$${PROOT}" "$${CFGROOT}" chmod 755 "$${CFGROOT}" - mkdir -p "$${CFGROOT}/boot" - chmod 755 "$${CFGROOT}/boot" + mkdir -p -m 755 "$${CFGROOT}/boot" mount -t vfat "$${PBOOT}" "$${CFGROOT}/boot" - chmod 755 "$${CFGROOT}/boot" _umount: ${CFGROOT} -umount "$${CFGROOT}/boot"