]> git.plutz.net Git - blast/blob - modules/default.mk
default packages
[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 dnsutils file firmware-linux-free gzip htop ifupdown iputils-ping irqbalance isc-dhcp-client less make net-tools nmap ntpdate openssh-client pciutils 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 -pm 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 _timeouts: ${CFGROOT}
123         printf '%s\n' DefaultTimeoutStartSec=10s DefaultTimeoutStopSec=10s >>"${CFGROOT}/etc/systemd/system.conf"
124
125
126 .PHONY: _systemd_timeout
127 _config: _systemd_timeout
128 _systemd_timeout: ${CFGROOT}
129         mkdir -p "$${CFGROOT}/etc/systemd"
130         printf 'DefaultTimeout%sSec=%s\n' Start 10s Stop 10s >>"$${CFGROOT}/etc/systemd/system.conf"
131
132 ifdef wifi
133   _config: ${CFGROOT}/etc/network/interfaces.d/wifi
134   ifdef wifipass
135     export wifi wifipass
136     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
137         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
138         printf '  wpa-ssid "%s"\n  wpa-psk "%s"\n' "$$wifi" "$$wifipass" >>$@
139   else
140     export wifi
141     ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT}
142         printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@
143         printf '  wireless-essid "%s"\n' "$$wifi" >>$@
144   endif
145 endif
146
147 .PHONY: _fstab
148
149 ifdef _fstab
150   _config: ${CFGROOT}/etc/fstab
151   export _fstab
152
153 else
154   ifdef fsuuid
155     define _fstab :=
156 UUID=${fsuuid}  /               btrfs   auto,rw,subvol=${release}       0 0
157 UUID=${fsuuid}  /home           btrfs   auto,nofail,rw,subvol=home      0 0
158 UUID=${fsuuid}  /mnt/fsroot     btrfs   auto,nofail,rw                  0 0
159 LABEL=SWAP      swap            swap    auto,nofail,sw                  0 0
160 LABEL=EFIBOOT   /boot/efi       vfat    auto,nofail,ro                  0 0
161 endef
162     _config: ${CFGROOT}/etc/fstab
163     export _fstab
164
165   endif
166 endif
167
168 ${CFGROOT}/etc/fstab: ${CFGROOT}
169         printf '%s' "$${_fstab}" >"$@"
170
171
172 _config: ${CFGROOT}/etc/sysctl.d/quiet_console
173
174 ${CFGROOT}/etc/sysctl.d/quiet_console: ${CFGROOT}
175         printf '%s\n' "kernel.printk=3 4 1 7" >"$@"