##// END OF EJS Templates
Fixed: DEFLOCAL now works with MINBASE, author added on request
drtyhlpr -
r88:29663cdbff03
parent child
Show More
@@ -1,307 +1,307
1 1 # rpi2-gen-image
2 2 ## Introduction
3 3 `rpi2-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for the Raspberry 2 (RPi2) computer. The script at this time only supports the bootstrapping of the current stable Debian 8 "jessie" release.
4 4
5 5 ## Build dependencies
6 6 The following list of Debian packages must be installed on the build system because they are essentially required for the bootstrapping process. The script will check if all required packages are installed and missing packages will be installed automatically if confirmed by the user.
7 7
8 8 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git```
9 9
10 10 ## Command-line parameters
11 11 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi2-gen-image.sh` script via (simple) shell-variables. Unlike environment shell-variables (simple) shell-variables are defined at the beginning of the command-line call of the `rpi2-gen-image.sh` script.
12 12
13 13 #####Command-line examples:
14 14 ```shell
15 15 ENABLE_UBOOT=true ./rpi2-gen-image.sh
16 16 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi2-gen-image.sh
17 17 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi2-gen-image.sh
18 18 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi2-gen-image.sh
19 19 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi2-gen-image.sh
20 20 ENABLE_MINBASE=true ./rpi2-gen-image.sh
21 21 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi2-gen-image.sh
22 22 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi2-gen-image.sh
23 23 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi2-gen-image.sh
24 24 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi2-gen-image.sh
25 25 ```
26 26
27 27 #### APT settings:
28 28 ##### `APT_SERVER`="ftp.debian.org"
29 29 Set Debian packages server address. Choose a server from the list of Debian worldwide [mirror sites](https://www.debian.org/mirror/list). Using a nearby server will probably speed-up all required downloads within the bootstrapping process.
30 30
31 31 ##### `APT_PROXY`=""
32 32 Set Proxy server address. Using a local Proxy-Cache like `apt-cacher-ng` will speed-up the bootstrapping process because all required Debian packages will only be downloaded from the Debian mirror site once.
33 33
34 34 ##### `APT_INCLUDES`=""
35 35 A comma separated list of additional packages to be installed during bootstrapping.
36 36
37 37 #### General system settings:
38 38 ##### `HOSTNAME`="rpi2-jessie"
39 39 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
40 40
41 41 ##### `PASSWORD`="raspberry"
42 42 Set system `root` password. The same password is used for the created user `pi`. It's **STRONGLY** recommended that you choose a custom password.
43 43
44 44 ##### `DEFLOCAL`="en_US.UTF-8"
45 Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. The script variant `minbase` (ENABLE_MINBASE=true) doesn't install `locales`.
45 Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. Please note that on using this parameter the script will automatically install the required packages `locales`, `keyboard-configuration` and `console-setup`.
46 46
47 47 ##### `TIMEZONE`="Europe/Berlin"
48 48 Set default system timezone. All available timezones can be found in the `/usr/share/zoneinfo/` directory. This setting can also be changed inside the running OS using the `dpkg-reconfigure tzdata` command.
49 49
50 50 ##### `EXPANDROOT`=true
51 51 Expand the root partition and filesystem automatically on first boot.
52 52
53 53 #### Keyboard settings:
54 54 These options are used to configure keyboard layout in `/etc/default/keyboard` for console and Xorg. These settings can also be changed inside the running OS using the `dpkg-reconfigure keyboard-configuration` command.
55 55
56 56 ##### `XKB_MODEL`=""
57 57 Set the name of the model of your keyboard type.
58 58
59 59 ##### `XKB_LAYOUT`=""
60 60 Set the supported keyboard layout(s).
61 61
62 62 ##### `XKB_VARIANT`=""
63 63 Set the supported variant(s) of the keyboard layout(s).
64 64
65 65 ##### `XKB_OPTIONS`=""
66 66 Set extra xkb configuration options.
67 67
68 68 #### Networking settings (DHCP):
69 69 This parameter is used to set up networking auto configuration in `/etc/systemd/network/eth.network`.
70 70
71 71 #####`ENABLE_DHCP`=true
72 72 Set the system to use DHCP. This requires an DHCP server.
73 73
74 74 #### Networking settings (static):
75 75 These parameters are used to set up a static networking configuration in /etc/systemd/network/eth.network. The following static networking parameters are only supported if `ENABLE_DHCP` was set to `false`.
76 76
77 77 #####`NET_ADDRESS`=""
78 78 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
79 79
80 80 #####`NET_GATEWAY`=""
81 81 Set the IP address for the default gateway.
82 82
83 83 #####`NET_DNS_1`=""
84 84 Set the IP address for the first DNS server.
85 85
86 86 #####`NET_DNS_2`=""
87 87 Set the IP address for the second DNS server.
88 88
89 89 #####`NET_DNS_DOMAINS`=""
90 90 Set the default DNS search domains to use for non fully qualified host names.
91 91
92 92 #####`NET_NTP_1`=""
93 93 Set the IP address for the first NTP server.
94 94
95 95 #####`NET_NTP_2`=""
96 96 Set the IP address for the second NTP server.
97 97
98 98 #### Basic system features:
99 99 ##### `ENABLE_CONSOLE`=true
100 100 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
101 101
102 102 ##### `ENABLE_IPV6`=true
103 103 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
104 104
105 105 ##### `ENABLE_SSHD`=true
106 106 Install and enable OpenSSH service. The default configuration of the service doesn't allow `root` to login. Please use the user `pi` instead and `su -` or `sudo` to execute commands as root.
107 107
108 108 ##### `ENABLE_RSYSLOG`=true
109 109 If set to false, disable and uninstall rsyslog (so logs will be available only
110 110 in journal files)
111 111
112 112 ##### `ENABLE_SOUND`=true
113 113 Enable sound hardware and install Advanced Linux Sound Architecture.
114 114
115 115 ##### `ENABLE_HWRANDOM`=true
116 116 Enable Hardware Random Number Generator. Strong random numbers are important for most network based communications that use encryption. It's recommended to be enabled.
117 117
118 118 ##### `ENABLE_MINGPU`=false
119 119 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
120 120
121 121 ##### `ENABLE_DBUS`=true
122 122 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
123 123
124 124 ##### `ENABLE_XORG`=false
125 125 Install Xorg open-source X Window System.
126 126
127 127 ##### `ENABLE_WM`=""
128 128 Install a user defined window manager for the X Window System. To make sure all X related package dependencies are getting installed `ENABLE_XORG` will automatically get enabled if `ENABLE_WM` is used. The `rpi2-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
129 129
130 130 #### Advanced system features:
131 131 ##### `ENABLE_MINBASE`=false
132 132 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
133 133
134 134 ##### `ENABLE_REDUCE`=false
135 135 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
136 136
137 137 ##### `ENABLE_UBOOT`=false
138 138 Replace default RPi2 second stage bootloader (bootcode.bin) with U-Boot bootloader. U-Boot can boot images via the network using the BOOTP/TFTP protocol.
139 139
140 140 ##### `ENABLE_FBTURBO`=false
141 141 Install and enable the hardware accelerated Xorg video driver `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
142 142
143 143 ##### `ENABLE_IPTABLES`=false
144 144 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
145 145
146 146 ##### `ENABLE_USER`=true
147 147 Create non-root user with password raspberry. Unless overridden with `USER_NAME`=user, username will be `pi`.
148 148
149 149 ##### `USER_NAME`=pi
150 150 Non-root user to create. Ignored if `ENABLE_USER`=false
151 151
152 152 ##### `ENABLE_ROOT`=true
153 153 Set root user password so root login will be enabled
154 154
155 155 ##### `ENABLE_ROOT_SSH`=true
156 156 Enable password root login via SSH. May be a security risk with default
157 157 password, use only in trusted environments.
158 158
159 159 ##### `ENABLE_HARDNET`=false
160 160 Enable IPv4/IPv6 network stack hardening settings.
161 161
162 162 ##### `ENABLE_SPLITFS`=false
163 163 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
164 164
165 165 ##### `CHROOT_SCRIPTS`=""
166 166 Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this directory is run in lexicographical order.
167 167
168 168 ##### `ENABLE_INITRAMFS`=false
169 169 Create an initramfs that that will be loaded during the Linux startup process. `ENABLE_INITRAMFS` will automatically get enabled if `ENABLE_CRYPTFS`=true. This parameter will be ignored if `BUILD_KERNEL`=false.
170 170
171 171 #### Kernel compilation:
172 172 ##### `BUILD_KERNEL`=false
173 173 Build and install the latest RPi2 Linux kernel. Currently only the default RPi2 kernel configuration is used.
174 174
175 175 ##### `KERNEL_REDUCE`=false
176 176 Reduce the size of the generated kernel by removing unwanted device, network and filesystem drivers (experimental).
177 177
178 178 ##### `KERNEL_THREADS`=1
179 179 Number of parallel kernel building threads. If the parameter is left untouched the script will automatically determine the number of CPU cores to set the number of parallel threads to speed the kernel compilation.
180 180
181 181 ##### `KERNEL_HEADERS`=true
182 182 Install kernel headers with built kernel.
183 183
184 184 ##### `KERNEL_MENUCONFIG`=false
185 185 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
186 186
187 187 ##### `KERNEL_REMOVESRC`=true
188 188 Remove all kernel sources from the generated OS image after it was built and installed.
189 189
190 190 ##### `KERNELSRC_DIR`=""
191 191 Path to a directory of [RaspberryPi Linux kernel sources](https://github.com/raspberrypi/linux) that will be copied, configured, build and installed inside the chroot.
192 192
193 193 ##### `KERNELSRC_CLEAN`=false
194 194 Clean the existing kernel sources directory `KERNELSRC_DIR` (using `make mrproper`) after it was copied to the chroot and before the compilation of the kernel has started. This parameter will be ignored if no `KERNELSRC_DIR` was specified or if `KERNELSRC_PREBUILT`=true.
195 195
196 196 ##### `KERNELSRC_CONFIG`=true
197 197 Run `make bcm2709_defconfig` (and optional `make menuconfig`) to configure the kernel sources before building. This parameter is automatically set to `true` if no existing kernel sources directory was specified using `KERNELSRC_DIR`. This parameter is ignored if `KERNELSRC_PREBUILT`=true.
198 198
199 199 ##### `KERNELSRC_PREBUILT`=false
200 200 With this parameter set to true the script expects the existing kernel sources directory to be already successfully cross-compiled. The parameters `KERNELSRC_CLEAN`, `KERNELSRC_CONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed.
201 201
202 202 ##### `FIRMWAREDIR`=""
203 203 The directory containing a local copy of the firmware from the [RaspberryPi firmware project](https://github.com/raspberrypi/firmware). Default is to download the latest firmware directly from the project.
204 204
205 205 #### Reduce disk usage:
206 206 The following list of parameters is ignored if `ENABLE_REDUCE`=false.
207 207
208 208 ##### `REDUCE_APT`=true
209 209 Configure APT to use compressed package repository lists and no package caching files.
210 210
211 211 ##### `REDUCE_DOC`=true
212 212 Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
213 213
214 214 ##### `REDUCE_MAN`=true
215 215 Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
216 216
217 217 ##### `REDUCE_VIM`=false
218 218 Replace `vim-tiny` package by `levee` a tiny vim clone.
219 219
220 220 ##### `REDUCE_BASH`=false
221 221 Remove `bash` package and switch to `dash` shell (experimental).
222 222
223 223 ##### `REDUCE_HWDB`=true
224 224 Remove PCI related hwdb files (experimental).
225 225
226 226 ##### `REDUCE_SSHD`=true
227 227 Replace `openssh-server` with `dropbear`.
228 228
229 229 ##### `REDUCE_LOCALE`=true
230 230 Remove all `locale` translation files.
231 231
232 232 #### Encrypted root partition:
233 233
234 234 ##### `ENABLE_CRYPTFS`=false
235 235 Enable full system encryption with dm-crypt. Setup a fully LUKS encrypted root partition (aes-xts-plain64:sha512) and generate required initramfs. The /boot directory will not be encrypted. This parameter will be ignored if `BUILD_KERNEL`=false. `ENABLE_CRYPTFS` is experimental. SSH-to-initramfs is currently not supported but will be soon - feel free to help.
236 236
237 237 ##### `CRYPTFS_PASSWORD`=""
238 238 Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true.
239 239
240 240 ##### `CRYPTFS_MAPPING`="secure"
241 241 Set name of dm-crypt managed device-mapper mapping.
242 242
243 243 ##### `CRYPTFS_CIPHER`="aes-xts-plain64:sha512"
244 244 Set cipher specification string. `aes-xts*` ciphers are strongly recommended.
245 245
246 246 ##### `CRYPTFS_XTSKEYSIZE`=512
247 247 Sets key size in bits. The argument has to be a multiple of 8.
248 248
249 249 ## Understanding the script
250 250 The functions of this script that are required for the different stages of the bootstrapping are split up into single files located inside the `bootstrap.d` directory. During the bootstrapping every script in this directory gets executed in lexicographical order:
251 251
252 252 | Script | Description |
253 253 | --- | --- |
254 254 | `10-bootstrap.sh` | Debootstrap basic system |
255 255 | `11-apt.sh` | Setup APT repositories |
256 256 | `12-locale.sh` | Setup Locales and keyboard settings |
257 257 | `13-kernel.sh` | Build and install RPi2 Kernel |
258 258 | `20-networking.sh` | Setup Networking |
259 259 | `21-firewall.sh` | Setup Firewall |
260 260 | `30-security.sh` | Setup Users and Security settings |
261 261 | `31-logging.sh` | Setup Logging |
262 262 | `41-uboot.sh` | Build and Setup U-Boot |
263 263 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
264 264 | `50-firstboot.sh` | First boot actions |
265 265 | `99-reduce.sh` | Reduce the disk space usage |
266 266
267 267 All the required configuration files that will be copied to the generated OS image are located inside the `files` directory. It is not recommended to modify these configuration files manually.
268 268
269 269 | Directory | Description |
270 270 | --- | --- |
271 271 | `apt` | APT management configuration files |
272 272 | `boot` | Boot and RPi2 configuration files |
273 273 | `dpkg` | Package Manager configuration |
274 274 | `firstboot` | Scripts that get executed on first boot |
275 275 | `initramfs` | Initramfs scripts |
276 276 | `iptables` | Firewall configuration files |
277 277 | `locales` | Locales configuration |
278 278 | `modules` | Kernel Modules configuration |
279 279 | `mount` | Fstab configuration |
280 280 | `network` | Networking configuration files |
281 281 | `sysctl.d` | Swapping and Network Hardening configuration |
282 282 | `xorg` | fbturbo Xorg driver configuration |
283 283
284 284 Debian custom packages, i.e. those not in the debian repositories, can be installed by placing them in the `packages` directory. They are installed immediately after packages from the repositories are installed. Any dependencies listed in the custom packages will be downloaded automatically from the repositories. Do not list these custom packages in `APT_INCLUDES`.
285 285
286 286 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
287 287
288 288 ## Logging of the bootstrapping process
289 289 All information related to the bootstrapping process and the commands executed by the `rpi2-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
290 290
291 291 ```shell
292 292 script -c 'APT_SERVER=ftp.de.debian.org ./rpi2-gen-image.sh' ./build.log
293 293 ```
294 294
295 295 ## Flashing the image file
296 296 After the image file was successfully created by the `rpi2-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2 computer. This can be performed by using the tools `bmaptool` or `dd`. Using `bmaptool` will probably speed-up the copy process because `bmaptool` copies more wisely than `dd`.
297 297
298 298 #####Flashing examples:
299 299 ```shell
300 300 bmaptool copy ./images/jessie/2015-12-13-debian-jessie.img /dev/mmcblk0
301 301 dd bs=4M if=./images/jessie/2015-12-13-debian-jessie.img of=/dev/mmcblk0
302 302 ```
303 303 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
304 304 ```shell
305 305 bmaptool copy ./images/jessie/2015-12-13-debian-jessie-frmw.img /dev/mmcblk0
306 306 bmaptool copy ./images/jessie/2015-12-13-debian-jessie-root.img /dev/sdc
307 307 ```
@@ -1,58 +1,58
1 1 #
2 2 # Setup Locales and keyboard settings
3 3 #
4 4
5 5 # Load utility functions
6 6 . ./functions.sh
7 7
8 8 # Install and setup timezone
9 9 echo ${TIMEZONE} > "${ETCDIR}/timezone"
10 10 chroot_exec dpkg-reconfigure -f noninteractive tzdata
11 11
12 12 # Install and setup default locale and keyboard configuration
13 if [ "$ENABLE_MINBASE" = false ] ; then
13 if [ $(echo "$APT_INCLUDES" | grep ",locales") ] ; then
14 14 # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug
15 15 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957
16 16 # ... so we have to set locales manually
17 17 if [ "$DEFLOCAL" = "en_US.UTF-8" ] ; then
18 18 chroot_exec echo "locales locales/locales_to_be_generated multiselect ${DEFLOCAL} UTF-8" | debconf-set-selections
19 19 else
20 20 # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale
21 21 chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections
22 22 sed -i "/en_US.UTF-8/s/^#//" "${ETCDIR}/locale.gen"
23 23 fi
24 24
25 25 sed -i "/${DEFLOCAL}/s/^#//" "${ETCDIR}/locale.gen"
26 26 chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections
27 27 chroot_exec locale-gen
28 28 chroot_exec update-locale LANG="${DEFLOCAL}"
29 29
30 30 # Install and setup default keyboard configuration
31 31 if [ "$XKB_MODEL" != "" ] ; then
32 32 sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" "${ETCDIR}/default/keyboard"
33 33 fi
34 34 if [ "$XKB_LAYOUT" != "" ] ; then
35 35 sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" "${ETCDIR}/default/keyboard"
36 36 fi
37 37 if [ "$XKB_VARIANT" != "" ] ; then
38 38 sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" "${ETCDIR}/default/keyboard"
39 39 fi
40 40 if [ "$XKB_OPTIONS" != "" ] ; then
41 41 sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" "${ETCDIR}/default/keyboard"
42 42 fi
43 43 chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration
44 44
45 45 # Install and setup font console
46 46 case "${DEFLOCAL}" in
47 47 *UTF-8)
48 48 sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' "${ETCDIR}/default/console-setup"
49 49 ;;
50 50 *)
51 51 sed -i 's/^CHARMAP.*/CHARMAP="guess"/' "${ETCDIR}/default/console-setup"
52 52 ;;
53 53 esac
54 54 chroot_exec dpkg-reconfigure -f noninteractive console-setup
55 else # ENABLE_MINBASE=true
55 else # (no locales were installed)
56 56 # Install POSIX default locale
57 57 install_readonly files/locales/locale "${ETCDIR}/default/locale"
58 58 fi
@@ -1,517 +1,517
1 1 #!/bin/sh
2 2
3 3 ########################################################################
4 # rpi2-gen-image.sh ver2a 12/2015
4 # rpi2-gen-image.sh 2015-2016
5 5 #
6 6 # Advanced debian "jessie" bootstrap script for RPi2
7 7 #
8 8 # This program is free software; you can redistribute it and/or
9 9 # modify it under the terms of the GNU General Public License
10 10 # as published by the Free Software Foundation; either version 2
11 11 # of the License, or (at your option) any later version.
12 12 #
13 # some parts based on rpi2-build-image:
14 # Copyright (C) 2015 Ryan Finnie <ryan@finnie.org>
15 # Copyright (C) 2015 Luca Falavigna <dktrkranz@debian.org>
13 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
14 #
15 # Big thanks for patches and enhancements by 10+ github contributors!
16 16 ########################################################################
17 17
18 18 # Are we running as root?
19 19 if [ "$(id -u)" -ne "0" ] ; then
20 20 echo "error: this script must be executed with root privileges!"
21 21 exit 1
22 22 fi
23 23
24 24 # Check if ./functions.sh script exists
25 25 if [ ! -r "./functions.sh" ] ; then
26 26 echo "error: './functions.sh' required script not found!"
27 27 exit 1
28 28 fi
29 29
30 30 # Load utility functions
31 31 . ./functions.sh
32 32
33 33 # Introduce settings
34 34 set -e
35 35 echo -n -e "\n#\n# RPi2 Bootstrap Settings\n#\n"
36 36 set -x
37 37
38 38 # Debian release
39 39 RELEASE=${RELEASE:=jessie}
40 40 KERNEL_ARCH=${KERNEL_ARCH:=arm}
41 41 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
42 42 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
43 43 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
44 44 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
45 45 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
46 46 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
47 47 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
48 48 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
49 49
50 50 # Build directories
51 51 BASEDIR="$(pwd)/images/${RELEASE}"
52 52 BUILDDIR="${BASEDIR}/build"
53 53
54 54 # Chroot directories
55 55 R="${BUILDDIR}/chroot"
56 56 ETCDIR="${R}/etc"
57 57 BOOTDIR="${R}/boot/firmware"
58 58 KERNELDIR="${R}/usr/src/linux"
59 59
60 60 # Firmware directory: Blank if download from github
61 61 FIRMWAREDIR=${FIRMWAREDIR:=""}
62 62
63 63 # General settings
64 64 HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}}
65 65 PASSWORD=${PASSWORD:=raspberry}
66 66 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
67 67 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
68 68 EXPANDROOT=${EXPANDROOT:=true}
69 69
70 70 # Keyboard settings
71 71 XKB_MODEL=${XKB_MODEL:=""}
72 72 XKB_LAYOUT=${XKB_LAYOUT:=""}
73 73 XKB_VARIANT=${XKB_VARIANT:=""}
74 74 XKB_OPTIONS=${XKB_OPTIONS:=""}
75 75
76 76 # Network settings (DHCP)
77 77 ENABLE_DHCP=${ENABLE_DHCP:=true}
78 78
79 79 # Network settings (static)
80 80 NET_ADDRESS=${NET_ADDRESS:=""}
81 81 NET_GATEWAY=${NET_GATEWAY:=""}
82 82 NET_DNS_1=${NET_DNS_1:=""}
83 83 NET_DNS_2=${NET_DNS_2:=""}
84 84 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
85 85 NET_NTP_1=${NET_NTP_1:=""}
86 86 NET_NTP_2=${NET_NTP_2:=""}
87 87
88 88 # APT settings
89 89 APT_PROXY=${APT_PROXY:=""}
90 90 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
91 91
92 92 # Feature settings
93 93 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
94 94 ENABLE_IPV6=${ENABLE_IPV6:=true}
95 95 ENABLE_SSHD=${ENABLE_SSHD:=true}
96 96 ENABLE_SOUND=${ENABLE_SOUND:=true}
97 97 ENABLE_DBUS=${ENABLE_DBUS:=true}
98 98 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
99 99 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
100 100 ENABLE_XORG=${ENABLE_XORG:=false}
101 101 ENABLE_WM=${ENABLE_WM:=""}
102 102 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
103 103 ENABLE_USER=${ENABLE_USER:=true}
104 104 USER_NAME=${USER_NAME:="pi"}
105 105 ENABLE_ROOT=${ENABLE_ROOT:=false}
106 106 ENABLE_ROOT_SSH=${ENABLE_ROOT_SSH:=false}
107 107
108 108 # Advanced settings
109 109 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
110 110 ENABLE_REDUCE=${ENABLE_REDUCE:=flase}
111 111 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
112 112 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
113 113 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
114 114 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
115 115 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
116 116 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
117 117
118 118 # Kernel compilation settings
119 119 BUILD_KERNEL=${BUILD_KERNEL:=false}
120 120 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
121 121 KERNEL_THREADS=${KERNEL_THREADS:=1}
122 122 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
123 123 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
124 124 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
125 125
126 126 # Kernel compilation from source directory settings
127 127 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
128 128 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
129 129 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
130 130 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
131 131
132 132 # Reduce disk usage settings
133 133 REDUCE_APT=${REDUCE_APT:=true}
134 134 REDUCE_DOC=${REDUCE_DOC:=true}
135 135 REDUCE_MAN=${REDUCE_MAN:=true}
136 136 REDUCE_VIM=${REDUCE_VIM:=false}
137 137 REDUCE_BASH=${REDUCE_BASH:=false}
138 138 REDUCE_HWDB=${REDUCE_HWDB:=true}
139 139 REDUCE_SSHD=${REDUCE_SSHD:=true}
140 140 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
141 141
142 142 # Encrypted filesystem settings
143 143 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
144 144 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
145 145 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
146 146 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
147 147 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
148 148
149 149 # Stop the Crypto Wars
150 150 DISABLE_FBI=${DISABLE_FBI:=false}
151 151
152 152 # Chroot scripts directory
153 153 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
154 154
155 155 # Packages required in the chroot build environment
156 156 APT_INCLUDES=${APT_INCLUDES:=""}
157 157 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo"
158 158
159 159 # Packages required for bootstrapping
160 160 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git"
161 161 MISSING_PACKAGES=""
162 162
163 163 set +x
164 164
165 165 # Add packages required for kernel cross compilation
166 166 if [ "$BUILD_KERNEL" = true ] ; then
167 167 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
168 168 fi
169 169
170 170 # Add libncurses5 to enable kernel menuconfig
171 171 if [ "$KERNEL_MENUCONFIG" = true ] ; then
172 172 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses5-dev"
173 173 fi
174 174
175 175 # Stop the Crypto Wars
176 176 if [ "$DISABLE_FBI" = true ] ; then
177 177 ENABLE_CRYPTFS=true
178 178 fi
179 179
180 180 # Add cryptsetup package to enable filesystem encryption
181 181 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
182 182 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
183 183 APT_INCLUDES="${APT_INCLUDES},cryptsetup"
184 184
185 185 if [ -z "$CRYPTFS_PASSWORD" ] ; then
186 186 echo "error: no password defined (CRYPTFS_PASSWORD)!"
187 187 exit 1
188 188 fi
189 189 ENABLE_INITRAMFS=true
190 190 fi
191 191
192 192 # Add initramfs generation tools
193 193 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
194 194 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
195 195 fi
196 196
197 197 # Check if all required packages are installed on the build system
198 198 for package in $REQUIRED_PACKAGES ; do
199 199 if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
200 200 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
201 201 fi
202 202 done
203 203
204 204 # Ask if missing packages should get installed right now
205 205 if [ -n "$MISSING_PACKAGES" ] ; then
206 206 echo "the following packages needed by this script are not installed:"
207 207 echo "$MISSING_PACKAGES"
208 208
209 209 echo -n "\ndo you want to install the missing packages right now? [y/n] "
210 210 read confirm
211 211 [ "$confirm" != "y" ] && exit 1
212 212 fi
213 213
214 214 # Make sure all required packages are installed
215 215 apt-get -qq -y install ${REQUIRED_PACKAGES}
216 216
217 217 # Check if ./bootstrap.d directory exists
218 218 if [ ! -d "./bootstrap.d/" ] ; then
219 219 echo "error: './bootstrap.d' required directory not found!"
220 220 exit 1
221 221 fi
222 222
223 223 # Check if ./files directory exists
224 224 if [ ! -d "./files/" ] ; then
225 225 echo "error: './files' required directory not found!"
226 226 exit 1
227 227 fi
228 228
229 229 # Check if specified KERNELSRC_DIR directory exists
230 230 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
231 231 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
232 232 exit 1
233 233 fi
234 234
235 235 # Check if specified CHROOT_SCRIPTS directory exists
236 236 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
237 237 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
238 238 exit 1
239 239 fi
240 240
241 241 # Check if specified device mapping already exists (will be used by cryptsetup)
242 242 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
243 243 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
244 244 exit 1
245 245 fi
246 246
247 247 # Don't clobber an old build
248 248 if [ -e "$BUILDDIR" ] ; then
249 249 echo "error: directory ${BUILDDIR} already exists, not proceeding"
250 250 exit 1
251 251 fi
252 252
253 253 # Setup chroot directory
254 254 mkdir -p "${R}"
255 255
256 256 # Check if build directory has enough of free disk space >512MB
257 257 if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then
258 258 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
259 259 exit 1
260 260 fi
261 261
262 262 set -x
263 263
264 264 # Call "cleanup" function on various signals and errors
265 265 trap cleanup 0 1 2 3 6
266 266
267 267 # Add required packages for the minbase installation
268 if [ "$ENABLE_MINBASE" = true ] ; then
268 if [ "$ENABLE_MINBASE" = true ] && [ "$DEFLOCAL" == "en_US.UTF-8" ] ; then
269 269 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
270 270 else
271 271 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
272 272 fi
273 273
274 274 # Add parted package, required to get partprobe utility
275 275 if [ "$EXPANDROOT" = true ] ; then
276 276 APT_INCLUDES="${APT_INCLUDES},parted"
277 277 fi
278 278
279 279 # Add dbus package, recommended if using systemd
280 280 if [ "$ENABLE_DBUS" = true ] ; then
281 281 APT_INCLUDES="${APT_INCLUDES},dbus"
282 282 fi
283 283
284 284 # Add iptables IPv4/IPv6 package
285 285 if [ "$ENABLE_IPTABLES" = true ] ; then
286 286 APT_INCLUDES="${APT_INCLUDES},iptables"
287 287 fi
288 288
289 289 # Add openssh server package
290 290 if [ "$ENABLE_SSHD" = true ] ; then
291 291 APT_INCLUDES="${APT_INCLUDES},openssh-server"
292 292 fi
293 293
294 294 # Add alsa-utils package
295 295 if [ "$ENABLE_SOUND" = true ] ; then
296 296 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
297 297 fi
298 298
299 299 # Add rng-tools package
300 300 if [ "$ENABLE_HWRANDOM" = true ] ; then
301 301 APT_INCLUDES="${APT_INCLUDES},rng-tools"
302 302 fi
303 303
304 304 # Add fbturbo video driver
305 305 if [ "$ENABLE_FBTURBO" = true ] ; then
306 306 # Enable xorg package dependencies
307 307 ENABLE_XORG=true
308 308 fi
309 309
310 310 # Add user defined window manager package
311 311 if [ -n "$ENABLE_WM" ] ; then
312 312 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
313 313
314 314 # Enable xorg package dependencies
315 315 ENABLE_XORG=true
316 316 fi
317 317
318 318 # Add xorg package
319 319 if [ "$ENABLE_XORG" = true ] ; then
320 320 APT_INCLUDES="${APT_INCLUDES},xorg"
321 321 fi
322 322
323 323 # Replace selected packages with smaller clones
324 324 if [ "$ENABLE_REDUCE" = true ] ; then
325 325 # Add levee package instead of vim-tiny
326 326 if [ "$REDUCE_VIM" = true ] ; then
327 327 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
328 328 fi
329 329
330 330 # Add dropbear package instead of openssh-server
331 331 if [ "$REDUCE_SSHD" = true ] ; then
332 332 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/openssh-server/dropbear/")"
333 333 fi
334 334 fi
335 335
336 336 # Configure kernel sources if no KERNELSRC_DIR
337 337 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
338 338 KERNELSRC_CONFIG=true
339 339 fi
340 340
341 341 # Configure reduced kernel
342 342 if [ "$KERNEL_REDUCE" = true ] ; then
343 343 KERNELSRC_CONFIG=false
344 344 fi
345 345
346 346 # Execute bootstrap scripts
347 347 for SCRIPT in bootstrap.d/*.sh; do
348 348 head -n 3 "$SCRIPT"
349 349 . "$SCRIPT"
350 350 done
351 351
352 352 ## Execute custom bootstrap scripts
353 353 if [ -d "custom.d" ] ; then
354 354 for SCRIPT in custom.d/*.sh; do
355 355 . "$SCRIPT"
356 356 done
357 357 fi
358 358
359 359 # Execute custom scripts inside the chroot
360 360 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
361 361 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
362 362 chroot_exec /bin/bash -x <<'EOF'
363 363 for SCRIPT in /chroot_scripts/* ; do
364 364 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
365 365 $SCRIPT
366 366 fi
367 367 done
368 368 EOF
369 369 rm -rf "${R}/chroot_scripts"
370 370 fi
371 371
372 372 # Remove apt-utils
373 373 chroot_exec apt-get purge -qq -y --force-yes apt-utils
374 374
375 375 # Generate required machine-id
376 376 MACHINE_ID=$(dbus-uuidgen)
377 377 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
378 378 echo -n "${MACHINE_ID}" > "${ETCDIR}/machine-id"
379 379
380 380 # APT Cleanup
381 381 chroot_exec apt-get -y clean
382 382 chroot_exec apt-get -y autoclean
383 383 chroot_exec apt-get -y autoremove
384 384
385 385 # Unmount mounted filesystems
386 386 umount -l "${R}/proc"
387 387 umount -l "${R}/sys"
388 388
389 389 # Clean up directories
390 390 rm -rf "${R}/run/*"
391 391 rm -rf "${R}/tmp/*"
392 392
393 393 # Clean up files
394 394 rm -f "${ETCDIR}/ssh/ssh_host_*"
395 395 rm -f "${ETCDIR}/dropbear/dropbear_*"
396 396 rm -f "${ETCDIR}/apt/sources.list.save"
397 397 rm -f "${ETCDIR}/resolvconf/resolv.conf.d/original"
398 398 rm -f "${ETCDIR}/*-"
399 399 rm -f "${ETCDIR}/apt/apt.conf.d/10proxy"
400 400 rm -f "${ETCDIR}/resolv.conf"
401 401 rm -f "${R}/root/.bash_history"
402 402 rm -f "${R}/var/lib/urandom/random-seed"
403 403 rm -f "${R}/initrd.img"
404 404 rm -f "${R}/vmlinuz"
405 405 rm -f "${R}${QEMU_BINARY}"
406 406
407 407 # Calculate size of the chroot directory in KB
408 408 CHROOT_SIZE=$(expr `du -s "${R}" | awk '{ print $1 }'`)
409 409
410 410 # Calculate the amount of needed 512 Byte sectors
411 411 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
412 412 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
413 413 ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS})
414 414
415 415 # The root partition is EXT4
416 416 # This means more space than the actual used space of the chroot is used.
417 417 # As overhead for journaling and reserved blocks 20% are added.
418 418 ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 20) \* 1024 \/ 512)
419 419
420 420 # Calculate required image size in 512 Byte sectors
421 421 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS})
422 422
423 423 # Prepare date string for image file name
424 424 DATE="$(date +%Y-%m-%d)"
425 425
426 426 # Prepare image file
427 427 if [ "$ENABLE_SPLITFS" = true ] ; then
428 428 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=${TABLE_SECTORS}
429 429 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS}
430 430 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=${TABLE_SECTORS}
431 431 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=0 seek=${ROOT_SECTORS}
432 432
433 433 # Write firmware/boot partition tables
434 434 sfdisk -q -L -uS -f "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" 2> /dev/null <<EOM
435 435 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
436 436 EOM
437 437
438 438 # Write root partition table
439 439 sfdisk -q -L -uS -f "$BASEDIR/${DATE}-debian-${RELEASE}-root.img" 2> /dev/null <<EOM
440 440 ${TABLE_SECTORS},${ROOT_SECTORS},83
441 441 EOM
442 442
443 443 # Setup temporary loop devices
444 444 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-frmw.img)"
445 445 ROOT_LOOP="$(losetup -o 1M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-root.img)"
446 446 else # ENABLE_SPLITFS=false
447 447 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=${TABLE_SECTORS}
448 448 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=0 seek=${IMAGE_SECTORS}
449 449
450 450 # Write partition table
451 451 sfdisk -q -L -uS -f "$BASEDIR/${DATE}-debian-${RELEASE}.img" 2> /dev/null <<EOM
452 452 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
453 453 ${ROOT_OFFSET},${ROOT_SECTORS},83
454 454 EOM
455 455
456 456 # Setup temporary loop devices
457 457 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
458 458 ROOT_LOOP="$(losetup -o 65M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
459 459 fi
460 460
461 461 if [ "$ENABLE_CRYPTFS" = true ] ; then
462 462 # Create dummy ext4 fs
463 463 mkfs.ext4 "$ROOT_LOOP"
464 464
465 465 # Setup password keyfile
466 466 echo -n ${CRYPTFS_PASSWORD} > .password
467 467 chmod 600 .password
468 468
469 469 # Initialize encrypted partition
470 470 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
471 471
472 472 # Open encrypted partition and setup mapping
473 473 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
474 474
475 475 # Secure delete password keyfile
476 476 shred -zu .password
477 477
478 478 # Update temporary loop device
479 479 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
480 480
481 481 # Wipe encrypted partition (encryption cipher is used for randomness)
482 482 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count=$(blockdev --getsz "${ROOT_LOOP}")
483 483 fi
484 484
485 485 # Build filesystems
486 486 mkfs.vfat "$FRMW_LOOP"
487 487 mkfs.ext4 "$ROOT_LOOP"
488 488
489 489 # Mount the temporary loop devices
490 490 mkdir -p "$BUILDDIR/mount"
491 491 mount "$ROOT_LOOP" "$BUILDDIR/mount"
492 492
493 493 mkdir -p "$BUILDDIR/mount/boot/firmware"
494 494 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
495 495
496 496 # Copy all files from the chroot to the loop device mount point directory
497 497 rsync -a "${R}/" "$BUILDDIR/mount/"
498 498
499 499 # Unmount all temporary loop devices and mount points
500 500 cleanup
501 501
502 502 # Create block map file(s) of image(s)
503 503 if [ "$ENABLE_SPLITFS" = true ] ; then
504 504 # Create block map files for "bmaptool"
505 505 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img"
506 506 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-root.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-root.img"
507 507
508 508 # Image was successfully created
509 509 echo "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
510 510 echo "$BASEDIR/${DATE}-debian-${RELEASE}-root.img ($(expr \( ${TABLE_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
511 511 else
512 512 # Create block map file for "bmaptool"
513 513 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}.img"
514 514
515 515 # Image was successfully created
516 516 echo "$BASEDIR/${DATE}-debian-${RELEASE}.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
517 517 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant