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