##// END OF EJS Templates
erreurs
vidal -
r719:0e95ca156347
parent child
Show More
@@ -1,929 +1,919
1 #!/bin/sh
1 #!/bin/sh
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 Raspberry Pi
5 # Advanced Debian "stretch" and "buster" bootstrap script for Raspberry Pi
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# RPi 0/1/2/3/4 Bootstrap Settings\n#\n"
39 echo -n -e "\n#\n# RPi 0/1/2/3/4 Bootstrap Settings\n#\n"
40 set -x
40 set -x
41
41
42 # Raspberry Pi model configuration
42 # Raspberry Pi model configuration
43 RPI_MODEL=${RPI_MODEL:=2}
43 RPI_MODEL=${RPI_MODEL:=2}
44
44
45 # Debian release
45 # Debian release
46 RELEASE=${RELEASE:=buster}
46 RELEASE=${RELEASE:=buster}
47 if [ $RELEASE = "bullseye" ] ; then
47 if [ $RELEASE = "bullseye" ] ; then
48 RELEASE=testing
48 RELEASE=testing
49 fi
49 fi
50
50
51 # Kernel Branch
51 # Kernel Branch
52 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
52 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
53
53
54 # URLs
54 # URLs
55 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
55 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
56 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
56 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
57 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
57 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
58 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
58 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
59 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
59 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
60 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
60 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
61 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
61 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
62 NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git}
62 NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git}
63 SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git}
63 SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git}
64
64
65 # Kernel deb packages for 32bit kernel
65 # Kernel deb packages for 32bit kernel
66 RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb}
66 RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb}
67 RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb}
67 RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb}
68 # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used
68 # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used
69 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.19.80.20191022/bcmrpi3-kernel-bis-4.19.80.20191022.tar.xz}
69 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.19.80.20191022/bcmrpi3-kernel-bis-4.19.80.20191022.tar.xz}
70 # Default precompiled 64bit kernel
70 # Default precompiled 64bit kernel
71 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.19.80.20191022/bcmrpi3-kernel-4.19.80.20191022.tar.xz}
71 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.19.80.20191022/bcmrpi3-kernel-4.19.80.20191022.tar.xz}
72 # Sakaki BIS Kernel RPI4 - https://github.com/sakaki-/bcm2711-kernel-bis
72 # Sakaki BIS Kernel RPI4 - https://github.com/sakaki-/bcm2711-kernel-bis
73 RPI4_64_BIS_KERNEL_URL=${RPI4_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
73 RPI4_64_BIS_KERNEL_URL=${RPI4_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
74 # Default precompiled 64bit kernel - https://github.com/sakaki-/bcm2711-kernel
74 # Default precompiled 64bit kernel - https://github.com/sakaki-/bcm2711-kernel
75 RPI4_64_DEF_KERNEL_URL=${RPI4_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
75 RPI4_64_DEF_KERNEL_URL=${RPI4_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
76 # Generic
76 # Generic
77 RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL}
77 RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL}
78 RPI4_64_KERNEL_URL=${RPI4_64_KERNEL_URL:=$RPI4_64_DEF_KERNEL_URL}
78 RPI4_64_KERNEL_URL=${RPI4_64_KERNEL_URL:=$RPI4_64_DEF_KERNEL_URL}
79 # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul)
79 # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul)
80 KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git}
80 KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git}
81
81
82 # Build directories
82 # Build directories
83 WORKDIR=$(pwd)
83 WORKDIR=$(pwd)
84 BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}}
84 BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}}
85 BUILDDIR="${BASEDIR}/build"
85 BUILDDIR="${BASEDIR}/build"
86
86
87 # Chroot directories
87 # Chroot directories
88 R="${BUILDDIR}/chroot"
88 R="${BUILDDIR}/chroot"
89 ETC_DIR="${R}/etc"
89 ETC_DIR="${R}/etc"
90 LIB_DIR="${R}/lib"
90 LIB_DIR="${R}/lib"
91 BOOT_DIR="${R}/boot/firmware"
91 BOOT_DIR="${R}/boot/firmware"
92 KERNEL_DIR="${R}/usr/src/linux"
92 KERNEL_DIR="${R}/usr/src/linux"
93 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
93 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
94 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
94 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
95
95
96 # Firmware directory: Blank if download from github
96 # Firmware directory: Blank if download from github
97 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
97 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
98
98
99 # General settings
99 # General settings
100 SET_ARCH=${SET_ARCH:=32}
100 SET_ARCH=${SET_ARCH:=32}
101 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
101 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
102 PASSWORD=${PASSWORD:=raspberry}
102 PASSWORD=${PASSWORD:=raspberry}
103 USER_PASSWORD=${USER_PASSWORD:=raspberry}
103 USER_PASSWORD=${USER_PASSWORD:=raspberry}
104 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
104 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
105 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
105 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
106 EXPANDROOT=${EXPANDROOT:=true}
106 EXPANDROOT=${EXPANDROOT:=true}
107 ENABLE_DPHYSSWAP=${ENABLE_DPHYSSWAP:=true}
107 ENABLE_DPHYSSWAP=${ENABLE_DPHYSSWAP:=true}
108
108
109 # Keyboard settings
109 # Keyboard settings
110 XKB_MODEL=${XKB_MODEL:=""}
110 XKB_MODEL=${XKB_MODEL:=""}
111 XKB_LAYOUT=${XKB_LAYOUT:=""}
111 XKB_LAYOUT=${XKB_LAYOUT:=""}
112 XKB_VARIANT=${XKB_VARIANT:=""}
112 XKB_VARIANT=${XKB_VARIANT:=""}
113 XKB_OPTIONS=${XKB_OPTIONS:=""}
113 XKB_OPTIONS=${XKB_OPTIONS:=""}
114
114
115 # Network settings (DHCP)
115 # Network settings (DHCP)
116 ENABLE_DHCP=${ENABLE_DHCP:=true}
116 ENABLE_DHCP=${ENABLE_DHCP:=true}
117
117
118 # Network settings (static)
118 # Network settings (static)
119 NET_ADDRESS=${NET_ADDRESS:=""}
119 NET_ADDRESS=${NET_ADDRESS:=""}
120 NET_GATEWAY=${NET_GATEWAY:=""}
120 NET_GATEWAY=${NET_GATEWAY:=""}
121 NET_DNS_1=${NET_DNS_1:=""}
121 NET_DNS_1=${NET_DNS_1:=""}
122 NET_DNS_2=${NET_DNS_2:=""}
122 NET_DNS_2=${NET_DNS_2:=""}
123 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
123 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
124 NET_NTP_1=${NET_NTP_1:=""}
124 NET_NTP_1=${NET_NTP_1:=""}
125 NET_NTP_2=${NET_NTP_2:=""}
125 NET_NTP_2=${NET_NTP_2:=""}
126
126
127 # APT settings
127 # APT settings
128 APT_PROXY=${APT_PROXY:=""}
128 APT_PROXY=${APT_PROXY:=""}
129 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
129 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
130 KEEP_APT_PROXY=${KEEP_APT_PROXY:=false}
130 KEEP_APT_PROXY=${KEEP_APT_PROXY:=false}
131
131
132 # Feature settings
132 # Feature settings
133 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
133 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
134 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
134 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
135 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
135 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
136 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
136 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
137 ENABLE_I2C=${ENABLE_I2C:=false}
137 ENABLE_I2C=${ENABLE_I2C:=false}
138 ENABLE_SPI=${ENABLE_SPI:=false}
138 ENABLE_SPI=${ENABLE_SPI:=false}
139 ENABLE_IPV6=${ENABLE_IPV6:=true}
139 ENABLE_IPV6=${ENABLE_IPV6:=true}
140 ENABLE_SSHD=${ENABLE_SSHD:=true}
140 ENABLE_SSHD=${ENABLE_SSHD:=true}
141 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
141 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
142 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
142 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
143 ENABLE_SOUND=${ENABLE_SOUND:=true}
143 ENABLE_SOUND=${ENABLE_SOUND:=true}
144 ENABLE_DBUS=${ENABLE_DBUS:=true}
144 ENABLE_DBUS=${ENABLE_DBUS:=true}
145 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
145 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
146 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
146 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
147 ENABLE_XORG=${ENABLE_XORG:=false}
147 ENABLE_XORG=${ENABLE_XORG:=false}
148 ENABLE_WM=${ENABLE_WM:=""}
148 ENABLE_WM=${ENABLE_WM:=""}
149 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
149 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
150 ENABLE_USER=${ENABLE_USER:=true}
150 ENABLE_USER=${ENABLE_USER:=true}
151 USER_NAME=${USER_NAME:="pi"}
151 USER_NAME=${USER_NAME:="pi"}
152 ENABLE_ROOT=${ENABLE_ROOT:=false}
152 ENABLE_ROOT=${ENABLE_ROOT:=false}
153 ENABLE_QEMU=${ENABLE_QEMU:=false}
153 ENABLE_QEMU=${ENABLE_QEMU:=false}
154 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
154 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
155
155
156 # SSH settings
156 # SSH settings
157 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
157 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
158 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
158 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
159 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
159 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
160 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
160 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
161 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
161 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
162
162
163 # Advanced settings
163 # Advanced settings
164 ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false}
164 ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false}
165 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
165 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
166 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
166 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
167 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
167 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
168 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
168 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
169 ENABLE_USBBOOT=${ENABLE_USBBOOT=false}
169 ENABLE_USBBOOT=${ENABLE_USBBOOT=false}
170 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
170 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
171 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false}
171 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false}
172 ENABLE_NEXMON=${ENABLE_NEXMON:=false}
172 ENABLE_NEXMON=${ENABLE_NEXMON:=false}
173 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
173 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
174 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
174 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
175 NEXMONSRC_DIR=${NEXMONSRC_DIR:=""}
175 NEXMONSRC_DIR=${NEXMONSRC_DIR:=""}
176 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
176 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
177 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
177 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
178 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
178 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
179 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
179 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
180 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
180 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
181 ENABLE_SPLASH=${ENABLE_SPLASH:=true}
181 ENABLE_SPLASH=${ENABLE_SPLASH:=true}
182 ENABLE_LOGO=${ENABLE_LOGO:=true}
182 ENABLE_LOGO=${ENABLE_LOGO:=true}
183 ENABLE_SILENT_BOOT=${ENABLE_SILENT_BOOT=false}
183 ENABLE_SILENT_BOOT=${ENABLE_SILENT_BOOT=false}
184 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
184 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
185
185
186 # Kernel compilation settings
186 # Kernel compilation settings
187 BUILD_KERNEL=${BUILD_KERNEL:=true}
187 BUILD_KERNEL=${BUILD_KERNEL:=true}
188 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
188 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
189 KERNEL_THREADS=${KERNEL_THREADS:=1}
189 KERNEL_THREADS=${KERNEL_THREADS:=1}
190 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
190 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
191 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
191 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
192 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
192 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
193 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
193 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
194 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
194 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
195 KERNEL_ZSWAP=${KERNEL_ZSWAP:=false}
195 KERNEL_ZSWAP=${KERNEL_ZSWAP:=false}
196 KERNEL_VIRT=${KERNEL_VIRT:=false}
196 KERNEL_VIRT=${KERNEL_VIRT:=false}
197 KERNEL_BPF=${KERNEL_BPF:=false}
197 KERNEL_BPF=${KERNEL_BPF:=false}
198 KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=ondemand}
198 KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=ondemand}
199 KERNEL_SECURITY=${KERNEL_SECURITY:=false}
199 KERNEL_SECURITY=${KERNEL_SECURITY:=false}
200 KERNEL_NF=${KERNEL_NF:=false}
200 KERNEL_NF=${KERNEL_NF:=false}
201 KERNEL_DHKEY=${KERNEL_DHKEY:=true}
201 KERNEL_DHKEY=${KERNEL_DHKEY:=true}
202 KERNEL_BTRFS=${KERNEL_BTRFS:=false}
202 KERNEL_BTRFS=${KERNEL_BTRFS:=false}
203 KERNEL_NSPAN=${KERNEL_NSPAN:=false}
203 KERNEL_NSPAN=${KERNEL_NSPAN:=false}
204 KERNEL_POEHAT=${KERNEL_POEHAT:=false}
204 KERNEL_POEHAT=${KERNEL_POEHAT:=false}
205
205
206 # Kernel compilation from source directory settings
206 # Kernel compilation from source directory settings
207 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
207 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
208 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
208 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
209 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
209 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
210 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
210 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
211
211
212 # Reduce disk usage settings
212 # Reduce disk usage settings
213 REDUCE_APT=${REDUCE_APT:=true}
213 REDUCE_APT=${REDUCE_APT:=true}
214 REDUCE_DOC=${REDUCE_DOC:=true}
214 REDUCE_DOC=${REDUCE_DOC:=true}
215 REDUCE_MAN=${REDUCE_MAN:=true}
215 REDUCE_MAN=${REDUCE_MAN:=true}
216 REDUCE_VIM=${REDUCE_VIM:=false}
216 REDUCE_VIM=${REDUCE_VIM:=false}
217 REDUCE_BASH=${REDUCE_BASH:=false}
217 REDUCE_BASH=${REDUCE_BASH:=false}
218 REDUCE_HWDB=${REDUCE_HWDB:=true}
218 REDUCE_HWDB=${REDUCE_HWDB:=true}
219 REDUCE_SSHD=${REDUCE_SSHD:=true}
219 REDUCE_SSHD=${REDUCE_SSHD:=true}
220 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
220 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
221
221
222 # Encrypted filesystem settings
222 # Encrypted filesystem settings
223 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
223 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
224 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
224 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
225 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
225 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
226 <<<<<<< HEAD
227 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
228 =======
229 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
230 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64"}
226 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64"}
231 CRYPTFS_HASH=${CRYPTFS_HASH:="sha512"}
227 CRYPTFS_HASH=${CRYPTFS_HASH:="sha512"}
232 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
228 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
233 #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup
229 #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup
234 CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false}
230 CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false}
235 #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated
231 #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated
236 CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""}
232 CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""}
237
233
238 # Chroot scripts directory
234 # Chroot scripts directory
239 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
235 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
240
236
241 # Packages required in the chroot build environment
237 # Packages required in the chroot build environment
242 APT_INCLUDES=${APT_INCLUDES:=""}
238 APT_INCLUDES=${APT_INCLUDES:=""}
243 <<<<<<< HEAD
239
244 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
245 =======
246 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
247 APT_INCLUDES="${APT_INCLUDES},flex,bison,libssl-dev,apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
240 APT_INCLUDES="${APT_INCLUDES},flex,bison,libssl-dev,apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
248
241
249 # Packages to exclude from chroot build environment
242 # Packages to exclude from chroot build environment
250 APT_EXCLUDES=${APT_EXCLUDES:=""}
243 APT_EXCLUDES=${APT_EXCLUDES:=""}
251
244
252 # Packages required for bootstrapping
245 # Packages required for bootstrapping
253 <<<<<<< HEAD
246
254 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo"
255 =======
256 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
257 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus bison flex libssl-dev sudo"
247 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus bison flex libssl-dev sudo"
258 MISSING_PACKAGES=""
248 MISSING_PACKAGES=""
259
249
260 # Packages installed for c/c++ build environment in chroot (keep empty)
250 # Packages installed for c/c++ build environment in chroot (keep empty)
261 COMPILER_PACKAGES=""
251 COMPILER_PACKAGES=""
262
252
263 # Check if apt-cacher-ng has port 3142 open and set APT_PROXY
253 # Check if apt-cacher-ng has port 3142 open and set APT_PROXY
264 APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d')
254 APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d')
265 if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then
255 if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then
266 APT_PROXY=http://127.0.0.1:3142/
256 APT_PROXY=http://127.0.0.1:3142/
267 fi
257 fi
268
258
269 # Setup architecture specific settings
259 # Setup architecture specific settings
270 if [ -n "$SET_ARCH" ] ; then
260 if [ -n "$SET_ARCH" ] ; then
271 # 64-bit configuration
261 # 64-bit configuration
272 if [ "$SET_ARCH" = 64 ] ; then
262 if [ "$SET_ARCH" = 64 ] ; then
273 # General 64-bit depended settings
263 # General 64-bit depended settings
274 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
264 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
275 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
265 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
276 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
266 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
277
267
278 # Raspberry Pi model specific settings
268 # Raspberry Pi model specific settings
279 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
269 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
280 if [ "$RPI_MODEL" != 4 ] ; then
270 if [ "$RPI_MODEL" != 4 ] ; then
281 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
271 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
282 else
272 else
283 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
273 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
284 fi
274 fi
285
275
286 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
276 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
287 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
277 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
288 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
278 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
289 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
279 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
290 else
280 else
291 echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit"
281 echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit"
292 exit 1
282 exit 1
293 fi
283 fi
294 fi
284 fi
295
285
296 # 32-bit configuration
286 # 32-bit configuration
297 if [ "$SET_ARCH" = 32 ] ; then
287 if [ "$SET_ARCH" = 32 ] ; then
298 # General 32-bit dependend settings
288 # General 32-bit dependend settings
299 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
289 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
300 KERNEL_ARCH=${KERNEL_ARCH:=arm}
290 KERNEL_ARCH=${KERNEL_ARCH:=arm}
301 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
291 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
302
292
303 # Raspberry Pi model specific settings
293 # Raspberry Pi model specific settings
304 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
294 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
305 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
295 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
306 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
296 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
307 RELEASE_ARCH=${RELEASE_ARCH:=armel}
297 RELEASE_ARCH=${RELEASE_ARCH:=armel}
308 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
298 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
309 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
299 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
310 fi
300 fi
311
301
312 # Raspberry Pi model specific settings
302 # Raspberry Pi model specific settings
313 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
303 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
314 if [ "$RPI_MODEL" != 4 ] ; then
304 if [ "$RPI_MODEL" != 4 ] ; then
315 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
305 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
316 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
306 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
317 else
307 else
318 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
308 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
319 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7l.img}
309 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7l.img}
320 fi
310 fi
321
311
322 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
312 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
323 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
313 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
324 <<<<<<< HEAD
314 <<<<<<< HEAD
325 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
315 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
326 =======
316 =======
327 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
317 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
328
318
329 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
319 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
330 fi
320 fi
331 fi
321 fi
332 # SET_ARCH not set
322 # SET_ARCH not set
333 else
323 else
334 echo "error: Please set '32' or '64' as value for SET_ARCH"
324 echo "error: Please set '32' or '64' as value for SET_ARCH"
335 exit 1
325 exit 1
336 fi
326 fi
337 # Device specific configuration and U-Boot configuration
327 # Device specific configuration and U-Boot configuration
338 case "$RPI_MODEL" in
328 case "$RPI_MODEL" in
339 0)
329 0)
340 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
330 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
341 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
331 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
342 ;;
332 ;;
343 1)
333 1)
344 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
334 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
345 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
335 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
346 ;;
336 ;;
347 1P)
337 1P)
348 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
338 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
349 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
339 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
350 ;;
340 ;;
351 2)
341 2)
352 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
342 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
353 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
343 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
354 ;;
344 ;;
355 3)
345 3)
356 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
346 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
357 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
347 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
358 ;;
348 ;;
359 3P)
349 3P)
360 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
350 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
361 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
351 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
362 ;;
352 ;;
363 4)
353 4)
364 DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb}
354 DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb}
365 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig}
355 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig}
366 ;;
356 ;;
367 *)
357 *)
368 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
358 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
369 exit 1
359 exit 1
370 ;;
360 ;;
371 esac
361 esac
372
362
373 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
363 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
374 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
364 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
375 # Include bluetooth packages on supported boards
365 # Include bluetooth packages on supported boards
376 if [ "$ENABLE_BLUETOOTH" = true ] ; then
366 if [ "$ENABLE_BLUETOOTH" = true ] ; then
377 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
367 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
378 fi
368 fi
379 if [ "$ENABLE_WIRELESS" = true ] ; then
369 if [ "$ENABLE_WIRELESS" = true ] ; then
380 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb"
370 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb"
381 fi
371 fi
382 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
372 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
383 # Check if the internal wireless interface is not supported by the RPi model
373 # Check if the internal wireless interface is not supported by the RPi model
384 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
374 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
385 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
375 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
386 exit 1
376 exit 1
387 fi
377 fi
388 fi
378 fi
389
379
390 if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then
380 if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then
391 echo "error: You have to compile kernel sources, if you want to enable nexmon"
381 echo "error: You have to compile kernel sources, if you want to enable nexmon"
392 exit 1
382 exit 1
393 fi
383 fi
394
384
395 # Prepare date string for default image file name
385 # Prepare date string for default image file name
396 DATE="$(date +%Y-%m-%d)"
386 DATE="$(date +%Y-%m-%d)"
397 if [ -z "$KERNEL_BRANCH" ] ; then
387 if [ -z "$KERNEL_BRANCH" ] ; then
398 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
388 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
399 else
389 else
400 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
390 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
401 fi
391 fi
402
392
403 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
393 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
404 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
394 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
405 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
395 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
406 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
396 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
407 exit 1
397 exit 1
408 fi
398 fi
409 fi
399 fi
410
400
411 # Add cmake to compile videocore sources
401 # Add cmake to compile videocore sources
412 if [ "$ENABLE_VIDEOCORE" = true ] ; then
402 if [ "$ENABLE_VIDEOCORE" = true ] ; then
413 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
403 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
414 fi
404 fi
415
405
416 # Add deps for nexmon
406 # Add deps for nexmon
417 if [ "$ENABLE_NEXMON" = true ] ; then
407 if [ "$ENABLE_NEXMON" = true ] ; then
418 <<<<<<< HEAD
408 <<<<<<< HEAD
419 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool"
409 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool"
420 =======
410 =======
421 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
411 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
422 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf make autoconf automake build-essential libtool"
412 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf make autoconf automake build-essential libtool"
423 fi
413 fi
424
414
425 # Add libncurses5 to enable kernel menuconfig
415 # Add libncurses5 to enable kernel menuconfig
426 if [ "$KERNEL_MENUCONFIG" = true ] ; then
416 if [ "$KERNEL_MENUCONFIG" = true ] ; then
427 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
417 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
428 fi
418 fi
429
419
430 # Add ccache compiler cache for (faster) kernel cross (re)compilation
420 # Add ccache compiler cache for (faster) kernel cross (re)compilation
431 if [ "$KERNEL_CCACHE" = true ] ; then
421 if [ "$KERNEL_CCACHE" = true ] ; then
432 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
422 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
433 fi
423 fi
434
424
435 # Add cryptsetup package to enable filesystem encryption
425 # Add cryptsetup package to enable filesystem encryption
436 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
426 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
437 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
427 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
438 <<<<<<< HEAD
428 <<<<<<< HEAD
439 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
429 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
440 =======
430 =======
441 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
431 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
442 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup,cryptsetup-initramfs"
432 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup,cryptsetup-initramfs"
443
433
444 # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package
434 # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package
445 if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then
435 if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then
446 APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs"
436 APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs"
447 fi
437 fi
448
438
449 if [ -z "$CRYPTFS_PASSWORD" ] ; then
439 if [ -z "$CRYPTFS_PASSWORD" ] ; then
450 echo "error: no password defined (CRYPTFS_PASSWORD)!"
440 echo "error: no password defined (CRYPTFS_PASSWORD)!"
451 exit 1
441 exit 1
452 fi
442 fi
453 ENABLE_INITRAMFS=true
443 ENABLE_INITRAMFS=true
454 fi
444 fi
455
445
456 # Add initramfs generation tools
446 # Add initramfs generation tools
457 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
447 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
458 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
448 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
459 fi
449 fi
460
450
461 # Add device-tree-compiler required for building the U-Boot bootloader
451 # Add device-tree-compiler required for building the U-Boot bootloader
462 if [ "$ENABLE_UBOOT" = true ] ; then
452 if [ "$ENABLE_UBOOT" = true ] ; then
463 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
453 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
464 fi
454 fi
465
455
466 if [ "$ENABLE_USBBOOT" = true ] ; then
456 if [ "$ENABLE_USBBOOT" = true ] ; then
467 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then
457 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then
468 echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P"
458 echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P"
469 exit 1
459 exit 1
470 fi
460 fi
471 fi
461 fi
472
462
473 # Check if root SSH (v2) public key file exists
463 # Check if root SSH (v2) public key file exists
474 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
464 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
475 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
465 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
476 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
466 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
477 exit 1
467 exit 1
478 fi
468 fi
479 fi
469 fi
480
470
481 # Check if $USER_NAME SSH (v2) public key file exists
471 # Check if $USER_NAME SSH (v2) public key file exists
482 if [ -n "$SSH_USER_PUB_KEY" ] ; then
472 if [ -n "$SSH_USER_PUB_KEY" ] ; then
483 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
473 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
484 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
474 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
485 exit 1
475 exit 1
486 fi
476 fi
487 fi
477 fi
488
478
489 if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then
479 if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then
490 echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON"
480 echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON"
491 exit 1
481 exit 1
492 fi
482 fi
493
483
494 # Check if all required packages are installed on the build system
484 # Check if all required packages are installed on the build system
495 for package in $REQUIRED_PACKAGES ; do
485 for package in $REQUIRED_PACKAGES ; do
496 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
486 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
497 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
487 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
498 fi
488 fi
499 done
489 done
500
490
501 # If there are missing packages ask confirmation for install, or exit
491 # If there are missing packages ask confirmation for install, or exit
502 if [ -n "$MISSING_PACKAGES" ] ; then
492 if [ -n "$MISSING_PACKAGES" ] ; then
503 echo "the following packages needed by this script are not installed:"
493 echo "the following packages needed by this script are not installed:"
504 echo "$MISSING_PACKAGES"
494 echo "$MISSING_PACKAGES"
505
495
506 printf "\ndo you want to install the missing packages right now? [y/n] "
496 printf "\ndo you want to install the missing packages right now? [y/n] "
507 read -r confirm
497 read -r confirm
508 [ "$confirm" != "y" ] && exit 1
498 [ "$confirm" != "y" ] && exit 1
509
499
510 # Make sure all missing required packages are installed
500 # Make sure all missing required packages are installed
511 <<<<<<< HEAD
501 <<<<<<< HEAD
512 apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
502 apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
513 =======
503 =======
514 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
504 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
515 apt-get update && apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
505 apt-get update && apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
516 fi
506 fi
517
507
518 # Check if ./bootstrap.d directory exists
508 # Check if ./bootstrap.d directory exists
519 if [ ! -d "./bootstrap.d/" ] ; then
509 if [ ! -d "./bootstrap.d/" ] ; then
520 echo "error: './bootstrap.d' required directory not found!"
510 echo "error: './bootstrap.d' required directory not found!"
521 exit 1
511 exit 1
522 fi
512 fi
523
513
524 # Check if ./files directory exists
514 # Check if ./files directory exists
525 if [ ! -d "./files/" ] ; then
515 if [ ! -d "./files/" ] ; then
526 echo "error: './files' required directory not found!"
516 echo "error: './files' required directory not found!"
527 exit 1
517 exit 1
528 fi
518 fi
529
519
530 # Check if specified KERNELSRC_DIR directory exists
520 # Check if specified KERNELSRC_DIR directory exists
531 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
521 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
532 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
522 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
533 exit 1
523 exit 1
534 fi
524 fi
535
525
536 # Check if specified UBOOTSRC_DIR directory exists
526 # Check if specified UBOOTSRC_DIR directory exists
537 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
527 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
538 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
528 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
539 exit 1
529 exit 1
540 fi
530 fi
541
531
542 # Check if specified VIDEOCORESRC_DIR directory exists
532 # Check if specified VIDEOCORESRC_DIR directory exists
543 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
533 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
544 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
534 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
545 exit 1
535 exit 1
546 fi
536 fi
547
537
548 # Check if specified FBTURBOSRC_DIR directory exists
538 # Check if specified FBTURBOSRC_DIR directory exists
549 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
539 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
550 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
540 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
551 exit 1
541 exit 1
552 fi
542 fi
553
543
554 # Check if specified NEXMONSRC_DIR directory exists
544 # Check if specified NEXMONSRC_DIR directory exists
555 if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then
545 if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then
556 echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!"
546 echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!"
557 exit 1
547 exit 1
558 fi
548 fi
559
549
560 # Check if specified CHROOT_SCRIPTS directory exists
550 # Check if specified CHROOT_SCRIPTS directory exists
561 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
551 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
562 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
552 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
563 exit 1
553 exit 1
564 fi
554 fi
565
555
566 # Check if specified device mapping already exists (will be used by cryptsetup)
556 # Check if specified device mapping already exists (will be used by cryptsetup)
567 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
557 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
568 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
558 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
569 exit 1
559 exit 1
570 fi
560 fi
571
561
572 # Don't clobber an old build
562 # Don't clobber an old build
573 if [ -e "$BUILDDIR" ] ; then
563 if [ -e "$BUILDDIR" ] ; then
574 echo "error: directory ${BUILDDIR} already exists, not proceeding"
564 echo "error: directory ${BUILDDIR} already exists, not proceeding"
575 exit 1
565 exit 1
576 fi
566 fi
577
567
578 # Setup chroot directory
568 # Setup chroot directory
579 mkdir -p "${R}"
569 mkdir -p "${R}"
580
570
581 # Check if build directory has enough of free disk space >512MB
571 # Check if build directory has enough of free disk space >512MB
582 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
572 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
583 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
573 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
584 exit 1
574 exit 1
585 fi
575 fi
586
576
587 set -x
577 set -x
588
578
589 # Call "cleanup" function on various signals and errors
579 # Call "cleanup" function on various signals and errors
590 trap cleanup 0 1 2 3 6
580 trap cleanup 0 1 2 3 6
591
581
592 # Add required packages for the minbase installation
582 # Add required packages for the minbase installation
593 if [ "$ENABLE_MINBASE" = true ] ; then
583 if [ "$ENABLE_MINBASE" = true ] ; then
594 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
584 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
595 fi
585 fi
596
586
597 # Add parted package, required to get partprobe utility
587 # Add parted package, required to get partprobe utility
598 if [ "$EXPANDROOT" = true ] ; then
588 if [ "$EXPANDROOT" = true ] ; then
599 APT_INCLUDES="${APT_INCLUDES},parted"
589 APT_INCLUDES="${APT_INCLUDES},parted"
600 fi
590 fi
601
591
602 # Add dphys-swapfile package, required to enable swap
592 # Add dphys-swapfile package, required to enable swap
603 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
593 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
604 APT_INCLUDES="${APT_INCLUDES},dphys-swapfile"
594 APT_INCLUDES="${APT_INCLUDES},dphys-swapfile"
605 fi
595 fi
606
596
607 # Add dbus package, recommended if using systemd
597 # Add dbus package, recommended if using systemd
608 if [ "$ENABLE_DBUS" = true ] ; then
598 if [ "$ENABLE_DBUS" = true ] ; then
609 APT_INCLUDES="${APT_INCLUDES},dbus"
599 APT_INCLUDES="${APT_INCLUDES},dbus"
610 fi
600 fi
611
601
612 # Add iptables IPv4/IPv6 package
602 # Add iptables IPv4/IPv6 package
613 if [ "$ENABLE_IPTABLES" = true ] ; then
603 if [ "$ENABLE_IPTABLES" = true ] ; then
614 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
604 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
615 fi
605 fi
616 # Add apparmor for KERNEL_SECURITY
606 # Add apparmor for KERNEL_SECURITY
617 if [ "$KERNEL_SECURITY" = true ] ; then
607 if [ "$KERNEL_SECURITY" = true ] ; then
618 APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl"
608 APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl"
619 fi
609 fi
620
610
621 # Add openssh server package
611 # Add openssh server package
622 if [ "$ENABLE_SSHD" = true ] ; then
612 if [ "$ENABLE_SSHD" = true ] ; then
623 APT_INCLUDES="${APT_INCLUDES},openssh-server"
613 APT_INCLUDES="${APT_INCLUDES},openssh-server"
624 fi
614 fi
625
615
626 # Add alsa-utils package
616 # Add alsa-utils package
627 if [ "$ENABLE_SOUND" = true ] ; then
617 if [ "$ENABLE_SOUND" = true ] ; then
628 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
618 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
629 fi
619 fi
630
620
631 # Add rng-tools package
621 # Add rng-tools package
632 if [ "$ENABLE_HWRANDOM" = true ] ; then
622 if [ "$ENABLE_HWRANDOM" = true ] ; then
633 APT_INCLUDES="${APT_INCLUDES},rng-tools"
623 APT_INCLUDES="${APT_INCLUDES},rng-tools"
634 fi
624 fi
635
625
636 # Add fbturbo video driver
626 # Add fbturbo video driver
637 if [ "$ENABLE_FBTURBO" = true ] ; then
627 if [ "$ENABLE_FBTURBO" = true ] ; then
638 # Enable xorg package dependencies
628 # Enable xorg package dependencies
639 ENABLE_XORG=true
629 ENABLE_XORG=true
640 fi
630 fi
641
631
642 # Add user defined window manager package
632 # Add user defined window manager package
643 if [ -n "$ENABLE_WM" ] ; then
633 if [ -n "$ENABLE_WM" ] ; then
644 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
634 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
645
635
646 # Enable xorg package dependencies
636 # Enable xorg package dependencies
647 ENABLE_XORG=true
637 ENABLE_XORG=true
648 fi
638 fi
649
639
650 # Add xorg package
640 # Add xorg package
651 if [ "$ENABLE_XORG" = true ] ; then
641 if [ "$ENABLE_XORG" = true ] ; then
652 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
642 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
653 fi
643 fi
654
644
655 # Replace selected packages with smaller clones
645 # Replace selected packages with smaller clones
656 if [ "$ENABLE_REDUCE" = true ] ; then
646 if [ "$ENABLE_REDUCE" = true ] ; then
657 # Add levee package instead of vim-tiny
647 # Add levee package instead of vim-tiny
658 if [ "$REDUCE_VIM" = true ] ; then
648 if [ "$REDUCE_VIM" = true ] ; then
659 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
649 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
660 fi
650 fi
661
651
662 # Add dropbear package instead of openssh-server
652 # Add dropbear package instead of openssh-server
663 if [ "$REDUCE_SSHD" = true ] ; then
653 if [ "$REDUCE_SSHD" = true ] ; then
664 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
654 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
665 fi
655 fi
666 fi
656 fi
667
657
668 # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available
658 # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available
669 if [ "$ENABLE_SYSVINIT" = false ] ; then
659 if [ "$ENABLE_SYSVINIT" = false ] ; then
670 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
660 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
671 fi
661 fi
672
662
673 # Configure kernel sources if no KERNELSRC_DIR
663 # Configure kernel sources if no KERNELSRC_DIR
674 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
664 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
675 KERNELSRC_CONFIG=true
665 KERNELSRC_CONFIG=true
676 fi
666 fi
677
667
678 # Configure reduced kernel
668 # Configure reduced kernel
679 if [ "$KERNEL_REDUCE" = true ] ; then
669 if [ "$KERNEL_REDUCE" = true ] ; then
680 KERNELSRC_CONFIG=false
670 KERNELSRC_CONFIG=false
681 fi
671 fi
682
672
683 # Configure qemu compatible kernel
673 # Configure qemu compatible kernel
684 if [ "$ENABLE_QEMU" = true ] ; then
674 if [ "$ENABLE_QEMU" = true ] ; then
685 DTB_FILE=vexpress-v2p-ca15_a7.dtb
675 DTB_FILE=vexpress-v2p-ca15_a7.dtb
686 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
676 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
687 KERNEL_DEFCONFIG="vexpress_defconfig"
677 KERNEL_DEFCONFIG="vexpress_defconfig"
688 if [ "$KERNEL_MENUCONFIG" = false ] ; then
678 if [ "$KERNEL_MENUCONFIG" = false ] ; then
689 KERNEL_OLDDEFCONFIG=true
679 KERNEL_OLDDEFCONFIG=true
690 fi
680 fi
691 fi
681 fi
692
682
693 # Execute bootstrap scripts
683 # Execute bootstrap scripts
694 for SCRIPT in bootstrap.d/*.sh; do
684 for SCRIPT in bootstrap.d/*.sh; do
695 head -n 3 "$SCRIPT"
685 head -n 3 "$SCRIPT"
696 . "$SCRIPT"
686 . "$SCRIPT"
697 done
687 done
698
688
699 ## Execute custom bootstrap scripts
689 ## Execute custom bootstrap scripts
700 if [ -d "custom.d" ] ; then
690 if [ -d "custom.d" ] ; then
701 for SCRIPT in custom.d/*.sh; do
691 for SCRIPT in custom.d/*.sh; do
702 . "$SCRIPT"
692 . "$SCRIPT"
703 done
693 done
704 fi
694 fi
705
695
706 # Execute custom scripts inside the chroot
696 # Execute custom scripts inside the chroot
707 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
697 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
708 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
698 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
709 chroot_exec /bin/bash -x <<'EOF'
699 chroot_exec /bin/bash -x <<'EOF'
710 for SCRIPT in /chroot_scripts/* ; do
700 for SCRIPT in /chroot_scripts/* ; do
711 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
701 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
712 $SCRIPT
702 $SCRIPT
713 fi
703 fi
714 done
704 done
715 EOF
705 EOF
716 rm -rf "${R}/chroot_scripts"
706 rm -rf "${R}/chroot_scripts"
717 fi
707 fi
718
708
719 # Remove c/c++ build environment from the chroot
709 # Remove c/c++ build environment from the chroot
720 chroot_remove_cc
710 chroot_remove_cc
721
711
722 # Generate required machine-id
712 # Generate required machine-id
723 MACHINE_ID=$(dbus-uuidgen)
713 MACHINE_ID=$(dbus-uuidgen)
724 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
714 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
725 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
715 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
726
716
727 # APT Cleanup
717 # APT Cleanup
728 chroot_exec apt-get -y clean
718 chroot_exec apt-get -y clean
729 chroot_exec apt-get -y autoclean
719 chroot_exec apt-get -y autoclean
730 chroot_exec apt-get -y autoremove
720 chroot_exec apt-get -y autoremove
731
721
732 # Unmount mounted filesystems
722 # Unmount mounted filesystems
733 umount -l "${R}/proc"
723 umount -l "${R}/proc"
734 umount -l "${R}/sys"
724 umount -l "${R}/sys"
735
725
736 # Clean up directories
726 # Clean up directories
737 rm -rf "${R}/run/*"
727 rm -rf "${R}/run/*"
738 rm -rf "${R}/tmp/*"
728 rm -rf "${R}/tmp/*"
739
729
740 # Clean up APT proxy settings
730 # Clean up APT proxy settings
741 if [ "$KEEP_APT_PROXY" = false ] ; then
731 if [ "$KEEP_APT_PROXY" = false ] ; then
742 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
732 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
743 fi
733 fi
744
734
745 # Clean up files
735 # Clean up files
746 rm -f "${ETC_DIR}/ssh/ssh_host_*"
736 rm -f "${ETC_DIR}/ssh/ssh_host_*"
747 rm -f "${ETC_DIR}/dropbear/dropbear_*"
737 rm -f "${ETC_DIR}/dropbear/dropbear_*"
748 rm -f "${ETC_DIR}/apt/sources.list.save"
738 rm -f "${ETC_DIR}/apt/sources.list.save"
749 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
739 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
750 rm -f "${ETC_DIR}/*-"
740 rm -f "${ETC_DIR}/*-"
751 rm -f "${ETC_DIR}/resolv.conf"
741 rm -f "${ETC_DIR}/resolv.conf"
752 rm -f "${R}/root/.bash_history"
742 rm -f "${R}/root/.bash_history"
753 rm -f "${R}/var/lib/urandom/random-seed"
743 rm -f "${R}/var/lib/urandom/random-seed"
754 rm -f "${R}/initrd.img"
744 rm -f "${R}/initrd.img"
755 rm -f "${R}/vmlinuz"
745 rm -f "${R}/vmlinuz"
756 rm -f "${R}${QEMU_BINARY}"
746 rm -f "${R}${QEMU_BINARY}"
757
747
758 if [ "$ENABLE_QEMU" = true ] ; then
748 if [ "$ENABLE_QEMU" = true ] ; then
759 # Setup QEMU directory
749 # Setup QEMU directory
760 mkdir "${BASEDIR}/qemu"
750 mkdir "${BASEDIR}/qemu"
761
751
762 # Copy kernel image to QEMU directory
752 # Copy kernel image to QEMU directory
763 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
753 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
764
754
765 # Copy kernel config to QEMU directory
755 # Copy kernel config to QEMU directory
766 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
756 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
767
757
768 # Copy kernel dtbs to QEMU directory
758 # Copy kernel dtbs to QEMU directory
769 for dtb in "${BOOT_DIR}/"*.dtb ; do
759 for dtb in "${BOOT_DIR}/"*.dtb ; do
770 if [ -f "${dtb}" ] ; then
760 if [ -f "${dtb}" ] ; then
771 install_readonly "${dtb}" "${BASEDIR}/qemu/"
761 install_readonly "${dtb}" "${BASEDIR}/qemu/"
772 fi
762 fi
773 done
763 done
774
764
775 # Copy kernel overlays to QEMU directory
765 # Copy kernel overlays to QEMU directory
776 if [ -d "${BOOT_DIR}/overlays" ] ; then
766 if [ -d "${BOOT_DIR}/overlays" ] ; then
777 # Setup overlays dtbs directory
767 # Setup overlays dtbs directory
778 mkdir "${BASEDIR}/qemu/overlays"
768 mkdir "${BASEDIR}/qemu/overlays"
779
769
780 for dtb in "${BOOT_DIR}/overlays/"*.dtbo ; do
770 for dtb in "${BOOT_DIR}/overlays/"*.dtbo ; do
781 if [ -f "${dtb}" ] ; then
771 if [ -f "${dtb}" ] ; then
782 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
772 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
783 fi
773 fi
784 done
774 done
785 fi
775 fi
786
776
787 # Copy u-boot files to QEMU directory
777 # Copy u-boot files to QEMU directory
788 if [ "$ENABLE_UBOOT" = true ] ; then
778 if [ "$ENABLE_UBOOT" = true ] ; then
789 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
779 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
790 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
780 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
791 fi
781 fi
792 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
782 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
793 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
783 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
794 fi
784 fi
795 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
785 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
796 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
786 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
797 fi
787 fi
798 fi
788 fi
799
789
800 # Copy initramfs to QEMU directory
790 # Copy initramfs to QEMU directory
801 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
791 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
802 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
792 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
803 fi
793 fi
804 fi
794 fi
805
795
806 # Calculate size of the chroot directory in KB
796 # Calculate size of the chroot directory in KB
807 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
797 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
808
798
809 # Calculate the amount of needed 512 Byte sectors
799 # Calculate the amount of needed 512 Byte sectors
810 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
800 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
811 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
801 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
812 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
802 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
813
803
814 # The root partition is EXT4
804 # The root partition is EXT4
815 # This means more space than the actual used space of the chroot is used.
805 # This means more space than the actual used space of the chroot is used.
816 # As overhead for journaling and reserved blocks 35% are added.
806 # As overhead for journaling and reserved blocks 35% are added.
817 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
807 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
818
808
819 # Calculate required image size in 512 Byte sectors
809 # Calculate required image size in 512 Byte sectors
820 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
810 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
821
811
822 # Prepare image file
812 # Prepare image file
823 if [ "$ENABLE_SPLITFS" = true ] ; then
813 if [ "$ENABLE_SPLITFS" = true ] ; then
824 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
814 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
825 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
815 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
826 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
816 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
827 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
817 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
828
818
829 # Write firmware/boot partition tables
819 # Write firmware/boot partition tables
830 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
820 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
831 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
821 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
832 EOM
822 EOM
833
823
834 # Write root partition table
824 # Write root partition table
835 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
825 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
836 ${TABLE_SECTORS},${ROOT_SECTORS},83
826 ${TABLE_SECTORS},${ROOT_SECTORS},83
837 EOM
827 EOM
838
828
839 # Setup temporary loop devices
829 # Setup temporary loop devices
840 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
830 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
841 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
831 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
842 else # ENABLE_SPLITFS=false
832 else # ENABLE_SPLITFS=false
843 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
833 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
844 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
834 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
845
835
846 # Write partition table
836 # Write partition table
847 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
837 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
848 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
838 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
849 ${ROOT_OFFSET},${ROOT_SECTORS},83
839 ${ROOT_OFFSET},${ROOT_SECTORS},83
850 EOM
840 EOM
851
841
852 # Setup temporary loop devices
842 # Setup temporary loop devices
853 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
843 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
854 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
844 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
855 fi
845 fi
856
846
857 if [ "$ENABLE_CRYPTFS" = true ] ; then
847 if [ "$ENABLE_CRYPTFS" = true ] ; then
858 # Create dummy ext4 fs
848 # Create dummy ext4 fs
859 mkfs.ext4 "$ROOT_LOOP"
849 mkfs.ext4 "$ROOT_LOOP"
860
850
861 # Setup password keyfile
851 # Setup password keyfile
862 touch .password
852 touch .password
863 chmod 600 .password
853 chmod 600 .password
864 echo -n ${CRYPTFS_PASSWORD} > .password
854 echo -n ${CRYPTFS_PASSWORD} > .password
865
855
866 # Initialize encrypted partition
856 # Initialize encrypted partition
867 <<<<<<< HEAD
857 <<<<<<< HEAD
868 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
858 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
869 =======
859 =======
870 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
860 >>>>>>> af203dbe173e4e5ca755058b3284dc61375ca579
871 cryptsetup --verbose --debug -q luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -h "${CRYPTFS_HASH}" -s "${CRYPTFS_XTSKEYSIZE}" .password
861 cryptsetup --verbose --debug -q luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -h "${CRYPTFS_HASH}" -s "${CRYPTFS_XTSKEYSIZE}" .password
872
862
873 # Open encrypted partition and setup mapping
863 # Open encrypted partition and setup mapping
874 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
864 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
875
865
876 # Secure delete password keyfile
866 # Secure delete password keyfile
877 shred -zu .password
867 shred -zu .password
878
868
879 # Update temporary loop device
869 # Update temporary loop device
880 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
870 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
881
871
882 # Wipe encrypted partition (encryption cipher is used for randomness)
872 # Wipe encrypted partition (encryption cipher is used for randomness)
883 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
873 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
884 fi
874 fi
885
875
886 # Build filesystems
876 # Build filesystems
887 mkfs.vfat "$FRMW_LOOP"
877 mkfs.vfat "$FRMW_LOOP"
888 mkfs.ext4 "$ROOT_LOOP"
878 mkfs.ext4 "$ROOT_LOOP"
889
879
890 # Mount the temporary loop devices
880 # Mount the temporary loop devices
891 mkdir -p "$BUILDDIR/mount"
881 mkdir -p "$BUILDDIR/mount"
892 mount "$ROOT_LOOP" "$BUILDDIR/mount"
882 mount "$ROOT_LOOP" "$BUILDDIR/mount"
893
883
894 mkdir -p "$BUILDDIR/mount/boot/firmware"
884 mkdir -p "$BUILDDIR/mount/boot/firmware"
895 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
885 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
896
886
897 # Copy all files from the chroot to the loop device mount point directory
887 # Copy all files from the chroot to the loop device mount point directory
898 rsync -a "${R}/" "$BUILDDIR/mount/"
888 rsync -a "${R}/" "$BUILDDIR/mount/"
899
889
900 # Unmount all temporary loop devices and mount points
890 # Unmount all temporary loop devices and mount points
901 cleanup
891 cleanup
902
892
903 # Create block map file(s) of image(s)
893 # Create block map file(s) of image(s)
904 if [ "$ENABLE_SPLITFS" = true ] ; then
894 if [ "$ENABLE_SPLITFS" = true ] ; then
905 # Create block map files for "bmaptool"
895 # Create block map files for "bmaptool"
906 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
896 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
907 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
897 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
908
898
909 # Image was successfully created
899 # Image was successfully created
910 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
900 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
911 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
901 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
912 else
902 else
913 # Create block map file for "bmaptool"
903 # Create block map file for "bmaptool"
914 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
904 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
915
905
916 # Image was successfully created
906 # Image was successfully created
917 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
907 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
918
908
919 # Create qemu qcow2 image
909 # Create qemu qcow2 image
920 if [ "$ENABLE_QEMU" = true ] ; then
910 if [ "$ENABLE_QEMU" = true ] ; then
921 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
911 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
922 QEMU_SIZE=16G
912 QEMU_SIZE=16G
923
913
924 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
914 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
925 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
915 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
926
916
927 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
917 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
928 fi
918 fi
929 fi
919 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant