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