##// END OF EJS Templates
massive refactor and bugfes
burnbabyburn -
r310:b38cfe8b34fd
parent child
Show More
@@ -12,41 +12,21 if [ -z "$APT_PROXY" ] ; then
12 12 fi
13 13
14 14 if [ "$BUILD_KERNEL" = false ] ; then
15 if [ "$RPI_MODEL" = 2 ] ; then
16 # Install APT pinning configuration for flash-kernel package
17 install_readonly files/apt/flash-kernel "${ETC_DIR}/apt/preferences.d/flash-kernel"
18
19 # Install APT sources.list
20 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
21 echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETC_DIR}/apt/sources.list"
22
23 # Upgrade collabora package index and install collabora keyring
24 chroot_exec apt-get -qq -y update
25 chroot_exec apt-get -qq -y --allow-unauthenticated install collabora-obs-archive-keyring
26 # if RPI_MODEL = [0] || [1] || [1P]
27 else
28 echo "error: ATM there is just a precompiled kernel for model 2";
29 # insert apt configuration for precompiled kernel repository for RPI 0,1,1P
30 fi
31
15 echo "Downloading precompiled kernel"
16 echo "error: not configured"
17 exit 1;
32 18 else # BUILD_KERNEL=true
33 19 #autconfigure best apt server to not spam ftp.debian.org
34 rm files/apt/sources.list
20 #rm files/apt/sources.list
35 21 #netselect-apt does not know buster yet
36 if [ "$RELEASE" = "buster" ] ; then
37 RLS = "testing"
22 if [ "$RELEASE" = "buster" ] ; then
23 RELEASE=${RELEASE:=testing}
38 24 fi
39
40 if [ "$ENABLE_NONFREE" ] ; then
41 netselect-apt --arch "$RELEASE_ARCH" --sources --nonfree --outfile "${ETC_DIR}/apt/sources.list" -d "$RELEASE"
42 else
43 netselect-apt --arch "$RELEASE_ARCH" --sources --nonfree --outfile "${ETC_DIR}/apt/sources.list" -d "$RELEASE"
25 netselect_string=${netselect_string:=""}
26 if [ "$ENABLE_NONFREE" = true ] ; then
27 netselect-apt --arch "$RELEASE_ARCH" --sources "$netselect_string" --outfile "${ETC_DIR}/apt/sources.list" -d "$RLS"
44 28 fi
45 fi
46
47 # Allow the installation of non-free Debian packages
48 if [ "$ENABLE_NONFREE" = true ] ; then
49 sed -i "s/ contrib/ contrib non-free/" "${ETC_DIR}/apt/sources.list"
29 netselect-apt --arch "$RELEASE_ARCH" --sources "$netselect_string" --outfile "${ETC_DIR}/apt/sources.list" -d "$RLS"
50 30 fi
51 31
52 32 # Upgrade package index and update all installed packages and changed dependencies
@@ -54,13 +34,13 chroot_exec apt-get -qq -y update
54 34 chroot_exec apt-get -qq -y -u dist-upgrade
55 35
56 36 if [ "$APT_INCLUDES_LATE" ] ; then
57 chroot_exec apt-get -qq -y install $(echo $APT_INCLUDES_LATE |tr , ' ')
37 chroot_exec apt-get -qq -y install "$(echo "$APT_INCLUDES_LATE" |tr , ' ')"
58 38 fi
59 39
60 40 if [ -d packages ] ; then
61 41 for package in packages/*.deb ; do
62 cp $package ${R}/tmp
63 chroot_exec dpkg --unpack /tmp/$(basename $package)
42 cp "$package" "${R}"/tmp
43 chroot_exec dpkg --unpack /tmp/"$(basename "$package")"
64 44 done
65 45 fi
66 46 chroot_exec apt-get -qq -y -f install
@@ -6,11 +6,12
6 6 . ./functions.sh
7 7
8 8 # Install and setup timezone
9 echo ${TIMEZONE} > "${ETC_DIR}/timezone"
9 echo "${TIMEZONE}" > "${ETC_DIR}/timezone"
10 10 chroot_exec dpkg-reconfigure -f noninteractive tzdata
11 11
12 12 # Install and setup default locale and keyboard configuration
13 if [ $(echo "$APT_INCLUDES" | grep ",locales") ] ; then
13
14 if [ "$(echo "$APT_INCLUDES" | grep ",locales")" ] ; then
14 15 # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug
15 16 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957
16 17 # ... so we have to set locales manually
@@ -89,30 +89,30 if [ "$BUILD_KERNEL" = true ] ; then
89 89
90 90 # Set kernel configuration parameters to enable qemu emulation
91 91 if [ "$ENABLE_QEMU" = true ] ; then
92 echo "CONFIG_FHANDLE=y" >> ${KERNEL_DIR}/.config
93 echo "CONFIG_LBDAF=y" >> ${KERNEL_DIR}/.config
92 echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config
93 echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config
94 94
95 95 if [ "$ENABLE_CRYPTFS" = true ] ; then
96 echo "CONFIG_EMBEDDED=y" >> ${KERNEL_DIR}/.config
97 echo "CONFIG_EXPERT=y" >> ${KERNEL_DIR}/.config
98 echo "CONFIG_DAX=y" >> ${KERNEL_DIR}/.config
99 echo "CONFIG_MD=y" >> ${KERNEL_DIR}/.config
100 echo "CONFIG_BLK_DEV_MD=y" >> ${KERNEL_DIR}/.config
101 echo "CONFIG_MD_AUTODETECT=y" >> ${KERNEL_DIR}/.config
102 echo "CONFIG_BLK_DEV_DM=y" >> ${KERNEL_DIR}/.config
103 echo "CONFIG_BLK_DEV_DM_BUILTIN=y" >> ${KERNEL_DIR}/.config
104 echo "CONFIG_DM_CRYPT=y" >> ${KERNEL_DIR}/.config
105 echo "CONFIG_CRYPTO_BLKCIPHER=y" >> ${KERNEL_DIR}/.config
106 echo "CONFIG_CRYPTO_CBC=y" >> ${KERNEL_DIR}/.config
107 echo "CONFIG_CRYPTO_XTS=y" >> ${KERNEL_DIR}/.config
108 echo "CONFIG_CRYPTO_SHA512=y" >> ${KERNEL_DIR}/.config
109 echo "CONFIG_CRYPTO_MANAGER=y" >> ${KERNEL_DIR}/.config
110 fi
96 echo "CONFIG_EMBEDDED=y" >> "${KERNEL_DIR}"/.config
97 echo "CONFIG_EXPERT=y" >> "${KERNEL_DIR}"/.config
98 echo "CONFIG_DAX=y" >> "${KERNEL_DIR}"/.config
99 echo "CONFIG_MD=y" >> "${KERNEL_DIR}"/.config
100 echo "CONFIG_BLK_DEV_MD=y" >> "${KERNEL_DIR}"/.config
101 echo "CONFIG_MD_AUTODETECT=y" >> "${KERNEL_DIR}"/.config
102 echo "CONFIG_BLK_DEV_DM=y" >> "${KERNEL_DIR}"/.config
103 echo "CONFIG_BLK_DEV_DM_BUILTIN=y" >> "${KERNEL_DIR}"/.config
104 echo "CONFIG_DM_CRYPT=y" >> "${KERNEL_DIR}"/.config
105 echo "CONFIG_CRYPTO_BLKCIPHER=y" >> "${KERNEL_DIR}"/.config
106 echo "CONFIG_CRYPTO_CBC=y" >> "${KERNEL_DIR}"/.config
107 echo "CONFIG_CRYPTO_XTS=y" >> "${KERNEL_DIR}"/.config
108 echo "CONFIG_CRYPTO_SHA512=y" >> "${KERNEL_DIR}"/.config
109 echo "CONFIG_CRYPTO_MANAGER=y" >> "${KERNEL_DIR}"/.config
110 fi
111 111 fi
112 112
113 113 # Copy custom kernel configuration file
114 if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
115 cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
114 if [ -n "$KERNELSRC_USRCONFIG" ] ; then
115 cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config
116 116 fi
117 117
118 118 # Set kernel configuration parameters to their default values
@@ -134,11 +134,11 if [ "$BUILD_KERNEL" = true ] ; then
134 134 fi
135 135
136 136 # Cross compile kernel and dtbs
137 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
137 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
138 138
139 139 # Cross compile kernel modules
140 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
141 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
140 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
141 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
142 142 fi
143 143 fi
144 144
@@ -151,16 +151,16 if [ "$BUILD_KERNEL" = true ] ; then
151 151
152 152 # Install kernel modules
153 153 if [ "$ENABLE_REDUCE" = true ] ; then
154 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
154 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
155 155 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
156 156 fi
157 157 else
158 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
158 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
159 159 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
160 160 fi
161 161
162 162 # Install kernel firmware
163 if [ $(grep "^firmware_install:" "${KERNEL_DIR}/Makefile") ] ; then
163 if [ "$(grep "^firmware_install:" "${KERNEL_DIR}/Makefile")" ] ; then
164 164 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
165 165 fi
166 166 fi
@@ -174,7 +174,7 if [ "$BUILD_KERNEL" = true ] ; then
174 174 mkdir "${BOOT_DIR}"
175 175
176 176 # Get kernel release version
177 KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"`
177 KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release")
178 178
179 179 # Copy kernel configuration file to the boot directory
180 180 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
@@ -223,8 +223,8 if [ "$BUILD_KERNEL" = true ] ; then
223 223 rm -fr "${KERNEL_DIR}"
224 224 else
225 225 # Prepare compiled kernel modules
226 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
227 if [ $(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile") ] ; then
226 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
227 if [ "$(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile")" ] ; then
228 228 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
229 229 fi
230 230
@@ -234,37 +234,24 if [ "$BUILD_KERNEL" = true ] ; then
234 234 fi
235 235 fi
236 236 elif [ "$BUILD_KERNEL" = false ] ; then
237 # Collabora states this kernel is just for RPI 2 so better implement a check.
238 #From https://repositories.collabora.co.uk/debian/dists/jessie/rpi2/binary-armhf/Packages
239 #"The Linux kernel "${COLLABORA_KERNEL}" and modules for use on ARMv7 kernel for Raspberry pi 2 model B+"
240 # nested if to be easily extended for more precompiled kernels
241 if [ "$SET_ARCH" = 32 ] ; then
242 if [ "$RPI_MODEL" = 2 ] ; then
243 # Kernel installation
244 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel
245
246 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
247 chroot_exec apt-get -qq -y install flash-kernel
248
249 # Check if kernel installation was successful
250 VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)"
251 if [ -z "$VMLINUZ" ] ; then
252 echo "error: kernel installation failed! (/boot/vmlinuz-* not found)"
253 cleanup
254 exit 1
255 fi
256 # Copy vmlinuz kernel to the boot directory
257 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
258 fi
259 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
260 echo "error: no precompiled kernel found"
261 exit 1
262 # insert precompiled Kernel code here
263 fi
264 #if [ "$SET_ARCH" = 64 ]
237 echo " Install precompiled kernel..."
238 echo "error: not implemented"
239 # Check if kernel installation was successful
240 VMLINUZ="$(ls -1 "${R}"/boot/vmlinuz-* | sort | tail -n 1)"
241 if [ -z "$VMLINUZ" ] ; then
242 echo "error: kernel installation failed! (/boot/vmlinuz-* not found)"
243 cleanup
244 exit 1
245 fi
246 # Copy vmlinuz kernel to the boot directory
247 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
248
249 if [ "$SET_ARCH" = 64 ] ; then
250 echo "Using precompiled arm64 kernel"
265 251 else
266 echo "error: no precompiled 64bit kernel found"
252 echo "error: no precompiled arm64 (bcmrpi3) kernel found"
267 253 exit 1
268 254 # inset precompiled 64 bit kernel code here
269 255 fi
256 #fi build_kernel=true
270 257 fi
@@ -8,12 +8,15
8 8 if [ "$ENABLE_IPTABLES" = true ] ; then
9 9 # Create iptables configuration directory
10 10 mkdir -p "${ETC_DIR}/iptables"
11
11
12 #In Jessie iptables is old enough
13 if ! [ "$RELEASE" = jessie ] ; then
12 14 # make sure iptables-legacy,iptables-legacy-restore and iptables-legacy-save are the used alternatives
13 15 chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy
14 chroot_exec update-alternatives --verbose --set iptables-save /usr/sbin/iptables-legacy-save
15 chroot_exec update-alternatives --verbose --set iptables-restore /usr/sbin/iptables-legacy-restore
16
16 #chroot_exec update-alternatives --verbose --set iptables-save /usr/sbin/iptables-legacy-save
17 #chroot_exec update-alternatives --verbose --set iptables-restore /usr/sbin/iptables-legacy-restore
18 fi
19
17 20 # Install iptables systemd service
18 21 install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service"
19 22
@@ -4,5 +4,6 deb http://ftp.debian.org/debian jessie main contrib
4 4 deb http://ftp.debian.org/debian/ jessie-updates main contrib
5 5 #deb-src http://ftp.debian.org/debian/ jessie-updates main contrib
6 6
7 deb http://security.debian.org/ jessie/updates main contrib
7 #deb http://security.debian.org/ jessie/updates main contrib
8 8 #deb-src http://security.debian.org/ jessie/updates main contrib
9
@@ -1,9 +1,8
1 #!/bin/sh
2
1 #!/bin/bash
3 2 ########################################################################
4 3 # rpi23-gen-image.sh 2015-2017
5 4 #
6 # Advanced Debian "jessie", "stretch" and "buster" bootstrap script for RPi2/3
5 # Advanced Debian "stretch" and "buster" bootstrap script for RPi2/3
7 6 #
8 7 # This program is free software; you can redistribute it and/or
9 8 # modify it under the terms of the GNU General Public License
@@ -31,7 +30,7 fi
31 30 . ./functions.sh
32 31
33 32 # Load parameters from configuration template file
34 if [ ! -z "$CONFIG_TEMPLATE" ] ; then
33 if [ -n "$CONFIG_TEMPLATE" ] ; then
35 34 use_template
36 35 fi
37 36
@@ -44,7 +43,7 set -x
44 43 RPI_MODEL=${RPI_MODEL:=2}
45 44
46 45 # Debian release
47 RELEASE=${RELEASE:=jessie}
46 RELEASE=${RELEASE:=buster}
48 47
49 48 #Kernel Branch
50 49 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
@@ -53,10 +52,12 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
53 52 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
54 53 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
55 54 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
56 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
57 55 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
58 56 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
59 57
58 # Firmware directory: Blank if download from github
59 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
60
60 61 # Build directories
61 62 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
62 63 BUILDDIR="${BASEDIR}/build"
@@ -77,11 +78,8 BOOT_DIR="${R}/boot/firmware"
77 78 KERNEL_DIR="${R}/usr/src/linux"
78 79 WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm"
79 80
80 # Firmware directory: Blank if download from github
81 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
82
83 81 # General settings
84 SET_ARCH=${SET_ARCH}
82 SET_ARCH=${SET_ARCH:=32}
85 83 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
86 84 PASSWORD=${PASSWORD:=raspberry}
87 85 USER_PASSWORD=${USER_PASSWORD:=raspberry}
@@ -219,18 +217,18 if [ -n "$SET_ARCH" ] ; then
219 217 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
220 218 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
221 219 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
222
223 if ([ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]) ; then
220
221 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
224 222 # RPI 3 serie specific settings
225 223 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
226 224 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
227
225
228 226 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
229 227 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
230 else
228 else
231 229 echo "error: At the moment Raspberry PI 3 and 3B+ are the only Models which support 64bit"
232 230 exit 1
233 fi
231 fi
234 232 fi
235 233
236 234 ##################################
@@ -251,42 +249,72 if [ -n "$SET_ARCH" ] ; then
251 249 RELEASE_ARCH=${RELEASE_ARCH:=armel}
252 250 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
253 251 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
254 fi
252 fi
255 253 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
256 254 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
257 255 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
258 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
256 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
259 257 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
260 258 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
261 fi
262
263 #Device specific configuration
264 case "$RPI_MODEL" in
259 fi
260 #Device specific configuration
261 case "$RPI_MODEL" in
265 262 0)
266 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} ;;
263 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
264 ;;
267 265 1)
268 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} ;;
266 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
267 ;;
269 268 1P)
270 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} ;;
269 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
270 ;;
271 271 2)
272 272 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
273 273 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
274 #Precompiled Kernel rpi2
275 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
276 ;;
277 3)
278 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
279 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
280 ;;
274 ;;
275 3)
276 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
277 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
278 ;;
281 279 3P)
282 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
280 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
283 281 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
284 ;;
285 *)
282 ;;
283 *)
286 284 echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!"
287 exit 1
288 ;;
285 exit 1
286 ;;
289 287 esac
288
289 #Device specific configuration
290 # if [ "$RPI_MODEL" = 0 ] ; then
291 # DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
292 # fi
293 # if [ "$RPI_MODEL" = 1 ] ; then
294 # DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
295 # fi
296 # if [ "$RPI_MODEL" = 1P ] ; then
297 # DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
298 # fi
299 # if [ "$RPI_MODEL" = 2 ] ; then
300 # DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
301 # UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
302 # #Precompiled Kernel rpi2
303 # #COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
304 # fi
305 # if [ "$RPI_MODEL" = 3 ] ; then
306 # DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
307 # UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
308 # fi
309 # if [ "$RPI_MODEL" = 3P ] ; then
310 # DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
311 # UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
312 # fi
313 # if [ -z "$RPI_MODEL" ] ; then
314 # echo "error: Raspberry Pi model $RPI_MODEL is not set!"
315 # exit 1
316 # fi
317
290 318 #end 32 bit
291 319 fi
292 320 #SET_ARCH not set
@@ -296,7 +324,7 else
296 324 fi
297 325
298 326 # Check if the internal wireless interface is supported by the RPi model
299 if [ "$ENABLE_WIRELESS" = true ] && ([ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ]) ; then
327 if [ "$ENABLE_WIRELESS" = true ] && { [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; } ; then
300 328 echo "error: The selected Raspberry Pi model has no internal wireless interface"
301 329 exit 1
302 330 else
@@ -304,7 +332,7 else
304 332 fi
305 333
306 334 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
307 if [ ! -z "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
335 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
308 336 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
309 337 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
310 338 exit 1
@@ -344,7 +372,7 if [ "$ENABLE_UBOOT" = true ] ; then
344 372 fi
345 373
346 374 # Check if root SSH (v2) public key file exists
347 if [ ! -z "$SSH_ROOT_PUB_KEY" ] ; then
375 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
348 376 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
349 377 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
350 378 exit 1
@@ -352,7 +380,7 if [ ! -z "$SSH_ROOT_PUB_KEY" ] ; then
352 380 fi
353 381
354 382 # Check if $USER_NAME SSH (v2) public key file exists
355 if [ ! -z "$SSH_USER_PUB_KEY" ] ; then
383 if [ -n "$SSH_USER_PUB_KEY" ] ; then
356 384 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
357 385 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
358 386 exit 1
@@ -361,7 +389,7 fi
361 389
362 390 # Check if all required packages are installed on the build system
363 391 for package in $REQUIRED_PACKAGES ; do
364 if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
392 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
365 393 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
366 394 fi
367 395 done
@@ -371,12 +399,12 if [ -n "$MISSING_PACKAGES" ] ; then
371 399 echo "the following packages needed by this script are not installed:"
372 400 echo "$MISSING_PACKAGES"
373 401
374 echo -n "\ndo you want to install the missing packages right now? [y/n] "
375 read confirm
402 printf "\ndo you want to install the missing packages right now? [y/n] "
403 read -r confirm
376 404 [ "$confirm" != "y" ] && exit 1
377 405
378 406 # Make sure all missing required packages are installed
379 apt-get -qq -y install ${MISSING_PACKAGES}
407 apt-get -qq -y install "${MISSING_PACKAGES}"
380 408 fi
381 409
382 410 # Check if ./bootstrap.d directory exists
@@ -447,7 +475,7 if [ "$ENABLE_MINBASE" = true ] ; then
447 475 fi
448 476
449 477 # Add required locales packages
450 if [ "$DEFLOCAL" != "en_US.UTF-8" ] || ([ -n XKB_MODEL ] || [ -n XKB_LAYOUT ] || [ -n XKB_VARIANT ] || [ -n XKB_OPTIONS ]); then
478 if [ "$DEFLOCAL" != "en_US.UTF-8" ] || { [ -n "$XKB_MODEL" ] || [ -n "$XKB_LAYOUT" ] || [ -n "$XKB_VARIANT" ] || [ -n "$XKB_OPTIONS" ] ; } ; then
451 479 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
452 480 fi
453 481
@@ -509,15 +537,10 if [ "$ENABLE_REDUCE" = true ] ; then
509 537
510 538 # Add dropbear package instead of openssh-server
511 539 if [ "$REDUCE_SSHD" = true ] ; then
512 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/openssh-server/dropbear/")"
540 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
513 541 fi
514 542 fi
515 543
516 #backwards compability to jessie - untested
517 if [ "$RELEASE" != "jessie" ] ; then
518 APT_INCLUDES="${APT_INCLUDES},libnss-systemd"
519 fi
520
521 544 # Configure kernel sources if no KERNELSRC_DIR
522 545 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
523 546 KERNELSRC_CONFIG=true
@@ -557,11 +580,6 fi
557 580 # Remove c/c++ build environment from the chroot
558 581 chroot_remove_cc
559 582
560 # Remove apt-utils
561 if [ "$RELEASE" = "jessie" ] ; then
562 chroot_exec apt-get purge -qq -y --force-yes apt-utils
563 fi
564
565 583 # Generate required machine-id
566 584 MACHINE_ID=$(dbus-uuidgen)
567 585 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
@@ -651,54 +669,54 if [ "$ENABLE_QEMU" = true ] ; then
651 669 fi
652 670
653 671 # Calculate size of the chroot directory in KB
654 CHROOT_SIZE=$(expr `du -s "${R}" | awk '{ print $1 }'`)
672 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
655 673
656 674 # Calculate the amount of needed 512 Byte sectors
657 675 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
658 676 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
659 ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS})
677 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
660 678
661 679 # The root partition is EXT4
662 680 # This means more space than the actual used space of the chroot is used.
663 681 # As overhead for journaling and reserved blocks 35% are added.
664 ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 35) \* 1024 \/ 512)
682 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
665 683
666 684 # Calculate required image size in 512 Byte sectors
667 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS})
685 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
668 686
669 687 # Prepare image file
670 688 if [ "$ENABLE_SPLITFS" = true ] ; then
671 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=${TABLE_SECTORS}
672 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS}
673 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=${TABLE_SECTORS}
674 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek=${ROOT_SECTORS}
689 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
690 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
691 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
692 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
675 693
676 694 # Write firmware/boot partition tables
677 695 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
678 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
696 "${TABLE_SECTORS}","${FRMW_SECTORS}",c,*
679 697 EOM
680 698
681 699 # Write root partition table
682 700 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
683 ${TABLE_SECTORS},${ROOT_SECTORS},83
701 "${TABLE_SECTORS}","${ROOT_SECTORS}",83
684 702 EOM
685 703
686 704 # Setup temporary loop devices
687 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME-frmw.img)"
688 ROOT_LOOP="$(losetup -o 1M -f --show $IMAGE_NAME-root.img)"
705 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
706 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
689 707 else # ENABLE_SPLITFS=false
690 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=${TABLE_SECTORS}
691 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek=${IMAGE_SECTORS}
708 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
709 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
692 710
693 711 # Write partition table
694 712 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
695 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
696 ${ROOT_OFFSET},${ROOT_SECTORS},83
713 "${TABLE_SECTORS}","${FRMW_SECTORS}",c,*
714 "${ROOT_OFFSET}","${ROOT_SECTORS}",83
697 715 EOM
698 716
699 717 # Setup temporary loop devices
700 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME.img)"
701 ROOT_LOOP="$(losetup -o 65M -f --show $IMAGE_NAME.img)"
718 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
719 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
702 720 fi
703 721
704 722 if [ "$ENABLE_CRYPTFS" = true ] ; then
@@ -708,7 +726,7 if [ "$ENABLE_CRYPTFS" = true ] ; then
708 726 # Setup password keyfile
709 727 touch .password
710 728 chmod 600 .password
711 echo -n ${CRYPTFS_PASSWORD} > .password
729 echo -n "${CRYPTFS_PASSWORD}" > .password
712 730
713 731 # Initialize encrypted partition
714 732 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
@@ -723,7 +741,7 if [ "$ENABLE_CRYPTFS" = true ] ; then
723 741 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
724 742
725 743 # Wipe encrypted partition (encryption cipher is used for randomness)
726 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count=$(blockdev --getsz "${ROOT_LOOP}")
744 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
727 745 fi
728 746
729 747 # Build filesystems
@@ -750,22 +768,22 if [ "$ENABLE_SPLITFS" = true ] ; then
750 768 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
751 769
752 770 # Image was successfully created
753 echo "$IMAGE_NAME-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
754 echo "$IMAGE_NAME-root.img ($(expr \( ${TABLE_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
771 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
772 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
755 773 else
756 774 # Create block map file for "bmaptool"
757 775 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
758 776
759 777 # Image was successfully created
760 echo "$IMAGE_NAME.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
778 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
761 779
762 780 # Create qemu qcow2 image
763 781 if [ "$ENABLE_QEMU" = true ] ; then
764 782 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
765 783 QEMU_SIZE=16G
766 784
767 qemu-img convert -f raw -O qcow2 $IMAGE_NAME.img $QEMU_IMAGE.qcow2
768 qemu-img resize $QEMU_IMAGE.qcow2 $QEMU_SIZE
785 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
786 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
769 787
770 788 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
771 789 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant