@@ -1,255 +1,255 | |||
|
1 | 1 | # |
|
2 | 2 | # Build and Setup RPi2/3 Kernel |
|
3 | 3 | # |
|
4 | 4 | |
|
5 | 5 | # Load utility functions |
|
6 | 6 | . ./functions.sh |
|
7 | 7 | |
|
8 | 8 | # Fetch and build latest raspberry kernel |
|
9 | 9 | if [ "$BUILD_KERNEL" = true ] ; then |
|
10 | 10 | # Setup source directory |
|
11 | mkdir -p "${R}/usr/src/linux" | |
|
11 | mkdir -p "${KERNEL_DIR}" | |
|
12 | 12 | |
|
13 | 13 | # Copy existing kernel sources into chroot directory |
|
14 | 14 | if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then |
|
15 | 15 | # Copy kernel sources and include hidden files |
|
16 |
cp -r "${KERNELSRC_DIR}/". "${R} |
|
|
16 | cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}" | |
|
17 | 17 | |
|
18 | 18 | # Clean the kernel sources |
|
19 | 19 | if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then |
|
20 | 20 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper |
|
21 | 21 | fi |
|
22 | 22 | else # KERNELSRC_DIR="" |
|
23 | 23 | # Create temporary directory for kernel sources |
|
24 | 24 | temp_dir=$(as_nobody mktemp -d) |
|
25 | 25 | |
|
26 | 26 | # Fetch current RPi2/3 kernel sources |
|
27 | 27 | if [ -z "${KERNEL_BRANCH}" ] ; then |
|
28 | 28 | as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux |
|
29 | 29 | else |
|
30 | 30 | as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux |
|
31 | 31 | fi |
|
32 | 32 | |
|
33 | 33 | # Copy downloaded kernel sources |
|
34 |
cp -r "${temp_dir}/linux/"* "${R} |
|
|
34 | cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}" | |
|
35 | 35 | |
|
36 | 36 | # Remove temporary directory for kernel sources |
|
37 | 37 | rm -fr "${temp_dir}" |
|
38 | 38 | |
|
39 | 39 | # Set permissions of the kernel sources |
|
40 | 40 | chown -R root:root "${R}/usr/src" |
|
41 | 41 | fi |
|
42 | 42 | |
|
43 | 43 | # Calculate optimal number of kernel building threads |
|
44 | 44 | if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then |
|
45 | 45 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) |
|
46 | 46 | fi |
|
47 | 47 | |
|
48 | 48 | # Configure and build kernel |
|
49 | 49 | if [ "$KERNELSRC_PREBUILT" = false ] ; then |
|
50 | 50 | # Remove device, network and filesystem drivers from kernel configuration |
|
51 | 51 | if [ "$KERNEL_REDUCE" = true ] ; then |
|
52 | 52 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" |
|
53 | 53 | sed -i\ |
|
54 | 54 | -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\ |
|
55 | 55 | -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\ |
|
56 | 56 | -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\ |
|
57 | 57 | -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\ |
|
58 | 58 | -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\ |
|
59 | 59 | -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\ |
|
60 | 60 | -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\ |
|
61 | 61 | -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\ |
|
62 | 62 | -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\ |
|
63 | 63 | -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\ |
|
64 | 64 | -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\ |
|
65 | 65 | -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\ |
|
66 | 66 | -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\ |
|
67 | 67 | -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\ |
|
68 | 68 | -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\ |
|
69 | 69 | -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\ |
|
70 | 70 | -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\ |
|
71 | 71 | -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\ |
|
72 | 72 | -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\ |
|
73 | 73 | -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\ |
|
74 | 74 | -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\ |
|
75 | 75 | -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\ |
|
76 | 76 | -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\ |
|
77 | 77 | -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\ |
|
78 | 78 | -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\ |
|
79 | 79 | -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\ |
|
80 | 80 | -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\ |
|
81 | 81 | -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\ |
|
82 | 82 | -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\ |
|
83 | 83 | "${KERNEL_DIR}/.config" |
|
84 | 84 | fi |
|
85 | 85 | |
|
86 | 86 | if [ "$KERNELSRC_CONFIG" = true ] ; then |
|
87 | 87 | # Load default raspberry kernel configuration |
|
88 | 88 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" |
|
89 | 89 | |
|
90 | 90 | # Set kernel configuration parameters to enable qemu emulation |
|
91 | 91 | if [ "$ENABLE_QEMU" = true ] ; then |
|
92 | 92 | echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config |
|
93 | 93 | echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config |
|
94 | 94 | |
|
95 | 95 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
96 | 96 | { |
|
97 | 97 | echo "CONFIG_EMBEDDED=y" |
|
98 | 98 | echo "CONFIG_EXPERT=y" |
|
99 | 99 | echo "CONFIG_DAX=y" |
|
100 | 100 | echo "CONFIG_MD=y" |
|
101 | 101 | echo "CONFIG_BLK_DEV_MD=y" |
|
102 | 102 | echo "CONFIG_MD_AUTODETECT=y" |
|
103 | 103 | echo "CONFIG_BLK_DEV_DM=y" |
|
104 | 104 | echo "CONFIG_BLK_DEV_DM_BUILTIN=y" |
|
105 | 105 | echo "CONFIG_DM_CRYPT=y" |
|
106 | 106 | echo "CONFIG_CRYPTO_BLKCIPHER=y" |
|
107 | 107 | echo "CONFIG_CRYPTO_CBC=y" |
|
108 | 108 | echo "CONFIG_CRYPTO_XTS=y" |
|
109 | 109 | echo "CONFIG_CRYPTO_SHA512=y" |
|
110 | 110 | echo "CONFIG_CRYPTO_MANAGER=y" |
|
111 | 111 | } >> ${KERNEL_DIR}/.config |
|
112 | 112 | fi |
|
113 | 113 | fi |
|
114 | 114 | |
|
115 | 115 | # Copy custom kernel configuration file |
|
116 | 116 | if [ -n "$KERNELSRC_USRCONFIG" ] ; then |
|
117 | 117 | cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config |
|
118 | 118 | fi |
|
119 | 119 | |
|
120 | 120 | # Set kernel configuration parameters to their default values |
|
121 | 121 | if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then |
|
122 | 122 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig |
|
123 | 123 | fi |
|
124 | 124 | |
|
125 | 125 | # Start menu-driven kernel configuration (interactive) |
|
126 | 126 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
127 | 127 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig |
|
128 | 128 | fi |
|
129 | 129 | fi |
|
130 | 130 | |
|
131 | 131 | # Use ccache to cross compile the kernel |
|
132 | 132 | if [ "$KERNEL_CCACHE" = true ] ; then |
|
133 | 133 | cc="ccache ${CROSS_COMPILE}gcc" |
|
134 | 134 | else |
|
135 | 135 | cc="${CROSS_COMPILE}gcc" |
|
136 | 136 | fi |
|
137 | 137 | |
|
138 | 138 | # Cross compile kernel and dtbs |
|
139 | 139 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs |
|
140 | 140 | |
|
141 | 141 | # Cross compile kernel modules |
|
142 | 142 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then |
|
143 | 143 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules |
|
144 | 144 | fi |
|
145 | 145 | fi |
|
146 | 146 | |
|
147 | 147 | # Check if kernel compilation was successful |
|
148 | 148 | if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then |
|
149 | 149 | echo "error: kernel compilation failed! (kernel image not found)" |
|
150 | 150 | cleanup |
|
151 | 151 | exit 1 |
|
152 | 152 | fi |
|
153 | 153 | |
|
154 | 154 | # Install kernel modules |
|
155 | 155 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
156 | 156 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then |
|
157 | 157 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install |
|
158 | 158 | fi |
|
159 | 159 | else |
|
160 | 160 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then |
|
161 | 161 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install |
|
162 | 162 | fi |
|
163 | 163 | |
|
164 | 164 | # Install kernel firmware |
|
165 | 165 | if [ "$(grep "^firmware_install:" "${KERNEL_DIR}/Makefile")" ] ; then |
|
166 | 166 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install |
|
167 | 167 | fi |
|
168 | 168 | fi |
|
169 | 169 | |
|
170 | 170 | # Install kernel headers |
|
171 | 171 | if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then |
|
172 | 172 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install |
|
173 | 173 | fi |
|
174 | 174 | |
|
175 | 175 | # Prepare boot (firmware) directory |
|
176 | 176 | mkdir "${BOOT_DIR}" |
|
177 | 177 | |
|
178 | 178 | # Get kernel release version |
|
179 | 179 | KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release") |
|
180 | 180 | |
|
181 | 181 | # Copy kernel configuration file to the boot directory |
|
182 | 182 | install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}" |
|
183 | 183 | |
|
184 | 184 | # Prepare device tree directory |
|
185 | 185 | mkdir "${BOOT_DIR}/overlays" |
|
186 | 186 | |
|
187 | 187 | # Ensure the proper .dtb is located |
|
188 | 188 | if [ "$KERNEL_ARCH" = "arm" ] ; then |
|
189 | 189 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do |
|
190 | 190 | if [ -f "${dtb}" ] ; then |
|
191 | 191 | install_readonly "${dtb}" "${BOOT_DIR}/" |
|
192 | 192 | fi |
|
193 | 193 | done |
|
194 | 194 | else |
|
195 | 195 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do |
|
196 | 196 | if [ -f "${dtb}" ] ; then |
|
197 | 197 | install_readonly "${dtb}" "${BOOT_DIR}/" |
|
198 | 198 | fi |
|
199 | 199 | done |
|
200 | 200 | fi |
|
201 | 201 | |
|
202 | 202 | # Copy compiled dtb device tree files |
|
203 | 203 | if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then |
|
204 | 204 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do |
|
205 | 205 | if [ -f "${dtb}" ] ; then |
|
206 | 206 | install_readonly "${dtb}" "${BOOT_DIR}/overlays/" |
|
207 | 207 | fi |
|
208 | 208 | done |
|
209 | 209 | |
|
210 | 210 | if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then |
|
211 | 211 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README" |
|
212 | 212 | fi |
|
213 | 213 | fi |
|
214 | 214 | |
|
215 | 215 | if [ "$ENABLE_UBOOT" = false ] ; then |
|
216 | 216 | # Convert and copy kernel image to the boot directory |
|
217 | 217 | "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
218 | 218 | else |
|
219 | 219 | # Copy kernel image to the boot directory |
|
220 | 220 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
221 | 221 | fi |
|
222 | 222 | |
|
223 | 223 | # Remove kernel sources |
|
224 | 224 | if [ "$KERNEL_REMOVESRC" = true ] ; then |
|
225 | 225 | rm -fr "${KERNEL_DIR}" |
|
226 | 226 | else |
|
227 | 227 | # Prepare compiled kernel modules |
|
228 | 228 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then |
|
229 | 229 | if [ "$(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile")" ] ; then |
|
230 | 230 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare |
|
231 | 231 | fi |
|
232 | 232 | |
|
233 | 233 | # Create symlinks for kernel modules |
|
234 | 234 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build" |
|
235 | 235 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source" |
|
236 | 236 | fi |
|
237 | 237 | fi |
|
238 | 238 | |
|
239 | 239 | else # BUILD_KERNEL=false |
|
240 | 240 | # Kernel installation |
|
241 | 241 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel |
|
242 | 242 | |
|
243 | 243 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot |
|
244 | 244 | chroot_exec apt-get -qq -y install flash-kernel |
|
245 | 245 | |
|
246 | 246 | # Check if kernel installation was successful |
|
247 | 247 | VMLINUZ="$(ls -1 "${R}"/boot/vmlinuz-* | sort | tail -n 1)" |
|
248 | 248 | if [ -z "$VMLINUZ" ] ; then |
|
249 | 249 | echo "error: kernel installation failed! (/boot/vmlinuz-* not found)" |
|
250 | 250 | cleanup |
|
251 | 251 | exit 1 |
|
252 | 252 | fi |
|
253 | 253 | # Copy vmlinuz kernel to the boot directory |
|
254 | 254 | install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
255 | 255 | fi |
@@ -1,796 +1,796 | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | |
|
3 | 3 | ######################################################################## |
|
4 | 4 | # rpi23-gen-image.sh 2015-2017 |
|
5 | 5 | # |
|
6 | 6 | # Advanced Debian "jessie", "stretch" and "buster" bootstrap script for RPi2/3 |
|
7 | 7 | # |
|
8 | 8 | # This program is free software; you can redistribute it and/or |
|
9 | 9 | # modify it under the terms of the GNU General Public License |
|
10 | 10 | # as published by the Free Software Foundation; either version 2 |
|
11 | 11 | # of the License, or (at your option) any later version. |
|
12 | 12 | # |
|
13 | 13 | # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu> |
|
14 | 14 | # |
|
15 | 15 | # Big thanks for patches and enhancements by 20+ github contributors! |
|
16 | 16 | ######################################################################## |
|
17 | 17 | |
|
18 | 18 | # Are we running as root? |
|
19 | 19 | if [ "$(id -u)" -ne "0" ] ; then |
|
20 | 20 | echo "error: this script must be executed with root privileges!" |
|
21 | 21 | exit 1 |
|
22 | 22 | fi |
|
23 | 23 | |
|
24 | 24 | # Check if ./functions.sh script exists |
|
25 | 25 | if [ ! -r "./functions.sh" ] ; then |
|
26 | 26 | echo "error: './functions.sh' required script not found!" |
|
27 | 27 | exit 1 |
|
28 | 28 | fi |
|
29 | 29 | |
|
30 | 30 | # Load utility functions |
|
31 | 31 | . ./functions.sh |
|
32 | 32 | |
|
33 | 33 | # Load parameters from configuration template file |
|
34 | 34 | if [ -n "$CONFIG_TEMPLATE" ] ; then |
|
35 | 35 | use_template |
|
36 | 36 | fi |
|
37 | 37 | |
|
38 | 38 | # Introduce settings |
|
39 | 39 | set -e |
|
40 | 40 | echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n" |
|
41 | 41 | set -x |
|
42 | 42 | |
|
43 | 43 | # Raspberry Pi model configuration |
|
44 | 44 | RPI_MODEL=${RPI_MODEL:=2} |
|
45 | 45 | |
|
46 | 46 | #bcm2708-rpi-0-w.dtb (Used for Pi 0 and PI 0W) |
|
47 | 47 | RPI0_DTB_FILE=${RPI0_DTB_FILE:=bcm2708-rpi-0-w.dtb} |
|
48 | 48 | RPI0_UBOOT_CONFIG=${RPI0_UBOOT_CONFIG:=rpi_defconfig} |
|
49 | 49 | |
|
50 | 50 | #bcm2708-rpi-b.dtb (Used for Pi 1 model A and B) |
|
51 | 51 | RPI1_DTB_FILE=${RPI1_DTB_FILE:=bcm2708-rpi-b.dtb} |
|
52 | 52 | RPI1_UBOOT_CONFIG=${RPI1_UBOOT_CONFIG:=rpi_defconfig} |
|
53 | 53 | |
|
54 | 54 | #bcm2708-rpi-b-plus.dtb (Used for Pi 1 model B+ and A+) |
|
55 | 55 | RPI1P_DTB_FILE=${RPI1P_DTB_FILE:=bcm2708-rpi-b-plus.dtb} |
|
56 | 56 | RPI1P_UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG:=rpi_defconfig} |
|
57 | 57 | |
|
58 | 58 | #bcm2709-rpi-2-b.dtb (Used for Pi 2 model B) |
|
59 | 59 | RPI2_DTB_FILE=${RPI2_DTB_FILE:=bcm2709-rpi-2-b.dtb} |
|
60 | 60 | RPI2_UBOOT_CONFIG=${RPI2_UBOOT_CONFIG:=rpi_2_defconfig} |
|
61 | 61 | |
|
62 | 62 | #bcm2710-rpi-3-b.dtb (Used for Pi 3 model B) |
|
63 | 63 | RPI3_DTB_FILE=${RPI3_DTB_FILE:=bcm2710-rpi-3-b.dtb} |
|
64 | 64 | RPI3_UBOOT_CONFIG=${RPI3_UBOOT_CONFIG:=rpi_3_32b_defconfig} |
|
65 | 65 | |
|
66 | 66 | #bcm2710-rpi-3-b-plus.dtb (Used for Pi 3 model B+) |
|
67 | 67 | RPI3P_DTB_FILE=${RPI3P_DTB_FILE:=bcm2710-rpi-3-b-plus.dtb} |
|
68 | 68 | RPI3P_UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG:=rpi_3_32b_defconfig} |
|
69 | 69 | |
|
70 | 70 | # Debian release |
|
71 | 71 | RELEASE=${RELEASE:=jessie} |
|
72 | 72 | KERNEL_ARCH=${KERNEL_ARCH:=arm} |
|
73 | 73 | RELEASE_ARCH=${RELEASE_ARCH:=armhf} |
|
74 | 74 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} |
|
75 | 75 | COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2} |
|
76 | 76 | if [ "$KERNEL_ARCH" = "arm64" ] ; then |
|
77 | 77 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} |
|
78 | 78 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} |
|
79 | 79 | fi |
|
80 | 80 | |
|
81 | 81 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then |
|
82 | 82 | #RASPBERRY PI 1, PI ZERO, PI ZERO W, AND COMPUTE MODULE DEFAULT Kernel BUILD CONFIGURATION |
|
83 | 83 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} |
|
84 | 84 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} |
|
85 | 85 | else |
|
86 | 86 | #RASPBERRY PI 2, PI 3, PI 3+, AND COMPUTE MODULE 3 DEFAULT Kernel BUILD CONFIGURATION |
|
87 | 87 | #https://www.raspberrypi.org/documentation/linux/kernel/building.md |
|
88 | 88 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} |
|
89 | 89 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} |
|
90 | 90 | fi |
|
91 | 91 | |
|
92 | 92 | if [ "$RELEASE_ARCH" = "arm64" ] ; then |
|
93 | 93 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} |
|
94 | 94 | else |
|
95 | 95 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} |
|
96 | 96 | fi |
|
97 | 97 | KERNEL_BRANCH=${KERNEL_BRANCH:=""} |
|
98 | 98 | |
|
99 | 99 | # URLs |
|
100 | 100 | KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} |
|
101 | 101 | FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} |
|
102 | 102 | WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} |
|
103 | 103 | COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian} |
|
104 | 104 | FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} |
|
105 | 105 | UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} |
|
106 | 106 | VIDEOCORE_URL=${VIDEOCORE_URL=https://github.com/raspberrypi/userland} |
|
107 | 107 | |
|
108 | 108 | # Build directories |
|
109 | 109 | BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}} |
|
110 | 110 | BUILDDIR="${BASEDIR}/build" |
|
111 | 111 | |
|
112 | 112 | # Prepare date string for default image file name |
|
113 | 113 | DATE="$(date +%Y-%m-%d)" |
|
114 | 114 | if [ -z "$KERNEL_BRANCH" ] ; then |
|
115 | 115 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
116 | 116 | else |
|
117 | 117 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
118 | 118 | fi |
|
119 | 119 | |
|
120 | 120 | # Chroot directories |
|
121 | 121 | R="${BUILDDIR}/chroot" |
|
122 | 122 | ETC_DIR="${R}/etc" |
|
123 | 123 | LIB_DIR="${R}/lib" |
|
124 | 124 | BOOT_DIR="${R}/boot/firmware" |
|
125 | 125 | KERNEL_DIR="${R}/usr/src/linux" |
|
126 |
WLAN_FIRMWARE_DIR="${R} |
|
|
126 | WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm" | |
|
127 | 127 | |
|
128 | 128 | # Firmware directory: Blank if download from github |
|
129 | 129 | RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} |
|
130 | 130 | |
|
131 | 131 | # General settings |
|
132 | 132 | HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} |
|
133 | 133 | PASSWORD=${PASSWORD:=raspberry} |
|
134 | 134 | USER_PASSWORD=${USER_PASSWORD:=raspberry} |
|
135 | 135 | DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} |
|
136 | 136 | TIMEZONE=${TIMEZONE:="Europe/Berlin"} |
|
137 | 137 | EXPANDROOT=${EXPANDROOT:=true} |
|
138 | 138 | |
|
139 | 139 | # Keyboard settings |
|
140 | 140 | XKB_MODEL=${XKB_MODEL:=""} |
|
141 | 141 | XKB_LAYOUT=${XKB_LAYOUT:=""} |
|
142 | 142 | XKB_VARIANT=${XKB_VARIANT:=""} |
|
143 | 143 | XKB_OPTIONS=${XKB_OPTIONS:=""} |
|
144 | 144 | |
|
145 | 145 | # Network settings (DHCP) |
|
146 | 146 | ENABLE_DHCP=${ENABLE_DHCP:=true} |
|
147 | 147 | |
|
148 | 148 | # Network settings (static) |
|
149 | 149 | NET_ADDRESS=${NET_ADDRESS:=""} |
|
150 | 150 | NET_GATEWAY=${NET_GATEWAY:=""} |
|
151 | 151 | NET_DNS_1=${NET_DNS_1:=""} |
|
152 | 152 | NET_DNS_2=${NET_DNS_2:=""} |
|
153 | 153 | NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} |
|
154 | 154 | NET_NTP_1=${NET_NTP_1:=""} |
|
155 | 155 | NET_NTP_2=${NET_NTP_2:=""} |
|
156 | 156 | |
|
157 | 157 | # APT settings |
|
158 | 158 | APT_PROXY=${APT_PROXY:=""} |
|
159 | 159 | APT_SERVER=${APT_SERVER:="ftp.debian.org"} |
|
160 | 160 | |
|
161 | 161 | # Feature settings |
|
162 | 162 | ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} |
|
163 | 163 | ENABLE_I2C=${ENABLE_I2C:=false} |
|
164 | 164 | ENABLE_SPI=${ENABLE_SPI:=false} |
|
165 | 165 | ENABLE_IPV6=${ENABLE_IPV6:=true} |
|
166 | 166 | ENABLE_SSHD=${ENABLE_SSHD:=true} |
|
167 | 167 | ENABLE_NONFREE=${ENABLE_NONFREE:=false} |
|
168 | 168 | ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} |
|
169 | 169 | ENABLE_SOUND=${ENABLE_SOUND:=true} |
|
170 | 170 | ENABLE_DBUS=${ENABLE_DBUS:=true} |
|
171 | 171 | ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} |
|
172 | 172 | ENABLE_MINGPU=${ENABLE_MINGPU:=false} |
|
173 | 173 | ENABLE_XORG=${ENABLE_XORG:=false} |
|
174 | 174 | ENABLE_WM=${ENABLE_WM:=""} |
|
175 | 175 | ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} |
|
176 | 176 | ENABLE_USER=${ENABLE_USER:=true} |
|
177 | 177 | USER_NAME=${USER_NAME:="pi"} |
|
178 | 178 | ENABLE_ROOT=${ENABLE_ROOT:=false} |
|
179 | 179 | ENABLE_QEMU=${ENABLE_QEMU:=false} |
|
180 | 180 | ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false} |
|
181 | 181 | |
|
182 | 182 | # SSH settings |
|
183 | 183 | SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} |
|
184 | 184 | SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} |
|
185 | 185 | SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} |
|
186 | 186 | SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} |
|
187 | 187 | SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} |
|
188 | 188 | |
|
189 | 189 | # Advanced settings |
|
190 | 190 | ENABLE_MINBASE=${ENABLE_MINBASE:=false} |
|
191 | 191 | ENABLE_REDUCE=${ENABLE_REDUCE:=false} |
|
192 | 192 | ENABLE_UBOOT=${ENABLE_UBOOT:=false} |
|
193 | 193 | UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} |
|
194 | 194 | ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} |
|
195 | 195 | ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=true} |
|
196 | 196 | VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} |
|
197 | 197 | FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} |
|
198 | 198 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} |
|
199 | 199 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} |
|
200 | 200 | ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} |
|
201 | 201 | ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} |
|
202 | 202 | ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} |
|
203 | 203 | DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} |
|
204 | 204 | |
|
205 | 205 | # Kernel compilation settings |
|
206 | 206 | BUILD_KERNEL=${BUILD_KERNEL:=false} |
|
207 | 207 | KERNEL_REDUCE=${KERNEL_REDUCE:=false} |
|
208 | 208 | KERNEL_THREADS=${KERNEL_THREADS:=1} |
|
209 | 209 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} |
|
210 | 210 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} |
|
211 | 211 | KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} |
|
212 | 212 | KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} |
|
213 | 213 | KERNEL_CCACHE=${KERNEL_CCACHE:=false} |
|
214 | 214 | |
|
215 | 215 | if [ "$KERNEL_ARCH" = "arm64" ] ; then |
|
216 | 216 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} |
|
217 | 217 | else |
|
218 | 218 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} |
|
219 | 219 | fi |
|
220 | 220 | |
|
221 | 221 | # Kernel compilation from source directory settings |
|
222 | 222 | KERNELSRC_DIR=${KERNELSRC_DIR:=""} |
|
223 | 223 | KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} |
|
224 | 224 | KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} |
|
225 | 225 | KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} |
|
226 | 226 | |
|
227 | 227 | # Reduce disk usage settings |
|
228 | 228 | REDUCE_APT=${REDUCE_APT:=true} |
|
229 | 229 | REDUCE_DOC=${REDUCE_DOC:=true} |
|
230 | 230 | REDUCE_MAN=${REDUCE_MAN:=true} |
|
231 | 231 | REDUCE_VIM=${REDUCE_VIM:=false} |
|
232 | 232 | REDUCE_BASH=${REDUCE_BASH:=false} |
|
233 | 233 | REDUCE_HWDB=${REDUCE_HWDB:=true} |
|
234 | 234 | REDUCE_SSHD=${REDUCE_SSHD:=true} |
|
235 | 235 | REDUCE_LOCALE=${REDUCE_LOCALE:=true} |
|
236 | 236 | |
|
237 | 237 | # Encrypted filesystem settings |
|
238 | 238 | ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false} |
|
239 | 239 | CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""} |
|
240 | 240 | CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"} |
|
241 | 241 | CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"} |
|
242 | 242 | CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512} |
|
243 | 243 | |
|
244 | 244 | # Chroot scripts directory |
|
245 | 245 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} |
|
246 | 246 | |
|
247 | 247 | # Packages required in the chroot build environment |
|
248 | 248 | APT_INCLUDES=${APT_INCLUDES:=""} |
|
249 | 249 | APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils" |
|
250 | 250 | |
|
251 | 251 | #Packages to exclude from chroot build environment |
|
252 | 252 | APT_EXCLUDES=${APT_EXCLUDES:=""} |
|
253 | 253 | |
|
254 | 254 | # Packages required for bootstrapping |
|
255 | 255 | REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo" |
|
256 | 256 | MISSING_PACKAGES="" |
|
257 | 257 | |
|
258 | 258 | # Packages installed for c/c++ build environment in chroot (keep empty) |
|
259 | 259 | COMPILER_PACKAGES="" |
|
260 | 260 | |
|
261 | 261 | set +x |
|
262 | 262 | |
|
263 | 263 | #If init and systemd-sysv are wanted e.g. halt/reboot/shutdown scripts |
|
264 | 264 | if [ "$ENABLE_SYSVINIT" = false ] ; then |
|
265 | 265 | APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" |
|
266 | 266 | fi |
|
267 | 267 | |
|
268 | 268 | # Set Raspberry Pi model specific configuration |
|
269 | 269 | if [ "$RPI_MODEL" = 0 ] ; then |
|
270 | 270 | DTB_FILE=${RPI0_DTB_FILE} |
|
271 | 271 | UBOOT_CONFIG=${RPI0_UBOOT_CONFIG} |
|
272 | 272 | elif [ "$RPI_MODEL" = 1 ] ; then |
|
273 | 273 | DTB_FILE=${RPI1_DTB_FILE} |
|
274 | 274 | UBOOT_CONFIG=${RPI1_UBOOT_CONFIG} |
|
275 | 275 | elif [ "$RPI_MODEL" = 1P ] ; then |
|
276 | 276 | DTB_FILE=${RPI1P_DTB_FILE} |
|
277 | 277 | UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG} |
|
278 | 278 | elif [ "$RPI_MODEL" = 2 ] ; then |
|
279 | 279 | DTB_FILE=${RPI2_DTB_FILE} |
|
280 | 280 | UBOOT_CONFIG=${RPI2_UBOOT_CONFIG} |
|
281 | 281 | elif [ "$RPI_MODEL" = 3 ] ; then |
|
282 | 282 | DTB_FILE=${RPI3_DTB_FILE} |
|
283 | 283 | UBOOT_CONFIG=${RPI3_UBOOT_CONFIG} |
|
284 | 284 | elif [ "$RPI_MODEL" = 3P ] ; then |
|
285 | 285 | DTB_FILE=${RPI3P_DTB_FILE} |
|
286 | 286 | UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG} |
|
287 | 287 | else |
|
288 | 288 | echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!" |
|
289 | 289 | exit 1 |
|
290 | 290 | fi |
|
291 | 291 | |
|
292 | 292 | # Check if the internal wireless interface is supported by the RPi model |
|
293 | 293 | if [ "$ENABLE_WIRELESS" = true ] && ([ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ]); then |
|
294 | 294 | |
|
295 | 295 | echo "error: The selected Raspberry Pi model has no internal wireless interface" |
|
296 | 296 | exit 1 |
|
297 | 297 | fi |
|
298 | 298 | |
|
299 | 299 | # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported |
|
300 | 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 |
|
304 | 304 | fi |
|
305 | 305 | fi |
|
306 | 306 | |
|
307 | 307 | # Build RPi2/3 Linux kernel if required by Debian release |
|
308 | 308 | if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then |
|
309 | 309 | BUILD_KERNEL=true |
|
310 | 310 | fi |
|
311 | 311 | |
|
312 | 312 | # Add packages required for kernel cross compilation |
|
313 | 313 | if [ "$BUILD_KERNEL" = true ] ; then |
|
314 | 314 | if [ "$KERNEL_ARCH" = "arm" ] ; then |
|
315 | 315 | if [ "$RELEASE_ARCH" = "armel" ]; then |
|
316 | 316 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" |
|
317 | 317 | fi |
|
318 | 318 | if [ "$RELEASE_ARCH" = "armhf" ]; then |
|
319 | 319 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" |
|
320 | 320 | fi |
|
321 | 321 | fi |
|
322 | 322 | if [ "$RELEASE_ARCH" = "arm64" ]; then |
|
323 | 323 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" |
|
324 | 324 | fi |
|
325 | 325 | fi |
|
326 | 326 | |
|
327 | 327 | if [ "$ENABLE_VIDEOCORE" = true ] ; then |
|
328 | 328 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" |
|
329 | 329 | fi |
|
330 | 330 | |
|
331 | 331 | # Add libncurses5 to enable kernel menuconfig |
|
332 | 332 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
333 | 333 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev" |
|
334 | 334 | fi |
|
335 | 335 | |
|
336 | 336 | # Add ccache compiler cache for (faster) kernel cross (re)compilation |
|
337 | 337 | if [ "$KERNEL_CCACHE" = true ] ; then |
|
338 | 338 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache" |
|
339 | 339 | fi |
|
340 | 340 | |
|
341 | 341 | # Add cryptsetup package to enable filesystem encryption |
|
342 | 342 | if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then |
|
343 | 343 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" |
|
344 | 344 | APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup" |
|
345 | 345 | |
|
346 | 346 | if [ -z "$CRYPTFS_PASSWORD" ] ; then |
|
347 | 347 | echo "error: no password defined (CRYPTFS_PASSWORD)!" |
|
348 | 348 | exit 1 |
|
349 | 349 | fi |
|
350 | 350 | ENABLE_INITRAMFS=true |
|
351 | 351 | fi |
|
352 | 352 | |
|
353 | 353 | # Add initramfs generation tools |
|
354 | 354 | if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then |
|
355 | 355 | APT_INCLUDES="${APT_INCLUDES},initramfs-tools" |
|
356 | 356 | fi |
|
357 | 357 | |
|
358 | 358 | # Add device-tree-compiler required for building the U-Boot bootloader |
|
359 | 359 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
360 | 360 | APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex" |
|
361 | 361 | fi |
|
362 | 362 | |
|
363 | 363 | # Check if root SSH (v2) public key file exists |
|
364 | 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 |
|
368 | 368 | fi |
|
369 | 369 | fi |
|
370 | 370 | |
|
371 | 371 | # Check if $USER_NAME SSH (v2) public key file exists |
|
372 | 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 |
|
376 | 376 | fi |
|
377 | 377 | 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 | 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 |
|
385 | 385 | |
|
386 | 386 | # If there are missing packages ask confirmation for install, or exit |
|
387 | 387 | 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 | 391 | printf "\ndo you want to install the missing packages right now? [y/n] " |
|
392 | 392 | read -r confirm |
|
393 | 393 | [ "$confirm" != "y" ] && exit 1 |
|
394 | 394 | |
|
395 | 395 | # Make sure all missing required packages are installed |
|
396 | 396 | apt-get -qq -y install "${MISSING_PACKAGES}" |
|
397 | 397 | fi |
|
398 | 398 | |
|
399 | 399 | # Check if ./bootstrap.d directory exists |
|
400 | 400 | if [ ! -d "./bootstrap.d/" ] ; then |
|
401 | 401 | echo "error: './bootstrap.d' required directory not found!" |
|
402 | 402 | exit 1 |
|
403 | 403 | fi |
|
404 | 404 | |
|
405 | 405 | # Check if ./files directory exists |
|
406 | 406 | if [ ! -d "./files/" ] ; then |
|
407 | 407 | echo "error: './files' required directory not found!" |
|
408 | 408 | exit 1 |
|
409 | 409 | fi |
|
410 | 410 | |
|
411 | 411 | # Check if specified KERNELSRC_DIR directory exists |
|
412 | 412 | if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then |
|
413 | 413 | echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!" |
|
414 | 414 | exit 1 |
|
415 | 415 | fi |
|
416 | 416 | |
|
417 | 417 | # Check if specified UBOOTSRC_DIR directory exists |
|
418 | 418 | if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then |
|
419 | 419 | echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!" |
|
420 | 420 | exit 1 |
|
421 | 421 | fi |
|
422 | 422 | |
|
423 | 423 | # Check if specified VIDEOCORESRC_DIR directory exists |
|
424 | 424 | if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then |
|
425 | 425 | echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!" |
|
426 | 426 | exit 1 |
|
427 | 427 | fi |
|
428 | 428 | |
|
429 | 429 | # Check if specified FBTURBOSRC_DIR directory exists |
|
430 | 430 | if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then |
|
431 | 431 | echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!" |
|
432 | 432 | exit 1 |
|
433 | 433 | fi |
|
434 | 434 | |
|
435 | 435 | # Check if specified CHROOT_SCRIPTS directory exists |
|
436 | 436 | if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then |
|
437 | 437 | echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" |
|
438 | 438 | exit 1 |
|
439 | 439 | fi |
|
440 | 440 | |
|
441 | 441 | # Check if specified device mapping already exists (will be used by cryptsetup) |
|
442 | 442 | if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then |
|
443 | 443 | echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding" |
|
444 | 444 | exit 1 |
|
445 | 445 | fi |
|
446 | 446 | |
|
447 | 447 | # Don't clobber an old build |
|
448 | 448 | if [ -e "$BUILDDIR" ] ; then |
|
449 | 449 | echo "error: directory ${BUILDDIR} already exists, not proceeding" |
|
450 | 450 | exit 1 |
|
451 | 451 | fi |
|
452 | 452 | |
|
453 | 453 | # Setup chroot directory |
|
454 | 454 | mkdir -p "${R}" |
|
455 | 455 | |
|
456 | 456 | # Check if build directory has enough of free disk space >512MB |
|
457 | 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 |
|
461 | 461 | |
|
462 | 462 | set -x |
|
463 | 463 | |
|
464 | 464 | # Call "cleanup" function on various signals and errors |
|
465 | 465 | trap cleanup 0 1 2 3 6 |
|
466 | 466 | |
|
467 | 467 | # Add required packages for the minbase installation |
|
468 | 468 | if [ "$ENABLE_MINBASE" = true ] ; then |
|
469 | 469 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown" |
|
470 | 470 | fi |
|
471 | 471 | |
|
472 | 472 | # Add required locales packages |
|
473 | 473 | if [ "$DEFLOCAL" != "en_US.UTF-8" ] || ([ -n XKB_MODEL ] || [ -n XKB_LAYOUT ] || [ -n XKB_VARIANT ] || [ -n XKB_OPTIONS ]); then |
|
474 | 474 | APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup" |
|
475 | 475 | fi |
|
476 | 476 | |
|
477 | 477 | # Add parted package, required to get partprobe utility |
|
478 | 478 | if [ "$EXPANDROOT" = true ] ; then |
|
479 | 479 | APT_INCLUDES="${APT_INCLUDES},parted" |
|
480 | 480 | fi |
|
481 | 481 | |
|
482 | 482 | # Add dbus package, recommended if using systemd |
|
483 | 483 | if [ "$ENABLE_DBUS" = true ] ; then |
|
484 | 484 | APT_INCLUDES="${APT_INCLUDES},dbus" |
|
485 | 485 | fi |
|
486 | 486 | |
|
487 | 487 | # Add iptables IPv4/IPv6 package |
|
488 | 488 | if [ "$ENABLE_IPTABLES" = true ] ; then |
|
489 | 489 | APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent" |
|
490 | 490 | fi |
|
491 | 491 | |
|
492 | 492 | # Add openssh server package |
|
493 | 493 | if [ "$ENABLE_SSHD" = true ] ; then |
|
494 | 494 | APT_INCLUDES="${APT_INCLUDES},openssh-server" |
|
495 | 495 | fi |
|
496 | 496 | |
|
497 | 497 | # Add alsa-utils package |
|
498 | 498 | if [ "$ENABLE_SOUND" = true ] ; then |
|
499 | 499 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" |
|
500 | 500 | fi |
|
501 | 501 | |
|
502 | 502 | # Add rng-tools package |
|
503 | 503 | if [ "$ENABLE_HWRANDOM" = true ] ; then |
|
504 | 504 | APT_INCLUDES="${APT_INCLUDES},rng-tools" |
|
505 | 505 | fi |
|
506 | 506 | |
|
507 | 507 | # Add fbturbo video driver |
|
508 | 508 | if [ "$ENABLE_FBTURBO" = true ] ; then |
|
509 | 509 | # Enable xorg package dependencies |
|
510 | 510 | ENABLE_XORG=true |
|
511 | 511 | fi |
|
512 | 512 | |
|
513 | 513 | # Add user defined window manager package |
|
514 | 514 | if [ -n "$ENABLE_WM" ] ; then |
|
515 | 515 | APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" |
|
516 | 516 | |
|
517 | 517 | # Enable xorg package dependencies |
|
518 | 518 | ENABLE_XORG=true |
|
519 | 519 | fi |
|
520 | 520 | |
|
521 | 521 | # Add xorg package |
|
522 | 522 | if [ "$ENABLE_XORG" = true ] ; then |
|
523 | 523 | APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11" |
|
524 | 524 | fi |
|
525 | 525 | |
|
526 | 526 | # Replace selected packages with smaller clones |
|
527 | 527 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
528 | 528 | # Add levee package instead of vim-tiny |
|
529 | 529 | if [ "$REDUCE_VIM" = true ] ; then |
|
530 | 530 | APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")" |
|
531 | 531 | fi |
|
532 | 532 | |
|
533 | 533 | # Add dropbear package instead of openssh-server |
|
534 | 534 | if [ "$REDUCE_SSHD" = true ] ; then |
|
535 | 535 | APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" |
|
536 | 536 | fi |
|
537 | 537 | fi |
|
538 | 538 | |
|
539 | 539 | if [ "$RELEASE" != "jessie" ] ; then |
|
540 | 540 | APT_INCLUDES="${APT_INCLUDES},libnss-systemd" |
|
541 | 541 | fi |
|
542 | 542 | |
|
543 | 543 | # Configure kernel sources if no KERNELSRC_DIR |
|
544 | 544 | if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then |
|
545 | 545 | KERNELSRC_CONFIG=true |
|
546 | 546 | fi |
|
547 | 547 | |
|
548 | 548 | # Configure reduced kernel |
|
549 | 549 | if [ "$KERNEL_REDUCE" = true ] ; then |
|
550 | 550 | KERNELSRC_CONFIG=false |
|
551 | 551 | fi |
|
552 | 552 | |
|
553 | 553 | # Configure qemu compatible kernel |
|
554 | 554 | if [ "$ENABLE_QEMU" = true ] ; then |
|
555 | 555 | DTB_FILE=vexpress-v2p-ca15_a7.dtb |
|
556 | 556 | UBOOT_CONFIG=vexpress_ca15_tc2_defconfig |
|
557 | 557 | KERNEL_DEFCONFIG="vexpress_defconfig" |
|
558 | 558 | if [ "$KERNEL_MENUCONFIG" = false ] ; then |
|
559 | 559 | KERNEL_OLDDEFCONFIG=true |
|
560 | 560 | fi |
|
561 | 561 | fi |
|
562 | 562 | |
|
563 | 563 | # Execute bootstrap scripts |
|
564 | 564 | for SCRIPT in bootstrap.d/*.sh; do |
|
565 | 565 | head -n 3 "$SCRIPT" |
|
566 | 566 | . "$SCRIPT" |
|
567 | 567 | done |
|
568 | 568 | |
|
569 | 569 | ## Execute custom bootstrap scripts |
|
570 | 570 | if [ -d "custom.d" ] ; then |
|
571 | 571 | for SCRIPT in custom.d/*.sh; do |
|
572 | 572 | . "$SCRIPT" |
|
573 | 573 | done |
|
574 | 574 | fi |
|
575 | 575 | |
|
576 | 576 | # Execute custom scripts inside the chroot |
|
577 | 577 | if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then |
|
578 | 578 | cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" |
|
579 | 579 | chroot_exec /bin/bash -x <<'EOF' |
|
580 | 580 | for SCRIPT in /chroot_scripts/* ; do |
|
581 | 581 | if [ -f $SCRIPT -a -x $SCRIPT ] ; then |
|
582 | 582 | $SCRIPT |
|
583 | 583 | fi |
|
584 | 584 | done |
|
585 | 585 | EOF |
|
586 | 586 | rm -rf "${R}/chroot_scripts" |
|
587 | 587 | fi |
|
588 | 588 | |
|
589 | 589 | # Remove c/c++ build environment from the chroot |
|
590 | 590 | chroot_remove_cc |
|
591 | 591 | |
|
592 | 592 | # Remove apt-utils |
|
593 | 593 | if [ "$RELEASE" = "jessie" ] ; then |
|
594 | 594 | chroot_exec apt-get purge -qq -y --force-yes apt-utils |
|
595 | 595 | fi |
|
596 | 596 | |
|
597 | 597 | # Generate required machine-id |
|
598 | 598 | MACHINE_ID=$(dbus-uuidgen) |
|
599 | 599 | echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id" |
|
600 | 600 | echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id" |
|
601 | 601 | |
|
602 | 602 | # APT Cleanup |
|
603 | 603 | chroot_exec apt-get -y clean |
|
604 | 604 | chroot_exec apt-get -y autoclean |
|
605 | 605 | chroot_exec apt-get -y autoremove |
|
606 | 606 | |
|
607 | 607 | # Unmount mounted filesystems |
|
608 | 608 | umount -l "${R}/proc" |
|
609 | 609 | umount -l "${R}/sys" |
|
610 | 610 | |
|
611 | 611 | # Clean up directories |
|
612 | 612 | rm -rf "${R}/run/*" |
|
613 | 613 | rm -rf "${R}/tmp/*" |
|
614 | 614 | |
|
615 | 615 | # Clean up files |
|
616 | 616 | rm -f "${ETC_DIR}/ssh/ssh_host_*" |
|
617 | 617 | rm -f "${ETC_DIR}/dropbear/dropbear_*" |
|
618 | 618 | rm -f "${ETC_DIR}/apt/sources.list.save" |
|
619 | 619 | rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original" |
|
620 | 620 | rm -f "${ETC_DIR}/*-" |
|
621 | 621 | rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy" |
|
622 | 622 | rm -f "${ETC_DIR}/resolv.conf" |
|
623 | 623 | rm -f "${R}/root/.bash_history" |
|
624 | 624 | rm -f "${R}/var/lib/urandom/random-seed" |
|
625 | 625 | rm -f "${R}/initrd.img" |
|
626 | 626 | rm -f "${R}/vmlinuz" |
|
627 | 627 | rm -f "${R}${QEMU_BINARY}" |
|
628 | 628 | |
|
629 | 629 | if [ "$ENABLE_QEMU" = true ] ; then |
|
630 | 630 | # Setup QEMU directory |
|
631 | 631 | mkdir "${BASEDIR}/qemu" |
|
632 | 632 | |
|
633 | 633 | # Copy kernel image to QEMU directory |
|
634 | 634 | install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}" |
|
635 | 635 | |
|
636 | 636 | # Copy kernel config to QEMU directory |
|
637 | 637 | install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}" |
|
638 | 638 | |
|
639 | 639 | # Copy kernel dtbs to QEMU directory |
|
640 | 640 | for dtb in "${BOOT_DIR}/"*.dtb ; do |
|
641 | 641 | if [ -f "${dtb}" ] ; then |
|
642 | 642 | install_readonly "${dtb}" "${BASEDIR}/qemu/" |
|
643 | 643 | fi |
|
644 | 644 | done |
|
645 | 645 | |
|
646 | 646 | # Copy kernel overlays to QEMU directory |
|
647 | 647 | if [ -d "${BOOT_DIR}/overlays" ] ; then |
|
648 | 648 | # Setup overlays dtbs directory |
|
649 | 649 | mkdir "${BASEDIR}/qemu/overlays" |
|
650 | 650 | |
|
651 | 651 | for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do |
|
652 | 652 | if [ -f "${dtb}" ] ; then |
|
653 | 653 | install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/" |
|
654 | 654 | fi |
|
655 | 655 | done |
|
656 | 656 | fi |
|
657 | 657 | |
|
658 | 658 | # Copy u-boot files to QEMU directory |
|
659 | 659 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
660 | 660 | if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then |
|
661 | 661 | install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin" |
|
662 | 662 | fi |
|
663 | 663 | if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then |
|
664 | 664 | install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage" |
|
665 | 665 | fi |
|
666 | 666 | if [ -f "${BOOT_DIR}/boot.scr" ] ; then |
|
667 | 667 | install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr" |
|
668 | 668 | fi |
|
669 | 669 | fi |
|
670 | 670 | |
|
671 | 671 | # Copy initramfs to QEMU directory |
|
672 | 672 | if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then |
|
673 | 673 | install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}" |
|
674 | 674 | fi |
|
675 | 675 | fi |
|
676 | 676 | |
|
677 | 677 | # Calculate size of the chroot directory in KB |
|
678 | 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 | 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 | 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 | 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 | 695 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}" |
|
696 | 696 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}" |
|
697 | 697 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" |
|
698 | 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 |
|
702 | 702 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* |
|
703 | 703 | EOM |
|
704 | 704 | |
|
705 | 705 | # Write root partition table |
|
706 | 706 | sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM |
|
707 | 707 | ${TABLE_SECTORS},${ROOT_SECTORS},83 |
|
708 | 708 | EOM |
|
709 | 709 | |
|
710 | 710 | # Setup temporary loop devices |
|
711 | 711 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)" |
|
712 | 712 | ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)" |
|
713 | 713 | else # ENABLE_SPLITFS=false |
|
714 | 714 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}" |
|
715 | 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 |
|
719 | 719 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* |
|
720 | 720 | ${ROOT_OFFSET},${ROOT_SECTORS},83 |
|
721 | 721 | EOM |
|
722 | 722 | |
|
723 | 723 | # Setup temporary loop devices |
|
724 | 724 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)" |
|
725 | 725 | ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)" |
|
726 | 726 | fi |
|
727 | 727 | |
|
728 | 728 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
729 | 729 | # Create dummy ext4 fs |
|
730 | 730 | mkfs.ext4 "$ROOT_LOOP" |
|
731 | 731 | |
|
732 | 732 | # Setup password keyfile |
|
733 | 733 | touch .password |
|
734 | 734 | chmod 600 .password |
|
735 | 735 | echo -n ${CRYPTFS_PASSWORD} > .password |
|
736 | 736 | |
|
737 | 737 | # Initialize encrypted partition |
|
738 | 738 | echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password |
|
739 | 739 | |
|
740 | 740 | # Open encrypted partition and setup mapping |
|
741 | 741 | cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}" |
|
742 | 742 | |
|
743 | 743 | # Secure delete password keyfile |
|
744 | 744 | shred -zu .password |
|
745 | 745 | |
|
746 | 746 | # Update temporary loop device |
|
747 | 747 | ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}" |
|
748 | 748 | |
|
749 | 749 | # Wipe encrypted partition (encryption cipher is used for randomness) |
|
750 | 750 | dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")" |
|
751 | 751 | fi |
|
752 | 752 | |
|
753 | 753 | # Build filesystems |
|
754 | 754 | mkfs.vfat "$FRMW_LOOP" |
|
755 | 755 | mkfs.ext4 "$ROOT_LOOP" |
|
756 | 756 | |
|
757 | 757 | # Mount the temporary loop devices |
|
758 | 758 | mkdir -p "$BUILDDIR/mount" |
|
759 | 759 | mount "$ROOT_LOOP" "$BUILDDIR/mount" |
|
760 | 760 | |
|
761 | 761 | mkdir -p "$BUILDDIR/mount/boot/firmware" |
|
762 | 762 | mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" |
|
763 | 763 | |
|
764 | 764 | # Copy all files from the chroot to the loop device mount point directory |
|
765 | 765 | rsync -a "${R}/" "$BUILDDIR/mount/" |
|
766 | 766 | |
|
767 | 767 | # Unmount all temporary loop devices and mount points |
|
768 | 768 | cleanup |
|
769 | 769 | |
|
770 | 770 | # Create block map file(s) of image(s) |
|
771 | 771 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
772 | 772 | # Create block map files for "bmaptool" |
|
773 | 773 | bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img" |
|
774 | 774 | bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img" |
|
775 | 775 | |
|
776 | 776 | # Image was successfully created |
|
777 | 777 | echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
778 | 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 | 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 | 791 | qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2 |
|
792 | 792 | qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE |
|
793 | 793 | |
|
794 | 794 | echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created" |
|
795 | 795 | fi |
|
796 | 796 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant