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