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