]> git.plutz.net Git - blast/blob - modules/default.mk
keep line breaks in DEBCONF variable
[blast] / modules / default.mk
1 ifdef imagesize
2   ROOT_MB := $(shell printf '%i\n' "$$(( ${imagesize} - ${BOOT_MB} - 3 ))")
3 endif
4
5 PACKAGES += btrfs-tools 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
12
13 define DEBCONF :=
14
15 keyboard-configuration  keyboard-configuration/model    select  Generic 105-key (Intl) PC
16 keyboard-configuration  keyboard-configuration/variant  select  English (US) - English (Macintosh)
17 endef
18
19 .PHONY: _debconf_selections
20 _install: _debconf_selections
21 _debconf_selections: ${SYSROOT}
22         printf '%s\n' "$${DEBCONF}" |chroot "$${SYSROOT}" debconf-set-selections
23
24 .PHONY: _timezone _locales
25
26 ifdef timezone
27   export timezone
28   PACKAGES += tzdata
29   _config: _timezone
30 endif
31
32 ifdef locales
33   PACKAGES += locales
34   _config: _locales
35 endif
36
37 _timezone: ${CFGROOT}
38         printf '%s\n' "$${timezone}" >"$${CFGROOT}/etc/timezone"
39         ln -sf /usr/share/zoneinfo/"$${timezone}" "$${CFGROOT}/etc/localtime"
40
41 _locales: ${CFGROOT}
42         for l in $(subst ${comma_},${space_},${locales}); do \
43                 printf '%s %s\n' "$${l}" "$${l#*.}"; \
44         done >"$${CFGROOT}/etc/locale.gen"
45         printf 'LANG=%s\n' "$(firstword $(subst ${comma_},${space_},${locales}))" >"$${CFGROOT}/etc/default/locale"
46         chroot "$${CFGROOT}" locale-gen
47
48 .PHONY: _rootpass _users _hostname
49
50 ifdef rootpass
51   export rootpass
52   _config: _rootpass
53 endif
54
55 ifdef rootkey
56   export rootkey
57   _config: _rootkey
58 endif
59
60 ifdef users
61   _config: _users
62 endif
63
64 ifdef hostname
65   export hostname
66   _config: _hostname
67 endif
68
69 _rootpass: ${CFGROOT}
70         chroot "$${CFGROOT}" usermod -p "$$(openssl passwd "$${rootpass}")" root
71
72 ${rootkey}.pub:
73         ssh-keygen -N '' -f "$${rootkey}"
74
75 _rootkey: ${CFGROOT} ${rootkey}.pub
76         mkdir -m 700 "$${CFGROOT}/root/.ssh/"
77         cp "$${rootkey}.pub" "$${CFGROOT}/root/.ssh/authorized_keys"
78
79 _users: ${CFGROOT}
80         for u in $(subst ${comma_},${space_},${users}); do \
81                 chroot "$${CFGROOT}" useradd -m -s /bin/bash -p "$$(openssl passwd "")" "$$u"; \
82         done
83
84 _hostname: ${CFGROOT}
85         printf '%s\n' "$${hostname}" "$${CFGROOT}/etc/hostname"
86
87 ifdef wifi
88   _config: ${CFGROOT}/etc/network/interfaces.d/wifi
89   ifdef wifipass
90     export wifi wifipass
91     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
92         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
93         printf '  wpa-ssid "%s"\n  wpa-psk "%s"\n' "$$wifi" "$$wifipass" >>$@
94   else
95     export wifi
96     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
97         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
98         printf '  wireless-ssid "%s"\n' "$$wifi" >>$@
99   endif
100 endif