@@ -1,210 +1,214 | |||||
1 | # |
|
1 | # | |
2 | # Setup RPi2/3 config and cmdline |
|
2 | # Setup RPi2/3 config and cmdline | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | if [ "$BUILD_KERNEL" = true ] ; then |
|
8 | if [ "$BUILD_KERNEL" = true ] ; then | |
9 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then |
|
9 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then | |
10 | # Install boot binaries from local directory |
|
10 | # Install boot binaries from local directory | |
11 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin |
|
11 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin | |
12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat |
|
12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat | |
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat |
|
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat | |
14 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat |
|
14 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat | |
15 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf |
|
15 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf | |
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf |
|
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf | |
17 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf |
|
17 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf | |
18 | else |
|
18 | else | |
19 | # Create temporary directory for boot binaries |
|
19 | # Create temporary directory for boot binaries | |
20 | temp_dir=$(as_nobody mktemp -d) |
|
20 | temp_dir=$(as_nobody mktemp -d) | |
21 |
|
21 | |||
22 | # Install latest boot binaries from raspberry/firmware github |
|
22 | # Install latest boot binaries from raspberry/firmware github | |
23 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" |
|
23 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" | |
24 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" |
|
24 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" | |
25 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" |
|
25 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" | |
26 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" |
|
26 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" | |
27 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" |
|
27 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" | |
28 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" |
|
28 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" | |
29 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" |
|
29 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" | |
30 |
|
30 | |||
31 | # Move downloaded boot binaries |
|
31 | # Move downloaded boot binaries | |
32 | mv "${temp_dir}/"* "${BOOT_DIR}/" |
|
32 | mv "${temp_dir}/"* "${BOOT_DIR}/" | |
33 |
|
33 | |||
34 | # Remove temporary directory for boot binaries |
|
34 | # Remove temporary directory for boot binaries | |
35 | rm -fr "${temp_dir}" |
|
35 | rm -fr "${temp_dir}" | |
36 |
|
36 | |||
37 | # Set permissions of the boot binaries |
|
37 | # Set permissions of the boot binaries | |
38 | chown -R root:root "${BOOT_DIR}" |
|
38 | chown -R root:root "${BOOT_DIR}" | |
39 | chmod -R 600 "${BOOT_DIR}" |
|
39 | chmod -R 600 "${BOOT_DIR}" | |
40 | fi |
|
40 | fi | |
41 | fi |
|
41 | fi | |
42 |
|
42 | |||
43 | # Setup firmware boot cmdline |
|
43 | # Setup firmware boot cmdline | |
44 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
44 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
45 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
45 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
46 | else |
|
46 | else | |
47 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
47 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
48 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
48 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
49 | else |
|
49 | else | |
50 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
50 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
51 | fi |
|
51 | fi | |
52 | fi |
|
52 | fi | |
53 |
|
53 | |||
54 |
|
54 | |||
55 |
|
55 | |||
56 | # Add encrypted root partition to cmdline.txt |
|
56 | # Add encrypted root partition to cmdline.txt | |
57 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
57 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
58 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
58 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
59 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") |
|
59 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") | |
60 | else |
|
60 | else | |
61 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
61 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
62 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") |
|
62 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") | |
63 | else |
|
63 | else | |
64 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") |
|
64 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") | |
65 | fi |
|
65 | fi | |
66 | fi |
|
66 | fi | |
67 | fi |
|
67 | fi | |
68 |
|
68 | |||
69 | # Add serial console support |
|
69 | # Add serial console support | |
70 | if [ "$ENABLE_CONSOLE" = true ] ; then |
|
70 | if [ "$ENABLE_CONSOLE" = true ] ; then | |
71 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" |
|
71 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" | |
72 | fi |
|
72 | fi | |
73 |
|
73 | |||
74 | # Remove IPv6 networking support |
|
74 | # Remove IPv6 networking support | |
75 | if [ "$ENABLE_IPV6" = false ] ; then |
|
75 | if [ "$ENABLE_IPV6" = false ] ; then | |
76 | CMDLINE="${CMDLINE} ipv6.disable=1" |
|
76 | CMDLINE="${CMDLINE} ipv6.disable=1" | |
77 | fi |
|
77 | fi | |
78 |
|
78 | |||
79 | # Automatically assign predictable network interface names |
|
79 | # Automatically assign predictable network interface names | |
80 | if [ "$ENABLE_IFNAMES" = false ] ; then |
|
80 | if [ "$ENABLE_IFNAMES" = false ] ; then | |
81 | CMDLINE="${CMDLINE} net.ifnames=0" |
|
81 | CMDLINE="${CMDLINE} net.ifnames=0" | |
82 | else |
|
82 | else | |
83 | CMDLINE="${CMDLINE} net.ifnames=1" |
|
83 | CMDLINE="${CMDLINE} net.ifnames=1" | |
84 | fi |
|
84 | fi | |
85 |
|
85 | |||
86 | # Set init to systemd if required by Debian release |
|
86 | # Set init to systemd if required by Debian release | |
87 | if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then |
|
87 | if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then | |
88 | CMDLINE="${CMDLINE} init=/bin/systemd" |
|
88 | CMDLINE="${CMDLINE} init=/bin/systemd" | |
89 | fi |
|
89 | fi | |
90 |
|
90 | |||
91 | # Install firmware boot cmdline |
|
91 | # Install firmware boot cmdline | |
92 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" |
|
92 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" | |
93 |
|
93 | |||
94 | # Install firmware config |
|
94 | # Install firmware config | |
95 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" |
|
95 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" | |
96 |
|
96 | |||
97 | # Setup minimal GPU memory allocation size: 16MB (no X) |
|
97 | # Setup minimal GPU memory allocation size: 16MB (no X) | |
98 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
98 | if [ "$ENABLE_MINGPU" = true ] ; then | |
99 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" |
|
99 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" | |
100 | fi |
|
100 | fi | |
101 |
|
101 | |||
102 | # Setup boot with initramfs |
|
102 | # Setup boot with initramfs | |
103 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
103 | if [ "$ENABLE_INITRAMFS" = true ] ; then | |
104 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" |
|
104 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" | |
105 | fi |
|
105 | fi | |
106 |
|
106 | |||
107 | # Disable RPi3 Bluetooth and restore ttyAMA0 serial device |
|
107 | # Disable RPi3 Bluetooth and restore ttyAMA0 serial device | |
108 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 3P ]; then |
|
108 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 3P ]; then | |
109 | if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then |
|
109 | if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then | |
110 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" |
|
110 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" | |
111 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" |
|
111 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" | |
112 | else |
|
112 | else | |
113 | # Create temporary directory for Bluetooth sources |
|
113 | # Create temporary directory for Bluetooth sources | |
114 | temp_dir=$(as_nobody mktemp -d) |
|
114 | temp_dir=$(as_nobody mktemp -d) | |
115 |
|
115 | |||
116 | # Fetch Bluetooth sources |
|
116 | # Fetch Bluetooth sources | |
117 | as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" |
|
117 | as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" | |
118 |
|
118 | |||
119 | # Copy downloaded sources |
|
119 | # Copy downloaded sources | |
120 | mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" |
|
120 | mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" | |
121 |
|
121 | |||
|
122 | # Raspberry-sys-mod package for /dev/serial device needed by bluetooth service | |||
|
123 | wget -O "${R}/tmp/pi-bluetooth/99-com.rules" https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules | |||
|
124 | ||||
|
125 | # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/ | |||
|
126 | wget -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth | |||
|
127 | wget -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth | |||
|
128 | ||||
122 | # Set permissions |
|
129 | # Set permissions | |
123 | chown -R root:root "${R}/tmp/pi-bluetooth" |
|
130 | chown -R root:root "${R}/tmp/pi-bluetooth" | |
124 |
|
131 | |||
125 | # Install files to chroot |
|
132 | # Install files to chroot | |
126 | # Install tools |
|
133 | # Install tools | |
127 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" |
|
134 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" | |
128 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" |
|
135 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" | |
129 |
|
136 | |||
130 | # Install bluetooth udev rule |
|
137 | # Install bluetooth udev rule | |
131 | install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" |
|
138 | install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" | |
132 | #aur |
|
139 | # aur | |
133 | #install_readonly "${R}/tmp/pi-bluetooth/50-bluetooth-hci-auto-poweron.rules" "${ETC_DIR}/udev/rules.d/50-bluetooth-hci-auto-poweron.rules" |
|
140 | # install_readonly "${R}/tmp/pi-bluetooth/50-bluetooth-hci-auto-poweron.rules" "${ETC_DIR}/udev/rules.d/50-bluetooth-hci-auto-poweron.rules" | |
134 |
|
141 | |||
135 | # Install Firmware Flash file and apropiate licence |
|
142 | # Install Firmware Flash file and apropiate licence | |
136 | mkdir "${ETC_DIR}/firmware/" |
|
143 | mkdir "${ETC_DIR}/firmware/" | |
137 |
|
144 | |||
138 | #aur https://aur.archlinux.org/packages/pi-bluetooth/ |
|
145 | # Install firmware and licence | |
139 | #install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" |
|
146 | # install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" | |
140 | #install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/BCM43430A1.hcd" |
|
147 | # install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/BCM43430A1.hcd" | |
141 | wget -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth |
|
|||
142 | wget -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth |
|
|||
143 | install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" |
|
148 | install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" | |
144 | install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" |
|
149 | install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" | |
145 |
|
150 | |||
146 | # Install systemd service for bluetooth |
|
151 | # Install systemd service for bluetooth | |
147 | #install_readonly "${R}/tmp/pi-bluetooth/brcm43438.service" "${ETC_DIR}/systemd/system/brcm43438.service" |
|
152 | # install_readonly "${R}/tmp/pi-bluetooth/brcm43438.service" "${ETC_DIR}/systemd/system/brcm43438.service" | |
148 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" |
|
153 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" | |
149 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" |
|
154 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" | |
150 |
|
155 | |||
151 | # Raspberry-sys-mod package |
|
156 | ||
152 | wget -O "${R}/tmp/pi-bluetooth/99-com.rules" https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules |
|
|||
153 | install_readonly "${R}/tmp/pi-bluetooth/99-com.rules" "${ETC_DIR}/udev/rules.d/99-com.rules" |
|
157 | install_readonly "${R}/tmp/pi-bluetooth/99-com.rules" "${ETC_DIR}/udev/rules.d/99-com.rules" | |
154 |
|
158 | |||
155 | # Remove temporary directory |
|
159 | # Remove temporary directory | |
156 | rm -fr "${temp_dir}" |
|
160 | rm -fr "${temp_dir}" | |
157 |
|
161 | |||
158 | # Get /dev/serial back for compability |
|
162 | # Get /dev/serial back for compability | |
159 |
|
163 | |||
160 |
|
164 | |||
161 | fi |
|
165 | fi | |
162 | fi |
|
166 | fi | |
163 |
|
167 | |||
164 | # Create firmware configuration and cmdline symlinks |
|
168 | # Create firmware configuration and cmdline symlinks | |
165 | ln -sf firmware/config.txt "${R}/boot/config.txt" |
|
169 | ln -sf firmware/config.txt "${R}/boot/config.txt" | |
166 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" |
|
170 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" | |
167 |
|
171 | |||
168 | # Install and setup kernel modules to load at boot |
|
172 | # Install and setup kernel modules to load at boot | |
169 | mkdir -p "${LIB_DIR}/modules-load.d/" |
|
173 | mkdir -p "${LIB_DIR}/modules-load.d/" | |
170 | install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
174 | install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" | |
171 |
|
175 | |||
172 | # Load hardware random module at boot |
|
176 | # Load hardware random module at boot | |
173 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then |
|
177 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then | |
174 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
178 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
175 | fi |
|
179 | fi | |
176 |
|
180 | |||
177 | # Load sound module at boot |
|
181 | # Load sound module at boot | |
178 | if [ "$ENABLE_SOUND" = true ] ; then |
|
182 | if [ "$ENABLE_SOUND" = true ] ; then | |
179 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
183 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
180 | else |
|
184 | else | |
181 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" |
|
185 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" | |
182 | fi |
|
186 | fi | |
183 |
|
187 | |||
184 | # Enable I2C interface |
|
188 | # Enable I2C interface | |
185 | if [ "$ENABLE_I2C" = true ] ; then |
|
189 | if [ "$ENABLE_I2C" = true ] ; then | |
186 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" |
|
190 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" | |
187 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
191 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
188 | sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
192 | sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
189 | fi |
|
193 | fi | |
190 |
|
194 | |||
191 | # Enable SPI interface |
|
195 | # Enable SPI interface | |
192 | if [ "$ENABLE_SPI" = true ] ; then |
|
196 | if [ "$ENABLE_SPI" = true ] ; then | |
193 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" |
|
197 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" | |
194 | echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
198 | echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" | |
195 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then |
|
199 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then | |
196 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
200 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
197 | fi |
|
201 | fi | |
198 | fi |
|
202 | fi | |
199 |
|
203 | |||
200 | # Disable RPi2/3 under-voltage warnings |
|
204 | # Disable RPi2/3 under-voltage warnings | |
201 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
205 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
202 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" |
|
206 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" | |
203 | fi |
|
207 | fi | |
204 |
|
208 | |||
205 | # Install kernel modules blacklist |
|
209 | # Install kernel modules blacklist | |
206 | mkdir -p "${ETC_DIR}/modprobe.d/" |
|
210 | mkdir -p "${ETC_DIR}/modprobe.d/" | |
207 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" |
|
211 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" | |
208 |
|
212 | |||
209 | # Install sysctl.d configuration files |
|
213 | # Install sysctl.d configuration files | |
210 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
|
214 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
@@ -1,831 +1,829 | |||||
1 | #!/bin/bash |
|
1 | #!/bin/bash | |
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 RPi2/3 |
|
5 | # Advanced Debian "stretch" and "buster" bootstrap script for RPi2/3 | |
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# RPi2/3 Bootstrap Settings\n#\n" |
|
39 | echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n" | |
40 | set -x |
|
40 | set -x | |
41 |
|
41 | |||
42 | # Raspberry Pi model configuration |
|
42 | # Raspberry Pi model configuration | |
43 | export RPI_MODEL=${RPI_MODEL:=2} |
|
43 | export RPI_MODEL=${RPI_MODEL:=2} | |
44 |
|
44 | |||
45 | # Debian release |
|
45 | # Debian release | |
46 | export RELEASE=${RELEASE:=buster} |
|
46 | export RELEASE=${RELEASE:=buster} | |
47 |
|
47 | |||
48 | #Kernel Branch |
|
48 | #Kernel Branch | |
49 | export KERNEL_BRANCH=${KERNEL_BRANCH:=""} |
|
49 | export KERNEL_BRANCH=${KERNEL_BRANCH:=""} | |
50 |
|
50 | |||
51 | # URLs |
|
51 | # URLs | |
52 | KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} |
|
52 | KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} | |
53 | FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} |
|
53 | FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} | |
54 | WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} |
|
54 | WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} | |
55 | COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian} |
|
55 | COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian} | |
56 | FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} |
|
56 | FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} | |
57 | UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} |
|
57 | UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} | |
58 | VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland} |
|
58 | VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland} | |
59 | #BIS= Kernel has KVM and zswap enabled |
|
59 | #BIS= Kernel has KVM and zswap enabled | |
60 | RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz} |
|
60 | RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz} | |
61 | #default bcmrpi3_defconfig target kernel |
|
61 | #default bcmrpi3_defconfig target kernel | |
62 | RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz} |
|
62 | RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz} | |
63 | #enhanced kernel |
|
63 | #enhanced kernel | |
64 | RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_BIS_KERNEL_URL} |
|
64 | RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_BIS_KERNEL_URL} | |
65 | #https://aur.archlinux.org/packages/pi-bluetooth/ |
|
|||
66 | #BLUETOOTH_URL=${BLUETOOTH_URL:=https://aur.archlinux.org/pi-bluetooth.git} |
|
|||
67 | BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} |
|
65 | BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} | |
68 |
|
66 | |||
69 | # Build directories |
|
67 | # Build directories | |
70 | BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}} |
|
68 | BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}} | |
71 | BUILDDIR="${BASEDIR}/build" |
|
69 | BUILDDIR="${BASEDIR}/build" | |
72 |
|
70 | |||
73 | # Prepare date string for default image file name |
|
71 | # Prepare date string for default image file name | |
74 | DATE="$(date +%Y-%m-%d)" |
|
72 | DATE="$(date +%Y-%m-%d)" | |
75 | if [ -z "$KERNEL_BRANCH" ] ; then |
|
73 | if [ -z "$KERNEL_BRANCH" ] ; then | |
76 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
74 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} | |
77 | else |
|
75 | else | |
78 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
76 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} | |
79 | fi |
|
77 | fi | |
80 |
|
78 | |||
81 | # Chroot directories |
|
79 | # Chroot directories | |
82 | R="${BUILDDIR}/chroot" |
|
80 | R="${BUILDDIR}/chroot" | |
83 | ETC_DIR="${R}/etc" |
|
81 | ETC_DIR="${R}/etc" | |
84 | LIB_DIR="${R}/lib" |
|
82 | LIB_DIR="${R}/lib" | |
85 | BOOT_DIR="${R}/boot/firmware" |
|
83 | BOOT_DIR="${R}/boot/firmware" | |
86 | KERNEL_DIR="${R}/usr/src/linux" |
|
84 | KERNEL_DIR="${R}/usr/src/linux" | |
87 | WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm" |
|
85 | WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm" | |
88 |
|
86 | |||
89 | # Firmware directory: Blank if download from github |
|
87 | # Firmware directory: Blank if download from github | |
90 | RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} |
|
88 | RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} | |
91 | # General settings |
|
89 | # General settings | |
92 | SET_ARCH=${SET_ARCH:=32} |
|
90 | SET_ARCH=${SET_ARCH:=32} | |
93 | HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} |
|
91 | HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} | |
94 | PASSWORD=${PASSWORD:=raspberry} |
|
92 | PASSWORD=${PASSWORD:=raspberry} | |
95 | USER_PASSWORD=${USER_PASSWORD:=raspberry} |
|
93 | USER_PASSWORD=${USER_PASSWORD:=raspberry} | |
96 | DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} |
|
94 | DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} | |
97 | TIMEZONE=${TIMEZONE:="Europe/Berlin"} |
|
95 | TIMEZONE=${TIMEZONE:="Europe/Berlin"} | |
98 | EXPANDROOT=${EXPANDROOT:=true} |
|
96 | EXPANDROOT=${EXPANDROOT:=true} | |
99 |
|
97 | |||
100 | # Keyboard settings |
|
98 | # Keyboard settings | |
101 | XKB_MODEL=${XKB_MODEL:=""} |
|
99 | XKB_MODEL=${XKB_MODEL:=""} | |
102 | XKB_LAYOUT=${XKB_LAYOUT:=""} |
|
100 | XKB_LAYOUT=${XKB_LAYOUT:=""} | |
103 | XKB_VARIANT=${XKB_VARIANT:=""} |
|
101 | XKB_VARIANT=${XKB_VARIANT:=""} | |
104 | XKB_OPTIONS=${XKB_OPTIONS:=""} |
|
102 | XKB_OPTIONS=${XKB_OPTIONS:=""} | |
105 |
|
103 | |||
106 | # Network settings (DHCP) |
|
104 | # Network settings (DHCP) | |
107 | ENABLE_DHCP=${ENABLE_DHCP:=true} |
|
105 | ENABLE_DHCP=${ENABLE_DHCP:=true} | |
108 |
|
106 | |||
109 | # Network settings (static) |
|
107 | # Network settings (static) | |
110 | NET_ADDRESS=${NET_ADDRESS:=""} |
|
108 | NET_ADDRESS=${NET_ADDRESS:=""} | |
111 | NET_GATEWAY=${NET_GATEWAY:=""} |
|
109 | NET_GATEWAY=${NET_GATEWAY:=""} | |
112 | NET_DNS_1=${NET_DNS_1:=""} |
|
110 | NET_DNS_1=${NET_DNS_1:=""} | |
113 | NET_DNS_2=${NET_DNS_2:=""} |
|
111 | NET_DNS_2=${NET_DNS_2:=""} | |
114 | NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} |
|
112 | NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} | |
115 | NET_NTP_1=${NET_NTP_1:=""} |
|
113 | NET_NTP_1=${NET_NTP_1:=""} | |
116 | NET_NTP_2=${NET_NTP_2:=""} |
|
114 | NET_NTP_2=${NET_NTP_2:=""} | |
117 |
|
115 | |||
118 | # APT settings |
|
116 | # APT settings | |
119 | APT_PROXY=${APT_PROXY:=""} |
|
117 | APT_PROXY=${APT_PROXY:=""} | |
120 | APT_SERVER=${APT_SERVER:="ftp.debian.org"} |
|
118 | APT_SERVER=${APT_SERVER:="ftp.debian.org"} | |
121 |
|
119 | |||
122 | # Feature settings |
|
120 | # Feature settings | |
123 | ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} |
|
121 | ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} | |
124 | ENABLE_I2C=${ENABLE_I2C:=false} |
|
122 | ENABLE_I2C=${ENABLE_I2C:=false} | |
125 | ENABLE_SPI=${ENABLE_SPI:=false} |
|
123 | ENABLE_SPI=${ENABLE_SPI:=false} | |
126 | ENABLE_IPV6=${ENABLE_IPV6:=true} |
|
124 | ENABLE_IPV6=${ENABLE_IPV6:=true} | |
127 | ENABLE_SSHD=${ENABLE_SSHD:=true} |
|
125 | ENABLE_SSHD=${ENABLE_SSHD:=true} | |
128 | ENABLE_NONFREE=${ENABLE_NONFREE:=false} |
|
126 | ENABLE_NONFREE=${ENABLE_NONFREE:=false} | |
129 | ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} |
|
127 | ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} | |
130 | ENABLE_SOUND=${ENABLE_SOUND:=true} |
|
128 | ENABLE_SOUND=${ENABLE_SOUND:=true} | |
131 | ENABLE_DBUS=${ENABLE_DBUS:=true} |
|
129 | ENABLE_DBUS=${ENABLE_DBUS:=true} | |
132 | ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} |
|
130 | ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} | |
133 | ENABLE_MINGPU=${ENABLE_MINGPU:=false} |
|
131 | ENABLE_MINGPU=${ENABLE_MINGPU:=false} | |
134 | ENABLE_XORG=${ENABLE_XORG:=false} |
|
132 | ENABLE_XORG=${ENABLE_XORG:=false} | |
135 | ENABLE_WM=${ENABLE_WM:=""} |
|
133 | ENABLE_WM=${ENABLE_WM:=""} | |
136 | ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} |
|
134 | ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} | |
137 | ENABLE_USER=${ENABLE_USER:=true} |
|
135 | ENABLE_USER=${ENABLE_USER:=true} | |
138 | USER_NAME=${USER_NAME:="pi"} |
|
136 | USER_NAME=${USER_NAME:="pi"} | |
139 | ENABLE_ROOT=${ENABLE_ROOT:=false} |
|
137 | ENABLE_ROOT=${ENABLE_ROOT:=false} | |
140 | ENABLE_QEMU=${ENABLE_QEMU:=false} |
|
138 | ENABLE_QEMU=${ENABLE_QEMU:=false} | |
141 | ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false} |
|
139 | ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false} | |
142 |
|
140 | |||
143 | # SSH settings |
|
141 | # SSH settings | |
144 | SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} |
|
142 | SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} | |
145 | SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} |
|
143 | SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} | |
146 | SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} |
|
144 | SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} | |
147 | SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} |
|
145 | SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} | |
148 | SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} |
|
146 | SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} | |
149 |
|
147 | |||
150 | # Advanced settings |
|
148 | # Advanced settings | |
151 | ENABLE_MINBASE=${ENABLE_MINBASE:=false} |
|
149 | ENABLE_MINBASE=${ENABLE_MINBASE:=false} | |
152 | ENABLE_REDUCE=${ENABLE_REDUCE:=false} |
|
150 | ENABLE_REDUCE=${ENABLE_REDUCE:=false} | |
153 | ENABLE_UBOOT=${ENABLE_UBOOT:=false} |
|
151 | ENABLE_UBOOT=${ENABLE_UBOOT:=false} | |
154 | UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} |
|
152 | UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} | |
155 | ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false} |
|
153 | ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false} | |
156 | ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} |
|
154 | ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} | |
157 | ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=true} |
|
155 | ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=true} | |
158 | VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} |
|
156 | VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} | |
159 | FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} |
|
157 | FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} | |
160 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} |
|
158 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} | |
161 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} |
|
159 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} | |
162 | ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} |
|
160 | ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} | |
163 | ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} |
|
161 | ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} | |
164 | ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} |
|
162 | ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} | |
165 | DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} |
|
163 | DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} | |
166 |
|
164 | |||
167 | # Kernel compilation settings |
|
165 | # Kernel compilation settings | |
168 | BUILD_KERNEL=${BUILD_KERNEL:=true} |
|
166 | BUILD_KERNEL=${BUILD_KERNEL:=true} | |
169 | KERNEL_REDUCE=${KERNEL_REDUCE:=false} |
|
167 | KERNEL_REDUCE=${KERNEL_REDUCE:=false} | |
170 | KERNEL_THREADS=${KERNEL_THREADS:=1} |
|
168 | KERNEL_THREADS=${KERNEL_THREADS:=1} | |
171 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} |
|
169 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} | |
172 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} |
|
170 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} | |
173 | KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} |
|
171 | KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} | |
174 | KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} |
|
172 | KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} | |
175 | KERNEL_CCACHE=${KERNEL_CCACHE:=false} |
|
173 | KERNEL_CCACHE=${KERNEL_CCACHE:=false} | |
176 | KERNEL_ZSWAP=${KERNEL_ZSWAP:=false} |
|
174 | KERNEL_ZSWAP=${KERNEL_ZSWAP:=false} | |
177 | KERNEL_VIRT=${KERNEL_VIRT:=false} |
|
175 | KERNEL_VIRT=${KERNEL_VIRT:=false} | |
178 | KERNEL_BPF=${KERNEL_BPF:=true} |
|
176 | KERNEL_BPF=${KERNEL_BPF:=true} | |
179 |
|
177 | |||
180 | # Kernel compilation from source directory settings |
|
178 | # Kernel compilation from source directory settings | |
181 | KERNELSRC_DIR=${KERNELSRC_DIR:=""} |
|
179 | KERNELSRC_DIR=${KERNELSRC_DIR:=""} | |
182 | KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} |
|
180 | KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} | |
183 | KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} |
|
181 | KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} | |
184 | KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} |
|
182 | KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} | |
185 |
|
183 | |||
186 | # Reduce disk usage settings |
|
184 | # Reduce disk usage settings | |
187 | REDUCE_APT=${REDUCE_APT:=true} |
|
185 | REDUCE_APT=${REDUCE_APT:=true} | |
188 | REDUCE_DOC=${REDUCE_DOC:=true} |
|
186 | REDUCE_DOC=${REDUCE_DOC:=true} | |
189 | REDUCE_MAN=${REDUCE_MAN:=true} |
|
187 | REDUCE_MAN=${REDUCE_MAN:=true} | |
190 | REDUCE_VIM=${REDUCE_VIM:=false} |
|
188 | REDUCE_VIM=${REDUCE_VIM:=false} | |
191 | REDUCE_BASH=${REDUCE_BASH:=false} |
|
189 | REDUCE_BASH=${REDUCE_BASH:=false} | |
192 | REDUCE_HWDB=${REDUCE_HWDB:=true} |
|
190 | REDUCE_HWDB=${REDUCE_HWDB:=true} | |
193 | REDUCE_SSHD=${REDUCE_SSHD:=true} |
|
191 | REDUCE_SSHD=${REDUCE_SSHD:=true} | |
194 | REDUCE_LOCALE=${REDUCE_LOCALE:=true} |
|
192 | REDUCE_LOCALE=${REDUCE_LOCALE:=true} | |
195 |
|
193 | |||
196 | # Encrypted filesystem settings |
|
194 | # Encrypted filesystem settings | |
197 | ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false} |
|
195 | ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false} | |
198 | CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""} |
|
196 | CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""} | |
199 | CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"} |
|
197 | CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"} | |
200 | CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"} |
|
198 | CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"} | |
201 | CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512} |
|
199 | CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512} | |
202 |
|
200 | |||
203 | # Chroot scripts directory |
|
201 | # Chroot scripts directory | |
204 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} |
|
202 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} | |
205 |
|
203 | |||
206 | # Packages required in the chroot build environment |
|
204 | # Packages required in the chroot build environment | |
207 | APT_INCLUDES=${APT_INCLUDES:=""} |
|
205 | APT_INCLUDES=${APT_INCLUDES:=""} | |
208 | APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup" |
|
206 | APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup" | |
209 |
|
207 | |||
210 | #Packages to exclude from chroot build environment |
|
208 | #Packages to exclude from chroot build environment | |
211 | APT_EXCLUDES=${APT_EXCLUDES:=""} |
|
209 | APT_EXCLUDES=${APT_EXCLUDES:=""} | |
212 |
|
210 | |||
213 | # Packages required for bootstrapping |
|
211 | # Packages required for bootstrapping | |
214 | REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt" |
|
212 | REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt" | |
215 | MISSING_PACKAGES="" |
|
213 | MISSING_PACKAGES="" | |
216 |
|
214 | |||
217 | # Packages installed for c/c++ build environment in chroot (keep empty) |
|
215 | # Packages installed for c/c++ build environment in chroot (keep empty) | |
218 | COMPILER_PACKAGES="" |
|
216 | COMPILER_PACKAGES="" | |
219 |
|
217 | |||
220 | #If init and systemd-sysv are wanted e.g. halt/reboot/shutdown scripts |
|
218 | #If init and systemd-sysv are wanted e.g. halt/reboot/shutdown scripts | |
221 | if [ "$ENABLE_SYSVINIT" = false ] ; then |
|
219 | if [ "$ENABLE_SYSVINIT" = false ] ; then | |
222 | APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" |
|
220 | APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" | |
223 | fi |
|
221 | fi | |
224 |
|
222 | |||
225 | #Check if apt-cacher-ng has its default port open on and set APT_PROXY |
|
223 | #Check if apt-cacher-ng has its default port open on and set APT_PROXY | |
226 | if [ -n "$(lsof -i :3142)" ] ; then |
|
224 | if [ -n "$(lsof -i :3142)" ] ; then | |
227 | HTTP_PROXY=http://127.0.0.1:3142/ |
|
225 | HTTP_PROXY=http://127.0.0.1:3142/ | |
228 | fi |
|
226 | fi | |
229 |
|
227 | |||
230 | #ipinfo=$(curl ipinfo.io | grep country ) |
|
228 | #ipinfo=$(curl ipinfo.io | grep country ) | |
231 | #grep -o '\"[^"]*\"' $ipinfo | tr -d '"' |
|
229 | #grep -o '\"[^"]*\"' $ipinfo | tr -d '"' | |
232 | #grep -Po '"country":.*?[^\\]",' $(curl ipinfo.io | grep country ) |
|
230 | #grep -Po '"country":.*?[^\\]",' $(curl ipinfo.io | grep country ) | |
233 | #sed -i "s,http:,https:,g" "${ETC_DIR}/apt/sources.list" |
|
231 | #sed -i "s,http:,https:,g" "${ETC_DIR}/apt/sources.list" | |
234 | #autconfigure best apt server to not spam ftp.debian.org |
|
232 | #autconfigure best apt server to not spam ftp.debian.org | |
235 | #rm files/apt/sources.list |
|
233 | #rm files/apt/sources.list | |
236 | #netselect-apt does not know buster yet |
|
234 | #netselect-apt does not know buster yet | |
237 | if [ "$RELEASE" = "buster" ] ; then |
|
235 | if [ "$RELEASE" = "buster" ] ; then | |
238 | RLS=testing |
|
236 | RLS=testing | |
239 | else |
|
237 | else | |
240 | RLS="$RELEASE" |
|
238 | RLS="$RELEASE" | |
241 | fi |
|
239 | fi | |
242 |
|
240 | |||
243 | if [ -f "$(pwd)/files/apt/sources.list" ] ; then |
|
241 | if [ -f "$(pwd)/files/apt/sources.list" ] ; then | |
244 | rm "$(pwd)/files/apt/sources.list" |
|
242 | rm "$(pwd)/files/apt/sources.list" | |
245 | fi |
|
243 | fi | |
246 |
|
244 | |||
247 | if [ "$ENABLE_NONFREE" = true ] ; then |
|
245 | if [ "$ENABLE_NONFREE" = true ] ; then | |
248 | netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --nonfree --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" |
|
246 | netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --nonfree --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" | |
249 | else |
|
247 | else | |
250 | netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" |
|
248 | netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" | |
251 | fi |
|
249 | fi | |
252 |
|
250 | |||
253 | #sed and cut the result string so we can use it as APT_SERVER |
|
251 | #sed and cut the result string so we can use it as APT_SERVER | |
254 | APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3) |
|
252 | APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3) | |
255 | APT_SERVER=${APT_SERVER::-1} |
|
253 | APT_SERVER=${APT_SERVER::-1} | |
256 |
|
254 | |||
257 | #make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go! |
|
255 | #make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go! | |
258 | if [ -n "$SET_ARCH" ] ; then |
|
256 | if [ -n "$SET_ARCH" ] ; then | |
259 | echo "Setting Architecture specific settings" |
|
257 | echo "Setting Architecture specific settings" | |
260 | ################################## |
|
258 | ################################## | |
261 | # 64 bit config |
|
259 | # 64 bit config | |
262 | ################################## |
|
260 | ################################## | |
263 | if [ "$SET_ARCH" = 64 ] ; then |
|
261 | if [ "$SET_ARCH" = 64 ] ; then | |
264 | echo "64 bit mode selected - Setting up enviroment" |
|
262 | echo "64 bit mode selected - Setting up enviroment" | |
265 | # 64 bit depended settings |
|
263 | # 64 bit depended settings | |
266 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} |
|
264 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} | |
267 | KERNEL_ARCH=${KERNEL_ARCH:=arm64} |
|
265 | KERNEL_ARCH=${KERNEL_ARCH:=arm64} | |
268 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} |
|
266 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} | |
269 |
|
267 | |||
270 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then |
|
268 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then | |
271 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" |
|
269 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" | |
272 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} |
|
270 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} | |
273 | RELEASE_ARCH=${RELEASE_ARCH:=arm64} |
|
271 | RELEASE_ARCH=${RELEASE_ARCH:=arm64} | |
274 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} |
|
272 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} | |
275 | CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-} |
|
273 | CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-} | |
276 | else |
|
274 | else | |
277 | echo "error: Only Raspberry PI 3 and 3B+ support 64bit" |
|
275 | echo "error: Only Raspberry PI 3 and 3B+ support 64bit" | |
278 | exit 1 |
|
276 | exit 1 | |
279 | fi |
|
277 | fi | |
280 | fi |
|
278 | fi | |
281 |
|
279 | |||
282 | ################################## |
|
280 | ################################## | |
283 | # 32 bit config |
|
281 | # 32 bit config | |
284 | ################################## |
|
282 | ################################## | |
285 | if [ "$SET_ARCH" = 32 ] ; then |
|
283 | if [ "$SET_ARCH" = 32 ] ; then | |
286 | echo "32 bit mode selected - Setting up enviroment" |
|
284 | echo "32 bit mode selected - Setting up enviroment" | |
287 | #General 32bit configuration |
|
285 | #General 32bit configuration | |
288 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} |
|
286 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} | |
289 | KERNEL_ARCH=${KERNEL_ARCH:=arm} |
|
287 | KERNEL_ARCH=${KERNEL_ARCH:=arm} | |
290 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} |
|
288 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} | |
291 |
|
289 | |||
292 | #Raspberry setting grouped by board compability |
|
290 | #Raspberry setting grouped by board compability | |
293 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then |
|
291 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then | |
294 | echo "Setting settings for bcm2835 Raspberry PI boards" |
|
292 | echo "Setting settings for bcm2835 Raspberry PI boards" | |
295 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" |
|
293 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" | |
296 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} |
|
294 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} | |
297 | RELEASE_ARCH=${RELEASE_ARCH:=armel} |
|
295 | RELEASE_ARCH=${RELEASE_ARCH:=armel} | |
298 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img} |
|
296 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img} | |
299 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-} |
|
297 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-} | |
300 | fi |
|
298 | fi | |
301 | if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then |
|
299 | if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then | |
302 | echo "Setting settings for bcm2837 Raspberry PI boards" |
|
300 | echo "Setting settings for bcm2837 Raspberry PI boards" | |
303 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" |
|
301 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" | |
304 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} |
|
302 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} | |
305 | RELEASE_ARCH=${RELEASE_ARCH:=armhf} |
|
303 | RELEASE_ARCH=${RELEASE_ARCH:=armhf} | |
306 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} |
|
304 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} | |
307 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} |
|
305 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} | |
308 | fi |
|
306 | fi | |
309 | fi |
|
307 | fi | |
310 | #SET_ARCH not set |
|
308 | #SET_ARCH not set | |
311 | else |
|
309 | else | |
312 | echo "error: Please set '32' or '64' as value for SET_ARCH" |
|
310 | echo "error: Please set '32' or '64' as value for SET_ARCH" | |
313 | exit 1 |
|
311 | exit 1 | |
314 | fi |
|
312 | fi | |
315 |
|
313 | |||
316 | #Device specific configuration |
|
314 | #Device specific configuration | |
317 | echo "Select DTB-File" |
|
315 | echo "Select DTB-File" | |
318 | case "$RPI_MODEL" in |
|
316 | case "$RPI_MODEL" in | |
319 | 0) |
|
317 | 0) | |
320 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} |
|
318 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} | |
321 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} |
|
319 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} | |
322 | ;; |
|
320 | ;; | |
323 | 1) |
|
321 | 1) | |
324 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} |
|
322 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} | |
325 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} |
|
323 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} | |
326 | ;; |
|
324 | ;; | |
327 | 1P) |
|
325 | 1P) | |
328 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} |
|
326 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} | |
329 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} |
|
327 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} | |
330 | ;; |
|
328 | ;; | |
331 | 2) |
|
329 | 2) | |
332 | DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb} |
|
330 | DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb} | |
333 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig} |
|
331 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig} | |
334 | ;; |
|
332 | ;; | |
335 | 3) |
|
333 | 3) | |
336 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} |
|
334 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} | |
337 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} |
|
335 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} | |
338 | ;; |
|
336 | ;; | |
339 | 3P) |
|
337 | 3P) | |
340 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} |
|
338 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} | |
341 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} |
|
339 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} | |
342 | ;; |
|
340 | ;; | |
343 | *) |
|
341 | *) | |
344 | echo "error: Raspberry Pi model $RPI_MODEL is not supported!" |
|
342 | echo "error: Raspberry Pi model $RPI_MODEL is not supported!" | |
345 | exit 1 |
|
343 | exit 1 | |
346 | ;; |
|
344 | ;; | |
347 | esac |
|
345 | esac | |
348 | echo "$DTB_FILE selected" |
|
346 | echo "$DTB_FILE selected" | |
349 |
|
347 | |||
350 | #DEBUG off |
|
348 | #DEBUG off | |
351 | set +x |
|
349 | set +x | |
352 |
|
350 | |||
353 | # Check if the internal wireless interface is supported by the RPi model |
|
351 | # Check if the internal wireless interface is supported by the RPi model | |
354 | if [ "$ENABLE_WIRELESS" = true ] ; then |
|
352 | if [ "$ENABLE_WIRELESS" = true ] ; then | |
355 | if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then |
|
353 | if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then | |
356 | echo "error: The selected Raspberry Pi model has no internal wireless interface" |
|
354 | echo "error: The selected Raspberry Pi model has no internal wireless interface" | |
357 | exit 1 |
|
355 | exit 1 | |
358 | else |
|
356 | else | |
359 | echo "Raspberry Pi $RPI_MODEL has WIFI support" |
|
357 | echo "Raspberry Pi $RPI_MODEL has WIFI support" | |
360 | fi |
|
358 | fi | |
361 | fi |
|
359 | fi | |
362 |
|
360 | |||
363 | # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported |
|
361 | # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported | |
364 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
362 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
365 | if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then |
|
363 | if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then | |
366 | echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported" |
|
364 | echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported" | |
367 | exit 1 |
|
365 | exit 1 | |
368 | fi |
|
366 | fi | |
369 | fi |
|
367 | fi | |
370 |
|
368 | |||
371 | if [ "$ENABLE_VIDEOCORE" = true ] ; then |
|
369 | if [ "$ENABLE_VIDEOCORE" = true ] ; then | |
372 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" |
|
370 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" | |
373 | fi |
|
371 | fi | |
374 |
|
372 | |||
375 | # Add libncurses5 to enable kernel menuconfig |
|
373 | # Add libncurses5 to enable kernel menuconfig | |
376 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
374 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |
377 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev" |
|
375 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev" | |
378 | fi |
|
376 | fi | |
379 |
|
377 | |||
380 | # Add ccache compiler cache for (faster) kernel cross (re)compilation |
|
378 | # Add ccache compiler cache for (faster) kernel cross (re)compilation | |
381 | if [ "$KERNEL_CCACHE" = true ] ; then |
|
379 | if [ "$KERNEL_CCACHE" = true ] ; then | |
382 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache" |
|
380 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache" | |
383 | fi |
|
381 | fi | |
384 |
|
382 | |||
385 | # Add cryptsetup package to enable filesystem encryption |
|
383 | # Add cryptsetup package to enable filesystem encryption | |
386 | if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then |
|
384 | if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then | |
387 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" |
|
385 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" | |
388 | APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup" |
|
386 | APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup" | |
389 |
|
387 | |||
390 | if [ -z "$CRYPTFS_PASSWORD" ] ; then |
|
388 | if [ -z "$CRYPTFS_PASSWORD" ] ; then | |
391 | echo "error: no password defined (CRYPTFS_PASSWORD)!" |
|
389 | echo "error: no password defined (CRYPTFS_PASSWORD)!" | |
392 | exit 1 |
|
390 | exit 1 | |
393 | fi |
|
391 | fi | |
394 | ENABLE_INITRAMFS=true |
|
392 | ENABLE_INITRAMFS=true | |
395 | fi |
|
393 | fi | |
396 |
|
394 | |||
397 | # Add initramfs generation tools |
|
395 | # Add initramfs generation tools | |
398 | if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then |
|
396 | if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then | |
399 | APT_INCLUDES="${APT_INCLUDES},initramfs-tools" |
|
397 | APT_INCLUDES="${APT_INCLUDES},initramfs-tools" | |
400 | fi |
|
398 | fi | |
401 |
|
399 | |||
402 | # Add device-tree-compiler required for building the U-Boot bootloader |
|
400 | # Add device-tree-compiler required for building the U-Boot bootloader | |
403 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
401 | if [ "$ENABLE_UBOOT" = true ] ; then | |
404 | APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc" |
|
402 | APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc" | |
405 | else |
|
403 | else | |
406 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
404 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
407 | echo "error: Enabling UBOOTUSB requires u-boot to be enabled" |
|
405 | echo "error: Enabling UBOOTUSB requires u-boot to be enabled" | |
408 | exit 1 |
|
406 | exit 1 | |
409 | fi |
|
407 | fi | |
410 | fi |
|
408 | fi | |
411 |
|
409 | |||
412 | # Check if root SSH (v2) public key file exists |
|
410 | # Check if root SSH (v2) public key file exists | |
413 | if [ -n "$SSH_ROOT_PUB_KEY" ] ; then |
|
411 | if [ -n "$SSH_ROOT_PUB_KEY" ] ; then | |
414 | if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then |
|
412 | if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then | |
415 | echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!" |
|
413 | echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!" | |
416 | exit 1 |
|
414 | exit 1 | |
417 | fi |
|
415 | fi | |
418 | fi |
|
416 | fi | |
419 |
|
417 | |||
420 | # Check if $USER_NAME SSH (v2) public key file exists |
|
418 | # Check if $USER_NAME SSH (v2) public key file exists | |
421 | if [ -n "$SSH_USER_PUB_KEY" ] ; then |
|
419 | if [ -n "$SSH_USER_PUB_KEY" ] ; then | |
422 | if [ ! -f "$SSH_USER_PUB_KEY" ] ; then |
|
420 | if [ ! -f "$SSH_USER_PUB_KEY" ] ; then | |
423 | echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!" |
|
421 | echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!" | |
424 | exit 1 |
|
422 | exit 1 | |
425 | fi |
|
423 | fi | |
426 | fi |
|
424 | fi | |
427 |
|
425 | |||
428 | # Check if all required packages are installed on the build system |
|
426 | # Check if all required packages are installed on the build system | |
429 | for package in $REQUIRED_PACKAGES ; do |
|
427 | for package in $REQUIRED_PACKAGES ; do | |
430 | if [ "$(dpkg-query -W -f='${Status}' $package)" != "install ok installed" ] ; then |
|
428 | if [ "$(dpkg-query -W -f='${Status}' $package)" != "install ok installed" ] ; then | |
431 | MISSING_PACKAGES="${MISSING_PACKAGES} $package" |
|
429 | MISSING_PACKAGES="${MISSING_PACKAGES} $package" | |
432 | fi |
|
430 | fi | |
433 | done |
|
431 | done | |
434 |
|
432 | |||
435 | # If there are missing packages ask confirmation for install, or exit |
|
433 | # If there are missing packages ask confirmation for install, or exit | |
436 | if [ -n "$MISSING_PACKAGES" ] ; then |
|
434 | if [ -n "$MISSING_PACKAGES" ] ; then | |
437 | echo "the following packages needed by this script are not installed:" |
|
435 | echo "the following packages needed by this script are not installed:" | |
438 | echo "$MISSING_PACKAGES" |
|
436 | echo "$MISSING_PACKAGES" | |
439 |
|
437 | |||
440 | printf "\ndo you want to install the missing packages right now? [y/n] " |
|
438 | printf "\ndo you want to install the missing packages right now? [y/n] " | |
441 | read -r confirm |
|
439 | read -r confirm | |
442 | [ "$confirm" != "y" ] && exit 1 |
|
440 | [ "$confirm" != "y" ] && exit 1 | |
443 |
|
441 | |||
444 | # Make sure all missing required packages are installed |
|
442 | # Make sure all missing required packages are installed | |
445 | apt-get -qq -y install "${MISSING_PACKAGES}" |
|
443 | apt-get -qq -y install "${MISSING_PACKAGES}" | |
446 | fi |
|
444 | fi | |
447 |
|
445 | |||
448 | # Check if ./bootstrap.d directory exists |
|
446 | # Check if ./bootstrap.d directory exists | |
449 | if [ ! -d "./bootstrap.d/" ] ; then |
|
447 | if [ ! -d "./bootstrap.d/" ] ; then | |
450 | echo "error: './bootstrap.d' required directory not found!" |
|
448 | echo "error: './bootstrap.d' required directory not found!" | |
451 | exit 1 |
|
449 | exit 1 | |
452 | fi |
|
450 | fi | |
453 |
|
451 | |||
454 | # Check if ./files directory exists |
|
452 | # Check if ./files directory exists | |
455 | if [ ! -d "./files/" ] ; then |
|
453 | if [ ! -d "./files/" ] ; then | |
456 | echo "error: './files' required directory not found!" |
|
454 | echo "error: './files' required directory not found!" | |
457 | exit 1 |
|
455 | exit 1 | |
458 | fi |
|
456 | fi | |
459 |
|
457 | |||
460 | # Check if specified KERNELSRC_DIR directory exists |
|
458 | # Check if specified KERNELSRC_DIR directory exists | |
461 | if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then |
|
459 | if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then | |
462 | echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!" |
|
460 | echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!" | |
463 | exit 1 |
|
461 | exit 1 | |
464 | fi |
|
462 | fi | |
465 |
|
463 | |||
466 | # Check if specified UBOOTSRC_DIR directory exists |
|
464 | # Check if specified UBOOTSRC_DIR directory exists | |
467 | if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then |
|
465 | if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then | |
468 | echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!" |
|
466 | echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!" | |
469 | exit 1 |
|
467 | exit 1 | |
470 | fi |
|
468 | fi | |
471 |
|
469 | |||
472 | # Check if specified VIDEOCORESRC_DIR directory exists |
|
470 | # Check if specified VIDEOCORESRC_DIR directory exists | |
473 | if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then |
|
471 | if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then | |
474 | echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!" |
|
472 | echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!" | |
475 | exit 1 |
|
473 | exit 1 | |
476 | fi |
|
474 | fi | |
477 |
|
475 | |||
478 | # Check if specified FBTURBOSRC_DIR directory exists |
|
476 | # Check if specified FBTURBOSRC_DIR directory exists | |
479 | if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then |
|
477 | if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then | |
480 | echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!" |
|
478 | echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!" | |
481 | exit 1 |
|
479 | exit 1 | |
482 | fi |
|
480 | fi | |
483 |
|
481 | |||
484 | # Check if specified CHROOT_SCRIPTS directory exists |
|
482 | # Check if specified CHROOT_SCRIPTS directory exists | |
485 | if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then |
|
483 | if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then | |
486 | echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" |
|
484 | echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" | |
487 | exit 1 |
|
485 | exit 1 | |
488 | fi |
|
486 | fi | |
489 |
|
487 | |||
490 | # Check if specified device mapping already exists (will be used by cryptsetup) |
|
488 | # Check if specified device mapping already exists (will be used by cryptsetup) | |
491 | if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then |
|
489 | if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then | |
492 | echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding" |
|
490 | echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding" | |
493 | exit 1 |
|
491 | exit 1 | |
494 | fi |
|
492 | fi | |
495 |
|
493 | |||
496 | # Don't clobber an old build |
|
494 | # Don't clobber an old build | |
497 | if [ -e "$BUILDDIR" ] ; then |
|
495 | if [ -e "$BUILDDIR" ] ; then | |
498 | echo "error: directory ${BUILDDIR} already exists, not proceeding" |
|
496 | echo "error: directory ${BUILDDIR} already exists, not proceeding" | |
499 | exit 1 |
|
497 | exit 1 | |
500 | fi |
|
498 | fi | |
501 |
|
499 | |||
502 | # Setup chroot directory |
|
500 | # Setup chroot directory | |
503 | mkdir -p "${R}" |
|
501 | mkdir -p "${R}" | |
504 |
|
502 | |||
505 | # Check if build directory has enough of free disk space >512MB |
|
503 | # Check if build directory has enough of free disk space >512MB | |
506 | if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then |
|
504 | if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then | |
507 | echo "error: ${BUILDDIR} not enough space left to generate the output image!" |
|
505 | echo "error: ${BUILDDIR} not enough space left to generate the output image!" | |
508 | exit 1 |
|
506 | exit 1 | |
509 | fi |
|
507 | fi | |
510 |
|
508 | |||
511 | set -x |
|
509 | set -x | |
512 |
|
510 | |||
513 | # Call "cleanup" function on various signals and errors |
|
511 | # Call "cleanup" function on various signals and errors | |
514 | trap cleanup 0 1 2 3 6 |
|
512 | trap cleanup 0 1 2 3 6 | |
515 |
|
513 | |||
516 | # Add required packages for the minbase installation |
|
514 | # Add required packages for the minbase installation | |
517 | if [ "$ENABLE_MINBASE" = true ] ; then |
|
515 | if [ "$ENABLE_MINBASE" = true ] ; then | |
518 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown" |
|
516 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown" | |
519 | fi |
|
517 | fi | |
520 |
|
518 | |||
521 | # Add parted package, required to get partprobe utility |
|
519 | # Add parted package, required to get partprobe utility | |
522 | if [ "$EXPANDROOT" = true ] ; then |
|
520 | if [ "$EXPANDROOT" = true ] ; then | |
523 | APT_INCLUDES="${APT_INCLUDES},parted" |
|
521 | APT_INCLUDES="${APT_INCLUDES},parted" | |
524 | fi |
|
522 | fi | |
525 |
|
523 | |||
526 | # Add dbus package, recommended if using systemd |
|
524 | # Add dbus package, recommended if using systemd | |
527 | if [ "$ENABLE_DBUS" = true ] ; then |
|
525 | if [ "$ENABLE_DBUS" = true ] ; then | |
528 | APT_INCLUDES="${APT_INCLUDES},dbus" |
|
526 | APT_INCLUDES="${APT_INCLUDES},dbus" | |
529 | fi |
|
527 | fi | |
530 |
|
528 | |||
531 | # Add iptables IPv4/IPv6 package |
|
529 | # Add iptables IPv4/IPv6 package | |
532 | if [ "$ENABLE_IPTABLES" = true ] ; then |
|
530 | if [ "$ENABLE_IPTABLES" = true ] ; then | |
533 | APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent" |
|
531 | APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent" | |
534 | fi |
|
532 | fi | |
535 |
|
533 | |||
536 | # Add openssh server package |
|
534 | # Add openssh server package | |
537 | if [ "$ENABLE_SSHD" = true ] ; then |
|
535 | if [ "$ENABLE_SSHD" = true ] ; then | |
538 | APT_INCLUDES="${APT_INCLUDES},openssh-server" |
|
536 | APT_INCLUDES="${APT_INCLUDES},openssh-server" | |
539 | fi |
|
537 | fi | |
540 |
|
538 | |||
541 | # Add alsa-utils package |
|
539 | # Add alsa-utils package | |
542 | if [ "$ENABLE_SOUND" = true ] ; then |
|
540 | if [ "$ENABLE_SOUND" = true ] ; then | |
543 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" |
|
541 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" | |
544 | fi |
|
542 | fi | |
545 |
|
543 | |||
546 | # Add rng-tools package |
|
544 | # Add rng-tools package | |
547 | if [ "$ENABLE_HWRANDOM" = true ] ; then |
|
545 | if [ "$ENABLE_HWRANDOM" = true ] ; then | |
548 | APT_INCLUDES="${APT_INCLUDES},rng-tools" |
|
546 | APT_INCLUDES="${APT_INCLUDES},rng-tools" | |
549 | fi |
|
547 | fi | |
550 |
|
548 | |||
551 | # Add fbturbo video driver |
|
549 | # Add fbturbo video driver | |
552 | if [ "$ENABLE_FBTURBO" = true ] ; then |
|
550 | if [ "$ENABLE_FBTURBO" = true ] ; then | |
553 | # Enable xorg package dependencies |
|
551 | # Enable xorg package dependencies | |
554 | ENABLE_XORG=true |
|
552 | ENABLE_XORG=true | |
555 | fi |
|
553 | fi | |
556 |
|
554 | |||
557 | # Add user defined window manager package |
|
555 | # Add user defined window manager package | |
558 | if [ -n "$ENABLE_WM" ] ; then |
|
556 | if [ -n "$ENABLE_WM" ] ; then | |
559 | APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" |
|
557 | APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" | |
560 |
|
558 | |||
561 | # Enable xorg package dependencies |
|
559 | # Enable xorg package dependencies | |
562 | ENABLE_XORG=true |
|
560 | ENABLE_XORG=true | |
563 | fi |
|
561 | fi | |
564 |
|
562 | |||
565 | # Add xorg package |
|
563 | # Add xorg package | |
566 | if [ "$ENABLE_XORG" = true ] ; then |
|
564 | if [ "$ENABLE_XORG" = true ] ; then | |
567 | APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11" |
|
565 | APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11" | |
568 | fi |
|
566 | fi | |
569 |
|
567 | |||
570 | # Replace selected packages with smaller clones |
|
568 | # Replace selected packages with smaller clones | |
571 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
569 | if [ "$ENABLE_REDUCE" = true ] ; then | |
572 | # Add levee package instead of vim-tiny |
|
570 | # Add levee package instead of vim-tiny | |
573 | if [ "$REDUCE_VIM" = true ] ; then |
|
571 | if [ "$REDUCE_VIM" = true ] ; then | |
574 | APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")" |
|
572 | APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")" | |
575 | fi |
|
573 | fi | |
576 |
|
574 | |||
577 | # Add dropbear package instead of openssh-server |
|
575 | # Add dropbear package instead of openssh-server | |
578 | if [ "$REDUCE_SSHD" = true ] ; then |
|
576 | if [ "$REDUCE_SSHD" = true ] ; then | |
579 | APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" |
|
577 | APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" | |
580 | fi |
|
578 | fi | |
581 | fi |
|
579 | fi | |
582 |
|
580 | |||
583 | # Configure kernel sources if no KERNELSRC_DIR |
|
581 | # Configure kernel sources if no KERNELSRC_DIR | |
584 | if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then |
|
582 | if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then | |
585 | KERNELSRC_CONFIG=true |
|
583 | KERNELSRC_CONFIG=true | |
586 | fi |
|
584 | fi | |
587 |
|
585 | |||
588 | # Configure reduced kernel |
|
586 | # Configure reduced kernel | |
589 | if [ "$KERNEL_REDUCE" = true ] ; then |
|
587 | if [ "$KERNEL_REDUCE" = true ] ; then | |
590 | KERNELSRC_CONFIG=false |
|
588 | KERNELSRC_CONFIG=false | |
591 | fi |
|
589 | fi | |
592 |
|
590 | |||
593 | # Configure qemu compatible kernel |
|
591 | # Configure qemu compatible kernel | |
594 | if [ "$ENABLE_QEMU" = true ] ; then |
|
592 | if [ "$ENABLE_QEMU" = true ] ; then | |
595 | DTB_FILE=vexpress-v2p-ca15_a7.dtb |
|
593 | DTB_FILE=vexpress-v2p-ca15_a7.dtb | |
596 | UBOOT_CONFIG=vexpress_ca15_tc2_defconfig |
|
594 | UBOOT_CONFIG=vexpress_ca15_tc2_defconfig | |
597 | KERNEL_DEFCONFIG="vexpress_defconfig" |
|
595 | KERNEL_DEFCONFIG="vexpress_defconfig" | |
598 | if [ "$KERNEL_MENUCONFIG" = false ] ; then |
|
596 | if [ "$KERNEL_MENUCONFIG" = false ] ; then | |
599 | KERNEL_OLDDEFCONFIG=true |
|
597 | KERNEL_OLDDEFCONFIG=true | |
600 | fi |
|
598 | fi | |
601 | fi |
|
599 | fi | |
602 |
|
600 | |||
603 | # Execute bootstrap scripts |
|
601 | # Execute bootstrap scripts | |
604 | for SCRIPT in bootstrap.d/*.sh; do |
|
602 | for SCRIPT in bootstrap.d/*.sh; do | |
605 | head -n 3 "$SCRIPT" |
|
603 | head -n 3 "$SCRIPT" | |
606 | . "$SCRIPT" |
|
604 | . "$SCRIPT" | |
607 | done |
|
605 | done | |
608 |
|
606 | |||
609 | ## Execute custom bootstrap scripts |
|
607 | ## Execute custom bootstrap scripts | |
610 | if [ -d "custom.d" ] ; then |
|
608 | if [ -d "custom.d" ] ; then | |
611 | for SCRIPT in custom.d/*.sh; do |
|
609 | for SCRIPT in custom.d/*.sh; do | |
612 | . "$SCRIPT" |
|
610 | . "$SCRIPT" | |
613 | done |
|
611 | done | |
614 | fi |
|
612 | fi | |
615 |
|
613 | |||
616 | # Execute custom scripts inside the chroot |
|
614 | # Execute custom scripts inside the chroot | |
617 | if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then |
|
615 | if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then | |
618 | cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" |
|
616 | cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" | |
619 | chroot_exec /bin/bash -x <<'EOF' |
|
617 | chroot_exec /bin/bash -x <<'EOF' | |
620 | for SCRIPT in /chroot_scripts/* ; do |
|
618 | for SCRIPT in /chroot_scripts/* ; do | |
621 | if [ -f $SCRIPT -a -x $SCRIPT ] ; then |
|
619 | if [ -f $SCRIPT -a -x $SCRIPT ] ; then | |
622 | $SCRIPT |
|
620 | $SCRIPT | |
623 | fi |
|
621 | fi | |
624 | done |
|
622 | done | |
625 | EOF |
|
623 | EOF | |
626 | rm -rf "${R}/chroot_scripts" |
|
624 | rm -rf "${R}/chroot_scripts" | |
627 | fi |
|
625 | fi | |
628 |
|
626 | |||
629 | # Remove c/c++ build environment from the chroot |
|
627 | # Remove c/c++ build environment from the chroot | |
630 | chroot_remove_cc |
|
628 | chroot_remove_cc | |
631 |
|
629 | |||
632 | # Generate required machine-id |
|
630 | # Generate required machine-id | |
633 | MACHINE_ID=$(dbus-uuidgen) |
|
631 | MACHINE_ID=$(dbus-uuidgen) | |
634 | echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id" |
|
632 | echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id" | |
635 | echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id" |
|
633 | echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id" | |
636 |
|
634 | |||
637 | # APT Cleanup |
|
635 | # APT Cleanup | |
638 | chroot_exec apt-get -y clean |
|
636 | chroot_exec apt-get -y clean | |
639 | chroot_exec apt-get -y autoclean |
|
637 | chroot_exec apt-get -y autoclean | |
640 | chroot_exec apt-get -y autoremove |
|
638 | chroot_exec apt-get -y autoremove | |
641 |
|
639 | |||
642 | # Unmount mounted filesystems |
|
640 | # Unmount mounted filesystems | |
643 | umount -l "${R}/proc" |
|
641 | umount -l "${R}/proc" | |
644 | umount -l "${R}/sys" |
|
642 | umount -l "${R}/sys" | |
645 |
|
643 | |||
646 | # Clean up directories |
|
644 | # Clean up directories | |
647 | rm -rf "${R}/run/*" |
|
645 | rm -rf "${R}/run/*" | |
648 | rm -rf "${R}/tmp/*" |
|
646 | rm -rf "${R}/tmp/*" | |
649 |
|
647 | |||
650 | # Clean up files |
|
648 | # Clean up files | |
651 | rm -f "${ETC_DIR}/ssh/ssh_host_*" |
|
649 | rm -f "${ETC_DIR}/ssh/ssh_host_*" | |
652 | rm -f "${ETC_DIR}/dropbear/dropbear_*" |
|
650 | rm -f "${ETC_DIR}/dropbear/dropbear_*" | |
653 | rm -f "${ETC_DIR}/apt/sources.list.save" |
|
651 | rm -f "${ETC_DIR}/apt/sources.list.save" | |
654 | rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original" |
|
652 | rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original" | |
655 | rm -f "${ETC_DIR}/*-" |
|
653 | rm -f "${ETC_DIR}/*-" | |
656 | rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy" |
|
654 | rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy" | |
657 | rm -f "${ETC_DIR}/resolv.conf" |
|
655 | rm -f "${ETC_DIR}/resolv.conf" | |
658 | rm -f "${R}/root/.bash_history" |
|
656 | rm -f "${R}/root/.bash_history" | |
659 | rm -f "${R}/var/lib/urandom/random-seed" |
|
657 | rm -f "${R}/var/lib/urandom/random-seed" | |
660 | rm -f "${R}/initrd.img" |
|
658 | rm -f "${R}/initrd.img" | |
661 | rm -f "${R}/vmlinuz" |
|
659 | rm -f "${R}/vmlinuz" | |
662 | rm -f "${R}${QEMU_BINARY}" |
|
660 | rm -f "${R}${QEMU_BINARY}" | |
663 |
|
661 | |||
664 | if [ "$ENABLE_QEMU" = true ] ; then |
|
662 | if [ "$ENABLE_QEMU" = true ] ; then | |
665 | # Setup QEMU directory |
|
663 | # Setup QEMU directory | |
666 | mkdir "${BASEDIR}/qemu" |
|
664 | mkdir "${BASEDIR}/qemu" | |
667 |
|
665 | |||
668 | # Copy kernel image to QEMU directory |
|
666 | # Copy kernel image to QEMU directory | |
669 | install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}" |
|
667 | install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}" | |
670 |
|
668 | |||
671 | # Copy kernel config to QEMU directory |
|
669 | # Copy kernel config to QEMU directory | |
672 | install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}" |
|
670 | install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}" | |
673 |
|
671 | |||
674 | # Copy kernel dtbs to QEMU directory |
|
672 | # Copy kernel dtbs to QEMU directory | |
675 | for dtb in "${BOOT_DIR}/"*.dtb ; do |
|
673 | for dtb in "${BOOT_DIR}/"*.dtb ; do | |
676 | if [ -f "${dtb}" ] ; then |
|
674 | if [ -f "${dtb}" ] ; then | |
677 | install_readonly "${dtb}" "${BASEDIR}/qemu/" |
|
675 | install_readonly "${dtb}" "${BASEDIR}/qemu/" | |
678 | fi |
|
676 | fi | |
679 | done |
|
677 | done | |
680 |
|
678 | |||
681 | # Copy kernel overlays to QEMU directory |
|
679 | # Copy kernel overlays to QEMU directory | |
682 | if [ -d "${BOOT_DIR}/overlays" ] ; then |
|
680 | if [ -d "${BOOT_DIR}/overlays" ] ; then | |
683 | # Setup overlays dtbs directory |
|
681 | # Setup overlays dtbs directory | |
684 | mkdir "${BASEDIR}/qemu/overlays" |
|
682 | mkdir "${BASEDIR}/qemu/overlays" | |
685 |
|
683 | |||
686 | for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do |
|
684 | for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do | |
687 | if [ -f "${dtb}" ] ; then |
|
685 | if [ -f "${dtb}" ] ; then | |
688 | install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/" |
|
686 | install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/" | |
689 | fi |
|
687 | fi | |
690 | done |
|
688 | done | |
691 | fi |
|
689 | fi | |
692 |
|
690 | |||
693 | # Copy u-boot files to QEMU directory |
|
691 | # Copy u-boot files to QEMU directory | |
694 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
692 | if [ "$ENABLE_UBOOT" = true ] ; then | |
695 | if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then |
|
693 | if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then | |
696 | install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin" |
|
694 | install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin" | |
697 | fi |
|
695 | fi | |
698 | if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then |
|
696 | if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then | |
699 | install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage" |
|
697 | install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage" | |
700 | fi |
|
698 | fi | |
701 | if [ -f "${BOOT_DIR}/boot.scr" ] ; then |
|
699 | if [ -f "${BOOT_DIR}/boot.scr" ] ; then | |
702 | install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr" |
|
700 | install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr" | |
703 | fi |
|
701 | fi | |
704 | fi |
|
702 | fi | |
705 |
|
703 | |||
706 | # Copy initramfs to QEMU directory |
|
704 | # Copy initramfs to QEMU directory | |
707 | if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then |
|
705 | if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then | |
708 | install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}" |
|
706 | install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}" | |
709 | fi |
|
707 | fi | |
710 | fi |
|
708 | fi | |
711 |
|
709 | |||
712 | # Calculate size of the chroot directory in KB |
|
710 | # Calculate size of the chroot directory in KB | |
713 | CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')") |
|
711 | CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')") | |
714 |
|
712 | |||
715 | # Calculate the amount of needed 512 Byte sectors |
|
713 | # Calculate the amount of needed 512 Byte sectors | |
716 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) |
|
714 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) | |
717 | FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512) |
|
715 | FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512) | |
718 | ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}") |
|
716 | ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}") | |
719 |
|
717 | |||
720 | # The root partition is EXT4 |
|
718 | # The root partition is EXT4 | |
721 | # This means more space than the actual used space of the chroot is used. |
|
719 | # This means more space than the actual used space of the chroot is used. | |
722 | # As overhead for journaling and reserved blocks 35% are added. |
|
720 | # As overhead for journaling and reserved blocks 35% are added. | |
723 | ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512) |
|
721 | ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512) | |
724 |
|
722 | |||
725 | # Calculate required image size in 512 Byte sectors |
|
723 | # Calculate required image size in 512 Byte sectors | |
726 | IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}") |
|
724 | IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}") | |
727 |
|
725 | |||
728 | # Prepare image file |
|
726 | # Prepare image file | |
729 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
727 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
730 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}" |
|
728 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}" | |
731 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}" |
|
729 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}" | |
732 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" |
|
730 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" | |
733 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}" |
|
731 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}" | |
734 |
|
732 | |||
735 | # Write firmware/boot partition tables |
|
733 | # Write firmware/boot partition tables | |
736 | sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM |
|
734 | sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM | |
737 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* |
|
735 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* | |
738 | EOM |
|
736 | EOM | |
739 |
|
737 | |||
740 | # Write root partition table |
|
738 | # Write root partition table | |
741 | sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM |
|
739 | sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM | |
742 | ${TABLE_SECTORS},${ROOT_SECTORS},83 |
|
740 | ${TABLE_SECTORS},${ROOT_SECTORS},83 | |
743 | EOM |
|
741 | EOM | |
744 |
|
742 | |||
745 | # Setup temporary loop devices |
|
743 | # Setup temporary loop devices | |
746 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)" |
|
744 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)" | |
747 | ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)" |
|
745 | ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)" | |
748 | else # ENABLE_SPLITFS=false |
|
746 | else # ENABLE_SPLITFS=false | |
749 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}" |
|
747 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}" | |
750 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}" |
|
748 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}" | |
751 |
|
749 | |||
752 | # Write partition table |
|
750 | # Write partition table | |
753 | sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM |
|
751 | sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM | |
754 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* |
|
752 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* | |
755 | ${ROOT_OFFSET},${ROOT_SECTORS},83 |
|
753 | ${ROOT_OFFSET},${ROOT_SECTORS},83 | |
756 | EOM |
|
754 | EOM | |
757 |
|
755 | |||
758 | # Setup temporary loop devices |
|
756 | # Setup temporary loop devices | |
759 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)" |
|
757 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)" | |
760 | ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)" |
|
758 | ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)" | |
761 | fi |
|
759 | fi | |
762 |
|
760 | |||
763 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
761 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
764 | # Create dummy ext4 fs |
|
762 | # Create dummy ext4 fs | |
765 | mkfs.ext4 "$ROOT_LOOP" |
|
763 | mkfs.ext4 "$ROOT_LOOP" | |
766 |
|
764 | |||
767 | # Setup password keyfile |
|
765 | # Setup password keyfile | |
768 | touch .password |
|
766 | touch .password | |
769 | chmod 600 .password |
|
767 | chmod 600 .password | |
770 | echo -n ${CRYPTFS_PASSWORD} > .password |
|
768 | echo -n ${CRYPTFS_PASSWORD} > .password | |
771 |
|
769 | |||
772 | # Initialize encrypted partition |
|
770 | # Initialize encrypted partition | |
773 | echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password |
|
771 | echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password | |
774 |
|
772 | |||
775 | # Open encrypted partition and setup mapping |
|
773 | # Open encrypted partition and setup mapping | |
776 | cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}" |
|
774 | cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}" | |
777 |
|
775 | |||
778 | # Secure delete password keyfile |
|
776 | # Secure delete password keyfile | |
779 | shred -zu .password |
|
777 | shred -zu .password | |
780 |
|
778 | |||
781 | # Update temporary loop device |
|
779 | # Update temporary loop device | |
782 | ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}" |
|
780 | ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}" | |
783 |
|
781 | |||
784 | # Wipe encrypted partition (encryption cipher is used for randomness) |
|
782 | # Wipe encrypted partition (encryption cipher is used for randomness) | |
785 | dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")" |
|
783 | dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")" | |
786 | fi |
|
784 | fi | |
787 |
|
785 | |||
788 | # Build filesystems |
|
786 | # Build filesystems | |
789 | mkfs.vfat "$FRMW_LOOP" |
|
787 | mkfs.vfat "$FRMW_LOOP" | |
790 | mkfs.ext4 "$ROOT_LOOP" |
|
788 | mkfs.ext4 "$ROOT_LOOP" | |
791 |
|
789 | |||
792 | # Mount the temporary loop devices |
|
790 | # Mount the temporary loop devices | |
793 | mkdir -p "$BUILDDIR/mount" |
|
791 | mkdir -p "$BUILDDIR/mount" | |
794 | mount "$ROOT_LOOP" "$BUILDDIR/mount" |
|
792 | mount "$ROOT_LOOP" "$BUILDDIR/mount" | |
795 |
|
793 | |||
796 | mkdir -p "$BUILDDIR/mount/boot/firmware" |
|
794 | mkdir -p "$BUILDDIR/mount/boot/firmware" | |
797 | mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" |
|
795 | mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" | |
798 |
|
796 | |||
799 | # Copy all files from the chroot to the loop device mount point directory |
|
797 | # Copy all files from the chroot to the loop device mount point directory | |
800 | rsync -a "${R}/" "$BUILDDIR/mount/" |
|
798 | rsync -a "${R}/" "$BUILDDIR/mount/" | |
801 |
|
799 | |||
802 | # Unmount all temporary loop devices and mount points |
|
800 | # Unmount all temporary loop devices and mount points | |
803 | cleanup |
|
801 | cleanup | |
804 |
|
802 | |||
805 | # Create block map file(s) of image(s) |
|
803 | # Create block map file(s) of image(s) | |
806 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
804 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
807 | # Create block map files for "bmaptool" |
|
805 | # Create block map files for "bmaptool" | |
808 | bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img" |
|
806 | bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img" | |
809 | bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img" |
|
807 | bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img" | |
810 |
|
808 | |||
811 | # Image was successfully created |
|
809 | # Image was successfully created | |
812 | echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
810 | echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
813 | echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
811 | echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
814 | else |
|
812 | else | |
815 | # Create block map file for "bmaptool" |
|
813 | # Create block map file for "bmaptool" | |
816 | bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img" |
|
814 | bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img" | |
817 |
|
815 | |||
818 | # Image was successfully created |
|
816 | # Image was successfully created | |
819 | echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
817 | echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
820 |
|
818 | |||
821 | # Create qemu qcow2 image |
|
819 | # Create qemu qcow2 image | |
822 | if [ "$ENABLE_QEMU" = true ] ; then |
|
820 | if [ "$ENABLE_QEMU" = true ] ; then | |
823 | QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
821 | QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} | |
824 | QEMU_SIZE=16G |
|
822 | QEMU_SIZE=16G | |
825 |
|
823 | |||
826 | qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2 |
|
824 | qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2 | |
827 | qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE |
|
825 | qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE | |
828 |
|
826 | |||
829 | echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created" |
|
827 | echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created" | |
830 | fi |
|
828 | fi | |
831 | fi |
|
829 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant