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