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