]> git.plutz.net Git - blast/blob - modules/default.mk
Config option for keyboard layout
[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 ifndef keyboard
14 keyboard := English (US) - English (Macintosh)
15 endif
16
17 define DEBCONF :=
18 ${DEBCONF}
19
20 keyboard-configuration  keyboard-configuration/model    select  Generic 105-key (Intl) PC
21 keyboard-configuration  keyboard-configuration/variant  select  ${keyboard}
22 endef
23
24 define RPICONFIG :=
25 ${RPICONFIG}
26
27 dtoverlay=vc4-fkms-v3d,cma-256
28 endef
29
30 .PHONY: _debconf_selections _raspberry_config _keyboard
31 _install: _debconf_selections
32 _debconf_selections: ${SYSROOT}
33         printf '%s\n' "$${DEBCONF}" |chroot "$${SYSROOT}" debconf-set-selections
34
35 _config: _keyboard
36 _keyboard: ${CFGROOT} _debconf_selections
37         rm "$${CFGROOT}/etc/default/keyboard"
38         chroot "$${CFGROOT}" dpkg-reconfigure --default-priority -u keyboard-configuration
39
40 ifdef raspi
41   _config: _raspberry_config
42 endif
43 _raspberry_config: ${CFGROOT}
44         printf '%s\n' "$${RPICONFIG}" >>"$${CFGROOT}/boot/config.txt"
45
46 .PHONY: _timezone _locales
47
48 ifdef timezone
49   export timezone
50   PACKAGES += tzdata
51   _config: _timezone
52 endif
53
54 ifdef locales
55   PACKAGES += locales
56   _config: _locales
57 endif
58
59 _timezone: ${CFGROOT}
60         printf '%s\n' "$${timezone}" >"$${CFGROOT}/etc/timezone"
61         ln -sf /usr/share/zoneinfo/"$${timezone}" "$${CFGROOT}/etc/localtime"
62
63 _locales: ${CFGROOT}
64         for l in $(subst ${comma_},${space_},${locales}); do \
65                 printf '%s %s\n' "$${l}" "$${l#*.}"; \
66         done >"$${CFGROOT}/etc/locale.gen"
67         printf 'LANG=%s\n' "$(firstword $(subst ${comma_},${space_},${locales}))" >"$${CFGROOT}/etc/default/locale"
68         chroot "$${CFGROOT}" locale-gen
69
70 .PHONY: _rootpass _users _hostname
71
72 ifdef rootpass
73   export rootpass
74   _config: _rootpass
75 endif
76
77 ifdef rootkey
78   export rootkey
79   _config: _rootkey
80 endif
81
82 ifdef users
83   _config: _users
84 endif
85
86 ifdef hostname
87   export hostname
88   _config: _hostname
89 endif
90
91 _rootpass: ${CFGROOT}
92         chroot "$${CFGROOT}" usermod -p "$$(openssl passwd "$${rootpass}")" root
93
94 ${rootkey}.pub:
95         [ -f "$@" ] || ssh-keygen -N '' -f "$${rootkey}"
96
97 _rootkey: ${CFGROOT} ${rootkey}.pub
98         mkdir -m 700 "$${CFGROOT}/root/.ssh/"
99         cp "$${rootkey}.pub" "$${CFGROOT}/root/.ssh/authorized_keys"
100
101 _users: ${CFGROOT}
102         for u in $(subst ${comma_},${space_},${users}); do \
103                 chroot "$${CFGROOT}" useradd -s /bin/bash -p "$$(openssl passwd "")" "$$u"; \
104         done
105
106 _hostname: ${CFGROOT}
107         printf '%s\n' "$${hostname}" >"$${CFGROOT}/etc/hostname"
108
109 ifdef wifi
110   _config: ${CFGROOT}/etc/network/interfaces.d/wifi
111   ifdef wifipass
112     export wifi wifipass
113     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
114         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
115         printf '  wpa-ssid "%s"\n  wpa-psk "%s"\n' "$$wifi" "$$wifipass" >>$@
116   else
117     export wifi
118     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
119         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
120         printf '  wireless-ssid "%s"\n' "$$wifi" >>$@
121   endif
122 endif