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