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