##// END OF EJS Templates
a
Unknown -
r495:0f41c6c0ea5a
parent child
Show More
@@ -1,273 +1,273
1 #
1 #
2 # Setup RPi2/3 config and cmdline
2 # Setup RPi2/3 config and cmdline
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 #if [ "$BUILD_KERNEL" = true ] ; then
8 #if [ "$BUILD_KERNEL" = true ] ; then
9 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
9 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
10 # Install boot binaries from local directory
10 # Install boot binaries from local directory
11 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
11 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
14 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
14 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
15 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
15 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
17 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
17 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
18 else
18 else
19 # Create temporary directory for boot binaries
19 # Create temporary directory for boot binaries
20 temp_dir=$(as_nobody mktemp -d)
20 temp_dir=$(as_nobody mktemp -d)
21
21
22 # Install latest boot binaries from raspberry/firmware github
22 # Install latest boot binaries from raspberry/firmware github
23 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
23 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
24 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
24 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
26 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
26 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
27 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
27 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
28 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
28 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
29 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
29 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
30
30
31 # Move downloaded boot binaries
31 # Move downloaded boot binaries
32 mv "${temp_dir}/"* "${BOOT_DIR}/"
32 mv "${temp_dir}/"* "${BOOT_DIR}/"
33
33
34 # Remove temporary directory for boot binaries
34 # Remove temporary directory for boot binaries
35 rm -fr "${temp_dir}"
35 rm -fr "${temp_dir}"
36
36
37 # Set permissions of the boot binaries
37 # Set permissions of the boot binaries
38 chown -R root:root "${BOOT_DIR}"
38 chown -R root:root "${BOOT_DIR}"
39 chmod -R 600 "${BOOT_DIR}"
39 chmod -R 600 "${BOOT_DIR}"
40 fi
40 fi
41 #fi
41 #fi
42
42
43 # Setup firmware boot cmdline
43 # Setup firmware boot cmdline
44 if [ "$ENABLE_UBOOTUSB" = true ] ; then
44 if [ "$ENABLE_UBOOTUSB" = true ] ; then
45 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
45 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
46 else
46 else
47 if [ "$ENABLE_SPLITFS" = true ] ; then
47 if [ "$ENABLE_SPLITFS" = true ] ; then
48 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
48 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
49 else
49 else
50 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
50 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
51 fi
51 fi
52 fi
52 fi
53
53
54 # Add encrypted root partition to cmdline.txt
54 # Add encrypted root partition to cmdline.txt
55 if [ "$ENABLE_CRYPTFS" = true ] ; then
55 if [ "$ENABLE_CRYPTFS" = true ] ; then
56 if [ "$ENABLE_SPLITFS" = true ] ; then
56 if [ "$ENABLE_SPLITFS" = true ] ; then
57 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
57 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
58 else
58 else
59 if [ "$ENABLE_UBOOTUSB" = true ] ; then
59 if [ "$ENABLE_UBOOTUSB" = true ] ; then
60 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/")
60 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/")
61 else
61 else
62 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
62 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
63 fi
63 fi
64 fi
64 fi
65 fi
65 fi
66
66
67 # Enable Kernel messages on standard output
67 # Enable Kernel messages on standard output
68 if [ "$ENABLE_PRINTK" = true ] ; then
68 if [ "$ENABLE_PRINTK" = true ] ; then
69 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
69 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
70 fi
70 fi
71
71
72 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
72 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
73 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
73 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
74
74
75 # Remove IPv6 networking support
75 # Remove IPv6 networking support
76 if [ "$ENABLE_IPV6" = false ] ; then
76 if [ "$ENABLE_IPV6" = false ] ; then
77 CMDLINE="${CMDLINE} ipv6.disable=1"
77 CMDLINE="${CMDLINE} ipv6.disable=1"
78 fi
78 fi
79
79
80 # Automatically assign predictable network interface names
80 # Automatically assign predictable network interface names
81 if [ "$ENABLE_IFNAMES" = false ] ; then
81 if [ "$ENABLE_IFNAMES" = false ] ; then
82 CMDLINE="${CMDLINE} net.ifnames=0"
82 CMDLINE="${CMDLINE} net.ifnames=0"
83 else
83 else
84 CMDLINE="${CMDLINE} net.ifnames=1"
84 CMDLINE="${CMDLINE} net.ifnames=1"
85 fi
85 fi
86
86
87 # Install firmware config
87 # Install firmware config
88 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
88 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
89
89
90 # Locks CPU frequency at maximum
90 # Locks CPU frequency at maximum
91 if [ "$ENABLE_TURBO" = true ] ; then
91 if [ "$ENABLE_TURBO" = true ] ; then
92 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
92 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
93 # helps to avoid sdcard corruption when force_turbo is enabled.
93 # helps to avoid sdcard corruption when force_turbo is enabled.
94 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
94 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
95 fi
95 fi
96
96
97 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
97 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
98
98
99 # Bluetooth enabled
99 # Bluetooth enabled
100 if [ "$ENABLE_BLUETOOTH" = true ] ; then
100 if [ "$ENABLE_BLUETOOTH" = true ] ; then
101 # Create temporary directory for Bluetooth sources
101 # Create temporary directory for Bluetooth sources
102 temp_dir=$(as_nobody mktemp -d)
102 temp_dir=$(as_nobody mktemp -d)
103
103
104 # Fetch Bluetooth sources
104 # Fetch Bluetooth sources
105 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
105 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
106
106
107 # Copy downloaded sources
107 # Copy downloaded sources
108 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
108 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
109
109
110 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
110 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
111 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
111 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
112 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
112 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
113
113
114 # Set permissions
114 # Set permissions
115 chown -R root:root "${R}/tmp/pi-bluetooth"
115 chown -R root:root "${R}/tmp/pi-bluetooth"
116
116
117 # Install tools
117 # Install tools
118 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
118 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
119 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
119 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
120
120
121 # make scripts executable
121 # make scripts executable
122 chmod +x "${R}/usr/bin/bthelper"
122 chmod +x "${R}/usr/bin/bthelper"
123 chmod +x "${R}/usr/bin/btuart"
123 chmod +x "${R}/usr/bin/btuart"
124
124
125 # Install bluetooth udev rule
125 # Install bluetooth udev rule
126 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
126 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
127
127
128 # Install Firmware Flash file and apropiate licence
128 # Install Firmware Flash file and apropiate licence
129 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
129 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
130 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
130 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
131 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
131 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
132 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
132 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
133 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
133 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
134
134
135 # Remove temporary directories
135 # Remove temporary directories
136 rm -fr "${temp_dir}"
136 rm -fr "${temp_dir}"
137 rm -fr "${R}"/tmp/pi-bluetooth
137 rm -fr "${R}"/tmp/pi-bluetooth
138
138
139 # 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
139 # 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
140 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
140 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
141
141
142 # set overlay to swap ttyAMA0 and ttyS0
142 # set overlay to swap ttyAMA0 and ttyS0
143 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
143 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
144
144
145 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
145 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
146 if [ "$ENABLE_TURBO" = false ] ; then
146 if [ "$ENABLE_TURBO" = false ] ; then
147 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
147 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
148 fi
148 fi
149 fi
149 fi
150
150
151 # Activate services
151 # Activate services
152 chroot_exec systemctl enable pi-bluetooth.hciuart.service
152 chroot_exec systemctl enable pi-bluetooth.hciuart.service
153
153
154 else # if ENABLE_BLUETOOTH = false
154 else # if ENABLE_BLUETOOTH = false
155 # set overlay to disable bluetooth
155 # set overlay to disable bluetooth
156 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
156 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
157 fi # ENABLE_BLUETOOTH end
157 fi # ENABLE_BLUETOOTH end
158 fi
158 fi
159
159
160 # may need sudo systemctl disable hciuart
160 # may need sudo systemctl disable hciuart
161 if [ "$ENABLE_CONSOLE" = true ] ; then
161 if [ "$ENABLE_CONSOLE" = true ] ; then
162 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
162 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
163 # add string to cmdline
163 # add string to cmdline
164 CMDLINE="${CMDLINE} console=serial0,115200"
164 CMDLINE="${CMDLINE} console=serial0,115200"
165
165
166 # Enable serial console systemd style
166 # Enable serial console systemd style
167 chroot_exec systemctl enable serial-getty@serial0.service
167 chroot_exec systemctl enable serial-getty@serial0.service
168 else
168 else
169 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
169 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
170 fi
170 fi
171
171
172 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
172 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
173
173
174 # Remove cmdline.txt entry of starting zswap
174 # Remove cmdline.txt entry of starting zswap
175 if [ "$KERNEL_ZSWAP" = true ] ; then
175 if [ "$KERNEL_ZSWAP" = true ] ; then
176 sed -i 's|zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4||g'
176 sed -i 's|zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4||g'
177 fi
177 fi
178 # Create temporary directory for systemd-swap sources
178 # Create temporary directory for systemd-swap sources
179 temp_dir=$(as_nobody mktemp -d)
179 temp_dir=$(as_nobody mktemp -d)
180
180
181 # Fetch systemd-swap sources
181 # Fetch systemd-swap sources
182 as_nobody git -C "${temp_dir}" clone "${ZSWAP_URL}"
182 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
183
183
184 # Copy downloaded systemd-swap sources
184 # Copy downloaded systemd-swap sources
185 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
185 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
186
186
187 # Set permissions of the systemd-swap sources
187 # Set permissions of the systemd-swap sources
188 chown -R root:root "${R}/tmp/systemd-swap"
188 chown -R root:root "${R}/tmp/systemd-swap"
189
189
190 # Remove temporary directory for systemd-swap sources
190 # Remove temporary directory for systemd-swap sources
191 rm -fr "${temp_dir}"
191 rm -fr "${temp_dir}"
192
192
193 # Change into downloaded src dir
193 # Change into downloaded src dir
194 cd "${R}/tmp/systemd-swap" || exit
194 cd "${R}/tmp/systemd-swap" || exit
195
195
196 # Build package
196 # Build package
197 . ./systemd-swap/package.sh debian
197 . ./systemd-swap/package.sh debian
198
198
199 # Install package
199 # Install package
200 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap-*any.deb
200 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap-*any.deb
201
201
202 # Enable service
202 # Enable service
203 chroot_exec systemctl enable systemd-swap
203 chroot_exec systemctl enable systemd-swap
204
204
205 # Change back into script root dir
205 # Change back into script root dir
206 cd "${WORKDIR}" || exit
206 cd "${WORKDIR}" || exit
207 else
207 else
208 # Enable ZSWAP in cmdline if systemd-swap is not used
208 # Enable ZSWAP in cmdline if systemd-swap is not used
209 if [ "$KERNEL_ZSWAP" = true ] ; then
209 if [ "$KERNEL_ZSWAP" = true ] ; then
210 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
210 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
211 fi
211 fi
212 fi
212 fi
213
213
214 # Install firmware boot cmdline
214 # Install firmware boot cmdline
215 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
215 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
216
216
217 # Setup minimal GPU memory allocation size: 16MB (no X)
217 # Setup minimal GPU memory allocation size: 16MB (no X)
218 if [ "$ENABLE_MINGPU" = true ] ; then
218 if [ "$ENABLE_MINGPU" = true ] ; then
219 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
219 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
220 fi
220 fi
221
221
222 # Setup boot with initramfs
222 # Setup boot with initramfs
223 if [ "$ENABLE_INITRAMFS" = true ] ; then
223 if [ "$ENABLE_INITRAMFS" = true ] ; then
224 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
224 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
225 fi
225 fi
226
226
227 # Create firmware configuration and cmdline symlinks
227 # Create firmware configuration and cmdline symlinks
228 ln -sf firmware/config.txt "${R}/boot/config.txt"
228 ln -sf firmware/config.txt "${R}/boot/config.txt"
229 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
229 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
230
230
231 # Install and setup kernel modules to load at boot
231 # Install and setup kernel modules to load at boot
232 mkdir -p "${LIB_DIR}/modules-load.d/"
232 mkdir -p "${LIB_DIR}/modules-load.d/"
233 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
233 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
234
234
235 # Load hardware random module at boot
235 # Load hardware random module at boot
236 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
236 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
237 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
237 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
238 fi
238 fi
239
239
240 # Load sound module at boot
240 # Load sound module at boot
241 if [ "$ENABLE_SOUND" = true ] ; then
241 if [ "$ENABLE_SOUND" = true ] ; then
242 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
242 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
243 else
243 else
244 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
244 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
245 fi
245 fi
246
246
247 # Enable I2C interface
247 # Enable I2C interface
248 if [ "$ENABLE_I2C" = true ] ; then
248 if [ "$ENABLE_I2C" = true ] ; then
249 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
249 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
250 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
250 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
251 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
251 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
252 fi
252 fi
253
253
254 # Enable SPI interface
254 # Enable SPI interface
255 if [ "$ENABLE_SPI" = true ] ; then
255 if [ "$ENABLE_SPI" = true ] ; then
256 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
256 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
257 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
257 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
258 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
258 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
259 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
259 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
260 fi
260 fi
261 fi
261 fi
262
262
263 # Disable RPi2/3 under-voltage warnings
263 # Disable RPi2/3 under-voltage warnings
264 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
264 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
265 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
265 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
266 fi
266 fi
267
267
268 # Install kernel modules blacklist
268 # Install kernel modules blacklist
269 mkdir -p "${ETC_DIR}/modprobe.d/"
269 mkdir -p "${ETC_DIR}/modprobe.d/"
270 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
270 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
271
271
272 # Install sysctl.d configuration files
272 # Install sysctl.d configuration files
273 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
273 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
@@ -1,869 +1,869
1 #!/bin/sh
1 #!/bin/sh
2 ########################################################################
2 ########################################################################
3 # rpi23-gen-image.sh 2015-2017
3 # rpi23-gen-image.sh 2015-2017
4 #
4 #
5 # Advanced Debian "stretch" and "buster" bootstrap script for Raspberry Pi
5 # Advanced Debian "stretch" and "buster" bootstrap script for Raspberry Pi
6 #
6 #
7 # This program is free software; you can redistribute it and/or
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
10 # of the License, or (at your option) any later version.
11 #
11 #
12 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
12 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
13 #
13 #
14 # Big thanks for patches and enhancements by 20+ github contributors!
14 # Big thanks for patches and enhancements by 20+ github contributors!
15 ########################################################################
15 ########################################################################
16
16
17 # Are we running as root?
17 # Are we running as root?
18 if [ "$(id -u)" -ne "0" ] ; then
18 if [ "$(id -u)" -ne "0" ] ; then
19 echo "error: this script must be executed with root privileges!"
19 echo "error: this script must be executed with root privileges!"
20 exit 1
20 exit 1
21 fi
21 fi
22
22
23 # Check if ./functions.sh script exists
23 # Check if ./functions.sh script exists
24 if [ ! -r "./functions.sh" ] ; then
24 if [ ! -r "./functions.sh" ] ; then
25 echo "error: './functions.sh' required script not found!"
25 echo "error: './functions.sh' required script not found!"
26 exit 1
26 exit 1
27 fi
27 fi
28
28
29 # Load utility functions
29 # Load utility functions
30 . ./functions.sh
30 . ./functions.sh
31
31
32 # Load parameters from configuration template file
32 # Load parameters from configuration template file
33 if [ -n "$CONFIG_TEMPLATE" ] ; then
33 if [ -n "$CONFIG_TEMPLATE" ] ; then
34 use_template
34 use_template
35 fi
35 fi
36
36
37 # Introduce settings
37 # Introduce settings
38 set -e
38 set -e
39 echo -n -e "\n#\n# RPi 0/1/2/3 Bootstrap Settings\n#\n"
39 echo -n -e "\n#\n# RPi 0/1/2/3 Bootstrap Settings\n#\n"
40 set -x
40 set -x
41
41
42 # Raspberry Pi model configuration
42 # Raspberry Pi model configuration
43 RPI_MODEL=${RPI_MODEL:=2}
43 RPI_MODEL=${RPI_MODEL:=2}
44
44
45 # Debian release
45 # Debian release
46 RELEASE=${RELEASE:=buster}
46 RELEASE=${RELEASE:=buster}
47
47
48 # Kernel Branch
48 # Kernel Branch
49 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
49 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
50
50
51 # URLs
51 # URLs
52 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
52 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
53 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
53 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
54 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
54 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
55 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
55 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
56 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
56 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
57 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
57 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
58 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
58 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
59 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
59 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
60 NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git}
60 NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git}
61 SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git}
61 SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git}
62
62
63 # Kernel deb packages for 32bit kernel
63 # Kernel deb packages for 32bit kernel
64 RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb}
64 RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb}
65 RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb}
65 RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb}
66 # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used
66 # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used
67 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz}
67 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz}
68 # Default precompiled 64bit kernel
68 # Default precompiled 64bit kernel
69 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz}
69 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz}
70 # Generic
70 # Generic
71 RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL}
71 RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL}
72 # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul)
72 # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul)
73 KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git}
73 KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git}
74
74
75 # Build directories
75 # Build directories
76 WORKDIR=$(pwd)
76 WORKDIR=$(pwd)
77 BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}}
77 BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}}
78 BUILDDIR="${BASEDIR}/build"
78 BUILDDIR="${BASEDIR}/build"
79
79
80 # Chroot directories
80 # Chroot directories
81 R="${BUILDDIR}/chroot"
81 R="${BUILDDIR}/chroot"
82 ETC_DIR="${R}/etc"
82 ETC_DIR="${R}/etc"
83 LIB_DIR="${R}/lib"
83 LIB_DIR="${R}/lib"
84 BOOT_DIR="${R}/boot/firmware"
84 BOOT_DIR="${R}/boot/firmware"
85 KERNEL_DIR="${R}/usr/src/linux"
85 KERNEL_DIR="${R}/usr/src/linux"
86 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
86 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
87 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
87 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
88
88
89 # Firmware directory: Blank if download from github
89 # Firmware directory: Blank if download from github
90 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
90 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
91
91
92 # General settings
92 # General settings
93 SET_ARCH=${SET_ARCH:=32}
93 SET_ARCH=${SET_ARCH:=32}
94 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
94 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
95 PASSWORD=${PASSWORD:=raspberry}
95 PASSWORD=${PASSWORD:=raspberry}
96 USER_PASSWORD=${USER_PASSWORD:=raspberry}
96 USER_PASSWORD=${USER_PASSWORD:=raspberry}
97 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
97 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
98 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
98 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
99 EXPANDROOT=${EXPANDROOT:=true}
99 EXPANDROOT=${EXPANDROOT:=true}
100
100
101 # Keyboard settings
101 # Keyboard settings
102 XKB_MODEL=${XKB_MODEL:=""}
102 XKB_MODEL=${XKB_MODEL:=""}
103 XKB_LAYOUT=${XKB_LAYOUT:=""}
103 XKB_LAYOUT=${XKB_LAYOUT:=""}
104 XKB_VARIANT=${XKB_VARIANT:=""}
104 XKB_VARIANT=${XKB_VARIANT:=""}
105 XKB_OPTIONS=${XKB_OPTIONS:=""}
105 XKB_OPTIONS=${XKB_OPTIONS:=""}
106
106
107 # Network settings (DHCP)
107 # Network settings (DHCP)
108 ENABLE_DHCP=${ENABLE_DHCP:=true}
108 ENABLE_DHCP=${ENABLE_DHCP:=true}
109
109
110 # Network settings (static)
110 # Network settings (static)
111 NET_ADDRESS=${NET_ADDRESS:=""}
111 NET_ADDRESS=${NET_ADDRESS:=""}
112 NET_GATEWAY=${NET_GATEWAY:=""}
112 NET_GATEWAY=${NET_GATEWAY:=""}
113 NET_DNS_1=${NET_DNS_1:=""}
113 NET_DNS_1=${NET_DNS_1:=""}
114 NET_DNS_2=${NET_DNS_2:=""}
114 NET_DNS_2=${NET_DNS_2:=""}
115 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
115 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
116 NET_NTP_1=${NET_NTP_1:=""}
116 NET_NTP_1=${NET_NTP_1:=""}
117 NET_NTP_2=${NET_NTP_2:=""}
117 NET_NTP_2=${NET_NTP_2:=""}
118
118
119 # APT settings
119 # APT settings
120 APT_PROXY=${APT_PROXY:=""}
120 APT_PROXY=${APT_PROXY:=""}
121 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
121 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
122
122
123 # Feature settings
123 # Feature settings
124 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
124 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
125 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
125 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
126 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
126 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
127 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
127 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
128 ENABLE_I2C=${ENABLE_I2C:=false}
128 ENABLE_I2C=${ENABLE_I2C:=false}
129 ENABLE_SPI=${ENABLE_SPI:=false}
129 ENABLE_SPI=${ENABLE_SPI:=false}
130 ENABLE_IPV6=${ENABLE_IPV6:=true}
130 ENABLE_IPV6=${ENABLE_IPV6:=true}
131 ENABLE_SSHD=${ENABLE_SSHD:=true}
131 ENABLE_SSHD=${ENABLE_SSHD:=true}
132 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
132 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
133 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
133 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
134 ENABLE_SOUND=${ENABLE_SOUND:=true}
134 ENABLE_SOUND=${ENABLE_SOUND:=true}
135 ENABLE_DBUS=${ENABLE_DBUS:=true}
135 ENABLE_DBUS=${ENABLE_DBUS:=true}
136 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
136 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
137 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
137 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
138 ENABLE_XORG=${ENABLE_XORG:=false}
138 ENABLE_XORG=${ENABLE_XORG:=false}
139 ENABLE_WM=${ENABLE_WM:=""}
139 ENABLE_WM=${ENABLE_WM:=""}
140 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
140 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
141 ENABLE_USER=${ENABLE_USER:=true}
141 ENABLE_USER=${ENABLE_USER:=true}
142 USER_NAME=${USER_NAME:="pi"}
142 USER_NAME=${USER_NAME:="pi"}
143 ENABLE_ROOT=${ENABLE_ROOT:=false}
143 ENABLE_ROOT=${ENABLE_ROOT:=false}
144 ENABLE_QEMU=${ENABLE_QEMU:=false}
144 ENABLE_QEMU=${ENABLE_QEMU:=false}
145 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
145 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
146
146
147 # SSH settings
147 # SSH settings
148 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
148 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
149 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
149 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
150 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
150 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
151 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
151 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
152 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
152 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
153
153
154 # Advanced settings
154 # Advanced settings
155 ENABLE_SYSTEMDSWAP=${ENABLE_MINBASE:=false}
155 ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false}
156 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
156 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
157 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
157 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
158 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
158 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
159 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
159 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
160 ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false}
160 ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false}
161 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
161 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
162 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false}
162 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false}
163 ENABLE_NEXMON=${ENABLE_NEXMON:=false}
163 ENABLE_NEXMON=${ENABLE_NEXMON:=false}
164 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
164 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
165 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
165 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
166 NEXMONSRC_DIR=${NEXMONSRC_DIR:=""}
166 NEXMONSRC_DIR=${NEXMONSRC_DIR:=""}
167 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
167 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
168 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
168 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
169 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
169 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
170 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
170 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
171 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
171 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
172 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
172 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
173
173
174 # Kernel compilation settings
174 # Kernel compilation settings
175 BUILD_KERNEL=${BUILD_KERNEL:=true}
175 BUILD_KERNEL=${BUILD_KERNEL:=true}
176 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
176 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
177 KERNEL_THREADS=${KERNEL_THREADS:=1}
177 KERNEL_THREADS=${KERNEL_THREADS:=1}
178 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
178 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
179 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
179 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
180 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
180 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
181 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
181 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
182 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
182 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
183 KERNEL_ZSWAP=${KERNEL_ZSWAP:=false}
183 KERNEL_ZSWAP=${KERNEL_ZSWAP:=false}
184 KERNEL_VIRT=${KERNEL_VIRT:=false}
184 KERNEL_VIRT=${KERNEL_VIRT:=false}
185 KERNEL_BPF=${KERNEL_BPF:=false}
185 KERNEL_BPF=${KERNEL_BPF:=false}
186 KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=powersave}
186 KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=powersave}
187
187
188 # Kernel compilation from source directory settings
188 # Kernel compilation from source directory settings
189 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
189 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
190 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
190 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
191 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
191 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
192 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
192 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
193
193
194 # Reduce disk usage settings
194 # Reduce disk usage settings
195 REDUCE_APT=${REDUCE_APT:=true}
195 REDUCE_APT=${REDUCE_APT:=true}
196 REDUCE_DOC=${REDUCE_DOC:=true}
196 REDUCE_DOC=${REDUCE_DOC:=true}
197 REDUCE_MAN=${REDUCE_MAN:=true}
197 REDUCE_MAN=${REDUCE_MAN:=true}
198 REDUCE_VIM=${REDUCE_VIM:=false}
198 REDUCE_VIM=${REDUCE_VIM:=false}
199 REDUCE_BASH=${REDUCE_BASH:=false}
199 REDUCE_BASH=${REDUCE_BASH:=false}
200 REDUCE_HWDB=${REDUCE_HWDB:=true}
200 REDUCE_HWDB=${REDUCE_HWDB:=true}
201 REDUCE_SSHD=${REDUCE_SSHD:=true}
201 REDUCE_SSHD=${REDUCE_SSHD:=true}
202 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
202 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
203
203
204 # Encrypted filesystem settings
204 # Encrypted filesystem settings
205 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
205 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
206 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
206 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
207 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
207 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
208 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
208 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
209 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
209 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
210 #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup
210 #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup
211 CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false}
211 CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false}
212 #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated
212 #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated
213 CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""}
213 CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""}
214
214
215 # Chroot scripts directory
215 # Chroot scripts directory
216 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
216 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
217
217
218 # Packages required in the chroot build environment
218 # Packages required in the chroot build environment
219 APT_INCLUDES=${APT_INCLUDES:=""}
219 APT_INCLUDES=${APT_INCLUDES:=""}
220 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
220 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
221
221
222 #Packages to exclude from chroot build environment
222 #Packages to exclude from chroot build environment
223 APT_EXCLUDES=${APT_EXCLUDES:=""}
223 APT_EXCLUDES=${APT_EXCLUDES:=""}
224
224
225 # Packages required for bootstrapping
225 # Packages required for bootstrapping
226 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt"
226 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt"
227 MISSING_PACKAGES=""
227 MISSING_PACKAGES=""
228
228
229 # Packages installed for c/c++ build environment in chroot (keep empty)
229 # Packages installed for c/c++ build environment in chroot (keep empty)
230 COMPILER_PACKAGES=""
230 COMPILER_PACKAGES=""
231
231
232 # Check if apt-cacher-ng has port 3142 open and set APT_PROXY
232 # Check if apt-cacher-ng has port 3142 open and set APT_PROXY
233 APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d')
233 APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d')
234 if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then
234 if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then
235 APT_PROXY=http://127.0.0.1:3142/
235 APT_PROXY=http://127.0.0.1:3142/
236 fi
236 fi
237
237
238 # netselect-apt does not know buster yet
238 # netselect-apt does not know buster yet
239 if [ "$RELEASE" = "buster" ] ; then
239 if [ "$RELEASE" = "buster" ] ; then
240 RLS=testing
240 RLS=testing
241 else
241 else
242 RLS="$RELEASE"
242 RLS="$RELEASE"
243 fi
243 fi
244
244
245 if [ -f "$(pwd)/files/apt/sources.list" ] ; then
245 if [ -f "$(pwd)/files/apt/sources.list" ] ; then
246 rm "$(pwd)/files/apt/sources.list"
246 rm "$(pwd)/files/apt/sources.list"
247 fi
247 fi
248
248
249 if [ "$ENABLE_NONFREE" = true ] ; then
249 if [ "$ENABLE_NONFREE" = true ] ; then
250 netselect-apt --arch "$RELEASE_ARCH" -t 3 --sources --nonfree --outfile "$(pwd)/files/apt/sources.list" -d "$RLS"
250 netselect-apt --arch "$RELEASE_ARCH" -t 3 --sources --nonfree --outfile "$(pwd)/files/apt/sources.list" -d "$RLS"
251 else
251 else
252 netselect-apt --arch "$RELEASE_ARCH" -t 3 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS"
252 netselect-apt --arch "$RELEASE_ARCH" -t 3 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS"
253 fi
253 fi
254
254
255 # sed and cut the result string so we can use it as APT_SERVER
255 # sed and cut the result string so we can use it as APT_SERVER
256 APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3 | sed 's|/$|''|')
256 APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3 | sed 's|/$|''|')
257
257
258 # make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go!
258 # make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go!
259 if [ -n "$SET_ARCH" ] ; then
259 if [ -n "$SET_ARCH" ] ; then
260 # 64-bit configuration
260 # 64-bit configuration
261 if [ "$SET_ARCH" = 64 ] ; then
261 if [ "$SET_ARCH" = 64 ] ; then
262 # General 64-bit depended settings
262 # General 64-bit depended settings
263 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
263 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
264 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
264 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
265 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
265 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
266
266
267 # Raspberry Pi model specific settings
267 # Raspberry Pi model specific settings
268 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
268 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
269 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
269 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
270 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
270 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
271 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
271 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
272 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
272 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
273 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
273 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
274 else
274 else
275 echo "error: Only Raspberry PI 3 and 3B+ support 64-bit"
275 echo "error: Only Raspberry PI 3 and 3B+ support 64-bit"
276 exit 1
276 exit 1
277 fi
277 fi
278 fi
278 fi
279
279
280 # 32-bit configuration
280 # 32-bit configuration
281 if [ "$SET_ARCH" = 32 ] ; then
281 if [ "$SET_ARCH" = 32 ] ; then
282 # General 32-bit dependend settings
282 # General 32-bit dependend settings
283 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
283 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
284 KERNEL_ARCH=${KERNEL_ARCH:=arm}
284 KERNEL_ARCH=${KERNEL_ARCH:=arm}
285 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
285 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
286
286
287 # Raspberry Pi model specific settings
287 # Raspberry Pi model specific settings
288 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
288 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
289 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
289 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
290 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
290 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
291 RELEASE_ARCH=${RELEASE_ARCH:=armel}
291 RELEASE_ARCH=${RELEASE_ARCH:=armel}
292 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
292 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
293 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
293 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
294 fi
294 fi
295
295
296 # Raspberry Pi model specific settings
296 # Raspberry Pi model specific settings
297 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
297 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
298 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
298 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
299 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
299 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
300 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
300 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
301 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
301 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
302 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
302 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
303 fi
303 fi
304 fi
304 fi
305 # SET_ARCH not set
305 # SET_ARCH not set
306 else
306 else
307 echo "error: Please set '32' or '64' as value for SET_ARCH"
307 echo "error: Please set '32' or '64' as value for SET_ARCH"
308 exit 1
308 exit 1
309 fi
309 fi
310 # Device specific configuration and U-Boot configuration
310 # Device specific configuration and U-Boot configuration
311 case "$RPI_MODEL" in
311 case "$RPI_MODEL" in
312 0)
312 0)
313 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
313 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
314 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
314 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
315 ;;
315 ;;
316 1)
316 1)
317 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
317 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
318 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
318 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
319 ;;
319 ;;
320 1P)
320 1P)
321 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
321 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
322 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
322 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
323 ;;
323 ;;
324 2)
324 2)
325 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
325 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
326 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
326 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
327 ;;
327 ;;
328 3)
328 3)
329 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
329 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
330 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
330 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
331 ;;
331 ;;
332 3P)
332 3P)
333 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
333 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
334 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
334 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
335 ;;
335 ;;
336 *)
336 *)
337 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
337 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
338 exit 1
338 exit 1
339 ;;
339 ;;
340 esac
340 esac
341
341
342 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
342 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
343 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
343 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
344 # Include bluetooth packages on supported boards
344 # Include bluetooth packages on supported boards
345 if [ "$ENABLE_BLUETOOTH" = true ] ; then
345 if [ "$ENABLE_BLUETOOTH" = true ] ; then
346 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
346 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
347 fi
347 fi
348 if [ "$ENABLE_WIRELESS" = true ] ; then
348 if [ "$ENABLE_WIRELESS" = true ] ; then
349 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb"
349 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb"
350 fi
350 fi
351 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
351 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
352 # Check if the internal wireless interface is not supported by the RPi model
352 # Check if the internal wireless interface is not supported by the RPi model
353 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
353 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
354 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
354 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
355 exit 1
355 exit 1
356 fi
356 fi
357 fi
357 fi
358
358
359 if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then
359 if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then
360 echo "error: You have to compile kernel sources, if you want to enable nexmon"
360 echo "error: You have to compile kernel sources, if you want to enable nexmon"
361 exit 1
361 exit 1
362 fi
362 fi
363
363
364 # Prepare date string for default image file name
364 # Prepare date string for default image file name
365 DATE="$(date +%Y-%m-%d)"
365 DATE="$(date +%Y-%m-%d)"
366 if [ -z "$KERNEL_BRANCH" ] ; then
366 if [ -z "$KERNEL_BRANCH" ] ; then
367 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
367 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
368 else
368 else
369 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
369 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
370 fi
370 fi
371
371
372 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
372 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
373 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
373 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
374 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
374 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
375 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
375 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
376 exit 1
376 exit 1
377 fi
377 fi
378 fi
378 fi
379
379
380 set +x
380 set +x
381
381
382 # Add cmake to compile videocore sources
382 # Add cmake to compile videocore sources
383 if [ "$ENABLE_VIDEOCORE" = true ] ; then
383 if [ "$ENABLE_VIDEOCORE" = true ] ; then
384 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
384 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
385 fi
385 fi
386
386
387 # Add deps for nexmon
387 # Add deps for nexmon
388 if [ "$ENABLE_NEXMON" = true ] ; then
388 if [ "$ENABLE_NEXMON" = true ] ; then
389 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool"
389 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool"
390 fi
390 fi
391
391
392 # Add libncurses5 to enable kernel menuconfig
392 # Add libncurses5 to enable kernel menuconfig
393 if [ "$KERNEL_MENUCONFIG" = true ] ; then
393 if [ "$KERNEL_MENUCONFIG" = true ] ; then
394 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
394 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
395 fi
395 fi
396
396
397 # Add ccache compiler cache for (faster) kernel cross (re)compilation
397 # Add ccache compiler cache for (faster) kernel cross (re)compilation
398 if [ "$KERNEL_CCACHE" = true ] ; then
398 if [ "$KERNEL_CCACHE" = true ] ; then
399 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
399 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
400 fi
400 fi
401
401
402 # Add cryptsetup package to enable filesystem encryption
402 # Add cryptsetup package to enable filesystem encryption
403 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
403 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
404 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
404 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
405 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
405 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
406
406
407 # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package
407 # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package
408 if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then
408 if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then
409 APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs"
409 APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs"
410 fi
410 fi
411
411
412 if [ -z "$CRYPTFS_PASSWORD" ] ; then
412 if [ -z "$CRYPTFS_PASSWORD" ] ; then
413 echo "error: no password defined (CRYPTFS_PASSWORD)!"
413 echo "error: no password defined (CRYPTFS_PASSWORD)!"
414 exit 1
414 exit 1
415 fi
415 fi
416 ENABLE_INITRAMFS=true
416 ENABLE_INITRAMFS=true
417 fi
417 fi
418
418
419 # Add initramfs generation tools
419 # Add initramfs generation tools
420 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
420 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
421 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
421 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
422 fi
422 fi
423
423
424 # Add device-tree-compiler required for building the U-Boot bootloader
424 # Add device-tree-compiler required for building the U-Boot bootloader
425 if [ "$ENABLE_UBOOT" = true ] ; then
425 if [ "$ENABLE_UBOOT" = true ] ; then
426 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
426 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
427 else
427 else
428 if [ "$ENABLE_UBOOTUSB" = true ] ; then
428 if [ "$ENABLE_UBOOTUSB" = true ] ; then
429 echo "error: Enabling UBOOTUSB requires u-boot to be enabled"
429 echo "error: Enabling UBOOTUSB requires u-boot to be enabled"
430 exit 1
430 exit 1
431 fi
431 fi
432 fi
432 fi
433
433
434 # Check if root SSH (v2) public key file exists
434 # Check if root SSH (v2) public key file exists
435 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
435 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
436 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
436 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
437 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
437 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
438 exit 1
438 exit 1
439 fi
439 fi
440 fi
440 fi
441
441
442 # Check if $USER_NAME SSH (v2) public key file exists
442 # Check if $USER_NAME SSH (v2) public key file exists
443 if [ -n "$SSH_USER_PUB_KEY" ] ; then
443 if [ -n "$SSH_USER_PUB_KEY" ] ; then
444 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
444 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
445 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
445 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
446 exit 1
446 exit 1
447 fi
447 fi
448 fi
448 fi
449
449
450 if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then
450 if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then
451 echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON"
451 echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON"
452 exit 1
452 exit 1
453 fi
453 fi
454
454
455 # Check if all required packages are installed on the build system
455 # Check if all required packages are installed on the build system
456 for package in $REQUIRED_PACKAGES ; do
456 for package in $REQUIRED_PACKAGES ; do
457 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
457 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
458 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
458 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
459 fi
459 fi
460 done
460 done
461
461
462 # If there are missing packages ask confirmation for install, or exit
462 # If there are missing packages ask confirmation for install, or exit
463 if [ -n "$MISSING_PACKAGES" ] ; then
463 if [ -n "$MISSING_PACKAGES" ] ; then
464 echo "the following packages needed by this script are not installed:"
464 echo "the following packages needed by this script are not installed:"
465 echo "$MISSING_PACKAGES"
465 echo "$MISSING_PACKAGES"
466
466
467 printf "\ndo you want to install the missing packages right now? [y/n] "
467 printf "\ndo you want to install the missing packages right now? [y/n] "
468 read -r confirm
468 read -r confirm
469 [ "$confirm" != "y" ] && exit 1
469 [ "$confirm" != "y" ] && exit 1
470
470
471 # Make sure all missing required packages are installed
471 # Make sure all missing required packages are installed
472 apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
472 apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
473 fi
473 fi
474
474
475 # Check if ./bootstrap.d directory exists
475 # Check if ./bootstrap.d directory exists
476 if [ ! -d "./bootstrap.d/" ] ; then
476 if [ ! -d "./bootstrap.d/" ] ; then
477 echo "error: './bootstrap.d' required directory not found!"
477 echo "error: './bootstrap.d' required directory not found!"
478 exit 1
478 exit 1
479 fi
479 fi
480
480
481 # Check if ./files directory exists
481 # Check if ./files directory exists
482 if [ ! -d "./files/" ] ; then
482 if [ ! -d "./files/" ] ; then
483 echo "error: './files' required directory not found!"
483 echo "error: './files' required directory not found!"
484 exit 1
484 exit 1
485 fi
485 fi
486
486
487 # Check if specified KERNELSRC_DIR directory exists
487 # Check if specified KERNELSRC_DIR directory exists
488 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
488 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
489 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
489 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
490 exit 1
490 exit 1
491 fi
491 fi
492
492
493 # Check if specified UBOOTSRC_DIR directory exists
493 # Check if specified UBOOTSRC_DIR directory exists
494 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
494 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
495 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
495 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
496 exit 1
496 exit 1
497 fi
497 fi
498
498
499 # Check if specified VIDEOCORESRC_DIR directory exists
499 # Check if specified VIDEOCORESRC_DIR directory exists
500 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
500 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
501 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
501 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
502 exit 1
502 exit 1
503 fi
503 fi
504
504
505 # Check if specified FBTURBOSRC_DIR directory exists
505 # Check if specified FBTURBOSRC_DIR directory exists
506 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
506 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
507 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
507 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
508 exit 1
508 exit 1
509 fi
509 fi
510
510
511 # Check if specified NEXMONSRC_DIR directory exists
511 # Check if specified NEXMONSRC_DIR directory exists
512 if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then
512 if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then
513 echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!"
513 echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!"
514 exit 1
514 exit 1
515 fi
515 fi
516
516
517 # Check if specified CHROOT_SCRIPTS directory exists
517 # Check if specified CHROOT_SCRIPTS directory exists
518 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
518 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
519 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
519 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
520 exit 1
520 exit 1
521 fi
521 fi
522
522
523 # Check if specified device mapping already exists (will be used by cryptsetup)
523 # Check if specified device mapping already exists (will be used by cryptsetup)
524 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
524 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
525 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
525 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
526 exit 1
526 exit 1
527 fi
527 fi
528
528
529 # Don't clobber an old build
529 # Don't clobber an old build
530 if [ -e "$BUILDDIR" ] ; then
530 if [ -e "$BUILDDIR" ] ; then
531 echo "error: directory ${BUILDDIR} already exists, not proceeding"
531 echo "error: directory ${BUILDDIR} already exists, not proceeding"
532 exit 1
532 exit 1
533 fi
533 fi
534
534
535 # Setup chroot directory
535 # Setup chroot directory
536 mkdir -p "${R}"
536 mkdir -p "${R}"
537
537
538 # Check if build directory has enough of free disk space >512MB
538 # Check if build directory has enough of free disk space >512MB
539 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
539 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
540 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
540 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
541 exit 1
541 exit 1
542 fi
542 fi
543
543
544 set -x
544 set -x
545
545
546 # Call "cleanup" function on various signals and errors
546 # Call "cleanup" function on various signals and errors
547 trap cleanup 0 1 2 3 6
547 trap cleanup 0 1 2 3 6
548
548
549 # Add required packages for the minbase installation
549 # Add required packages for the minbase installation
550 if [ "$ENABLE_MINBASE" = true ] ; then
550 if [ "$ENABLE_MINBASE" = true ] ; then
551 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
551 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
552 fi
552 fi
553
553
554 # Add parted package, required to get partprobe utility
554 # Add parted package, required to get partprobe utility
555 if [ "$EXPANDROOT" = true ] ; then
555 if [ "$EXPANDROOT" = true ] ; then
556 APT_INCLUDES="${APT_INCLUDES},parted"
556 APT_INCLUDES="${APT_INCLUDES},parted"
557 fi
557 fi
558
558
559 # Add dbus package, recommended if using systemd
559 # Add dbus package, recommended if using systemd
560 if [ "$ENABLE_DBUS" = true ] ; then
560 if [ "$ENABLE_DBUS" = true ] ; then
561 APT_INCLUDES="${APT_INCLUDES},dbus"
561 APT_INCLUDES="${APT_INCLUDES},dbus"
562 fi
562 fi
563
563
564 # Add iptables IPv4/IPv6 package
564 # Add iptables IPv4/IPv6 package
565 if [ "$ENABLE_IPTABLES" = true ] ; then
565 if [ "$ENABLE_IPTABLES" = true ] ; then
566 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
566 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
567 fi
567 fi
568
568
569 # Add openssh server package
569 # Add openssh server package
570 if [ "$ENABLE_SSHD" = true ] ; then
570 if [ "$ENABLE_SSHD" = true ] ; then
571 APT_INCLUDES="${APT_INCLUDES},openssh-server"
571 APT_INCLUDES="${APT_INCLUDES},openssh-server"
572 fi
572 fi
573
573
574 # Add alsa-utils package
574 # Add alsa-utils package
575 if [ "$ENABLE_SOUND" = true ] ; then
575 if [ "$ENABLE_SOUND" = true ] ; then
576 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
576 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
577 fi
577 fi
578
578
579 # Add rng-tools package
579 # Add rng-tools package
580 if [ "$ENABLE_HWRANDOM" = true ] ; then
580 if [ "$ENABLE_HWRANDOM" = true ] ; then
581 APT_INCLUDES="${APT_INCLUDES},rng-tools"
581 APT_INCLUDES="${APT_INCLUDES},rng-tools"
582 fi
582 fi
583
583
584 # Add fbturbo video driver
584 # Add fbturbo video driver
585 if [ "$ENABLE_FBTURBO" = true ] ; then
585 if [ "$ENABLE_FBTURBO" = true ] ; then
586 # Enable xorg package dependencies
586 # Enable xorg package dependencies
587 ENABLE_XORG=true
587 ENABLE_XORG=true
588 fi
588 fi
589
589
590 # Add user defined window manager package
590 # Add user defined window manager package
591 if [ -n "$ENABLE_WM" ] ; then
591 if [ -n "$ENABLE_WM" ] ; then
592 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
592 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
593
593
594 # Enable xorg package dependencies
594 # Enable xorg package dependencies
595 ENABLE_XORG=true
595 ENABLE_XORG=true
596 fi
596 fi
597
597
598 # Add xorg package
598 # Add xorg package
599 if [ "$ENABLE_XORG" = true ] ; then
599 if [ "$ENABLE_XORG" = true ] ; then
600 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
600 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
601 fi
601 fi
602
602
603 # Replace selected packages with smaller clones
603 # Replace selected packages with smaller clones
604 if [ "$ENABLE_REDUCE" = true ] ; then
604 if [ "$ENABLE_REDUCE" = true ] ; then
605 # Add levee package instead of vim-tiny
605 # Add levee package instead of vim-tiny
606 if [ "$REDUCE_VIM" = true ] ; then
606 if [ "$REDUCE_VIM" = true ] ; then
607 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
607 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
608 fi
608 fi
609
609
610 # Add dropbear package instead of openssh-server
610 # Add dropbear package instead of openssh-server
611 if [ "$REDUCE_SSHD" = true ] ; then
611 if [ "$REDUCE_SSHD" = true ] ; then
612 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
612 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
613 fi
613 fi
614 fi
614 fi
615
615
616 # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available
616 # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available
617 if [ "$ENABLE_SYSVINIT" = false ] ; then
617 if [ "$ENABLE_SYSVINIT" = false ] ; then
618 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
618 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
619 fi
619 fi
620
620
621 # Configure kernel sources if no KERNELSRC_DIR
621 # Configure kernel sources if no KERNELSRC_DIR
622 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
622 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
623 KERNELSRC_CONFIG=true
623 KERNELSRC_CONFIG=true
624 fi
624 fi
625
625
626 # Configure reduced kernel
626 # Configure reduced kernel
627 if [ "$KERNEL_REDUCE" = true ] ; then
627 if [ "$KERNEL_REDUCE" = true ] ; then
628 KERNELSRC_CONFIG=false
628 KERNELSRC_CONFIG=false
629 fi
629 fi
630
630
631 # Configure qemu compatible kernel
631 # Configure qemu compatible kernel
632 if [ "$ENABLE_QEMU" = true ] ; then
632 if [ "$ENABLE_QEMU" = true ] ; then
633 DTB_FILE=vexpress-v2p-ca15_a7.dtb
633 DTB_FILE=vexpress-v2p-ca15_a7.dtb
634 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
634 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
635 KERNEL_DEFCONFIG="vexpress_defconfig"
635 KERNEL_DEFCONFIG="vexpress_defconfig"
636 if [ "$KERNEL_MENUCONFIG" = false ] ; then
636 if [ "$KERNEL_MENUCONFIG" = false ] ; then
637 KERNEL_OLDDEFCONFIG=true
637 KERNEL_OLDDEFCONFIG=true
638 fi
638 fi
639 fi
639 fi
640
640
641 # Execute bootstrap scripts
641 # Execute bootstrap scripts
642 for SCRIPT in bootstrap.d/*.sh; do
642 for SCRIPT in bootstrap.d/*.sh; do
643 head -n 3 "$SCRIPT"
643 head -n 3 "$SCRIPT"
644 . "$SCRIPT"
644 . "$SCRIPT"
645 done
645 done
646
646
647 ## Execute custom bootstrap scripts
647 ## Execute custom bootstrap scripts
648 if [ -d "custom.d" ] ; then
648 if [ -d "custom.d" ] ; then
649 for SCRIPT in custom.d/*.sh; do
649 for SCRIPT in custom.d/*.sh; do
650 . "$SCRIPT"
650 . "$SCRIPT"
651 done
651 done
652 fi
652 fi
653
653
654 # Execute custom scripts inside the chroot
654 # Execute custom scripts inside the chroot
655 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
655 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
656 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
656 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
657 chroot_exec /bin/bash -x <<'EOF'
657 chroot_exec /bin/bash -x <<'EOF'
658 for SCRIPT in /chroot_scripts/* ; do
658 for SCRIPT in /chroot_scripts/* ; do
659 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
659 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
660 $SCRIPT
660 $SCRIPT
661 fi
661 fi
662 done
662 done
663 EOF
663 EOF
664 rm -rf "${R}/chroot_scripts"
664 rm -rf "${R}/chroot_scripts"
665 fi
665 fi
666
666
667 # Remove c/c++ build environment from the chroot
667 # Remove c/c++ build environment from the chroot
668 chroot_remove_cc
668 chroot_remove_cc
669
669
670 # Generate required machine-id
670 # Generate required machine-id
671 MACHINE_ID=$(dbus-uuidgen)
671 MACHINE_ID=$(dbus-uuidgen)
672 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
672 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
673 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
673 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
674
674
675 # APT Cleanup
675 # APT Cleanup
676 chroot_exec apt-get -y clean
676 chroot_exec apt-get -y clean
677 chroot_exec apt-get -y autoclean
677 chroot_exec apt-get -y autoclean
678 chroot_exec apt-get -y autoremove
678 chroot_exec apt-get -y autoremove
679
679
680 # Unmount mounted filesystems
680 # Unmount mounted filesystems
681 umount -l "${R}/proc"
681 umount -l "${R}/proc"
682 umount -l "${R}/sys"
682 umount -l "${R}/sys"
683
683
684 # Clean up directories
684 # Clean up directories
685 rm -rf "${R}/run/*"
685 rm -rf "${R}/run/*"
686 rm -rf "${R}/tmp/*"
686 rm -rf "${R}/tmp/*"
687
687
688 # Clean up files
688 # Clean up files
689 rm -f "${ETC_DIR}/ssh/ssh_host_*"
689 rm -f "${ETC_DIR}/ssh/ssh_host_*"
690 rm -f "${ETC_DIR}/dropbear/dropbear_*"
690 rm -f "${ETC_DIR}/dropbear/dropbear_*"
691 rm -f "${ETC_DIR}/apt/sources.list.save"
691 rm -f "${ETC_DIR}/apt/sources.list.save"
692 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
692 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
693 rm -f "${ETC_DIR}/*-"
693 rm -f "${ETC_DIR}/*-"
694 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
694 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
695 rm -f "${ETC_DIR}/resolv.conf"
695 rm -f "${ETC_DIR}/resolv.conf"
696 rm -f "${R}/root/.bash_history"
696 rm -f "${R}/root/.bash_history"
697 rm -f "${R}/var/lib/urandom/random-seed"
697 rm -f "${R}/var/lib/urandom/random-seed"
698 rm -f "${R}/initrd.img"
698 rm -f "${R}/initrd.img"
699 rm -f "${R}/vmlinuz"
699 rm -f "${R}/vmlinuz"
700 rm -f "${R}${QEMU_BINARY}"
700 rm -f "${R}${QEMU_BINARY}"
701
701
702 if [ "$ENABLE_QEMU" = true ] ; then
702 if [ "$ENABLE_QEMU" = true ] ; then
703 # Setup QEMU directory
703 # Setup QEMU directory
704 mkdir "${BASEDIR}/qemu"
704 mkdir "${BASEDIR}/qemu"
705
705
706 # Copy kernel image to QEMU directory
706 # Copy kernel image to QEMU directory
707 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
707 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
708
708
709 # Copy kernel config to QEMU directory
709 # Copy kernel config to QEMU directory
710 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
710 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
711
711
712 # Copy kernel dtbs to QEMU directory
712 # Copy kernel dtbs to QEMU directory
713 for dtb in "${BOOT_DIR}/"*.dtb ; do
713 for dtb in "${BOOT_DIR}/"*.dtb ; do
714 if [ -f "${dtb}" ] ; then
714 if [ -f "${dtb}" ] ; then
715 install_readonly "${dtb}" "${BASEDIR}/qemu/"
715 install_readonly "${dtb}" "${BASEDIR}/qemu/"
716 fi
716 fi
717 done
717 done
718
718
719 # Copy kernel overlays to QEMU directory
719 # Copy kernel overlays to QEMU directory
720 if [ -d "${BOOT_DIR}/overlays" ] ; then
720 if [ -d "${BOOT_DIR}/overlays" ] ; then
721 # Setup overlays dtbs directory
721 # Setup overlays dtbs directory
722 mkdir "${BASEDIR}/qemu/overlays"
722 mkdir "${BASEDIR}/qemu/overlays"
723
723
724 for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do
724 for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do
725 if [ -f "${dtb}" ] ; then
725 if [ -f "${dtb}" ] ; then
726 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
726 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
727 fi
727 fi
728 done
728 done
729 fi
729 fi
730
730
731 # Copy u-boot files to QEMU directory
731 # Copy u-boot files to QEMU directory
732 if [ "$ENABLE_UBOOT" = true ] ; then
732 if [ "$ENABLE_UBOOT" = true ] ; then
733 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
733 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
734 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
734 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
735 fi
735 fi
736 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
736 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
737 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
737 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
738 fi
738 fi
739 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
739 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
740 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
740 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
741 fi
741 fi
742 fi
742 fi
743
743
744 # Copy initramfs to QEMU directory
744 # Copy initramfs to QEMU directory
745 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
745 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
746 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
746 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
747 fi
747 fi
748 fi
748 fi
749
749
750 # Calculate size of the chroot directory in KB
750 # Calculate size of the chroot directory in KB
751 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
751 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
752
752
753 # Calculate the amount of needed 512 Byte sectors
753 # Calculate the amount of needed 512 Byte sectors
754 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
754 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
755 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
755 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
756 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
756 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
757
757
758 # The root partition is EXT4
758 # The root partition is EXT4
759 # This means more space than the actual used space of the chroot is used.
759 # This means more space than the actual used space of the chroot is used.
760 # As overhead for journaling and reserved blocks 35% are added.
760 # As overhead for journaling and reserved blocks 35% are added.
761 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
761 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
762
762
763 # Calculate required image size in 512 Byte sectors
763 # Calculate required image size in 512 Byte sectors
764 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
764 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
765
765
766 # Prepare image file
766 # Prepare image file
767 if [ "$ENABLE_SPLITFS" = true ] ; then
767 if [ "$ENABLE_SPLITFS" = true ] ; then
768 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
768 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
769 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
769 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
770 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
770 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
771 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
771 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
772
772
773 # Write firmware/boot partition tables
773 # Write firmware/boot partition tables
774 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
774 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
775 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
775 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
776 EOM
776 EOM
777
777
778 # Write root partition table
778 # Write root partition table
779 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
779 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
780 ${TABLE_SECTORS},${ROOT_SECTORS},83
780 ${TABLE_SECTORS},${ROOT_SECTORS},83
781 EOM
781 EOM
782
782
783 # Setup temporary loop devices
783 # Setup temporary loop devices
784 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
784 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
785 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
785 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
786 else # ENABLE_SPLITFS=false
786 else # ENABLE_SPLITFS=false
787 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
787 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
788 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
788 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
789
789
790 # Write partition table
790 # Write partition table
791 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
791 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
792 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
792 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
793 ${ROOT_OFFSET},${ROOT_SECTORS},83
793 ${ROOT_OFFSET},${ROOT_SECTORS},83
794 EOM
794 EOM
795
795
796 # Setup temporary loop devices
796 # Setup temporary loop devices
797 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
797 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
798 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
798 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
799 fi
799 fi
800
800
801 if [ "$ENABLE_CRYPTFS" = true ] ; then
801 if [ "$ENABLE_CRYPTFS" = true ] ; then
802 # Create dummy ext4 fs
802 # Create dummy ext4 fs
803 mkfs.ext4 "$ROOT_LOOP"
803 mkfs.ext4 "$ROOT_LOOP"
804
804
805 # Setup password keyfile
805 # Setup password keyfile
806 touch .password
806 touch .password
807 chmod 600 .password
807 chmod 600 .password
808 echo -n ${CRYPTFS_PASSWORD} > .password
808 echo -n ${CRYPTFS_PASSWORD} > .password
809
809
810 # Initialize encrypted partition
810 # Initialize encrypted partition
811 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
811 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
812
812
813 # Open encrypted partition and setup mapping
813 # Open encrypted partition and setup mapping
814 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
814 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
815
815
816 # Secure delete password keyfile
816 # Secure delete password keyfile
817 shred -zu .password
817 shred -zu .password
818
818
819 # Update temporary loop device
819 # Update temporary loop device
820 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
820 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
821
821
822 # Wipe encrypted partition (encryption cipher is used for randomness)
822 # Wipe encrypted partition (encryption cipher is used for randomness)
823 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
823 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
824 fi
824 fi
825
825
826 # Build filesystems
826 # Build filesystems
827 mkfs.vfat "$FRMW_LOOP"
827 mkfs.vfat "$FRMW_LOOP"
828 mkfs.ext4 "$ROOT_LOOP"
828 mkfs.ext4 "$ROOT_LOOP"
829
829
830 # Mount the temporary loop devices
830 # Mount the temporary loop devices
831 mkdir -p "$BUILDDIR/mount"
831 mkdir -p "$BUILDDIR/mount"
832 mount "$ROOT_LOOP" "$BUILDDIR/mount"
832 mount "$ROOT_LOOP" "$BUILDDIR/mount"
833
833
834 mkdir -p "$BUILDDIR/mount/boot/firmware"
834 mkdir -p "$BUILDDIR/mount/boot/firmware"
835 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
835 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
836
836
837 # Copy all files from the chroot to the loop device mount point directory
837 # Copy all files from the chroot to the loop device mount point directory
838 rsync -a "${R}/" "$BUILDDIR/mount/"
838 rsync -a "${R}/" "$BUILDDIR/mount/"
839
839
840 # Unmount all temporary loop devices and mount points
840 # Unmount all temporary loop devices and mount points
841 cleanup
841 cleanup
842
842
843 # Create block map file(s) of image(s)
843 # Create block map file(s) of image(s)
844 if [ "$ENABLE_SPLITFS" = true ] ; then
844 if [ "$ENABLE_SPLITFS" = true ] ; then
845 # Create block map files for "bmaptool"
845 # Create block map files for "bmaptool"
846 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
846 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
847 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
847 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
848
848
849 # Image was successfully created
849 # Image was successfully created
850 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
850 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
851 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
851 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
852 else
852 else
853 # Create block map file for "bmaptool"
853 # Create block map file for "bmaptool"
854 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
854 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
855
855
856 # Image was successfully created
856 # Image was successfully created
857 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
857 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
858
858
859 # Create qemu qcow2 image
859 # Create qemu qcow2 image
860 if [ "$ENABLE_QEMU" = true ] ; then
860 if [ "$ENABLE_QEMU" = true ] ; then
861 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
861 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
862 QEMU_SIZE=16G
862 QEMU_SIZE=16G
863
863
864 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
864 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
865 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
865 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
866
866
867 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
867 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
868 fi
868 fi
869 fi
869 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant