]> git.plutz.net Git - blast/blob - modules/default.mk
ceb91ff07aee2c7f856a7a62c874991d7a25cffb
[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
19 console-setup   console-setup/charmap47 select  UTF-8
20 console-setup   console-setup/codeset47 select  # Latin1 and Latin5 - western Europe and Turkic languages
21 endef
22
23 ifndef rpivmem
24   rpivmem := 128
25 endif
26
27 define RPICONFIG :=
28 ${RPICONFIG}
29
30 dtoverlay=vc4-fkms-v3d,cma-${rpivmem}
31 endef
32
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
37
38 ifdef keyboard
39   _config: _keyboard
40 endif
41 _keyboard: ${CFGROOT}
42         -sed -Ei 's;^XKBLAYOUT=.*$$;XKBLAYOUT="${keyboard}";;' "$${CFGROOT}/etc/default/keyboard"
43
44 ifdef raspi
45   _config: _raspberry_config _raspberry_initrd
46 endif
47
48 _raspberry_config: ${CFGROOT}
49         printf '%s\n' "$${RPICONFIG}" >>"$${CFGROOT}/boot/config.txt"
50
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"
57
58 .PHONY: _timezone _locales
59
60 ifdef timezone
61   export timezone
62   PACKAGES += tzdata
63   _config: _timezone
64 endif
65
66 ifdef locales
67   PACKAGES += locales
68   _config: _locales
69 endif
70
71 _timezone: ${CFGROOT}
72         printf '%s\n' "$${timezone}" >"$${CFGROOT}/etc/timezone"
73         ln -sf /usr/share/zoneinfo/"$${timezone}" "$${CFGROOT}/etc/localtime"
74
75 _locales: ${CFGROOT}
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
81
82 .PHONY: _rootpass _users _hostname
83
84 ifdef rootpass
85   export rootpass
86   _config: _rootpass
87 endif
88
89 ifdef rootkey
90   export rootkey
91   _config: _rootkey
92 endif
93
94 ifdef users
95   _config: _users
96 endif
97
98 ifdef hostname
99   export hostname
100   _config: _hostname
101 endif
102
103 _rootpass: ${CFGROOT}
104         chroot "$${CFGROOT}" usermod -p "$$(openssl passwd "$${rootpass}")" root
105
106 ${rootkey}.pub:
107         [ -f "$@" ] || ssh-keygen -N '' -f "$${rootkey}"
108
109 _rootkey: ${CFGROOT} ${rootkey}.pub
110         mkdir -m 700 "$${CFGROOT}/root/.ssh/"
111         cp "$${rootkey}.pub" "$${CFGROOT}/root/.ssh/authorized_keys"
112
113 _users: ${CFGROOT}
114         for u in $(subst ${comma_},${space_},${users}); do \
115                 chroot "$${CFGROOT}" useradd -s /bin/bash -p "$$(openssl passwd "")" "$$u"; \
116         done
117
118 _hostname: ${CFGROOT}
119         printf '%s\n' "$${hostname}" >"$${CFGROOT}/etc/hostname"
120         sed -Ei "s;^127\.0\.0\.1.*$$;&  $${hostname};" "$${CFGROOT}/etc/hosts"
121
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"
127
128 ifdef wifi
129   _config: ${CFGROOT}/etc/network/interfaces.d/wifi
130   ifdef wifipass
131     export wifi wifipass
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" >>$@
135   else
136     export wifi
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" >>$@
140   endif
141 endif