-
DEFAULT: _target
+
+nul_:=
+comma_:=,
+space_:=${nul_} ${nul_}
+
.PHONY: clean .FORCE
-.PHONY: _qemu _bootstrap _install _copy _config _bootloader _squash
+.PHONY: _qemu _bootstrap _install _copy _config_raspi _config _bootloader _squash
.PHONY: _target _partition _format _mount _sparse _umount _partcopy _mbr
ARCH := amd64
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
+config.mk:
+ cp "config.example" "$@"
+
+include config.mk
+
ifdef disk
VOLUME := ${disk}
PBOOT := ${disk}1
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
_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
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"
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
_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
_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} cfg_seed/
+ 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}"
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##*/}"; \
_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"
--- /dev/null
+define display_ws5inch_boot =
+
+# Waveshare 5 Inch Display
+hdmi_group=2
+hdmi_mode=87
+hdmi_cvt=800 480 60 6 0 0 0
+hdmi_drive=1
+dtparam=i2c_arm=on
+dtparam=spi=on
+enable_uart=1
+dtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=50000,keep_vref_on=0,swapxy=0,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900
+endef
+
+define display_ws5inch_cfg =
+Section "InputClass"
+ Identifier "evdev touchscreen catchall"
+ MatchIsTouchscreen "on"
+ Option "Calibration" "200 3950 250 4000"
+ MatchDevicePath "/dev/input/event*"
+ Driver "evdev"
+EndSection
+endef
+
+export display_ws5inch_boot display_ws5inch_cfg
+
+PACKAGES := ${PACKAGES} xserver-xorg-input-evdev xinput xinput-calibrator
+
+.PHONY: _display_ws5inch
+_config: _display_ws5inch
+_display_ws5inch: ${CFGROOT} _copy _mount
+ printf %s "$${display_ws5inch_boot}" >>"$${CFGROOT}/boot/config.txt"
+ mkdir -p "$${CFGROOT}/usr/share/X11/xorg.conf.d/"
+ printf %s "$${display_ws5inch_cfg}" >"$${CFGROOT}/usr/share/X11/xorg.conf.d/45-evdev.conf"
+ #-chroot "$${CFGROOT}" adduser local input