@@ -19,7 +19,7 if [ "$ENABLE_MINBASE" = true ] ; then | |||
|
19 | 19 | fi |
|
20 | 20 | |
|
21 | 21 | # Base debootstrap (unpack only) |
|
22 | http_proxy=${APT_PROXY} debootstrap ${APT_EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian" | |
|
22 | http_proxy=${APT_PROXY} debootstrap "${APT_EXCLUDES}" --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian" | |
|
23 | 23 | |
|
24 | 24 | # Copy qemu emulator binary to chroot |
|
25 | 25 | install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}" |
@@ -41,13 +41,13 chroot_exec apt-get -qq -y update | |||
|
41 | 41 | chroot_exec apt-get -qq -y -u dist-upgrade |
|
42 | 42 | |
|
43 | 43 | if [ "$APT_INCLUDES_LATE" ] ; then |
|
44 | chroot_exec apt-get -qq -y install $(echo $APT_INCLUDES_LATE |tr , ' ') | |
|
44 | chroot_exec apt-get -qq -y install "$(echo "$APT_INCLUDES_LATE" |tr , ' ')" | |
|
45 | 45 | fi |
|
46 | 46 | |
|
47 | 47 | if [ -d packages ] ; then |
|
48 | 48 | for package in packages/*.deb ; do |
|
49 | cp $package ${R}/tmp | |
|
50 | chroot_exec dpkg --unpack /tmp/$(basename $package) | |
|
49 | cp "$package" "${R}"/tmp | |
|
50 | chroot_exec dpkg --unpack /tmp/"$(basename "$package")" | |
|
51 | 51 | done |
|
52 | 52 | fi |
|
53 | 53 | chroot_exec apt-get -qq -y -f install |
@@ -6,11 +6,11 | |||
|
6 | 6 | . ./functions.sh |
|
7 | 7 | |
|
8 | 8 | # Install and setup timezone |
|
9 | echo ${TIMEZONE} > "${ETC_DIR}/timezone" | |
|
9 | echo "${TIMEZONE}" > "${ETC_DIR}/timezone" | |
|
10 | 10 | chroot_exec dpkg-reconfigure -f noninteractive tzdata |
|
11 | 11 | |
|
12 | 12 | # Install and setup default locale and keyboard configuration |
|
13 | if [ $(echo "$APT_INCLUDES" | grep ",locales") ] ; then | |
|
13 | if [ "$(echo "$APT_INCLUDES" | grep ",locales")" ] ; then | |
|
14 | 14 | # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug |
|
15 | 15 | # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957 |
|
16 | 16 | # ... so we have to set locales manually |
@@ -89,30 +89,32 if [ "$BUILD_KERNEL" = true ] ; then | |||
|
89 | 89 | |
|
90 | 90 | # Set kernel configuration parameters to enable qemu emulation |
|
91 | 91 | if [ "$ENABLE_QEMU" = true ] ; then |
|
92 | echo "CONFIG_FHANDLE=y" >> ${KERNEL_DIR}/.config | |
|
93 | echo "CONFIG_LBDAF=y" >> ${KERNEL_DIR}/.config | |
|
92 | echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config | |
|
93 | echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config | |
|
94 | 94 | |
|
95 | 95 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
96 | echo "CONFIG_EMBEDDED=y" >> ${KERNEL_DIR}/.config | |
|
97 |
echo "CONFIG_E |
|
|
98 |
echo "CONFIG_ |
|
|
99 |
echo "CONFIG_ |
|
|
100 |
echo "CONFIG_ |
|
|
101 | echo "CONFIG_MD_AUTODETECT=y" >> ${KERNEL_DIR}/.config | |
|
102 | echo "CONFIG_BLK_DEV_DM=y" >> ${KERNEL_DIR}/.config | |
|
103 |
echo "CONFIG_BLK_DEV_DM |
|
|
104 | echo "CONFIG_DM_CRYPT=y" >> ${KERNEL_DIR}/.config | |
|
105 |
echo "CONFIG_CRYPT |
|
|
106 |
echo "CONFIG_CRYPTO_ |
|
|
107 |
echo "CONFIG_CRYPTO_ |
|
|
108 |
echo "CONFIG_CRYPTO_S |
|
|
109 |
echo "CONFIG_CRYPTO_ |
|
|
96 | { | |
|
97 | echo "CONFIG_EMBEDDED=y" | |
|
98 | echo "CONFIG_EXPERT=y" | |
|
99 | echo "CONFIG_DAX=y" | |
|
100 | echo "CONFIG_MD=y" | |
|
101 | echo "CONFIG_BLK_DEV_MD=y" | |
|
102 | echo "CONFIG_MD_AUTODETECT=y" | |
|
103 | echo "CONFIG_BLK_DEV_DM=y" | |
|
104 | echo "CONFIG_BLK_DEV_DM_BUILTIN=y" | |
|
105 | echo "CONFIG_DM_CRYPT=y" | |
|
106 | echo "CONFIG_CRYPTO_BLKCIPHER=y" | |
|
107 | echo "CONFIG_CRYPTO_CBC=y" | |
|
108 | echo "CONFIG_CRYPTO_XTS=y" | |
|
109 | echo "CONFIG_CRYPTO_SHA512=y" | |
|
110 | echo "CONFIG_CRYPTO_MANAGER=y" | |
|
111 | } >> ${KERNEL_DIR}/.config | |
|
110 | 112 | fi |
|
111 | 113 | fi |
|
112 | 114 | |
|
113 | 115 | # Copy custom kernel configuration file |
|
114 |
if [ |
|
|
115 | cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config | |
|
116 | if [ -n "$KERNELSRC_USRCONFIG" ] ; then | |
|
117 | cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config | |
|
116 | 118 | fi |
|
117 | 119 | |
|
118 | 120 | # Set kernel configuration parameters to their default values |
@@ -134,11 +136,11 if [ "$BUILD_KERNEL" = true ] ; then | |||
|
134 | 136 | fi |
|
135 | 137 | |
|
136 | 138 | # Cross compile kernel and dtbs |
|
137 | make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs | |
|
139 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs | |
|
138 | 140 | |
|
139 | 141 | # Cross compile kernel modules |
|
140 | if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then | |
|
141 | make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules | |
|
142 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then | |
|
143 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules | |
|
142 | 144 | fi |
|
143 | 145 | fi |
|
144 | 146 | |
@@ -151,16 +153,16 if [ "$BUILD_KERNEL" = true ] ; then | |||
|
151 | 153 | |
|
152 | 154 | # Install kernel modules |
|
153 | 155 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
154 | if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then | |
|
156 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then | |
|
155 | 157 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install |
|
156 | 158 | fi |
|
157 | 159 | else |
|
158 | if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then | |
|
160 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then | |
|
159 | 161 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install |
|
160 | 162 | fi |
|
161 | 163 | |
|
162 | 164 | # Install kernel firmware |
|
163 | if [ $(grep "^firmware_install:" "${KERNEL_DIR}/Makefile") ] ; then | |
|
165 | if [ "$(grep "^firmware_install:" "${KERNEL_DIR}/Makefile")" ] ; then | |
|
164 | 166 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install |
|
165 | 167 | fi |
|
166 | 168 | fi |
@@ -223,8 +225,8 if [ "$BUILD_KERNEL" = true ] ; then | |||
|
223 | 225 | rm -fr "${KERNEL_DIR}" |
|
224 | 226 | else |
|
225 | 227 | # Prepare compiled kernel modules |
|
226 | if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then | |
|
227 | if [ $(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile") ] ; then | |
|
228 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then | |
|
229 | if [ "$(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile")" ] ; then | |
|
228 | 230 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare |
|
229 | 231 | fi |
|
230 | 232 | |
@@ -242,7 +244,7 else # BUILD_KERNEL=false | |||
|
242 | 244 | chroot_exec apt-get -qq -y install flash-kernel |
|
243 | 245 | |
|
244 | 246 | # Check if kernel installation was successful |
|
245 | VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)" | |
|
247 | VMLINUZ="$(ls -1 "${R}"/boot/vmlinuz-* | sort | tail -n 1)" | |
|
246 | 248 | if [ -z "$VMLINUZ" ] ; then |
|
247 | 249 | echo "error: kernel installation failed! (/boot/vmlinuz-* not found)" |
|
248 | 250 | cleanup |
@@ -45,7 +45,7 if [ "$BUILD_KERNEL" = true ] && [ "$ENABLE_INITRAMFS" = true ] ; then | |||
|
45 | 45 | printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook" |
|
46 | 46 | |
|
47 | 47 | # Dummy mapping required by mkinitramfs |
|
48 | echo "0 1 crypt $(echo ${CRYPTFS_CIPHER} | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}" | |
|
48 | echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}" | |
|
49 | 49 | |
|
50 | 50 | # Generate initramfs with encrypted root partition support |
|
51 | 51 | chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}" |
@@ -8,13 +8,13 | |||
|
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 | cp ${RPI_FIRMWARE_DIR}/boot/bootcode.bin ${BOOT_DIR}/bootcode.bin | |
|
12 | cp ${RPI_FIRMWARE_DIR}/boot/fixup.dat ${BOOT_DIR}/fixup.dat | |
|
13 | cp ${RPI_FIRMWARE_DIR}/boot/fixup_cd.dat ${BOOT_DIR}/fixup_cd.dat | |
|
14 | cp ${RPI_FIRMWARE_DIR}/boot/fixup_x.dat ${BOOT_DIR}/fixup_x.dat | |
|
15 | cp ${RPI_FIRMWARE_DIR}/boot/start.elf ${BOOT_DIR}/start.elf | |
|
16 | cp ${RPI_FIRMWARE_DIR}/boot/start_cd.elf ${BOOT_DIR}/start_cd.elf | |
|
17 | cp ${RPI_FIRMWARE_DIR}/boot/start_x.elf ${BOOT_DIR}/start_x.elf | |
|
11 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin | |
|
12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat | |
|
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat | |
|
14 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat | |
|
15 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf | |
|
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf | |
|
17 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf | |
|
18 | 18 | else |
|
19 | 19 | # Create temporary directory for boot binaries |
|
20 | 20 | temp_dir=$(as_nobody mktemp -d) |
@@ -50,9 +50,9 fi | |||
|
50 | 50 | # Add encrypted root partition to cmdline.txt |
|
51 | 51 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
52 | 52 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
53 | CMDLINE=$(echo ${CMDLINE} | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") | |
|
53 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") | |
|
54 | 54 | else |
|
55 | CMDLINE=$(echo ${CMDLINE} | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") | |
|
55 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") | |
|
56 | 56 | fi |
|
57 | 57 | fi |
|
58 | 58 | |
@@ -139,7 +139,7 if [ "$ENABLE_SPI" = true ] ; then | |||
|
139 | 139 | fi |
|
140 | 140 | |
|
141 | 141 | # Disable RPi2/3 under-voltage warnings |
|
142 |
if [ |
|
|
142 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
|
143 | 143 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" |
|
144 | 144 | fi |
|
145 | 145 |
@@ -28,6 +28,6 if [ "$ENABLE_VIDEOCORE" = true ] ; then | |||
|
28 | 28 | fi |
|
29 | 29 | |
|
30 | 30 | 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 -DVIDEOCORE_BUILD_DIR="${R}"/opt/vc |
|
31 | make -j $(nproc) | |
|
32 | chroot_exec PATH=${PATH}:/opt/vc/bin | |
|
31 | make -j "$(nproc)" | |
|
32 | chroot_exec PATH="${PATH}":/opt/vc/bin | |
|
33 | 33 | fi |
@@ -89,14 +89,14 if [ "$ENABLE_HARDNET" = true ] ; then | |||
|
89 | 89 | fi |
|
90 | 90 | |
|
91 | 91 | # Enable time sync |
|
92 | if [ "NET_NTP_1" != "" ] ; then | |
|
92 | if [ "$NET_NTP_1" != "" ] ; then | |
|
93 | 93 | chroot_exec systemctl enable systemd-timesyncd.service |
|
94 | 94 | fi |
|
95 | 95 | |
|
96 | 96 | # Download the firmware binary blob required to use the RPi3 wireless interface |
|
97 | 97 | if [ "$ENABLE_WIRELESS" = true ] ; then |
|
98 | if [ ! -d ${WLAN_FIRMWARE_DIR} ] ; then | |
|
99 | mkdir -p ${WLAN_FIRMWARE_DIR} | |
|
98 | if [ ! -d "${WLAN_FIRMWARE_DIR}" ] ; then | |
|
99 | mkdir -p "${WLAN_FIRMWARE_DIR}" | |
|
100 | 100 | fi |
|
101 | 101 | |
|
102 | 102 | # Create temporary directory for firmware binary blob |
@@ -31,7 +31,7 fi | |||
|
31 | 31 | . ./functions.sh |
|
32 | 32 | |
|
33 | 33 | # Load parameters from configuration template file |
|
34 |
if [ |
|
|
34 | if [ -n "$CONFIG_TEMPLATE" ] ; then | |
|
35 | 35 | use_template |
|
36 | 36 | fi |
|
37 | 37 | |
@@ -297,7 +297,7 if [ "$ENABLE_WIRELESS" = true ] && ([ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P | |||
|
297 | 297 | fi |
|
298 | 298 | |
|
299 | 299 | # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported |
|
300 |
if [ |
|
|
300 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
|
301 | 301 | if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then |
|
302 | 302 | echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported" |
|
303 | 303 | exit 1 |
@@ -361,7 +361,7 if [ "$ENABLE_UBOOT" = true ] ; then | |||
|
361 | 361 | fi |
|
362 | 362 | |
|
363 | 363 | # Check if root SSH (v2) public key file exists |
|
364 |
if [ |
|
|
364 | if [ -n "$SSH_ROOT_PUB_KEY" ] ; then | |
|
365 | 365 | if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then |
|
366 | 366 | echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!" |
|
367 | 367 | exit 1 |
@@ -369,7 +369,7 if [ ! -z "$SSH_ROOT_PUB_KEY" ] ; then | |||
|
369 | 369 | fi |
|
370 | 370 | |
|
371 | 371 | # Check if $USER_NAME SSH (v2) public key file exists |
|
372 |
if [ |
|
|
372 | if [ -n "$SSH_USER_PUB_KEY" ] ; then | |
|
373 | 373 | if [ ! -f "$SSH_USER_PUB_KEY" ] ; then |
|
374 | 374 | echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!" |
|
375 | 375 | exit 1 |
@@ -378,7 +378,7 fi | |||
|
378 | 378 | |
|
379 | 379 | # Check if all required packages are installed on the build system |
|
380 | 380 | for package in $REQUIRED_PACKAGES ; do |
|
381 |
if [ " |
|
|
381 | if [ "$(dpkg-query -W -f='${Status}' $package)" != "install ok installed" ] ; then | |
|
382 | 382 | MISSING_PACKAGES="${MISSING_PACKAGES} $package" |
|
383 | 383 | fi |
|
384 | 384 | done |
@@ -388,12 +388,12 if [ -n "$MISSING_PACKAGES" ] ; then | |||
|
388 | 388 | echo "the following packages needed by this script are not installed:" |
|
389 | 389 | echo "$MISSING_PACKAGES" |
|
390 | 390 | |
|
391 |
|
|
|
392 | read confirm | |
|
391 | printf "\n\ndo you want to install the missing packages right now? [y/n] " | |
|
392 | read -r confirm | |
|
393 | 393 | [ "$confirm" != "y" ] && exit 1 |
|
394 | 394 | |
|
395 | 395 | # Make sure all missing required packages are installed |
|
396 | apt-get -qq -y install ${MISSING_PACKAGES} | |
|
396 | apt-get -qq -y install "${MISSING_PACKAGES}" | |
|
397 | 397 | fi |
|
398 | 398 | |
|
399 | 399 | # Check if ./bootstrap.d directory exists |
@@ -454,7 +454,7 fi | |||
|
454 | 454 | mkdir -p "${R}" |
|
455 | 455 | |
|
456 | 456 | # Check if build directory has enough of free disk space >512MB |
|
457 | if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then | |
|
457 | if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then | |
|
458 | 458 | echo "error: ${BUILDDIR} not enough space left to generate the output image!" |
|
459 | 459 | exit 1 |
|
460 | 460 | fi |
@@ -532,7 +532,7 if [ "$ENABLE_REDUCE" = true ] ; then | |||
|
532 | 532 | |
|
533 | 533 | # Add dropbear package instead of openssh-server |
|
534 | 534 | if [ "$REDUCE_SSHD" = true ] ; then |
|
535 | APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/openssh-server/dropbear/")" | |
|
535 | APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" | |
|
536 | 536 | fi |
|
537 | 537 | fi |
|
538 | 538 | |
@@ -675,27 +675,27 if [ "$ENABLE_QEMU" = true ] ; then | |||
|
675 | 675 | fi |
|
676 | 676 | |
|
677 | 677 | # Calculate size of the chroot directory in KB |
|
678 |
CHROOT_SIZE=$(expr |
|
|
678 | CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')") | |
|
679 | 679 | |
|
680 | 680 | # Calculate the amount of needed 512 Byte sectors |
|
681 | 681 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) |
|
682 | 682 | FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512) |
|
683 | ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS}) | |
|
683 | ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}") | |
|
684 | 684 | |
|
685 | 685 | # The root partition is EXT4 |
|
686 | 686 | # This means more space than the actual used space of the chroot is used. |
|
687 | 687 | # As overhead for journaling and reserved blocks 35% are added. |
|
688 | ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 35) \* 1024 \/ 512) | |
|
688 | ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512) | |
|
689 | 689 | |
|
690 | 690 | # Calculate required image size in 512 Byte sectors |
|
691 | IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS}) | |
|
691 | IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}") | |
|
692 | 692 | |
|
693 | 693 | # Prepare image file |
|
694 | 694 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
695 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=${TABLE_SECTORS} | |
|
696 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS} | |
|
697 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=${TABLE_SECTORS} | |
|
698 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek=${ROOT_SECTORS} | |
|
695 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}" | |
|
696 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}" | |
|
697 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" | |
|
698 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}" | |
|
699 | 699 | |
|
700 | 700 | # Write firmware/boot partition tables |
|
701 | 701 | sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM |
@@ -708,11 +708,11 ${TABLE_SECTORS},${ROOT_SECTORS},83 | |||
|
708 | 708 | EOM |
|
709 | 709 | |
|
710 | 710 | # Setup temporary loop devices |
|
711 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME-frmw.img)" | |
|
712 | ROOT_LOOP="$(losetup -o 1M -f --show $IMAGE_NAME-root.img)" | |
|
711 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME-frmw.img")" | |
|
712 | ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME-root.img")" | |
|
713 | 713 | else # ENABLE_SPLITFS=false |
|
714 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=${TABLE_SECTORS} | |
|
715 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek=${IMAGE_SECTORS} | |
|
714 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}" | |
|
715 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}" | |
|
716 | 716 | |
|
717 | 717 | # Write partition table |
|
718 | 718 | sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM |
@@ -721,8 +721,8 ${ROOT_OFFSET},${ROOT_SECTORS},83 | |||
|
721 | 721 | EOM |
|
722 | 722 | |
|
723 | 723 | # Setup temporary loop devices |
|
724 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME.img)" | |
|
725 | ROOT_LOOP="$(losetup -o 65M -f --show $IMAGE_NAME.img)" | |
|
724 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME.img")" | |
|
725 | ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME.img")" | |
|
726 | 726 | fi |
|
727 | 727 | |
|
728 | 728 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
@@ -747,7 +747,7 if [ "$ENABLE_CRYPTFS" = true ] ; then | |||
|
747 | 747 | ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}" |
|
748 | 748 | |
|
749 | 749 | # Wipe encrypted partition (encryption cipher is used for randomness) |
|
750 | dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count=$(blockdev --getsz "${ROOT_LOOP}") | |
|
750 | dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")" | |
|
751 | 751 | fi |
|
752 | 752 | |
|
753 | 753 | # Build filesystems |
@@ -774,22 +774,22 if [ "$ENABLE_SPLITFS" = true ] ; then | |||
|
774 | 774 | bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img" |
|
775 | 775 | |
|
776 | 776 | # Image was successfully created |
|
777 | echo "$IMAGE_NAME-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
|
778 | echo "$IMAGE_NAME-root.img ($(expr \( ${TABLE_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
|
777 | echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
|
778 | echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
|
779 | 779 | else |
|
780 | 780 | # Create block map file for "bmaptool" |
|
781 | 781 | bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img" |
|
782 | 782 | |
|
783 | 783 | # Image was successfully created |
|
784 | echo "$IMAGE_NAME.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
|
784 | echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
|
785 | 785 | |
|
786 | 786 | # Create qemu qcow2 image |
|
787 | 787 | if [ "$ENABLE_QEMU" = true ] ; then |
|
788 | 788 | QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
789 | 789 | QEMU_SIZE=16G |
|
790 | 790 | |
|
791 | qemu-img convert -f raw -O qcow2 $IMAGE_NAME.img $QEMU_IMAGE.qcow2 | |
|
792 | qemu-img resize $QEMU_IMAGE.qcow2 $QEMU_SIZE | |
|
791 | qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2 | |
|
792 | qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE | |
|
793 | 793 | |
|
794 | 794 | echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created" |
|
795 | 795 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant