]> git.plutz.net Git - blast/blob - modules/default.mk
raspi modules, systemd timeout
[blast] / modules / default.mk
1 ifdef imagesize
2   ROOT_MB := $(shell printf '%i\n' "$$(( ${imagesize} - ${BOOT_MB} - 3 ))")
3 endif
4
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
6
7 ifdef packages
8   PACKAGES += $(subst ${comma_},${space_},${packages})
9 endif
10
11 export DEBCONF RPICONFIG
12
13 define DEBCONF :=
14 ${DEBCONF}
15
16 keyboard-configuration  keyboard-configuration/model    select  Generic 105-key (Intl) PC
17 keyboard-configuration  keyboard-configuration/variant  select  English (US) - English (Macintosh)
18 endef
19
20 define RPICONFIG :=
21 ${RPICONFIG}
22
23 dtoverlay=vc4-fkms-v3d,cma-256
24 endef
25
26 .PHONY: _debconf_selections _raspberry_config _keyboard
27 _install: _debconf_selections
28 _debconf_selections: ${SYSROOT}
29         printf '%s\n' "$${DEBCONF}" |chroot "$${SYSROOT}" debconf-set-selections
30
31 ifdef keyboard
32   _config: _keyboard
33 endif
34 _keyboard: ${CFGROOT}
35         -sed -Ei 's;^XKBLAYOUT=.*$$;XKBLAYOUT="${keyboard}";;' "$${CFGROOT}/etc/default/keyboard"
36
37 ifdef raspi
38   _config: _raspberry_config _raspberry_initrd
39 endif
40
41 _raspberry_config: ${CFGROOT}
42         printf '%s\n' "$${RPICONFIG}" >>"$${CFGROOT}/boot/config.txt"
43
44 _raspberry_initrd: ${CFGROOT}
45         printf '${fstype}\n' >>"$${CFGROOT}/etc/initramfs-tools/modules"
46         k="${kernel}"; \
47         [ "$$k" ] || k="$$(echo "$${CFGROOT}"/lib/modules/*-v7+)"; \
48         chroot $${CFGROOT} update-initramfs -c -k "$${k##*/}"; \
49         printf 'initramfs initrd.img-%s\n' "$${k##*/}" >>"$${CFGROOT}/boot/config.txt"
50
51 .PHONY: _timezone _locales
52
53 ifdef timezone
54   export timezone
55   PACKAGES += tzdata
56   _config: _timezone
57 endif
58
59 ifdef locales
60   PACKAGES += locales
61   _config: _locales
62 endif
63
64 _timezone: ${CFGROOT}
65         printf '%s\n' "$${timezone}" >"$${CFGROOT}/etc/timezone"
66         ln -sf /usr/share/zoneinfo/"$${timezone}" "$${CFGROOT}/etc/localtime"
67
68 _locales: ${CFGROOT}
69         for l in $(subst ${comma_},${space_},${locales}); do \
70                 printf '%s %s\n' "$${l}" "$${l#*.}"; \
71         done >"$${CFGROOT}/etc/locale.gen"
72         printf 'LANG=%s\n' "$(firstword $(subst ${comma_},${space_},${locales}))" >"$${CFGROOT}/etc/default/locale"
73         chroot "$${CFGROOT}" locale-gen
74
75 .PHONY: _rootpass _users _hostname
76
77 ifdef rootpass
78   export rootpass
79   _config: _rootpass
80 endif
81
82 ifdef rootkey
83   export rootkey
84   _config: _rootkey
85 endif
86
87 ifdef users
88   _config: _users
89 endif
90
91 ifdef hostname
92   export hostname
93   _config: _hostname
94 endif
95
96 _rootpass: ${CFGROOT}
97         chroot "$${CFGROOT}" usermod -p "$$(openssl passwd "$${rootpass}")" root
98
99 ${rootkey}.pub:
100         [ -f "$@" ] || ssh-keygen -N '' -f "$${rootkey}"
101
102 _rootkey: ${CFGROOT} ${rootkey}.pub
103         mkdir -m 700 "$${CFGROOT}/root/.ssh/"
104         cp "$${rootkey}.pub" "$${CFGROOT}/root/.ssh/authorized_keys"
105
106 _users: ${CFGROOT}
107         for u in $(subst ${comma_},${space_},${users}); do \
108                 chroot "$${CFGROOT}" useradd -s /bin/bash -p "$$(openssl passwd "")" "$$u"; \
109         done
110
111 _hostname: ${CFGROOT}
112         printf '%s\n' "$${hostname}" >"$${CFGROOT}/etc/hostname"
113         sed -Ei "s;^127\.0\.0\.1.*$$;&  $${hostname};" "$${CFGROOT}/etc/hosts"
114
115 .PHONY: _systemd_timeout
116 _config: _systemd_timeout
117 _systemd_timeout: ${CFGROOT}
118         mkdir -p "$${CFGROOT}/etc/systemd"
119         printf 'DefaultTimeout%sSec=%s\n' Start 10s Stop 10s >>"$${CFGROOT}/etc/systemd/system.conf"
120
121 ifdef wifi
122   _config: ${CFGROOT}/etc/network/interfaces.d/wifi
123   ifdef wifipass
124     export wifi wifipass
125     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
126         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
127         printf '  wpa-ssid "%s"\n  wpa-psk "%s"\n' "$$wifi" "$$wifipass" >>$@
128   else
129     export wifi
130     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
131         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
132         printf '  wireless-essid "%s"\n' "$$wifi" >>$@
133   endif
134 endif