@@ -1,323 +1,323 | |||
|
1 | 1 | # |
|
2 | 2 | # Setup RPi2/3/4 config and cmdline |
|
3 | 3 | # |
|
4 | 4 | |
|
5 | 5 | # Load utility functions |
|
6 | 6 | . ./functions.sh |
|
7 | 7 | |
|
8 | 8 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then |
|
9 | 9 | # Install boot binaries from local directory |
|
10 | 10 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin |
|
11 | 11 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat |
|
12 | 12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat |
|
13 | 13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat |
|
14 | 14 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf |
|
15 | 15 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf |
|
16 | 16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf |
|
17 | 17 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup4cd.dat "${BOOT_DIR}"/fixup4cd.dat |
|
18 | 18 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup4.dat "${BOOT_DIR}"/fixup4.dat |
|
19 | 19 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup4db.dat "${BOOT_DIR}"/fixup4db.dat |
|
20 | 20 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup4x.dat "${BOOT_DIR}"/fixup4x.dat |
|
21 | 21 | cp "${RPI_FIRMWARE_DIR}"/boot/start4cd.elf "${BOOT_DIR}"/start4cd.elf |
|
22 | 22 | cp "${RPI_FIRMWARE_DIR}"/boot/start4db.elf "${BOOT_DIR}"/start4db.elf |
|
23 |
cp "${RPI_FIRMWARE_DIR}"/boot/start4.elf "${BOOT_DIR}"/start4 |
|
|
23 | cp "${RPI_FIRMWARE_DIR}"/boot/start4.elf "${BOOT_DIR}"/start4.elf | |
|
24 | 24 | cp "${RPI_FIRMWARE_DIR}"/boot/start4x.elf "${BOOT_DIR}"/start4x.elf |
|
25 | 25 | else |
|
26 | 26 | # Create temporary directory for boot binaries |
|
27 | 27 | temp_dir=$(as_nobody mktemp -d) |
|
28 | 28 | |
|
29 | 29 | # Install latest boot binaries from raspberry/firmware github |
|
30 | 30 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" |
|
31 | 31 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" |
|
32 | 32 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" |
|
33 | 33 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" |
|
34 | 34 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" |
|
35 | 35 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" |
|
36 | 36 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" |
|
37 | 37 | as_nobody wget -q -O "${temp_dir}/fixup4cd.dat" "${FIRMWARE_URL}/fixup4cd.dat" |
|
38 | 38 | as_nobody wget -q -O "${temp_dir}/fixup4.dat" "${FIRMWARE_URL}/fixup4.dat" |
|
39 | 39 | as_nobody wget -q -O "${temp_dir}/fixup4db.dat" "${FIRMWARE_URL}/fixup4db.dat" |
|
40 | 40 | as_nobody wget -q -O "${temp_dir}/fixup4x.dat" "${FIRMWARE_URL}/fixup4x.dat" |
|
41 | 41 | as_nobody wget -q -O "${temp_dir}/start4cd.elf" "${FIRMWARE_URL}/start4cd.elf" |
|
42 | 42 | as_nobody wget -q -O "${temp_dir}/start4db.elf" "${FIRMWARE_URL}/start4db.elf" |
|
43 |
as_nobody wget -q -O "${temp_dir}/start4 |
|
|
43 | as_nobody wget -q -O "${temp_dir}/start4.elf" "${FIRMWARE_URL}/start4.elf" | |
|
44 | 44 | as_nobody wget -q -O "${temp_dir}/start4x.elf" "${FIRMWARE_URL}/start4x.elf" |
|
45 | 45 | |
|
46 | 46 | # Move downloaded boot binaries |
|
47 | 47 | mv "${temp_dir}/"* "${BOOT_DIR}/" |
|
48 | 48 | |
|
49 | 49 | # Remove temporary directory for boot binaries |
|
50 | 50 | rm -fr "${temp_dir}" |
|
51 | 51 | |
|
52 | 52 | # Set permissions of the boot binaries |
|
53 | 53 | chown -R root:root "${BOOT_DIR}" |
|
54 | 54 | chmod -R 600 "${BOOT_DIR}" |
|
55 | 55 | fi |
|
56 | 56 | |
|
57 | 57 | # Setup firmware boot cmdline |
|
58 | 58 | if [ "$ENABLE_USBBOOT" = true ] ; then |
|
59 | 59 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" |
|
60 | 60 | else |
|
61 | 61 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
62 | 62 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" |
|
63 | 63 | else |
|
64 | 64 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" |
|
65 | 65 | fi |
|
66 | 66 | fi |
|
67 | 67 | |
|
68 | 68 | # Add encrypted root partition to cmdline.txt |
|
69 | 69 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
70 | 70 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
71 | 71 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") |
|
72 | 72 | else |
|
73 | 73 | if [ "$ENABLE_USBBOOT" = true ] ; then |
|
74 | 74 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") |
|
75 | 75 | else |
|
76 | 76 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") |
|
77 | 77 | fi |
|
78 | 78 | fi |
|
79 | 79 | fi |
|
80 | 80 | |
|
81 | 81 | # Enable Kernel messages on standard output |
|
82 | 82 | if [ "$ENABLE_PRINTK" = true ] ; then |
|
83 | 83 | install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf" |
|
84 | 84 | fi |
|
85 | 85 | |
|
86 | 86 | # Enable Kernel messages on standard output |
|
87 | 87 | if [ "$KERNEL_SECURITY" = true ] ; then |
|
88 | 88 | install_readonly files/sysctl.d/84-rpi-ASLR.conf "${ETC_DIR}/sysctl.d/84-rpi-ASLR.conf" |
|
89 | 89 | fi |
|
90 | 90 | |
|
91 | 91 | # Install udev rule for serial alias - serial0 = console serial1=bluetooth |
|
92 | 92 | install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules" |
|
93 | 93 | |
|
94 | 94 | # Remove IPv6 networking support |
|
95 | 95 | if [ "$ENABLE_IPV6" = false ] ; then |
|
96 | 96 | CMDLINE="${CMDLINE} ipv6.disable=1" |
|
97 | 97 | fi |
|
98 | 98 | |
|
99 | 99 | # Automatically assign predictable network interface names |
|
100 | 100 | if [ "$ENABLE_IFNAMES" = false ] ; then |
|
101 | 101 | CMDLINE="${CMDLINE} net.ifnames=0" |
|
102 | 102 | else |
|
103 | 103 | CMDLINE="${CMDLINE} net.ifnames=1" |
|
104 | 104 | fi |
|
105 | 105 | |
|
106 | 106 | # Disable Raspberry Pi console logo |
|
107 | 107 | if [ "$ENABLE_LOGO" = false ] ; then |
|
108 | 108 | CMDLINE="${CMDLINE} logo.nologo" |
|
109 | 109 | fi |
|
110 | 110 | |
|
111 | 111 | # Strictly limit verbosity of boot up console messages |
|
112 | 112 | if [ "$ENABLE_SILENT_BOOT" = true ] ; then |
|
113 | 113 | CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0" |
|
114 | 114 | fi |
|
115 | 115 | |
|
116 | 116 | # Install firmware config |
|
117 | 117 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" |
|
118 | 118 | |
|
119 | 119 | # Disable Raspberry Pi console logo |
|
120 | 120 | if [ "$ENABLE_SPLASH" = false ] ; then |
|
121 | 121 | echo "disable_splash=1" >> "${BOOT_DIR}/config.txt" |
|
122 | 122 | fi |
|
123 | 123 | |
|
124 | 124 | # Locks CPU frequency at maximum |
|
125 | 125 | if [ "$ENABLE_TURBO" = true ] ; then |
|
126 | 126 | echo "force_turbo=1" >> "${BOOT_DIR}/config.txt" |
|
127 | 127 | # helps to avoid sdcard corruption when force_turbo is enabled. |
|
128 | 128 | echo "boot_delay=1" >> "${BOOT_DIR}/config.txt" |
|
129 | 129 | fi |
|
130 | 130 | |
|
131 | 131 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; then |
|
132 | 132 | |
|
133 | 133 | # Bluetooth enabled |
|
134 | 134 | if [ "$ENABLE_BLUETOOTH" = true ] ; then |
|
135 | 135 | # Create temporary directory for Bluetooth sources |
|
136 | 136 | temp_dir=$(as_nobody mktemp -d) |
|
137 | 137 | |
|
138 | 138 | # Fetch Bluetooth sources |
|
139 | 139 | as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" |
|
140 | 140 | |
|
141 | 141 | # Copy downloaded sources |
|
142 | 142 | mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" |
|
143 | 143 | |
|
144 | 144 | # Set permissions |
|
145 | 145 | chown -R root:root "${R}/tmp/pi-bluetooth" |
|
146 | 146 | |
|
147 | 147 | # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/ |
|
148 | 148 | wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth |
|
149 | 149 | wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd |
|
150 | 150 | |
|
151 | 151 | # Install tools |
|
152 | 152 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" |
|
153 | 153 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" |
|
154 | 154 | |
|
155 | 155 | # make scripts executable |
|
156 | 156 | chmod +x "${R}/usr/bin/bthelper" |
|
157 | 157 | chmod +x "${R}/usr/bin/btuart" |
|
158 | 158 | |
|
159 | 159 | # Install bluetooth udev rule |
|
160 | 160 | install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" |
|
161 | 161 | |
|
162 | 162 | # Install Firmware Flash file and apropiate licence |
|
163 | 163 | mkdir -p "$BLUETOOTH_FIRMWARE_DIR" |
|
164 | 164 | install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx" |
|
165 | 165 | install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd" |
|
166 | 166 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" |
|
167 | 167 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" |
|
168 | 168 | |
|
169 | 169 | # Remove temporary directories |
|
170 | 170 | rm -fr "${temp_dir}" |
|
171 | 171 | rm -fr "${R}"/tmp/pi-bluetooth |
|
172 | 172 | |
|
173 | 173 | # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0 |
|
174 | 174 | if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then |
|
175 | 175 | # set overlay to swap ttyAMA0 and ttyS0 |
|
176 | 176 | echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt" |
|
177 | 177 | |
|
178 | 178 | if [ "$ENABLE_TURBO" = false ] ; then |
|
179 | 179 | echo "core_freq=250" >> "${BOOT_DIR}/config.txt" |
|
180 | 180 | fi |
|
181 | 181 | |
|
182 | 182 | fi |
|
183 | 183 | |
|
184 | 184 | # Activate services |
|
185 | 185 | chroot_exec systemctl enable pi-bluetooth.hciuart.service |
|
186 | 186 | |
|
187 | 187 | else # if ENABLE_BLUETOOTH = false |
|
188 | 188 | # set overlay to disable bluetooth |
|
189 | 189 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" |
|
190 | 190 | fi # ENABLE_BLUETOOTH end |
|
191 | 191 | fi |
|
192 | 192 | |
|
193 | 193 | # may need sudo systemctl disable hciuart |
|
194 | 194 | if [ "$ENABLE_CONSOLE" = true ] ; then |
|
195 | 195 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" |
|
196 | 196 | #More debug output on early but with serial console |
|
197 | 197 | echo "uart_2ndstage=1" >> "${BOOT_DIR}/config.txt" |
|
198 | 198 | |
|
199 | 199 | # add string to cmdline |
|
200 | 200 | CMDLINE="${CMDLINE} console=serial0,115200" |
|
201 | 201 | |
|
202 | 202 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then |
|
203 | 203 | # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken |
|
204 | 204 | if [ "$ENABLE_TURBO" = false ] ; then |
|
205 | 205 | echo "core_freq=250" >> "${BOOT_DIR}/config.txt" |
|
206 | 206 | fi |
|
207 | 207 | fi |
|
208 | 208 | |
|
209 | 209 | # Enable serial console systemd style |
|
210 | 210 | chroot_exec systemctl enable serial-getty@serial0.service |
|
211 | 211 | else |
|
212 | 212 | echo "enable_uart=0" >> "${BOOT_DIR}/config.txt" |
|
213 | 213 | fi |
|
214 | 214 | |
|
215 | 215 | # Disable dphys-swapfile service. Will get enabled on first boot |
|
216 | 216 | if [ "$ENABLE_DPHYSSWAP" = true ] ; then |
|
217 | 217 | chroot_exec systemctl disable dphys-swapfile |
|
218 | 218 | fi |
|
219 | 219 | |
|
220 | 220 | if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then |
|
221 | 221 | # Create temporary directory for systemd-swap sources |
|
222 | 222 | temp_dir=$(as_nobody mktemp -d) |
|
223 | 223 | |
|
224 | 224 | # Fetch systemd-swap sources |
|
225 | 225 | as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}" |
|
226 | 226 | |
|
227 | 227 | # Copy downloaded systemd-swap sources |
|
228 | 228 | mv "${temp_dir}/systemd-swap" "${R}/tmp/" |
|
229 | 229 | |
|
230 | 230 | # Change into downloaded src dir |
|
231 | 231 | cd "${R}/tmp/systemd-swap" || exit |
|
232 | 232 | |
|
233 | 233 | # Get Verion |
|
234 | 234 | VERSION=$(git tag | tail -n 1) |
|
235 | 235 | #sed -i "s/DEB_NAME=.*/DEB_NAME=systemd-swap_all/g" "${R}/tmp/systemd-swap/package.sh" |
|
236 | 236 | |
|
237 | 237 | # Build package |
|
238 | 238 | bash ./package.sh debian |
|
239 | 239 | |
|
240 | 240 | # Change back into script root dir |
|
241 | 241 | cd "${WORKDIR}" || exit |
|
242 | 242 | |
|
243 | 243 | # Set permissions of the systemd-swap sources |
|
244 | 244 | chown -R root:root "${R}/tmp/systemd-swap" |
|
245 | 245 | |
|
246 | 246 | # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR. |
|
247 | 247 | chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_"$VERSION"_all.deb |
|
248 | 248 | |
|
249 | 249 | # Enable service |
|
250 | 250 | chroot_exec systemctl enable systemd-swap |
|
251 | 251 | |
|
252 | 252 | # Remove temporary directory for systemd-swap sources |
|
253 | 253 | rm -fr "${temp_dir}" |
|
254 | 254 | else |
|
255 | 255 | # Enable ZSWAP in cmdline if systemd-swap is not used |
|
256 | 256 | if [ "$KERNEL_ZSWAP" = true ] ; then |
|
257 | 257 | CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4" |
|
258 | 258 | fi |
|
259 | 259 | fi |
|
260 | 260 | if [ "$KERNEL_SECURITY" = true ] ; then |
|
261 | 261 | CMDLINE="${CMDLINE} apparmor=1 security=apparmor" |
|
262 | 262 | fi |
|
263 | 263 | |
|
264 | 264 | # Install firmware boot cmdline |
|
265 | 265 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" |
|
266 | 266 | |
|
267 | 267 | # Setup minimal GPU memory allocation size: 16MB (no X) |
|
268 | 268 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
269 | 269 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" |
|
270 | 270 | fi |
|
271 | 271 | |
|
272 | 272 | # Setup boot with initramfs |
|
273 | 273 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
274 | 274 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" |
|
275 | 275 | fi |
|
276 | 276 | |
|
277 | 277 | # Create firmware configuration and cmdline symlinks |
|
278 | 278 | ln -sf firmware/config.txt "${R}/boot/config.txt" |
|
279 | 279 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" |
|
280 | 280 | |
|
281 | 281 | # Install and setup kernel modules to load at boot |
|
282 | 282 | mkdir -p "${LIB_DIR}/modules-load.d/" |
|
283 | 283 | install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
284 | 284 | |
|
285 | 285 | # Load hardware random module at boot |
|
286 | 286 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then |
|
287 | 287 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
288 | 288 | fi |
|
289 | 289 | |
|
290 | 290 | # Load sound module at boot |
|
291 | 291 | if [ "$ENABLE_SOUND" = true ] ; then |
|
292 | 292 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
293 | 293 | else |
|
294 | 294 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" |
|
295 | 295 | fi |
|
296 | 296 | |
|
297 | 297 | # Enable I2C interface |
|
298 | 298 | if [ "$ENABLE_I2C" = true ] ; then |
|
299 | 299 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" |
|
300 | 300 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
301 | 301 | sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
302 | 302 | fi |
|
303 | 303 | |
|
304 | 304 | # Enable SPI interface |
|
305 | 305 | if [ "$ENABLE_SPI" = true ] ; then |
|
306 | 306 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" |
|
307 | 307 | echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
308 | 308 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then |
|
309 | 309 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
310 | 310 | fi |
|
311 | 311 | fi |
|
312 | 312 | |
|
313 | 313 | # Disable RPi2/3 under-voltage warnings |
|
314 | 314 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
315 | 315 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" |
|
316 | 316 | fi |
|
317 | 317 | |
|
318 | 318 | # Install kernel modules blacklist |
|
319 | 319 | mkdir -p "${ETC_DIR}/modprobe.d/" |
|
320 | 320 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" |
|
321 | 321 | |
|
322 | 322 | # Install sysctl.d configuration files |
|
323 | 323 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
@@ -1,98 +1,105 | |||
|
1 | 1 | # |
|
2 | 2 | # Reduce system disk usage |
|
3 | 3 | # |
|
4 | 4 | |
|
5 | 5 | # Load utility functions |
|
6 | 6 | . ./functions.sh |
|
7 | 7 | |
|
8 | 8 | if [ "$ENABLE_IPV6" = false ] ; then |
|
9 | 9 | "$LIB_DIR"/xtables/libip6t_ah.so |
|
10 | 10 | "$LIB_DIR"/xtables/libip6t_dst.so |
|
11 | 11 | "$LIB_DIR"/xtables/libip6t_eui64.so |
|
12 | 12 | "$LIB_DIR"/xtables/libip6t_frag.so |
|
13 | 13 | "$LIB_DIR"/xtables/libip6t_hbh.so |
|
14 | 14 | "$LIB_DIR"/xtables/libip6t_hl.so |
|
15 | 15 | "$LIB_DIR"/xtables/libip6t_HL.so |
|
16 | 16 | "$LIB_DIR"/xtables/libip6t_icmp6.so |
|
17 | 17 | "$LIB_DIR"/xtables/libip6t_ipv6header.so |
|
18 | 18 | "$LIB_DIR"/xtables/libip6t_LOG.so |
|
19 | 19 | "$LIB_DIR"/xtables/libip6t_mh.so |
|
20 | 20 | "$LIB_DIR"/xtables/libip6t_REJECT.so |
|
21 | 21 | "$LIB_DIR"/xtables/libip6t_rt.so |
|
22 | 22 | "$LIB_DIR"/xtables/libip6t_DNAT.so |
|
23 | 23 | "$LIB_DIR"/xtables/libip6t_DNPT.so |
|
24 | 24 | "$LIB_DIR"/xtables/libip6t_MASQUERADE.so |
|
25 | 25 | "$LIB_DIR"/xtables/libip6t_NETMAP.so |
|
26 | 26 | "$LIB_DIR"/xtables/libip6t_REDIRECT.so |
|
27 | 27 | "$LIB_DIR"/xtables/libip6t_SNAT.so |
|
28 | 28 | "$LIB_DIR"/xtables/libip6t_SNPT.so |
|
29 | 29 | fi |
|
30 | 30 | # Reduce the image size by various operations |
|
31 | 31 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
32 | 32 | if [ "$REDUCE_APT" = true ] ; then |
|
33 | 33 | # Install dpkg configuration file |
|
34 | 34 | if [ "$REDUCE_DOC" = true ] || [ "$REDUCE_MAN" = true ] ; then |
|
35 | 35 | install_readonly files/dpkg/01nodoc "${ETC_DIR}/dpkg/dpkg.cfg.d/01nodoc" |
|
36 | 36 | fi |
|
37 | 37 | |
|
38 | 38 | # Install APT configuration files |
|
39 | 39 | install_readonly files/apt/02nocache "${ETC_DIR}/apt/apt.conf.d/02nocache" |
|
40 | 40 | install_readonly files/apt/03compress "${ETC_DIR}/apt/apt.conf.d/03compress" |
|
41 | 41 | install_readonly files/apt/04norecommends "${ETC_DIR}/apt/apt.conf.d/04norecommends" |
|
42 | 42 | |
|
43 | 43 | # Remove APT cache files |
|
44 | 44 | rm -fr "${R}/var/cache/apt/pkgcache.bin" |
|
45 | 45 | rm -fr "${R}/var/cache/apt/srcpkgcache.bin" |
|
46 | 46 | fi |
|
47 | 47 | |
|
48 | 48 | # Remove all doc files |
|
49 | 49 | if [ "$REDUCE_DOC" = true ] ; then |
|
50 | 50 | find "${R}/usr/share/doc" -depth -type f ! -name copyright -print0 | xargs -0 rm || true |
|
51 | 51 | find "${R}/usr/share/doc" -empty -print0 | xargs -0 rmdir || true |
|
52 | 52 | fi |
|
53 | 53 | |
|
54 | 54 | # Remove all man pages and info files |
|
55 | 55 | if [ "$REDUCE_MAN" = true ] ; then |
|
56 | 56 | rm -rf "${R}/usr/share/man" "${R}/usr/share/groff" "${R}/usr/share/info" "${R}/usr/share/lintian" "${R}/usr/share/linda" "${R}/var/cache/man" |
|
57 | 57 | fi |
|
58 | 58 | |
|
59 | 59 | # Remove all locale translation files |
|
60 | 60 | if [ "$REDUCE_LOCALE" = true ] ; then |
|
61 | 61 | find "${R}/usr/share/locale" -mindepth 1 -maxdepth 1 ! -name 'en' -print0 | xargs -0 rm -r |
|
62 | 62 | fi |
|
63 | 63 | |
|
64 | 64 | # Remove hwdb PCI device classes (experimental) |
|
65 | 65 | if [ "$REDUCE_HWDB" = true ] ; then |
|
66 | 66 | rm -fr "/lib/udev/hwdb.d/20-pci-*" |
|
67 | 67 | fi |
|
68 | 68 | |
|
69 | 69 | # Replace bash shell by dash shell (experimental) |
|
70 | 70 | if [ "$REDUCE_BASH" = true ] ; then |
|
71 | 71 | # Purge bash and update alternatives |
|
72 | 72 | echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash |
|
73 | 73 | chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100 |
|
74 | 74 | fi |
|
75 | 75 | |
|
76 | 76 | # Remove sound utils and libraries |
|
77 | 77 | if [ "$ENABLE_SOUND" = false ] ; then |
|
78 | chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 libasound2 libasound2-data | |
|
78 | if [ "$ENABLE_BLUETOOTH" = false ] ; then | |
|
79 | chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 libasound2 libasound2-data | |
|
80 | else | |
|
81 | chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 | |
|
82 | fi | |
|
79 | 83 | fi |
|
80 | 84 | |
|
81 | 85 | # Remove GPU kernels |
|
82 | 86 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
83 | 87 | rm -f "${BOOT_DIR}/start.elf" |
|
84 | 88 | rm -f "${BOOT_DIR}/fixup.dat" |
|
85 | 89 | rm -f "${BOOT_DIR}/start_x.elf" |
|
86 | 90 | rm -f "${BOOT_DIR}/fixup_x.dat" |
|
87 | 91 | fi |
|
88 | 92 | |
|
89 | 93 | # Remove kernel and initrd from /boot (already in /boot/firmware) |
|
90 | 94 | if [ "$BUILD_KERNEL" = false ] ; then |
|
91 | 95 | rm -f "${R}/boot/vmlinuz-*" |
|
92 | 96 | rm -f "${R}/boot/initrd.img-*" |
|
93 | 97 | fi |
|
98 | ||
|
99 | #Reduce BOOT | |
|
100 | #Only necessary files for my gen pi | |
|
94 | 101 | |
|
95 | 102 | # Clean APT list of repositories |
|
96 | 103 | rm -fr "${R}/var/lib/apt/lists/*" |
|
97 | 104 | chroot_exec apt-get -qq -y update |
|
98 | 105 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant