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