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