]> git.plutz.net Git - blast/blob - modules/default.mk
7c3133f913fa182f348e591fdc135ee282f21971
[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
39 endif
40 _raspberry_config: ${CFGROOT}
41         printf '%s\n' "$${RPICONFIG}" >>"$${CFGROOT}/boot/config.txt"
42
43 .PHONY: _timezone _locales
44
45 ifdef timezone
46   export timezone
47   PACKAGES += tzdata
48   _config: _timezone
49 endif
50
51 ifdef locales
52   PACKAGES += locales
53   _config: _locales
54 endif
55
56 _timezone: ${CFGROOT}
57         printf '%s\n' "$${timezone}" >"$${CFGROOT}/etc/timezone"
58         ln -sf /usr/share/zoneinfo/"$${timezone}" "$${CFGROOT}/etc/localtime"
59
60 _locales: ${CFGROOT}
61         for l in $(subst ${comma_},${space_},${locales}); do \
62                 printf '%s %s\n' "$${l}" "$${l#*.}"; \
63         done >"$${CFGROOT}/etc/locale.gen"
64         printf 'LANG=%s\n' "$(firstword $(subst ${comma_},${space_},${locales}))" >"$${CFGROOT}/etc/default/locale"
65         chroot "$${CFGROOT}" locale-gen
66
67 .PHONY: _rootpass _users _hostname
68
69 ifdef rootpass
70   export rootpass
71   _config: _rootpass
72 endif
73
74 ifdef rootkey
75   export rootkey
76   _config: _rootkey
77 endif
78
79 ifdef users
80   _config: _users
81 endif
82
83 ifdef hostname
84   export hostname
85   _config: _hostname
86 endif
87
88 _rootpass: ${CFGROOT}
89         chroot "$${CFGROOT}" usermod -p "$$(openssl passwd "$${rootpass}")" root
90
91 ${rootkey}.pub:
92         [ -f "$@" ] || ssh-keygen -N '' -f "$${rootkey}"
93
94 _rootkey: ${CFGROOT} ${rootkey}.pub
95         mkdir -m 700 "$${CFGROOT}/root/.ssh/"
96         cp "$${rootkey}.pub" "$${CFGROOT}/root/.ssh/authorized_keys"
97
98 _users: ${CFGROOT}
99         for u in $(subst ${comma_},${space_},${users}); do \
100                 chroot "$${CFGROOT}" useradd -s /bin/bash -p "$$(openssl passwd "")" "$$u"; \
101         done
102
103 _hostname: ${CFGROOT}
104         printf '%s\n' "$${hostname}" >"$${CFGROOT}/etc/hostname"
105         sed -Ei "s;^127\.0\.0\.1.*$$;&  $${hostname};" "$${CFGROOT}/etc/hosts"
106
107 ifdef wifi
108   _config: ${CFGROOT}/etc/network/interfaces.d/wifi
109   ifdef wifipass
110     export wifi wifipass
111     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
112         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
113         printf '  wpa-ssid "%s"\n  wpa-psk "%s"\n' "$$wifi" "$$wifipass" >>$@
114   else
115     export wifi
116     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
117         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
118         printf '  wireless-ssid "%s"\n' "$$wifi" >>$@
119   endif
120 endif