2 ROOT_MB := $(shell printf '%i\n' "$$(( ${imagesize} - ${BOOT_MB} - 3 ))")
5 PACKAGES += btrfs-progs bzip2 ca-certificates cron deborphan firmware-linux-free gzip htop ifupdown iputils-ping irqbalance isc-dhcp-client less make net-tools nmap ntpdate openssh-client psmisc rsync sshfs sudo traceroute unzip vim wget wireless-tools wpasupplicant xz-utils zip
8 PACKAGES += $(subst ${comma_},${space_},${packages})
11 export DEBCONF RPICONFIG
16 keyboard-configuration keyboard-configuration/model select Generic 105-key (Intl) PC
17 keyboard-configuration keyboard-configuration/variant select English (US) - English (Macintosh)
19 console-setup console-setup/charmap47 select UTF-8
20 console-setup console-setup/codeset47 select # Latin1 and Latin5 - western Europe and Turkic languages
30 dtoverlay=vc4-fkms-v3d,cma-${rpivmem}
33 .PHONY: _debconf_selections _raspberry_config _keyboard
34 _install: _debconf_selections
35 _debconf_selections: ${SYSROOT}
36 printf '%s\n' "$${DEBCONF}" |chroot "$${SYSROOT}" debconf-set-selections
42 -sed -Ei 's;^XKBLAYOUT=.*$$;XKBLAYOUT="${keyboard}";;' "$${CFGROOT}/etc/default/keyboard"
45 _config: _raspberry_config _raspberry_initrd
48 _raspberry_config: ${CFGROOT}
49 printf '%s\n' "$${RPICONFIG}" >>"$${CFGROOT}/boot/config.txt"
51 _raspberry_initrd: ${CFGROOT}
52 printf '${fstype}\n' >>"$${CFGROOT}/etc/initramfs-tools/modules"
53 k="$$(printf '%s\n' "$${CFGROOT}"/lib/modules/* |sed 's;^.*/;;; /-/d')"; \
54 [ "${kernel}" ] && k="${kernel}"; \
55 chroot $${CFGROOT} update-initramfs -c -k "$${k##*/}"; \
56 printf 'initramfs initrd.img-%s\n' "$${k##*/}" >>"$${CFGROOT}/boot/config.txt"
58 .PHONY: _timezone _locales
72 printf '%s\n' "$${timezone}" >"$${CFGROOT}/etc/timezone"
73 ln -sf /usr/share/zoneinfo/"$${timezone}" "$${CFGROOT}/etc/localtime"
76 for l in $(subst ${comma_},${space_},${locales}); do \
77 printf '%s %s\n' "$${l}" "$${l#*.}"; \
78 done >"$${CFGROOT}/etc/locale.gen"
79 printf 'LANG=%s\n' "$(firstword $(subst ${comma_},${space_},${locales}))" >"$${CFGROOT}/etc/default/locale"
80 chroot "$${CFGROOT}" locale-gen
82 .PHONY: _rootpass _users _hostname
103 _rootpass: ${CFGROOT}
104 chroot "$${CFGROOT}" usermod -p "$$(openssl passwd "$${rootpass}")" root
107 [ -f "$@" ] || ssh-keygen -N '' -f "$${rootkey}"
109 _rootkey: ${CFGROOT} ${rootkey}.pub
110 mkdir -m 700 "$${CFGROOT}/root/.ssh/"
111 cp "$${rootkey}.pub" "$${CFGROOT}/root/.ssh/authorized_keys"
114 for u in $(subst ${comma_},${space_},${users}); do \
115 chroot "$${CFGROOT}" useradd -s /bin/bash -p "$$(openssl passwd "")" "$$u"; \
118 _hostname: ${CFGROOT}
119 printf '%s\n' "$${hostname}" >"$${CFGROOT}/etc/hostname"
120 sed -Ei "s;^127\.0\.0\.1.*$$;& $${hostname};" "$${CFGROOT}/etc/hosts"
122 .PHONY: _systemd_timeout
123 _config: _systemd_timeout
124 _systemd_timeout: ${CFGROOT}
125 mkdir -p "$${CFGROOT}/etc/systemd"
126 printf 'DefaultTimeout%sSec=%s\n' Start 10s Stop 10s >>"$${CFGROOT}/etc/systemd/system.conf"
129 _config: ${CFGROOT}/etc/network/interfaces.d/wifi
132 ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
133 printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
134 printf ' wpa-ssid "%s"\n wpa-psk "%s"\n' "$$wifi" "$$wifipass" >>$@
137 ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
138 printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
139 printf ' wireless-essid "%s"\n' "$$wifi" >>$@
146 _config: ${CFGROOT}/etc/fstab
152 UUID=${fsuuid} / btrfs auto,rw,subvol=${release} 0 0
153 UUID=${fsuuid} /home btrfs auto,nofail,rw,subvol=home 0 0
154 UUID=${fsuuid} /mnt/fsroot btrfs auto,nofail,rw 0 0
155 LABEL=SWAP swap swap auto,nofail,sw 0 0
156 LABEL=EFIBOOT /boot/efi vfat auto,nofail,ro 0 0
158 _config: ${CFGROOT}/etc/fstab
164 ${CFGROOT}/etc/fstab: ${CFGROOT}
165 printf '%s' "$${_fstab}" >"$@"
168 _config: ${CFGROOT}/etc/sysctl.d/quiet_console
170 ${CFGROOT}/etc/sysctl.d/quiet_console: ${CFGROOT}
171 printf '%s\n' "kernel.printk=3 4 1 7" >"$@"