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