##// END OF EJS Templates
Added: QEMU initramfs output
drtyhlpr -
r260:bd495e424ce6
parent child
Show More
@@ -1,741 +1,746
1 #!/bin/sh
1 #!/bin/sh
2
2
3 ########################################################################
3 ########################################################################
4 # rpi23-gen-image.sh 2015-2017
4 # rpi23-gen-image.sh 2015-2017
5 #
5 #
6 # Advanced Debian "jessie", "stretch" and "buster" bootstrap script for RPi2/3
6 # Advanced Debian "jessie", "stretch" and "buster" bootstrap script for RPi2/3
7 #
7 #
8 # This program is free software; you can redistribute it and/or
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
11 # of the License, or (at your option) any later version.
12 #
12 #
13 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
13 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
14 #
14 #
15 # Big thanks for patches and enhancements by 20+ github contributors!
15 # Big thanks for patches and enhancements by 20+ github contributors!
16 ########################################################################
16 ########################################################################
17
17
18 # Are we running as root?
18 # Are we running as root?
19 if [ "$(id -u)" -ne "0" ] ; then
19 if [ "$(id -u)" -ne "0" ] ; then
20 echo "error: this script must be executed with root privileges!"
20 echo "error: this script must be executed with root privileges!"
21 exit 1
21 exit 1
22 fi
22 fi
23
23
24 # Check if ./functions.sh script exists
24 # Check if ./functions.sh script exists
25 if [ ! -r "./functions.sh" ] ; then
25 if [ ! -r "./functions.sh" ] ; then
26 echo "error: './functions.sh' required script not found!"
26 echo "error: './functions.sh' required script not found!"
27 exit 1
27 exit 1
28 fi
28 fi
29
29
30 # Load utility functions
30 # Load utility functions
31 . ./functions.sh
31 . ./functions.sh
32
32
33 # Load parameters from configuration template file
33 # Load parameters from configuration template file
34 if [ ! -z "$CONFIG_TEMPLATE" ] ; then
34 if [ ! -z "$CONFIG_TEMPLATE" ] ; then
35 use_template
35 use_template
36 fi
36 fi
37
37
38 # Introduce settings
38 # Introduce settings
39 set -e
39 set -e
40 echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n"
40 echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n"
41 set -x
41 set -x
42
42
43 # Raspberry Pi model configuration
43 # Raspberry Pi model configuration
44 RPI_MODEL=${RPI_MODEL:=2}
44 RPI_MODEL=${RPI_MODEL:=2}
45 #bcm2708-rpi-0-w.dtb (Used for Pi 0 and PI 0W)
45 #bcm2708-rpi-0-w.dtb (Used for Pi 0 and PI 0W)
46 RPI0_DTB_FILE=${RPI0_DTB_FILE:=bcm2708-rpi-0-w.dtb}
46 RPI0_DTB_FILE=${RPI0_DTB_FILE:=bcm2708-rpi-0-w.dtb}
47 RPI0_UBOOT_CONFIG=${RPI0_UBOOT_CONFIG:=rpi_defconfig}
47 RPI0_UBOOT_CONFIG=${RPI0_UBOOT_CONFIG:=rpi_defconfig}
48 #bcm2708-rpi-b.dtb (Used for Pi 1 model A and B)
48 #bcm2708-rpi-b.dtb (Used for Pi 1 model A and B)
49 RPI1_DTB_FILE=${RPI1_DTB_FILE:=bcm2708-rpi-b.dtb}
49 RPI1_DTB_FILE=${RPI1_DTB_FILE:=bcm2708-rpi-b.dtb}
50 RPI1_UBOOT_CONFIG=${RPI1_UBOOT_CONFIG:=rpi_defconfig}
50 RPI1_UBOOT_CONFIG=${RPI1_UBOOT_CONFIG:=rpi_defconfig}
51 #bcm2708-rpi-b-plus.dtb (Used for Pi 1 model B+ and A+)
51 #bcm2708-rpi-b-plus.dtb (Used for Pi 1 model B+ and A+)
52 RPI1P_DTB_FILE=${RPI1P_DTB_FILE:=bcm2708-rpi-b-plus.dtb}
52 RPI1P_DTB_FILE=${RPI1P_DTB_FILE:=bcm2708-rpi-b-plus.dtb}
53 RPI1P_UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG:=rpi_defconfig}
53 RPI1P_UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG:=rpi_defconfig}
54 #bcm2709-rpi-2-b.dtb (Used for Pi 2 model B)
54 #bcm2709-rpi-2-b.dtb (Used for Pi 2 model B)
55 RPI2_DTB_FILE=${RPI2_DTB_FILE:=bcm2709-rpi-2-b.dtb}
55 RPI2_DTB_FILE=${RPI2_DTB_FILE:=bcm2709-rpi-2-b.dtb}
56 RPI2_UBOOT_CONFIG=${RPI2_UBOOT_CONFIG:=rpi_2_defconfig}
56 RPI2_UBOOT_CONFIG=${RPI2_UBOOT_CONFIG:=rpi_2_defconfig}
57 #bcm2710-rpi-3-b.dtb (Used for Pi 3 model B)
57 #bcm2710-rpi-3-b.dtb (Used for Pi 3 model B)
58 RPI3_DTB_FILE=${RPI3_DTB_FILE:=bcm2710-rpi-3-b.dtb}
58 RPI3_DTB_FILE=${RPI3_DTB_FILE:=bcm2710-rpi-3-b.dtb}
59 RPI3_UBOOT_CONFIG=${RPI3_UBOOT_CONFIG:=rpi_3_32b_defconfig}
59 RPI3_UBOOT_CONFIG=${RPI3_UBOOT_CONFIG:=rpi_3_32b_defconfig}
60 #bcm2710-rpi-3-b-plus.dtb (Used for Pi 3 model B+)
60 #bcm2710-rpi-3-b-plus.dtb (Used for Pi 3 model B+)
61 RPI3P_DTB_FILE=${RPI3P_DTB_FILE:=bcm2710-rpi-3-b-plus.dtb}
61 RPI3P_DTB_FILE=${RPI3P_DTB_FILE:=bcm2710-rpi-3-b-plus.dtb}
62 RPI3P_UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG:=rpi_3_32b_defconfig}
62 RPI3P_UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG:=rpi_3_32b_defconfig}
63
63
64 # Debian release
64 # Debian release
65 RELEASE=${RELEASE:=jessie}
65 RELEASE=${RELEASE:=jessie}
66 KERNEL_ARCH=${KERNEL_ARCH:=arm}
66 KERNEL_ARCH=${KERNEL_ARCH:=arm}
67 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
67 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
68 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
68 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
69 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
69 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
70 if [ "$KERNEL_ARCH" = "arm64" ] ; then
70 if [ "$KERNEL_ARCH" = "arm64" ] ; then
71 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
71 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
72 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
72 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
73 fi
73 fi
74
74
75 if [ "$RPI_MODEL" = 0 || "$RPI_MODEL" = 1 || "$RPI_MODEL" = 1P ] ; then
75 if [ "$RPI_MODEL" = 0 || "$RPI_MODEL" = 1 || "$RPI_MODEL" = 1P ] ; then
76 #RASPBERRY PI 1, PI ZERO, PI ZERO W, AND COMPUTE MODULE DEFAULT Kernel BUILD CONFIGURATION
76 #RASPBERRY PI 1, PI ZERO, PI ZERO W, AND COMPUTE MODULE DEFAULT Kernel BUILD CONFIGURATION
77 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
77 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
78 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
78 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
79 else
79 else
80 #RASPBERRY PI 2, PI 3, PI 3+, AND COMPUTE MODULE 3 DEFAULT Kernel BUILD CONFIGURATION
80 #RASPBERRY PI 2, PI 3, PI 3+, AND COMPUTE MODULE 3 DEFAULT Kernel BUILD CONFIGURATION
81 #https://www.raspberrypi.org/documentation/linux/kernel/building.md
81 #https://www.raspberrypi.org/documentation/linux/kernel/building.md
82 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
82 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
83 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
83 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
84 fi
84 fi
85
85
86 if [ "$RELEASE_ARCH" = "arm64" ] ; then
86 if [ "$RELEASE_ARCH" = "arm64" ] ; then
87 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
87 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
88 else
88 else
89 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
89 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
90 fi
90 fi
91 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
91 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
92
92
93 # URLs
93 # URLs
94 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
94 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
95 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
95 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
96 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
96 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
97 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
97 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
98 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
98 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
99 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
99 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
100
100
101 # Build directories
101 # Build directories
102 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
102 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
103 BUILDDIR="${BASEDIR}/build"
103 BUILDDIR="${BASEDIR}/build"
104
104
105 # Prepare date string for default image file name
105 # Prepare date string for default image file name
106 DATE="$(date +%Y-%m-%d)"
106 DATE="$(date +%Y-%m-%d)"
107 if [ -z "$KERNEL_BRANCH" ] ; then
107 if [ -z "$KERNEL_BRANCH" ] ; then
108 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
108 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
109 else
109 else
110 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
110 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
111 fi
111 fi
112
112
113 # Chroot directories
113 # Chroot directories
114 R="${BUILDDIR}/chroot"
114 R="${BUILDDIR}/chroot"
115 ETC_DIR="${R}/etc"
115 ETC_DIR="${R}/etc"
116 LIB_DIR="${R}/lib"
116 LIB_DIR="${R}/lib"
117 BOOT_DIR="${R}/boot/firmware"
117 BOOT_DIR="${R}/boot/firmware"
118 KERNEL_DIR="${R}/usr/src/linux"
118 KERNEL_DIR="${R}/usr/src/linux"
119 WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm"
119 WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm"
120
120
121 # Firmware directory: Blank if download from github
121 # Firmware directory: Blank if download from github
122 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
122 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
123
123
124 # General settings
124 # General settings
125 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
125 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
126 PASSWORD=${PASSWORD:=raspberry}
126 PASSWORD=${PASSWORD:=raspberry}
127 USER_PASSWORD=${USER_PASSWORD:=raspberry}
127 USER_PASSWORD=${USER_PASSWORD:=raspberry}
128 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
128 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
129 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
129 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
130 EXPANDROOT=${EXPANDROOT:=true}
130 EXPANDROOT=${EXPANDROOT:=true}
131
131
132 # Keyboard settings
132 # Keyboard settings
133 XKB_MODEL=${XKB_MODEL:=""}
133 XKB_MODEL=${XKB_MODEL:=""}
134 XKB_LAYOUT=${XKB_LAYOUT:=""}
134 XKB_LAYOUT=${XKB_LAYOUT:=""}
135 XKB_VARIANT=${XKB_VARIANT:=""}
135 XKB_VARIANT=${XKB_VARIANT:=""}
136 XKB_OPTIONS=${XKB_OPTIONS:=""}
136 XKB_OPTIONS=${XKB_OPTIONS:=""}
137
137
138 # Network settings (DHCP)
138 # Network settings (DHCP)
139 ENABLE_DHCP=${ENABLE_DHCP:=true}
139 ENABLE_DHCP=${ENABLE_DHCP:=true}
140
140
141 # Network settings (static)
141 # Network settings (static)
142 NET_ADDRESS=${NET_ADDRESS:=""}
142 NET_ADDRESS=${NET_ADDRESS:=""}
143 NET_GATEWAY=${NET_GATEWAY:=""}
143 NET_GATEWAY=${NET_GATEWAY:=""}
144 NET_DNS_1=${NET_DNS_1:=""}
144 NET_DNS_1=${NET_DNS_1:=""}
145 NET_DNS_2=${NET_DNS_2:=""}
145 NET_DNS_2=${NET_DNS_2:=""}
146 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
146 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
147 NET_NTP_1=${NET_NTP_1:=""}
147 NET_NTP_1=${NET_NTP_1:=""}
148 NET_NTP_2=${NET_NTP_2:=""}
148 NET_NTP_2=${NET_NTP_2:=""}
149
149
150 # APT settings
150 # APT settings
151 APT_PROXY=${APT_PROXY:=""}
151 APT_PROXY=${APT_PROXY:=""}
152 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
152 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
153
153
154 # Feature settings
154 # Feature settings
155 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
155 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
156 ENABLE_I2C=${ENABLE_I2C:=false}
156 ENABLE_I2C=${ENABLE_I2C:=false}
157 ENABLE_SPI=${ENABLE_SPI:=false}
157 ENABLE_SPI=${ENABLE_SPI:=false}
158 ENABLE_IPV6=${ENABLE_IPV6:=true}
158 ENABLE_IPV6=${ENABLE_IPV6:=true}
159 ENABLE_SSHD=${ENABLE_SSHD:=true}
159 ENABLE_SSHD=${ENABLE_SSHD:=true}
160 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
160 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
161 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
161 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
162 ENABLE_SOUND=${ENABLE_SOUND:=true}
162 ENABLE_SOUND=${ENABLE_SOUND:=true}
163 ENABLE_DBUS=${ENABLE_DBUS:=true}
163 ENABLE_DBUS=${ENABLE_DBUS:=true}
164 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
164 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
165 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
165 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
166 ENABLE_XORG=${ENABLE_XORG:=false}
166 ENABLE_XORG=${ENABLE_XORG:=false}
167 ENABLE_WM=${ENABLE_WM:=""}
167 ENABLE_WM=${ENABLE_WM:=""}
168 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
168 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
169 ENABLE_USER=${ENABLE_USER:=true}
169 ENABLE_USER=${ENABLE_USER:=true}
170 USER_NAME=${USER_NAME:="pi"}
170 USER_NAME=${USER_NAME:="pi"}
171 ENABLE_ROOT=${ENABLE_ROOT:=false}
171 ENABLE_ROOT=${ENABLE_ROOT:=false}
172 ENABLE_QEMU=${ENABLE_QEMU:=false}
172 ENABLE_QEMU=${ENABLE_QEMU:=false}
173
173
174 # SSH settings
174 # SSH settings
175 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
175 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
176 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
176 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
177 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
177 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
178 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
178 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
179 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
179 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
180
180
181 # Advanced settings
181 # Advanced settings
182 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
182 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
183 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
183 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
184 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
184 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
185 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
185 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
186 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
186 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
187 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
187 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
188 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
188 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
189 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
189 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
190 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
190 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
191 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
191 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
192 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
192 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
193 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
193 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
194
194
195 # Kernel compilation settings
195 # Kernel compilation settings
196 BUILD_KERNEL=${BUILD_KERNEL:=false}
196 BUILD_KERNEL=${BUILD_KERNEL:=false}
197 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
197 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
198 KERNEL_THREADS=${KERNEL_THREADS:=1}
198 KERNEL_THREADS=${KERNEL_THREADS:=1}
199 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
199 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
200 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
200 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
201 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
201 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
202 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
202 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
203 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
203 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
204
204
205 if [ "$KERNEL_ARCH" = "arm64" ] ; then
205 if [ "$KERNEL_ARCH" = "arm64" ] ; then
206 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
206 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
207 else
207 else
208 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
208 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
209 fi
209 fi
210
210
211 # Kernel compilation from source directory settings
211 # Kernel compilation from source directory settings
212 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
212 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
213 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
213 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
214 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
214 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
215 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
215 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
216
216
217 # Reduce disk usage settings
217 # Reduce disk usage settings
218 REDUCE_APT=${REDUCE_APT:=true}
218 REDUCE_APT=${REDUCE_APT:=true}
219 REDUCE_DOC=${REDUCE_DOC:=true}
219 REDUCE_DOC=${REDUCE_DOC:=true}
220 REDUCE_MAN=${REDUCE_MAN:=true}
220 REDUCE_MAN=${REDUCE_MAN:=true}
221 REDUCE_VIM=${REDUCE_VIM:=false}
221 REDUCE_VIM=${REDUCE_VIM:=false}
222 REDUCE_BASH=${REDUCE_BASH:=false}
222 REDUCE_BASH=${REDUCE_BASH:=false}
223 REDUCE_HWDB=${REDUCE_HWDB:=true}
223 REDUCE_HWDB=${REDUCE_HWDB:=true}
224 REDUCE_SSHD=${REDUCE_SSHD:=true}
224 REDUCE_SSHD=${REDUCE_SSHD:=true}
225 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
225 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
226
226
227 # Encrypted filesystem settings
227 # Encrypted filesystem settings
228 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
228 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
229 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
229 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
230 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
230 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
231 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
231 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
232 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
232 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
233
233
234 # Chroot scripts directory
234 # Chroot scripts directory
235 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
235 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
236
236
237 # Packages required in the chroot build environment
237 # Packages required in the chroot build environment
238 APT_INCLUDES=${APT_INCLUDES:=""}
238 APT_INCLUDES=${APT_INCLUDES:=""}
239 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils"
239 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils"
240
240
241 # Packages required for bootstrapping
241 # Packages required for bootstrapping
242 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo"
242 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo"
243 MISSING_PACKAGES=""
243 MISSING_PACKAGES=""
244
244
245 # Packages installed for c/c++ build environment in chroot (keep empty)
245 # Packages installed for c/c++ build environment in chroot (keep empty)
246 COMPILER_PACKAGES=""
246 COMPILER_PACKAGES=""
247
247
248 set +x
248 set +x
249
249
250 # Set Raspberry Pi model specific configuration
250 # Set Raspberry Pi model specific configuration
251 if [ "$RPI_MODEL" = 0 ] ; then
251 if [ "$RPI_MODEL" = 0 ] ; then
252 DTB_FILE=${RPI2_DTB_FILE}
252 DTB_FILE=${RPI2_DTB_FILE}
253 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
253 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
254 elif [ "$RPI_MODEL" = 1 ] ; then
254 elif [ "$RPI_MODEL" = 1 ] ; then
255 DTB_FILE=${RPI2_DTB_FILE}
255 DTB_FILE=${RPI2_DTB_FILE}
256 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
256 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
257 elif [ "$RPI_MODEL" = 1P ] ; then
257 elif [ "$RPI_MODEL" = 1P ] ; then
258 DTB_FILE=${RPI2_DTB_FILE}
258 DTB_FILE=${RPI2_DTB_FILE}
259 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
259 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
260 elif [ "$RPI_MODEL" = 2 ] ; then
260 elif [ "$RPI_MODEL" = 2 ] ; then
261 DTB_FILE=${RPI2_DTB_FILE}
261 DTB_FILE=${RPI2_DTB_FILE}
262 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
262 UBOOT_CONFIG=${RPI2_UBOOT_CONFIG}
263 elif [ "$RPI_MODEL" = 3 ] ; then
263 elif [ "$RPI_MODEL" = 3 ] ; then
264 DTB_FILE=${RPI3_DTB_FILE}
264 DTB_FILE=${RPI3_DTB_FILE}
265 UBOOT_CONFIG=${RPI3_UBOOT_CONFIG}
265 UBOOT_CONFIG=${RPI3_UBOOT_CONFIG}
266 BUILD_KERNEL=true
266 BUILD_KERNEL=true
267 elif [ "$RPI_MODEL" = 3P ] ; then
267 elif [ "$RPI_MODEL" = 3P ] ; then
268 DTB_FILE=${RPI3P_DTB_FILE}
268 DTB_FILE=${RPI3P_DTB_FILE}
269 UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG}
269 UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG}
270 BUILD_KERNEL=true
270 BUILD_KERNEL=true
271 else
271 else
272 echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!"
272 echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!"
273 exit 1
273 exit 1
274 fi
274 fi
275
275
276 # Check if the internal wireless interface is supported by the RPi model
276 # Check if the internal wireless interface is supported by the RPi model
277 if [ "$ENABLE_WIRELESS" = true ] && [ "$RPI_MODEL" = 2 ]; then
277 if [ "$ENABLE_WIRELESS" = true ] && [ "$RPI_MODEL" = 2 ]; then
278 echo "error: The selected Raspberry Pi model has no internal wireless interface"
278 echo "error: The selected Raspberry Pi model has no internal wireless interface"
279 exit 1
279 exit 1
280 fi
280 fi
281
281
282 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
282 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
283 if [ ! -z "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
283 if [ ! -z "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
284 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
284 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
285 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
285 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
286 exit 1
286 exit 1
287 fi
287 fi
288 fi
288 fi
289
289
290 # Build RPi2/3 Linux kernel if required by Debian release
290 # Build RPi2/3 Linux kernel if required by Debian release
291 if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
291 if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then
292 BUILD_KERNEL=true
292 BUILD_KERNEL=true
293 fi
293 fi
294
294
295 # Add packages required for kernel cross compilation
295 # Add packages required for kernel cross compilation
296 if [ "$BUILD_KERNEL" = true ] ; then
296 if [ "$BUILD_KERNEL" = true ] ; then
297 if [ "$KERNEL_ARCH" = "arm" ] ; then
297 if [ "$KERNEL_ARCH" = "arm" ] ; then
298 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
298 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
299 else
299 else
300 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
300 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
301 fi
301 fi
302 fi
302 fi
303
303
304 # Add libncurses5 to enable kernel menuconfig
304 # Add libncurses5 to enable kernel menuconfig
305 if [ "$KERNEL_MENUCONFIG" = true ] ; then
305 if [ "$KERNEL_MENUCONFIG" = true ] ; then
306 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses5-dev"
306 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses5-dev"
307 fi
307 fi
308
308
309 # Add ccache compiler cache for (faster) kernel cross (re)compilation
309 # Add ccache compiler cache for (faster) kernel cross (re)compilation
310 if [ "$KERNEL_CCACHE" = true ] ; then
310 if [ "$KERNEL_CCACHE" = true ] ; then
311 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
311 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
312 fi
312 fi
313
313
314 # Add cryptsetup package to enable filesystem encryption
314 # Add cryptsetup package to enable filesystem encryption
315 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
315 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
316 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
316 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
317 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
317 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
318
318
319 if [ -z "$CRYPTFS_PASSWORD" ] ; then
319 if [ -z "$CRYPTFS_PASSWORD" ] ; then
320 echo "error: no password defined (CRYPTFS_PASSWORD)!"
320 echo "error: no password defined (CRYPTFS_PASSWORD)!"
321 exit 1
321 exit 1
322 fi
322 fi
323 ENABLE_INITRAMFS=true
323 ENABLE_INITRAMFS=true
324 fi
324 fi
325
325
326 # Add initramfs generation tools
326 # Add initramfs generation tools
327 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
327 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
328 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
328 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
329 fi
329 fi
330
330
331 # Add device-tree-compiler required for building the U-Boot bootloader
331 # Add device-tree-compiler required for building the U-Boot bootloader
332 if [ "$ENABLE_UBOOT" = true ] ; then
332 if [ "$ENABLE_UBOOT" = true ] ; then
333 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler"
333 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler"
334 fi
334 fi
335
335
336 # Check if root SSH (v2) public key file exists
336 # Check if root SSH (v2) public key file exists
337 if [ ! -z "$SSH_ROOT_PUB_KEY" ] ; then
337 if [ ! -z "$SSH_ROOT_PUB_KEY" ] ; then
338 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
338 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
339 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
339 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
340 exit 1
340 exit 1
341 fi
341 fi
342 fi
342 fi
343
343
344 # Check if $USER_NAME SSH (v2) public key file exists
344 # Check if $USER_NAME SSH (v2) public key file exists
345 if [ ! -z "$SSH_USER_PUB_KEY" ] ; then
345 if [ ! -z "$SSH_USER_PUB_KEY" ] ; then
346 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
346 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
347 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
347 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
348 exit 1
348 exit 1
349 fi
349 fi
350 fi
350 fi
351
351
352 # Check if all required packages are installed on the build system
352 # Check if all required packages are installed on the build system
353 for package in $REQUIRED_PACKAGES ; do
353 for package in $REQUIRED_PACKAGES ; do
354 if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
354 if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
355 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
355 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
356 fi
356 fi
357 done
357 done
358
358
359 # If there are missing packages ask confirmation for install, or exit
359 # If there are missing packages ask confirmation for install, or exit
360 if [ -n "$MISSING_PACKAGES" ] ; then
360 if [ -n "$MISSING_PACKAGES" ] ; then
361 echo "the following packages needed by this script are not installed:"
361 echo "the following packages needed by this script are not installed:"
362 echo "$MISSING_PACKAGES"
362 echo "$MISSING_PACKAGES"
363
363
364 echo -n "\ndo you want to install the missing packages right now? [y/n] "
364 echo -n "\ndo you want to install the missing packages right now? [y/n] "
365 read confirm
365 read confirm
366 [ "$confirm" != "y" ] && exit 1
366 [ "$confirm" != "y" ] && exit 1
367
367
368 # Make sure all missing required packages are installed
368 # Make sure all missing required packages are installed
369 apt-get -qq -y install ${MISSING_PACKAGES}
369 apt-get -qq -y install ${MISSING_PACKAGES}
370 fi
370 fi
371
371
372 # Check if ./bootstrap.d directory exists
372 # Check if ./bootstrap.d directory exists
373 if [ ! -d "./bootstrap.d/" ] ; then
373 if [ ! -d "./bootstrap.d/" ] ; then
374 echo "error: './bootstrap.d' required directory not found!"
374 echo "error: './bootstrap.d' required directory not found!"
375 exit 1
375 exit 1
376 fi
376 fi
377
377
378 # Check if ./files directory exists
378 # Check if ./files directory exists
379 if [ ! -d "./files/" ] ; then
379 if [ ! -d "./files/" ] ; then
380 echo "error: './files' required directory not found!"
380 echo "error: './files' required directory not found!"
381 exit 1
381 exit 1
382 fi
382 fi
383
383
384 # Check if specified KERNELSRC_DIR directory exists
384 # Check if specified KERNELSRC_DIR directory exists
385 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
385 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
386 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
386 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
387 exit 1
387 exit 1
388 fi
388 fi
389
389
390 # Check if specified UBOOTSRC_DIR directory exists
390 # Check if specified UBOOTSRC_DIR directory exists
391 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
391 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
392 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
392 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
393 exit 1
393 exit 1
394 fi
394 fi
395
395
396 # Check if specified FBTURBOSRC_DIR directory exists
396 # Check if specified FBTURBOSRC_DIR directory exists
397 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
397 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
398 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
398 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
399 exit 1
399 exit 1
400 fi
400 fi
401
401
402 # Check if specified CHROOT_SCRIPTS directory exists
402 # Check if specified CHROOT_SCRIPTS directory exists
403 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
403 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
404 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
404 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
405 exit 1
405 exit 1
406 fi
406 fi
407
407
408 # Check if specified device mapping already exists (will be used by cryptsetup)
408 # Check if specified device mapping already exists (will be used by cryptsetup)
409 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
409 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
410 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
410 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
411 exit 1
411 exit 1
412 fi
412 fi
413
413
414 # Don't clobber an old build
414 # Don't clobber an old build
415 if [ -e "$BUILDDIR" ] ; then
415 if [ -e "$BUILDDIR" ] ; then
416 echo "error: directory ${BUILDDIR} already exists, not proceeding"
416 echo "error: directory ${BUILDDIR} already exists, not proceeding"
417 exit 1
417 exit 1
418 fi
418 fi
419
419
420 # Setup chroot directory
420 # Setup chroot directory
421 mkdir -p "${R}"
421 mkdir -p "${R}"
422
422
423 # Check if build directory has enough of free disk space >512MB
423 # Check if build directory has enough of free disk space >512MB
424 if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then
424 if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then
425 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
425 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
426 exit 1
426 exit 1
427 fi
427 fi
428
428
429 set -x
429 set -x
430
430
431 # Call "cleanup" function on various signals and errors
431 # Call "cleanup" function on various signals and errors
432 trap cleanup 0 1 2 3 6
432 trap cleanup 0 1 2 3 6
433
433
434 # Add required packages for the minbase installation
434 # Add required packages for the minbase installation
435 if [ "$ENABLE_MINBASE" = true ] ; then
435 if [ "$ENABLE_MINBASE" = true ] ; then
436 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
436 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
437 fi
437 fi
438
438
439 # Add required locales packages
439 # Add required locales packages
440 if [ "$DEFLOCAL" != "en_US.UTF-8" ] ; then
440 if [ "$DEFLOCAL" != "en_US.UTF-8" ] ; then
441 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
441 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
442 fi
442 fi
443
443
444 # Add parted package, required to get partprobe utility
444 # Add parted package, required to get partprobe utility
445 if [ "$EXPANDROOT" = true ] ; then
445 if [ "$EXPANDROOT" = true ] ; then
446 APT_INCLUDES="${APT_INCLUDES},parted"
446 APT_INCLUDES="${APT_INCLUDES},parted"
447 fi
447 fi
448
448
449 # Add dbus package, recommended if using systemd
449 # Add dbus package, recommended if using systemd
450 if [ "$ENABLE_DBUS" = true ] ; then
450 if [ "$ENABLE_DBUS" = true ] ; then
451 APT_INCLUDES="${APT_INCLUDES},dbus"
451 APT_INCLUDES="${APT_INCLUDES},dbus"
452 fi
452 fi
453
453
454 # Add iptables IPv4/IPv6 package
454 # Add iptables IPv4/IPv6 package
455 if [ "$ENABLE_IPTABLES" = true ] ; then
455 if [ "$ENABLE_IPTABLES" = true ] ; then
456 APT_INCLUDES="${APT_INCLUDES},iptables"
456 APT_INCLUDES="${APT_INCLUDES},iptables"
457 fi
457 fi
458
458
459 # Add openssh server package
459 # Add openssh server package
460 if [ "$ENABLE_SSHD" = true ] ; then
460 if [ "$ENABLE_SSHD" = true ] ; then
461 APT_INCLUDES="${APT_INCLUDES},openssh-server"
461 APT_INCLUDES="${APT_INCLUDES},openssh-server"
462 fi
462 fi
463
463
464 # Add alsa-utils package
464 # Add alsa-utils package
465 if [ "$ENABLE_SOUND" = true ] ; then
465 if [ "$ENABLE_SOUND" = true ] ; then
466 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
466 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
467 fi
467 fi
468
468
469 # Add rng-tools package
469 # Add rng-tools package
470 if [ "$ENABLE_HWRANDOM" = true ] ; then
470 if [ "$ENABLE_HWRANDOM" = true ] ; then
471 APT_INCLUDES="${APT_INCLUDES},rng-tools"
471 APT_INCLUDES="${APT_INCLUDES},rng-tools"
472 fi
472 fi
473
473
474 # Add fbturbo video driver
474 # Add fbturbo video driver
475 if [ "$ENABLE_FBTURBO" = true ] ; then
475 if [ "$ENABLE_FBTURBO" = true ] ; then
476 # Enable xorg package dependencies
476 # Enable xorg package dependencies
477 ENABLE_XORG=true
477 ENABLE_XORG=true
478 fi
478 fi
479
479
480 # Add user defined window manager package
480 # Add user defined window manager package
481 if [ -n "$ENABLE_WM" ] ; then
481 if [ -n "$ENABLE_WM" ] ; then
482 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
482 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
483
483
484 # Enable xorg package dependencies
484 # Enable xorg package dependencies
485 ENABLE_XORG=true
485 ENABLE_XORG=true
486 fi
486 fi
487
487
488 # Add xorg package
488 # Add xorg package
489 if [ "$ENABLE_XORG" = true ] ; then
489 if [ "$ENABLE_XORG" = true ] ; then
490 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
490 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
491 fi
491 fi
492
492
493 # Replace selected packages with smaller clones
493 # Replace selected packages with smaller clones
494 if [ "$ENABLE_REDUCE" = true ] ; then
494 if [ "$ENABLE_REDUCE" = true ] ; then
495 # Add levee package instead of vim-tiny
495 # Add levee package instead of vim-tiny
496 if [ "$REDUCE_VIM" = true ] ; then
496 if [ "$REDUCE_VIM" = true ] ; then
497 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
497 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
498 fi
498 fi
499
499
500 # Add dropbear package instead of openssh-server
500 # Add dropbear package instead of openssh-server
501 if [ "$REDUCE_SSHD" = true ] ; then
501 if [ "$REDUCE_SSHD" = true ] ; then
502 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/openssh-server/dropbear/")"
502 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/openssh-server/dropbear/")"
503 fi
503 fi
504 fi
504 fi
505
505
506 if [ "$RELEASE" != "jessie" ] ; then
506 if [ "$RELEASE" != "jessie" ] ; then
507 APT_INCLUDES="${APT_INCLUDES},libnss-systemd"
507 APT_INCLUDES="${APT_INCLUDES},libnss-systemd"
508 fi
508 fi
509
509
510 # Configure kernel sources if no KERNELSRC_DIR
510 # Configure kernel sources if no KERNELSRC_DIR
511 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
511 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
512 KERNELSRC_CONFIG=true
512 KERNELSRC_CONFIG=true
513 fi
513 fi
514
514
515 # Configure reduced kernel
515 # Configure reduced kernel
516 if [ "$KERNEL_REDUCE" = true ] ; then
516 if [ "$KERNEL_REDUCE" = true ] ; then
517 KERNELSRC_CONFIG=false
517 KERNELSRC_CONFIG=false
518 fi
518 fi
519
519
520 # Configure qemu compatible kernel
520 # Configure qemu compatible kernel
521 if [ "$ENABLE_QEMU" = true ] ; then
521 if [ "$ENABLE_QEMU" = true ] ; then
522 KERNEL_DEFCONFIG="vexpress_defconfig"
522 KERNEL_DEFCONFIG="vexpress_defconfig"
523 KERNEL_OLDDEFCONFIG=true
523 KERNEL_OLDDEFCONFIG=true
524 fi
524 fi
525
525
526 # Execute bootstrap scripts
526 # Execute bootstrap scripts
527 for SCRIPT in bootstrap.d/*.sh; do
527 for SCRIPT in bootstrap.d/*.sh; do
528 head -n 3 "$SCRIPT"
528 head -n 3 "$SCRIPT"
529 . "$SCRIPT"
529 . "$SCRIPT"
530 done
530 done
531
531
532 ## Execute custom bootstrap scripts
532 ## Execute custom bootstrap scripts
533 if [ -d "custom.d" ] ; then
533 if [ -d "custom.d" ] ; then
534 for SCRIPT in custom.d/*.sh; do
534 for SCRIPT in custom.d/*.sh; do
535 . "$SCRIPT"
535 . "$SCRIPT"
536 done
536 done
537 fi
537 fi
538
538
539 # Execute custom scripts inside the chroot
539 # Execute custom scripts inside the chroot
540 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
540 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
541 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
541 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
542 chroot_exec /bin/bash -x <<'EOF'
542 chroot_exec /bin/bash -x <<'EOF'
543 for SCRIPT in /chroot_scripts/* ; do
543 for SCRIPT in /chroot_scripts/* ; do
544 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
544 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
545 $SCRIPT
545 $SCRIPT
546 fi
546 fi
547 done
547 done
548 EOF
548 EOF
549 rm -rf "${R}/chroot_scripts"
549 rm -rf "${R}/chroot_scripts"
550 fi
550 fi
551
551
552 # Remove c/c++ build environment from the chroot
552 # Remove c/c++ build environment from the chroot
553 chroot_remove_cc
553 chroot_remove_cc
554
554
555 # Remove apt-utils
555 # Remove apt-utils
556 if [ "$RELEASE" = "jessie" ] ; then
556 if [ "$RELEASE" = "jessie" ] ; then
557 chroot_exec apt-get purge -qq -y --force-yes apt-utils
557 chroot_exec apt-get purge -qq -y --force-yes apt-utils
558 fi
558 fi
559
559
560 # Generate required machine-id
560 # Generate required machine-id
561 MACHINE_ID=$(dbus-uuidgen)
561 MACHINE_ID=$(dbus-uuidgen)
562 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
562 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
563 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
563 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
564
564
565 # APT Cleanup
565 # APT Cleanup
566 chroot_exec apt-get -y clean
566 chroot_exec apt-get -y clean
567 chroot_exec apt-get -y autoclean
567 chroot_exec apt-get -y autoclean
568 chroot_exec apt-get -y autoremove
568 chroot_exec apt-get -y autoremove
569
569
570 # Unmount mounted filesystems
570 # Unmount mounted filesystems
571 umount -l "${R}/proc"
571 umount -l "${R}/proc"
572 umount -l "${R}/sys"
572 umount -l "${R}/sys"
573
573
574 # Clean up directories
574 # Clean up directories
575 rm -rf "${R}/run/*"
575 rm -rf "${R}/run/*"
576 rm -rf "${R}/tmp/*"
576 rm -rf "${R}/tmp/*"
577
577
578 # Clean up files
578 # Clean up files
579 rm -f "${ETC_DIR}/ssh/ssh_host_*"
579 rm -f "${ETC_DIR}/ssh/ssh_host_*"
580 rm -f "${ETC_DIR}/dropbear/dropbear_*"
580 rm -f "${ETC_DIR}/dropbear/dropbear_*"
581 rm -f "${ETC_DIR}/apt/sources.list.save"
581 rm -f "${ETC_DIR}/apt/sources.list.save"
582 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
582 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
583 rm -f "${ETC_DIR}/*-"
583 rm -f "${ETC_DIR}/*-"
584 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
584 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
585 rm -f "${ETC_DIR}/resolv.conf"
585 rm -f "${ETC_DIR}/resolv.conf"
586 rm -f "${R}/root/.bash_history"
586 rm -f "${R}/root/.bash_history"
587 rm -f "${R}/var/lib/urandom/random-seed"
587 rm -f "${R}/var/lib/urandom/random-seed"
588 rm -f "${R}/initrd.img"
588 rm -f "${R}/initrd.img"
589 rm -f "${R}/vmlinuz"
589 rm -f "${R}/vmlinuz"
590 rm -f "${R}${QEMU_BINARY}"
590 rm -f "${R}${QEMU_BINARY}"
591
591
592 if [ "$ENABLE_QEMU" = true ] ; then
592 if [ "$ENABLE_QEMU" = true ] ; then
593 # Setup QEMU directory
593 # Setup QEMU directory
594 mkdir "${BASEDIR}/qemu"
594 mkdir "${BASEDIR}/qemu"
595
595
596 # Copy kernel image to QEMU directory
596 # Copy kernel image to QEMU directory
597 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
597 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
598
598
599 # Copy kernel config to QEMU directory
599 # Copy kernel config to QEMU directory
600 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
600 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
601
601
602 # Copy kernel dtbs to QEMU directory
602 # Copy kernel dtbs to QEMU directory
603 for dtb in "${BOOT_DIR}/"*.dtb ; do
603 for dtb in "${BOOT_DIR}/"*.dtb ; do
604 if [ -f "${dtb}" ] ; then
604 if [ -f "${dtb}" ] ; then
605 install_readonly "${dtb}" "${BASEDIR}/qemu/"
605 install_readonly "${dtb}" "${BASEDIR}/qemu/"
606 fi
606 fi
607 done
607 done
608
608
609 # Copy kernel overlays to QEMU directory
609 # Copy kernel overlays to QEMU directory
610 if [ -d "${BOOT_DIR}/overlays" ] ; then
610 if [ -d "${BOOT_DIR}/overlays" ] ; then
611 # Setup overlays dtbs directory
611 # Setup overlays dtbs directory
612 mkdir "${BASEDIR}/qemu/overlays"
612 mkdir "${BASEDIR}/qemu/overlays"
613
613
614 for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do
614 for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do
615 if [ -f "${dtb}" ] ; then
615 if [ -f "${dtb}" ] ; then
616 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
616 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
617 fi
617 fi
618 done
618 done
619 fi
619 fi
620
621 # Copy initramfs to QEMU directory
622 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
623 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
624 fi
620 fi
625 fi
621
626
622 # Calculate size of the chroot directory in KB
627 # Calculate size of the chroot directory in KB
623 CHROOT_SIZE=$(expr `du -s "${R}" | awk '{ print $1 }'`)
628 CHROOT_SIZE=$(expr `du -s "${R}" | awk '{ print $1 }'`)
624
629
625 # Calculate the amount of needed 512 Byte sectors
630 # Calculate the amount of needed 512 Byte sectors
626 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
631 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
627 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
632 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
628 ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS})
633 ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS})
629
634
630 # The root partition is EXT4
635 # The root partition is EXT4
631 # This means more space than the actual used space of the chroot is used.
636 # This means more space than the actual used space of the chroot is used.
632 # As overhead for journaling and reserved blocks 35% are added.
637 # As overhead for journaling and reserved blocks 35% are added.
633 ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 35) \* 1024 \/ 512)
638 ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 35) \* 1024 \/ 512)
634
639
635 # Calculate required image size in 512 Byte sectors
640 # Calculate required image size in 512 Byte sectors
636 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS})
641 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS})
637
642
638 # Prepare image file
643 # Prepare image file
639 if [ "$ENABLE_SPLITFS" = true ] ; then
644 if [ "$ENABLE_SPLITFS" = true ] ; then
640 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=${TABLE_SECTORS}
645 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=${TABLE_SECTORS}
641 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS}
646 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS}
642 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=${TABLE_SECTORS}
647 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=${TABLE_SECTORS}
643 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek=${ROOT_SECTORS}
648 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek=${ROOT_SECTORS}
644
649
645 # Write firmware/boot partition tables
650 # Write firmware/boot partition tables
646 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
651 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
647 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
652 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
648 EOM
653 EOM
649
654
650 # Write root partition table
655 # Write root partition table
651 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
656 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
652 ${TABLE_SECTORS},${ROOT_SECTORS},83
657 ${TABLE_SECTORS},${ROOT_SECTORS},83
653 EOM
658 EOM
654
659
655 # Setup temporary loop devices
660 # Setup temporary loop devices
656 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME-frmw.img)"
661 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME-frmw.img)"
657 ROOT_LOOP="$(losetup -o 1M -f --show $IMAGE_NAME-root.img)"
662 ROOT_LOOP="$(losetup -o 1M -f --show $IMAGE_NAME-root.img)"
658 else # ENABLE_SPLITFS=false
663 else # ENABLE_SPLITFS=false
659 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=${TABLE_SECTORS}
664 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=${TABLE_SECTORS}
660 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek=${IMAGE_SECTORS}
665 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek=${IMAGE_SECTORS}
661
666
662 # Write partition table
667 # Write partition table
663 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
668 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
664 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
669 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
665 ${ROOT_OFFSET},${ROOT_SECTORS},83
670 ${ROOT_OFFSET},${ROOT_SECTORS},83
666 EOM
671 EOM
667
672
668 # Setup temporary loop devices
673 # Setup temporary loop devices
669 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME.img)"
674 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME.img)"
670 ROOT_LOOP="$(losetup -o 65M -f --show $IMAGE_NAME.img)"
675 ROOT_LOOP="$(losetup -o 65M -f --show $IMAGE_NAME.img)"
671 fi
676 fi
672
677
673 if [ "$ENABLE_CRYPTFS" = true ] ; then
678 if [ "$ENABLE_CRYPTFS" = true ] ; then
674 # Create dummy ext4 fs
679 # Create dummy ext4 fs
675 mkfs.ext4 "$ROOT_LOOP"
680 mkfs.ext4 "$ROOT_LOOP"
676
681
677 # Setup password keyfile
682 # Setup password keyfile
678 touch .password
683 touch .password
679 chmod 600 .password
684 chmod 600 .password
680 echo -n ${CRYPTFS_PASSWORD} > .password
685 echo -n ${CRYPTFS_PASSWORD} > .password
681
686
682 # Initialize encrypted partition
687 # Initialize encrypted partition
683 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
688 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
684
689
685 # Open encrypted partition and setup mapping
690 # Open encrypted partition and setup mapping
686 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
691 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
687
692
688 # Secure delete password keyfile
693 # Secure delete password keyfile
689 shred -zu .password
694 shred -zu .password
690
695
691 # Update temporary loop device
696 # Update temporary loop device
692 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
697 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
693
698
694 # Wipe encrypted partition (encryption cipher is used for randomness)
699 # Wipe encrypted partition (encryption cipher is used for randomness)
695 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count=$(blockdev --getsz "${ROOT_LOOP}")
700 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count=$(blockdev --getsz "${ROOT_LOOP}")
696 fi
701 fi
697
702
698 # Build filesystems
703 # Build filesystems
699 mkfs.vfat "$FRMW_LOOP"
704 mkfs.vfat "$FRMW_LOOP"
700 mkfs.ext4 "$ROOT_LOOP"
705 mkfs.ext4 "$ROOT_LOOP"
701
706
702 # Mount the temporary loop devices
707 # Mount the temporary loop devices
703 mkdir -p "$BUILDDIR/mount"
708 mkdir -p "$BUILDDIR/mount"
704 mount "$ROOT_LOOP" "$BUILDDIR/mount"
709 mount "$ROOT_LOOP" "$BUILDDIR/mount"
705
710
706 mkdir -p "$BUILDDIR/mount/boot/firmware"
711 mkdir -p "$BUILDDIR/mount/boot/firmware"
707 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
712 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
708
713
709 # Copy all files from the chroot to the loop device mount point directory
714 # Copy all files from the chroot to the loop device mount point directory
710 rsync -a "${R}/" "$BUILDDIR/mount/"
715 rsync -a "${R}/" "$BUILDDIR/mount/"
711
716
712 # Unmount all temporary loop devices and mount points
717 # Unmount all temporary loop devices and mount points
713 cleanup
718 cleanup
714
719
715 # Create block map file(s) of image(s)
720 # Create block map file(s) of image(s)
716 if [ "$ENABLE_SPLITFS" = true ] ; then
721 if [ "$ENABLE_SPLITFS" = true ] ; then
717 # Create block map files for "bmaptool"
722 # Create block map files for "bmaptool"
718 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
723 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
719 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
724 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
720
725
721 # Image was successfully created
726 # Image was successfully created
722 echo "$IMAGE_NAME-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
727 echo "$IMAGE_NAME-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
723 echo "$IMAGE_NAME-root.img ($(expr \( ${TABLE_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
728 echo "$IMAGE_NAME-root.img ($(expr \( ${TABLE_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
724 else
729 else
725 # Create block map file for "bmaptool"
730 # Create block map file for "bmaptool"
726 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
731 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
727
732
728 # Image was successfully created
733 # Image was successfully created
729 echo "$IMAGE_NAME.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
734 echo "$IMAGE_NAME.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
730
735
731 # Create qemu qcow2 image
736 # Create qemu qcow2 image
732 if [ "$ENABLE_QEMU" = true ] ; then
737 if [ "$ENABLE_QEMU" = true ] ; then
733 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
738 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
734 QEMU_SIZE=16G
739 QEMU_SIZE=16G
735
740
736 qemu-img convert -f raw -O qcow2 $IMAGE_NAME.img $QEMU_IMAGE.qcow2
741 qemu-img convert -f raw -O qcow2 $IMAGE_NAME.img $QEMU_IMAGE.qcow2
737 qemu-img resize $QEMU_IMAGE.qcow2 $QEMU_SIZE
742 qemu-img resize $QEMU_IMAGE.qcow2 $QEMU_SIZE
738
743
739 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
744 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
740 fi
745 fi
741 fi
746 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant