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