##// END OF EJS Templates
autoselect local apt-cacher-ng instance...
burnbabyburn -
r343:b08ad2f7992a
parent child
Show More
@@ -1,487 +1,487
1 # rpi23-gen-image
1 # rpi23-gen-image
2 ## Introduction
2 ## Introduction
3 `rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2) and Raspberry Pi 3 (RPi3) computers. The script at this time supports the bootstrapping of the Debian (armhf) releases `stretch` and `buster`. Raspberry Pi 3 images are generated for 32-bit mode only. Raspberry Pi 3 64-bit images can be generated using custom configuration parameters (```templates/rpi3-stretch-arm64-4.11.y```).
3 `rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2) and Raspberry Pi 3 (RPi3) computers. The script at this time supports the bootstrapping of the Debian (armhf) releases `stretch` and `buster`. Raspberry Pi 3 images are generated for 32-bit mode only. Raspberry Pi 3 64-bit images can be generated using custom configuration parameters (```templates/rpi3-stretch-arm64-4.11.y```).
4
4
5 ## Build dependencies
5 ## Build dependencies
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.
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 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo```
8 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo```
9
9
10 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the RPi3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf) cross-compiler toolchain.
10 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the RPi3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf) cross-compiler toolchain.
11
11
12 The script has been tested using the default `crossbuild-essential-armhf` toolchain meta package on Debian Linux and `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
12 The script has been tested using the default `crossbuild-essential-armhf` toolchain meta package on Debian Linux and `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
13
13
14 ## Command-line parameters
14 ## Command-line parameters
15 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi23-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 `rpi23-gen-image.sh` script.
15 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi23-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 `rpi23-gen-image.sh` script.
16
16
17 ##### Command-line examples:
17 ##### Command-line examples:
18 ```shell
18 ```shell
19 ENABLE_UBOOT=true ./rpi23-gen-image.sh
19 ENABLE_UBOOT=true ./rpi23-gen-image.sh
20 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh
20 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh
21 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh
21 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh
22 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh
22 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh
23 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh
23 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh
24 ENABLE_MINBASE=true ./rpi23-gen-image.sh
24 ENABLE_MINBASE=true ./rpi23-gen-image.sh
25 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh
25 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh
26 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh
26 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh
27 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
27 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
28 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
28 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
29 RELEASE=stretch BUILD_KERNEL=true ./rpi23-gen-image.sh
29 RELEASE=stretch BUILD_KERNEL=true ./rpi23-gen-image.sh
30 RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
30 RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
31 RELEASE=stretch RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
31 RELEASE=stretch RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
32 ```
32 ```
33
33
34 ## Configuration template files
34 ## Configuration template files
35 To avoid long lists of command-line parameters and to help to store the favourite parameter configurations the `rpi23-gen-image.sh` script supports so called configuration template files (`CONFIG_TEMPLATE`=template). These are simple text files located in the `./templates` directory that contain the list of configuration parameters that will be used. New configuration template files can be added to the `./templates` directory.
35 To avoid long lists of command-line parameters and to help to store the favourite parameter configurations the `rpi23-gen-image.sh` script supports so called configuration template files (`CONFIG_TEMPLATE`=template). These are simple text files located in the `./templates` directory that contain the list of configuration parameters that will be used. New configuration template files can be added to the `./templates` directory.
36
36
37 ##### Command-line examples:
37 ##### Command-line examples:
38 ```shell
38 ```shell
39 CONFIG_TEMPLATE=rpi3stretch ./rpi23-gen-image.sh
39 CONFIG_TEMPLATE=rpi3stretch ./rpi23-gen-image.sh
40 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
40 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
41 ```
41 ```
42
42
43 ## Supported parameters and settings
43 ## Supported parameters and settings
44 #### APT settings:
44 #### APT settings:
45 ##### `APT_SERVER`="ftp.debian.org/debian"
45 ##### `APT_SERVER`="ftp.debian.org/debian"
46 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.
46 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.
47
47
48 ##### `APT_PROXY`=""
48 ##### `APT_PROXY`=""
49 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.
49 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. If `apt-cacher-ng` is running on default `http://127.0.0.1:3142` it is autodetected and you don't need to set this.
50
50
51 ##### `APT_INCLUDES`=""
51 ##### `APT_INCLUDES`=""
52 A comma separated list of additional packages to be installed by debootstrap during bootstrapping.
52 A comma separated list of additional packages to be installed by debootstrap during bootstrapping.
53
53
54 ##### `APT_INCLUDES_LATE`=""
54 ##### `APT_INCLUDES_LATE`=""
55 A comma separated list of additional packages to be installed by apt after bootstrapping and after APT sources are set up. This is useful for packages with pre-depends, which debootstrap do not handle well.
55 A comma separated list of additional packages to be installed by apt after bootstrapping and after APT sources are set up. This is useful for packages with pre-depends, which debootstrap do not handle well.
56
56
57 ---
57 ---
58
58
59 #### General system settings:
59 #### General system settings:
60 ##### `RPI_MODEL`=2
60 ##### `RPI_MODEL`=2
61 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
61 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
62 `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W
62 `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W
63 `1` = Used for Pi 1 model A and B
63 `1` = Used for Pi 1 model A and B
64 `1P` = Used for Pi 1 model B+ and A+
64 `1P` = Used for Pi 1 model B+ and A+
65 `2` = Used for Pi 2 model B
65 `2` = Used for Pi 2 model B
66 `3` = Used for Pi 3 model B
66 `3` = Used for Pi 3 model B
67 `3P` = Used for Pi 3 model B+
67 `3P` = Used for Pi 3 model B+
68 `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used.
68 `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used.
69
69
70 ##### `RELEASE`="buster"
70 ##### `RELEASE`="buster"
71 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "stretch" and "buster". `BUILD_KERNEL`=true will automatically be set if the Debian releases `stretch` or `buster` are used.
71 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "stretch" and "buster". `BUILD_KERNEL`=true will automatically be set if the Debian releases `stretch` or `buster` are used.
72
72
73 ##### `RELEASE_ARCH`="armhf"
73 ##### `RELEASE_ARCH`="armhf"
74 Set the desired Debian release architecture.
74 Set the desired Debian release architecture.
75
75
76 ##### `HOSTNAME`="rpi$RPI_MODEL-$RELEASE"
76 ##### `HOSTNAME`="rpi$RPI_MODEL-$RELEASE"
77 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
77 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
78
78
79 ##### `PASSWORD`="raspberry"
79 ##### `PASSWORD`="raspberry"
80 Set system `root` password. It's **STRONGLY** recommended that you choose a custom password.
80 Set system `root` password. It's **STRONGLY** recommended that you choose a custom password.
81
81
82 ##### `USER_PASSWORD`="raspberry"
82 ##### `USER_PASSWORD`="raspberry"
83 Set password for the created non-root user `USER_NAME`=pi. Ignored if `ENABLE_USER`=false. It's **STRONGLY** recommended that you choose a custom password.
83 Set password for the created non-root user `USER_NAME`=pi. Ignored if `ENABLE_USER`=false. It's **STRONGLY** recommended that you choose a custom password.
84
84
85 ##### `DEFLOCAL`="en_US.UTF-8"
85 ##### `DEFLOCAL`="en_US.UTF-8"
86 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`.
86 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`.
87
87
88 ##### `TIMEZONE`="Europe/Berlin"
88 ##### `TIMEZONE`="Europe/Berlin"
89 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.
89 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.
90
90
91 ##### `EXPANDROOT`=true
91 ##### `EXPANDROOT`=true
92 Expand the root partition and filesystem automatically on first boot.
92 Expand the root partition and filesystem automatically on first boot.
93
93
94 ##### `ENABLE_QEMU`=false
94 ##### `ENABLE_QEMU`=false
95 Generate kernel (`vexpress_defconfig`), file system image (`qcow2`) and DTB files that can be used for QEMU full system emulation (`vexpress-A15`). The output files are stored in the `$(pwd)/images/qemu` directory. You can find more information about running the generated image in the QEMU section of this readme file.
95 Generate kernel (`vexpress_defconfig`), file system image (`qcow2`) and DTB files that can be used for QEMU full system emulation (`vexpress-A15`). The output files are stored in the `$(pwd)/images/qemu` directory. You can find more information about running the generated image in the QEMU section of this readme file.
96
96
97 ---
97 ---
98
98
99 #### Keyboard settings:
99 #### Keyboard settings:
100 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.
100 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.
101
101
102 ##### `XKB_MODEL`=""
102 ##### `XKB_MODEL`=""
103 Set the name of the model of your keyboard type.
103 Set the name of the model of your keyboard type.
104
104
105 ##### `XKB_LAYOUT`=""
105 ##### `XKB_LAYOUT`=""
106 Set the supported keyboard layout(s).
106 Set the supported keyboard layout(s).
107
107
108 ##### `XKB_VARIANT`=""
108 ##### `XKB_VARIANT`=""
109 Set the supported variant(s) of the keyboard layout(s).
109 Set the supported variant(s) of the keyboard layout(s).
110
110
111 ##### `XKB_OPTIONS`=""
111 ##### `XKB_OPTIONS`=""
112 Set extra xkb configuration options.
112 Set extra xkb configuration options.
113
113
114 ---
114 ---
115
115
116 #### Networking settings (DHCP):
116 #### Networking settings (DHCP):
117 This parameter is used to set up networking auto configuration in `/etc/systemd/network/eth.network`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.`
117 This parameter is used to set up networking auto configuration in `/etc/systemd/network/eth.network`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.`
118
118
119 ##### `ENABLE_DHCP`=true
119 ##### `ENABLE_DHCP`=true
120 Set the system to use DHCP. This requires an DHCP server.
120 Set the system to use DHCP. This requires an DHCP server.
121
121
122 ---
122 ---
123
123
124 #### Networking settings (static):
124 #### Networking settings (static):
125 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`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.
125 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`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.
126
126
127 ##### `NET_ADDRESS`=""
127 ##### `NET_ADDRESS`=""
128 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
128 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
129
129
130 ##### `NET_GATEWAY`=""
130 ##### `NET_GATEWAY`=""
131 Set the IP address for the default gateway.
131 Set the IP address for the default gateway.
132
132
133 ##### `NET_DNS_1`=""
133 ##### `NET_DNS_1`=""
134 Set the IP address for the first DNS server.
134 Set the IP address for the first DNS server.
135
135
136 ##### `NET_DNS_2`=""
136 ##### `NET_DNS_2`=""
137 Set the IP address for the second DNS server.
137 Set the IP address for the second DNS server.
138
138
139 ##### `NET_DNS_DOMAINS`=""
139 ##### `NET_DNS_DOMAINS`=""
140 Set the default DNS search domains to use for non fully qualified host names.
140 Set the default DNS search domains to use for non fully qualified host names.
141
141
142 ##### `NET_NTP_1`=""
142 ##### `NET_NTP_1`=""
143 Set the IP address for the first NTP server.
143 Set the IP address for the first NTP server.
144
144
145 ##### `NET_NTP_2`=""
145 ##### `NET_NTP_2`=""
146 Set the IP address for the second NTP server.
146 Set the IP address for the second NTP server.
147
147
148 ---
148 ---
149
149
150 #### Basic system features:
150 #### Basic system features:
151 ##### `ENABLE_CONSOLE`=true
151 ##### `ENABLE_CONSOLE`=true
152 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
152 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
153
153
154 ##### `ENABLE_I2C`=false
154 ##### `ENABLE_I2C`=false
155 Enable I2C interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
155 Enable I2C interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
156
156
157 ##### `ENABLE_SPI`=false
157 ##### `ENABLE_SPI`=false
158 Enable SPI interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
158 Enable SPI interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
159
159
160 ##### `ENABLE_IPV6`=true
160 ##### `ENABLE_IPV6`=true
161 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
161 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
162
162
163 ##### `ENABLE_SSHD`=true
163 ##### `ENABLE_SSHD`=true
164 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.
164 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.
165
165
166 ##### `ENABLE_NONFREE`=false
166 ##### `ENABLE_NONFREE`=false
167 Allow the installation of non-free Debian packages that do not comply with the DFSG. This is required to install closed-source firmware binary blobs.
167 Allow the installation of non-free Debian packages that do not comply with the DFSG. This is required to install closed-source firmware binary blobs.
168
168
169 ##### `ENABLE_WIRELESS`=false
169 ##### `ENABLE_WIRELESS`=false
170 Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `3`.
170 Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `3`.
171
171
172 ##### `ENABLE_RSYSLOG`=true
172 ##### `ENABLE_RSYSLOG`=true
173 If set to false, disable and uninstall rsyslog (so logs will be available only
173 If set to false, disable and uninstall rsyslog (so logs will be available only
174 in journal files)
174 in journal files)
175
175
176 ##### `ENABLE_SOUND`=true
176 ##### `ENABLE_SOUND`=true
177 Enable sound hardware and install Advanced Linux Sound Architecture.
177 Enable sound hardware and install Advanced Linux Sound Architecture.
178
178
179 ##### `ENABLE_HWRANDOM`=true
179 ##### `ENABLE_HWRANDOM`=true
180 Enable Hardware Random Number Generator. Strong random numbers are important for most network based communications that use encryption. It's recommended to be enabled.
180 Enable Hardware Random Number Generator. Strong random numbers are important for most network based communications that use encryption. It's recommended to be enabled.
181
181
182 ##### `ENABLE_MINGPU`=false
182 ##### `ENABLE_MINGPU`=false
183 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
183 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
184
184
185 ##### `ENABLE_DBUS`=true
185 ##### `ENABLE_DBUS`=true
186 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
186 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
187
187
188 ##### `ENABLE_XORG`=false
188 ##### `ENABLE_XORG`=false
189 Install Xorg open-source X Window System.
189 Install Xorg open-source X Window System.
190
190
191 ##### `ENABLE_WM`=""
191 ##### `ENABLE_WM`=""
192 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 `rpi23-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
192 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 `rpi23-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
193
193
194 ---
194 ---
195
195
196 #### Advanced system features:
196 #### Advanced system features:
197 ##### `ENABLE_MINBASE`=false
197 ##### `ENABLE_MINBASE`=false
198 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
198 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
199
199
200 ##### `ENABLE_REDUCE`=false
200 ##### `ENABLE_REDUCE`=false
201 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
201 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
202
202
203 ##### `ENABLE_UBOOT`=false
203 ##### `ENABLE_UBOOT`=false
204 Replace the default RPi2/3 second stage bootloader (bootcode.bin) with [U-Boot bootloader](https://git.denx.de/?p=u-boot.git;a=summary). U-Boot can boot images via the network using the BOOTP/TFTP protocol.
204 Replace the default RPi2/3 second stage bootloader (bootcode.bin) with [U-Boot bootloader](https://git.denx.de/?p=u-boot.git;a=summary). U-Boot can boot images via the network using the BOOTP/TFTP protocol.
205
205
206 ##### `UBOOTSRC_DIR`=""
206 ##### `UBOOTSRC_DIR`=""
207 Path to a directory (`u-boot`) of [U-Boot bootloader sources](https://git.denx.de/?p=u-boot.git;a=summary) that will be copied, configured, build and installed inside the chroot.
207 Path to a directory (`u-boot`) of [U-Boot bootloader sources](https://git.denx.de/?p=u-boot.git;a=summary) that will be copied, configured, build and installed inside the chroot.
208
208
209 ##### `ENABLE_FBTURBO`=false
209 ##### `ENABLE_FBTURBO`=false
210 Install and enable the [hardware accelerated Xorg video driver](https://github.com/ssvb/xf86-video-fbturbo) `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
210 Install and enable the [hardware accelerated Xorg video driver](https://github.com/ssvb/xf86-video-fbturbo) `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
211
211
212 ##### `FBTURBOSRC_DIR`=""
212 ##### `FBTURBOSRC_DIR`=""
213 Path to a directory (`xf86-video-fbturbo`) of [hardware accelerated Xorg video driver sources](https://github.com/ssvb/xf86-video-fbturbo) that will be copied, configured, build and installed inside the chroot.
213 Path to a directory (`xf86-video-fbturbo`) of [hardware accelerated Xorg video driver sources](https://github.com/ssvb/xf86-video-fbturbo) that will be copied, configured, build and installed inside the chroot.
214
214
215 ##### `ENABLE_VIDEOCORE`=false
215 ##### `ENABLE_VIDEOCORE`=false
216 Install and enable the [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) `vcgencmd`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
216 Install and enable the [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) `vcgencmd`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
217
217
218 ##### `VIDEOCORESRC_DIR`=""
218 ##### `VIDEOCORESRC_DIR`=""
219 Path to a directory (`userland`) of [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot.
219 Path to a directory (`userland`) of [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot.
220
220
221 ##### `ENABLE_IPTABLES`=false
221 ##### `ENABLE_IPTABLES`=false
222 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
222 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
223
223
224 ##### `ENABLE_USER`=true
224 ##### `ENABLE_USER`=true
225 Create non-root user with password `USER_PASSWORD`=raspberry. Unless overridden with `USER_NAME`=user, username will be `pi`.
225 Create non-root user with password `USER_PASSWORD`=raspberry. Unless overridden with `USER_NAME`=user, username will be `pi`.
226
226
227 ##### `USER_NAME`=pi
227 ##### `USER_NAME`=pi
228 Non-root user to create. Ignored if `ENABLE_USER`=false
228 Non-root user to create. Ignored if `ENABLE_USER`=false
229
229
230 ##### `ENABLE_ROOT`=false
230 ##### `ENABLE_ROOT`=false
231 Set root user password so root login will be enabled
231 Set root user password so root login will be enabled
232
232
233 ##### `ENABLE_HARDNET`=false
233 ##### `ENABLE_HARDNET`=false
234 Enable IPv4/IPv6 network stack hardening settings.
234 Enable IPv4/IPv6 network stack hardening settings.
235
235
236 ##### `ENABLE_SPLITFS`=false
236 ##### `ENABLE_SPLITFS`=false
237 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
237 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
238
238
239 ##### `CHROOT_SCRIPTS`=""
239 ##### `CHROOT_SCRIPTS`=""
240 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.
240 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.
241
241
242 ##### `ENABLE_INITRAMFS`=false
242 ##### `ENABLE_INITRAMFS`=false
243 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.
243 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.
244
244
245 ##### `ENABLE_IFNAMES`=true
245 ##### `ENABLE_IFNAMES`=true
246 Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names. This parameter is only supported if the Debian releases `stretch` or `buster` are used.
246 Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names. This parameter is only supported if the Debian releases `stretch` or `buster` are used.
247
247
248 ##### `DISABLE_UNDERVOLT_WARNINGS`=
248 ##### `DISABLE_UNDERVOLT_WARNINGS`=
249 Disable RPi2/3 under-voltage warnings and overlays. Setting the parameter to `1` will disable the warning overlay. Setting it to `2` will additionally allow RPi2/3 turbo mode when low-voltage is present.
249 Disable RPi2/3 under-voltage warnings and overlays. Setting the parameter to `1` will disable the warning overlay. Setting it to `2` will additionally allow RPi2/3 turbo mode when low-voltage is present.
250
250
251 ---
251 ---
252
252
253 #### SSH settings:
253 #### SSH settings:
254 ##### `SSH_ENABLE_ROOT`=false
254 ##### `SSH_ENABLE_ROOT`=false
255 Enable password root login via SSH. This may be a security risk with default password, use only in trusted environments. `ENABLE_ROOT` must be set to `true`.
255 Enable password root login via SSH. This may be a security risk with default password, use only in trusted environments. `ENABLE_ROOT` must be set to `true`.
256
256
257 ##### `SSH_DISABLE_PASSWORD_AUTH`=false
257 ##### `SSH_DISABLE_PASSWORD_AUTH`=false
258 Disable password based SSH authentication. Only public key based SSH (v2) authentication will be supported.
258 Disable password based SSH authentication. Only public key based SSH (v2) authentication will be supported.
259
259
260 ##### `SSH_LIMIT_USERS`=false
260 ##### `SSH_LIMIT_USERS`=false
261 Limit the users that are allowed to login via SSH. Only allow user `USER_NAME`=pi and root if `SSH_ENABLE_ROOT`=true to login. This parameter will be ignored if `dropbear` SSH is used (`REDUCE_SSHD`=true).
261 Limit the users that are allowed to login via SSH. Only allow user `USER_NAME`=pi and root if `SSH_ENABLE_ROOT`=true to login. This parameter will be ignored if `dropbear` SSH is used (`REDUCE_SSHD`=true).
262
262
263 ##### `SSH_ROOT_PUB_KEY`=""
263 ##### `SSH_ROOT_PUB_KEY`=""
264 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `root`. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported. `ENABLE_ROOT` **and** `SSH_ENABLE_ROOT` must be set to `true`.
264 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `root`. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported. `ENABLE_ROOT` **and** `SSH_ENABLE_ROOT` must be set to `true`.
265
265
266 ##### `SSH_USER_PUB_KEY`=""
266 ##### `SSH_USER_PUB_KEY`=""
267 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `USER_NAME`=pi. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported.
267 Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `USER_NAME`=pi. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported.
268
268
269 ---
269 ---
270
270
271 #### Kernel compilation:
271 #### Kernel compilation:
272 ##### `BUILD_KERNEL`=false
272 ##### `BUILD_KERNEL`=false
273 Build and install the latest RPi2/3 Linux kernel. Currently only the default RPi2/3 kernel configuration is used. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used.
273 Build and install the latest RPi2/3 Linux kernel. Currently only the default RPi2/3 kernel configuration is used. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used.
274
274
275 ##### `CROSS_COMPILE`="arm-linux-gnueabihf-"
275 ##### `CROSS_COMPILE`="arm-linux-gnueabihf-"
276 This sets the cross compile enviornment for the compiler.
276 This sets the cross compile enviornment for the compiler.
277
277
278 ##### `KERNEL_ARCH`="arm"
278 ##### `KERNEL_ARCH`="arm"
279 This sets the kernel architecture for the compiler.
279 This sets the kernel architecture for the compiler.
280
280
281 ##### `KERNEL_IMAGE`="kernel7.img"
281 ##### `KERNEL_IMAGE`="kernel7.img"
282 Name of the image file in the boot partition. If not set, `KERNEL_IMAGE` will be set to "kernel8.img" automatically if building for arm64.
282 Name of the image file in the boot partition. If not set, `KERNEL_IMAGE` will be set to "kernel8.img" automatically if building for arm64.
283
283
284 ##### `KERNEL_BRANCH`=""
284 ##### `KERNEL_BRANCH`=""
285 Name of the requested branch from the GIT location for the RPi Kernel. Default is using the current default branch from the GIT site.
285 Name of the requested branch from the GIT location for the RPi Kernel. Default is using the current default branch from the GIT site.
286
286
287 ##### `QEMU_BINARY`="/usr/bin/qemu-arm-static"
287 ##### `QEMU_BINARY`="/usr/bin/qemu-arm-static"
288 Sets the QEMU enviornment for the Debian archive. If not set, `QEMU_BINARY` will be set to "/usr/bin/qemu-aarch64-static" automatically if building for arm64.
288 Sets the QEMU enviornment for the Debian archive. If not set, `QEMU_BINARY` will be set to "/usr/bin/qemu-aarch64-static" automatically if building for arm64.
289
289
290 ##### `KERNEL_DEFCONFIG`="bcm2709_defconfig"
290 ##### `KERNEL_DEFCONFIG`="bcm2709_defconfig"
291 Sets the default config for kernel compiling. If not set, `KERNEL_DEFCONFIG` will be set to "bcmrpi3\_defconfig" automatically if building for arm64.
291 Sets the default config for kernel compiling. If not set, `KERNEL_DEFCONFIG` will be set to "bcmrpi3\_defconfig" automatically if building for arm64.
292
292
293 ##### `KERNEL_REDUCE`=false
293 ##### `KERNEL_REDUCE`=false
294 Reduce the size of the generated kernel by removing unwanted device, network and filesystem drivers (experimental).
294 Reduce the size of the generated kernel by removing unwanted device, network and filesystem drivers (experimental).
295
295
296 ##### `KERNEL_THREADS`=1
296 ##### `KERNEL_THREADS`=1
297 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.
297 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.
298
298
299 ##### `KERNEL_HEADERS`=true
299 ##### `KERNEL_HEADERS`=true
300 Install kernel headers with built kernel.
300 Install kernel headers with built kernel.
301
301
302 ##### `KERNEL_MENUCONFIG`=false
302 ##### `KERNEL_MENUCONFIG`=false
303 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
303 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
304
304
305 ##### `KERNEL_OLDDEFCONFIG`=false
305 ##### `KERNEL_OLDDEFCONFIG`=false
306 Run `make olddefconfig` to automatically set all new kernel configuration options to their recommended default values.
306 Run `make olddefconfig` to automatically set all new kernel configuration options to their recommended default values.
307
307
308 ##### `KERNEL_CCACHE`=false
308 ##### `KERNEL_CCACHE`=false
309 Compile the kernel using ccache. This speeds up kernel recompilation by caching previous compilations and detecting when the same compilation is being done again.
309 Compile the kernel using ccache. This speeds up kernel recompilation by caching previous compilations and detecting when the same compilation is being done again.
310
310
311 ##### `KERNEL_REMOVESRC`=true
311 ##### `KERNEL_REMOVESRC`=true
312 Remove all kernel sources from the generated OS image after it was built and installed.
312 Remove all kernel sources from the generated OS image after it was built and installed.
313
313
314 ##### `KERNELSRC_DIR`=""
314 ##### `KERNELSRC_DIR`=""
315 Path to a directory (`linux`) of [RaspberryPi Linux kernel sources](https://github.com/raspberrypi/linux) that will be copied, configured, build and installed inside the chroot.
315 Path to a directory (`linux`) of [RaspberryPi Linux kernel sources](https://github.com/raspberrypi/linux) that will be copied, configured, build and installed inside the chroot.
316
316
317 ##### `KERNELSRC_CLEAN`=false
317 ##### `KERNELSRC_CLEAN`=false
318 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.
318 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.
319
319
320 ##### `KERNELSRC_CONFIG`=true
320 ##### `KERNELSRC_CONFIG`=true
321 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.
321 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.
322
322
323 ##### `KERNELSRC_USRCONFIG`=""
323 ##### `KERNELSRC_USRCONFIG`=""
324 Copy own config file to kernel `.config`. If `KERNEL_MENUCONFIG`=true then running after copy.
324 Copy own config file to kernel `.config`. If `KERNEL_MENUCONFIG`=true then running after copy.
325
325
326 ##### `KERNELSRC_PREBUILT`=false
326 ##### `KERNELSRC_PREBUILT`=false
327 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`, `KERNELSRC_USRCONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed.
327 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`, `KERNELSRC_USRCONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed.
328
328
329 ##### `RPI_FIRMWARE_DIR`=""
329 ##### `RPI_FIRMWARE_DIR`=""
330 The directory (`firmware`) 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.
330 The directory (`firmware`) 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.
331
331
332 ---
332 ---
333
333
334 #### Reduce disk usage:
334 #### Reduce disk usage:
335 The following list of parameters is ignored if `ENABLE_REDUCE`=false.
335 The following list of parameters is ignored if `ENABLE_REDUCE`=false.
336
336
337 ##### `REDUCE_APT`=true
337 ##### `REDUCE_APT`=true
338 Configure APT to use compressed package repository lists and no package caching files.
338 Configure APT to use compressed package repository lists and no package caching files.
339
339
340 ##### `REDUCE_DOC`=true
340 ##### `REDUCE_DOC`=true
341 Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
341 Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
342
342
343 ##### `REDUCE_MAN`=true
343 ##### `REDUCE_MAN`=true
344 Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
344 Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
345
345
346 ##### `REDUCE_VIM`=false
346 ##### `REDUCE_VIM`=false
347 Replace `vim-tiny` package by `levee` a tiny vim clone.
347 Replace `vim-tiny` package by `levee` a tiny vim clone.
348
348
349 ##### `REDUCE_BASH`=false
349 ##### `REDUCE_BASH`=false
350 Remove `bash` package and switch to `dash` shell (experimental).
350 Remove `bash` package and switch to `dash` shell (experimental).
351
351
352 ##### `REDUCE_HWDB`=true
352 ##### `REDUCE_HWDB`=true
353 Remove PCI related hwdb files (experimental).
353 Remove PCI related hwdb files (experimental).
354
354
355 ##### `REDUCE_SSHD`=true
355 ##### `REDUCE_SSHD`=true
356 Replace `openssh-server` with `dropbear`.
356 Replace `openssh-server` with `dropbear`.
357
357
358 ##### `REDUCE_LOCALE`=true
358 ##### `REDUCE_LOCALE`=true
359 Remove all `locale` translation files.
359 Remove all `locale` translation files.
360
360
361 ---
361 ---
362
362
363 #### Encrypted root partition:
363 #### Encrypted root partition:
364 ##### `ENABLE_CRYPTFS`=false
364 ##### `ENABLE_CRYPTFS`=false
365 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.
365 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.
366
366
367 ##### `CRYPTFS_PASSWORD`=""
367 ##### `CRYPTFS_PASSWORD`=""
368 Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true.
368 Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true.
369
369
370 ##### `CRYPTFS_MAPPING`="secure"
370 ##### `CRYPTFS_MAPPING`="secure"
371 Set name of dm-crypt managed device-mapper mapping.
371 Set name of dm-crypt managed device-mapper mapping.
372
372
373 ##### `CRYPTFS_CIPHER`="aes-xts-plain64:sha512"
373 ##### `CRYPTFS_CIPHER`="aes-xts-plain64:sha512"
374 Set cipher specification string. `aes-xts*` ciphers are strongly recommended.
374 Set cipher specification string. `aes-xts*` ciphers are strongly recommended.
375
375
376 ##### `CRYPTFS_XTSKEYSIZE`=512
376 ##### `CRYPTFS_XTSKEYSIZE`=512
377 Sets key size in bits. The argument has to be a multiple of 8.
377 Sets key size in bits. The argument has to be a multiple of 8.
378
378
379 ---
379 ---
380
380
381 #### Build settings:
381 #### Build settings:
382 ##### `BASEDIR`=$(pwd)/images/${RELEASE}
382 ##### `BASEDIR`=$(pwd)/images/${RELEASE}
383 Set a path to a working directory used by the script to generate an image.
383 Set a path to a working directory used by the script to generate an image.
384
384
385 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}
385 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}
386 Set a filename for the output file(s). Note: the script will create $IMAGE_NAME.img if `ENABLE_SPLITFS`=false or $IMAGE_NAME-frmw.img and $IMAGE_NAME-root.img if `ENABLE_SPLITFS`=true. Note 2: If the KERNEL_BRANCH is not set, the word "CURRENT" is used.
386 Set a filename for the output file(s). Note: the script will create $IMAGE_NAME.img if `ENABLE_SPLITFS`=false or $IMAGE_NAME-frmw.img and $IMAGE_NAME-root.img if `ENABLE_SPLITFS`=true. Note 2: If the KERNEL_BRANCH is not set, the word "CURRENT" is used.
387
387
388 ## Understanding the script
388 ## Understanding the script
389 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:
389 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:
390
390
391 | Script | Description |
391 | Script | Description |
392 | --- | --- |
392 | --- | --- |
393 | `10-bootstrap.sh` | Debootstrap basic system |
393 | `10-bootstrap.sh` | Debootstrap basic system |
394 | `11-apt.sh` | Setup APT repositories |
394 | `11-apt.sh` | Setup APT repositories |
395 | `12-locale.sh` | Setup Locales and keyboard settings |
395 | `12-locale.sh` | Setup Locales and keyboard settings |
396 | `13-kernel.sh` | Build and install RPi2/3 Kernel |
396 | `13-kernel.sh` | Build and install RPi2/3 Kernel |
397 | `14-fstab.sh` | Setup fstab and initramfs |
397 | `14-fstab.sh` | Setup fstab and initramfs |
398 | `15-rpi-config.sh` | Setup RPi2/3 config and cmdline |
398 | `15-rpi-config.sh` | Setup RPi2/3 config and cmdline |
399 | `20-networking.sh` | Setup Networking |
399 | `20-networking.sh` | Setup Networking |
400 | `21-firewall.sh` | Setup Firewall |
400 | `21-firewall.sh` | Setup Firewall |
401 | `30-security.sh` | Setup Users and Security settings |
401 | `30-security.sh` | Setup Users and Security settings |
402 | `31-logging.sh` | Setup Logging |
402 | `31-logging.sh` | Setup Logging |
403 | `32-sshd.sh` | Setup SSH and public keys |
403 | `32-sshd.sh` | Setup SSH and public keys |
404 | `41-uboot.sh` | Build and Setup U-Boot |
404 | `41-uboot.sh` | Build and Setup U-Boot |
405 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
405 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
406 | `50-firstboot.sh` | First boot actions |
406 | `50-firstboot.sh` | First boot actions |
407 | `99-reduce.sh` | Reduce the disk space usage |
407 | `99-reduce.sh` | Reduce the disk space usage |
408
408
409 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.
409 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.
410
410
411 | Directory | Description |
411 | Directory | Description |
412 | --- | --- |
412 | --- | --- |
413 | `apt` | APT management configuration files |
413 | `apt` | APT management configuration files |
414 | `boot` | Boot and RPi2/3 configuration files |
414 | `boot` | Boot and RPi2/3 configuration files |
415 | `dpkg` | Package Manager configuration |
415 | `dpkg` | Package Manager configuration |
416 | `etc` | Configuration files and rc scripts |
416 | `etc` | Configuration files and rc scripts |
417 | `firstboot` | Scripts that get executed on first boot |
417 | `firstboot` | Scripts that get executed on first boot |
418 | `initramfs` | Initramfs scripts |
418 | `initramfs` | Initramfs scripts |
419 | `iptables` | Firewall configuration files |
419 | `iptables` | Firewall configuration files |
420 | `locales` | Locales configuration |
420 | `locales` | Locales configuration |
421 | `modules` | Kernel Modules configuration |
421 | `modules` | Kernel Modules configuration |
422 | `mount` | Fstab configuration |
422 | `mount` | Fstab configuration |
423 | `network` | Networking configuration files |
423 | `network` | Networking configuration files |
424 | `sysctl.d` | Swapping and Network Hardening configuration |
424 | `sysctl.d` | Swapping and Network Hardening configuration |
425 | `xorg` | fbturbo Xorg driver configuration |
425 | `xorg` | fbturbo Xorg driver configuration |
426
426
427 ## Custom packages and scripts
427 ## Custom packages and scripts
428 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`.
428 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`.
429
429
430 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
430 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
431
431
432 ## Logging of the bootstrapping process
432 ## Logging of the bootstrapping process
433 All information related to the bootstrapping process and the commands executed by the `rpi23-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
433 All information related to the bootstrapping process and the commands executed by the `rpi23-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
434
434
435 ```shell
435 ```shell
436 script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log
436 script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log
437 ```
437 ```
438
438
439 ## Flashing the image file
439 ## Flashing the image file
440 After the image file was successfully created by the `rpi23-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2/3 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`.
440 After the image file was successfully created by the `rpi23-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2/3 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`.
441
441
442 ##### Flashing examples:
442 ##### Flashing examples:
443 ```shell
443 ```shell
444 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie.img /dev/mmcblk0
444 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie.img /dev/mmcblk0
445 dd bs=4M if=./images/jessie/2017-01-23-rpi3-jessie.img of=/dev/mmcblk0
445 dd bs=4M if=./images/jessie/2017-01-23-rpi3-jessie.img of=/dev/mmcblk0
446 ```
446 ```
447 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
447 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
448 ```shell
448 ```shell
449 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-frmw.img /dev/mmcblk0
449 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-frmw.img /dev/mmcblk0
450 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc
450 bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc
451 ```
451 ```
452
452
453 ## QEMU emulation
453 ## QEMU emulation
454 Start QEMU full system emulation:
454 Start QEMU full system emulation:
455 ```shell
455 ```shell
456 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=tty1"
456 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=tty1"
457 ```
457 ```
458
458
459 Start QEMU full system emulation and output to console:
459 Start QEMU full system emulation and output to console:
460 ```shell
460 ```shell
461 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio
461 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio
462 ```
462 ```
463
463
464 Start QEMU full system emulation with SMP and output to console:
464 Start QEMU full system emulation with SMP and output to console:
465 ```shell
465 ```shell
466 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -smp cpus=2,maxcpus=2 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio
466 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -smp cpus=2,maxcpus=2 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio
467 ```
467 ```
468
468
469 Start QEMU full system emulation with cryptfs, initramfs and output to console:
469 Start QEMU full system emulation with cryptfs, initramfs and output to console:
470 ```shell
470 ```shell
471 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -initrd "initramfs-${KERNEL_VERSION}" -append "root=/dev/mapper/secure cryptdevice=/dev/mmcblk0p2:secure rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio
471 qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -initrd "initramfs-${KERNEL_VERSION}" -append "root=/dev/mapper/secure cryptdevice=/dev/mmcblk0p2:secure rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio
472 ```
472 ```
473
473
474 ## Weekly image builds
474 ## Weekly image builds
475 The image files are provided by JRWR'S I/O PORT and are built once a Sunday at midnight UTC!
475 The image files are provided by JRWR'S I/O PORT and are built once a Sunday at midnight UTC!
476 * [Debian Stretch Raspberry Pi2/3 Weekly Image Builds](https://jrwr.io/doku.php?id=projects:debianpi)
476 * [Debian Stretch Raspberry Pi2/3 Weekly Image Builds](https://jrwr.io/doku.php?id=projects:debianpi)
477
477
478 ## External links and references
478 ## External links and references
479 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
479 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
480 * [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2)
480 * [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2)
481 * [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains)
481 * [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains)
482 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
482 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
483 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
483 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
484 * [U-BOOT git repository](https://git.denx.de/?p=u-boot.git;a=summary)
484 * [U-BOOT git repository](https://git.denx.de/?p=u-boot.git;a=summary)
485 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
485 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
486 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm80211/brcm)
486 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm80211/brcm)
487 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
487 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
@@ -1,41 +1,41
1 #
1 #
2 # Debootstrap basic system
2 # Debootstrap basic system
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 VARIANT=""
8 VARIANT=""
9 COMPONENTS="main"
9 COMPONENTS="main"
10
10
11 # Use non-free Debian packages if needed
11 # Use non-free Debian packages if needed
12 if [ "$ENABLE_NONFREE" = true ] ; then
12 if [ "$ENABLE_NONFREE" = true ] ; then
13 COMPONENTS="main,non-free,contrib"
13 COMPONENTS="main,non-free,contrib"
14 fi
14 fi
15
15
16 # Use minbase bootstrap variant which only includes essential packages
16 # Use minbase bootstrap variant which only includes essential packages
17 if [ "$ENABLE_MINBASE" = true ] ; then
17 if [ "$ENABLE_MINBASE" = true ] ; then
18 VARIANT="--variant=minbase"
18 VARIANT="--variant=minbase"
19 fi
19 fi
20
20
21 # Base debootstrap (unpack only)
21 # Base debootstrap (unpack only)
22 http_proxy=${APT_PROXY} debootstrap "${APT_EXCLUDES}" --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}"
22 http_proxy=${APT_PROXY} debootstrap ${APT_EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}"
23
23
24 # Copy qemu emulator binary to chroot
24 # Copy qemu emulator binary to chroot
25 install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}"
25 install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}"
26
26
27 # Copy debian-archive-keyring.pgp
27 # Copy debian-archive-keyring.pgp
28 mkdir -p "${R}/usr/share/keyrings"
28 mkdir -p "${R}/usr/share/keyrings"
29 install_readonly /usr/share/keyrings/debian-archive-keyring.gpg "${R}/usr/share/keyrings/debian-archive-keyring.gpg"
29 install_readonly /usr/share/keyrings/debian-archive-keyring.gpg "${R}/usr/share/keyrings/debian-archive-keyring.gpg"
30
30
31 # Complete the bootstrapping process
31 # Complete the bootstrapping process
32 chroot_exec /debootstrap/debootstrap --second-stage
32 chroot_exec /debootstrap/debootstrap --second-stage
33
33
34 # Mount required filesystems
34 # Mount required filesystems
35 mount -t proc none "${R}/proc"
35 mount -t proc none "${R}/proc"
36 mount -t sysfs none "${R}/sys"
36 mount -t sysfs none "${R}/sys"
37
37
38 # Mount pseudo terminal slave if supported by Debian release
38 # Mount pseudo terminal slave if supported by Debian release
39 if [ -d "${R}/dev/pts" ] ; then
39 if [ -d "${R}/dev/pts" ] ; then
40 mount --bind /dev/pts "${R}/dev/pts"
40 mount --bind /dev/pts "${R}/dev/pts"
41 fi
41 fi
@@ -1,33 +1,46
1 #
1 #
2 # Setup videocore - Raspberry Userland
2 # Setup videocore - Raspberry Userland
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 if [ "$ENABLE_VIDEOCORE" = true ] ; then
8 if [ "$ENABLE_VIDEOCORE" = true ] ; then
9 # Copy existing videocore sources into chroot directory
9 # Copy existing videocore sources into chroot directory
10 if [ -n "$VIDEOCORESRC_DIR" ] && [ -d "$VIDEOCORESRC_DIR" ] ; then
10 if [ -n "$VIDEOCORESRC_DIR" ] && [ -d "$VIDEOCORESRC_DIR" ] ; then
11 # Copy local U-Boot sources
11 # Copy local U-Boot sources
12 cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp"
12 cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp"
13 else
13 else
14 # Create temporary directory for U-Boot sources
14 # Create temporary directory for U-Boot sources
15 temp_dir=$(as_nobody mktemp -d)
15 temp_dir=$(as_nobody mktemp -d)
16
16
17 # Fetch U-Boot sources
17 # Fetch U-Boot sources
18 as_nobody git -C "${temp_dir}" clone "${VIDEOCORE_URL}"
18 as_nobody git -C "${temp_dir}" clone "${VIDEOCORE_URL}"
19
19
20 # Copy downloaded U-Boot sources
20 # Copy downloaded U-Boot sources
21 mv "${temp_dir}/userland" "${R}/tmp/"
21 mv "${temp_dir}/userland" "${R}/tmp/"
22
22
23 # Set permissions of the U-Boot sources
23 # Set permissions of the U-Boot sources
24 chown -R root:root "${R}/tmp/userland"
24 chown -R root:root "${R}/tmp/userland"
25
25
26 # Remove temporary directory for U-Boot sources
26 # Remove temporary directory for U-Boot sources
27 rm -fr "${temp_dir}"
27 rm -fr "${temp_dir}"
28 fi
28 fi
29
29
30 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DARM64=ON -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_ASM_COMPILER=aarch64-linux-gnu-gcc -DVIDEOCORE_BUILD_DIR="${R}"/opt/vc
30 if [ "$RELEASE_ARCH" = "arm64" ] ; then
31 make -j $(nproc)
31 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DARM64=ON -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_ASM_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DVIDEOCORE_BUILD_DIR="${R}"/opt/vc "${R}/tmp/userland"
32 chroot_exec PATH=${PATH}:/opt/vc/bin
32 fi
33
34 if [ "$RELEASE_ARCH" = "armel" ] ; then
35 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ -DCMAKE_ASM_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DCMAKE_SYSTEM_PROCESSOR="arm" -DVIDEOCORE_BUILD_DIR="${R}"/opt/vc "${R}/tmp/userland"
36 fi
37
38 if [ "$RELEASE_ARCH" = "armhf" ] ; then
39 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DVIDEOCORE_BUILD_DIR="${R}"/opt/vc "${R}/tmp/userland"
40 fi
41
42 #build userland
43 make -j "$(nproc)"
44 #include default_installdir in path
45 chroot_exec PATH="${PATH}":/opt/vc/bin
33 fi
46 fi
@@ -1,806 +1,819
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
59
60 # Build directories
60 # Build directories
61 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
61 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
62 BUILDDIR="${BASEDIR}/build"
62 BUILDDIR="${BASEDIR}/build"
63
63
64 # Prepare date string for default image file name
64 # Prepare date string for default image file name
65 DATE="$(date +%Y-%m-%d)"
65 DATE="$(date +%Y-%m-%d)"
66 if [ -z "$KERNEL_BRANCH" ] ; then
66 if [ -z "$KERNEL_BRANCH" ] ; then
67 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
67 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
68 else
68 else
69 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
69 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
70 fi
70 fi
71
71
72 # Chroot directories
72 # Chroot directories
73 R="${BUILDDIR}/chroot"
73 R="${BUILDDIR}/chroot"
74 ETC_DIR="${R}/etc"
74 ETC_DIR="${R}/etc"
75 LIB_DIR="${R}/lib"
75 LIB_DIR="${R}/lib"
76 BOOT_DIR="${R}/boot/firmware"
76 BOOT_DIR="${R}/boot/firmware"
77 KERNEL_DIR="${R}/usr/src/linux"
77 KERNEL_DIR="${R}/usr/src/linux"
78 WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm"
78 WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm"
79
79
80 # Firmware directory: Blank if download from github
80 # Firmware directory: Blank if download from github
81 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
81 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
82 # General settings
82 # General settings
83 SET_ARCH=${SET_ARCH:=32}
83 SET_ARCH=${SET_ARCH:=32}
84 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
84 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
85 PASSWORD=${PASSWORD:=raspberry}
85 PASSWORD=${PASSWORD:=raspberry}
86 USER_PASSWORD=${USER_PASSWORD:=raspberry}
86 USER_PASSWORD=${USER_PASSWORD:=raspberry}
87 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
87 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
88 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
88 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
89 EXPANDROOT=${EXPANDROOT:=true}
89 EXPANDROOT=${EXPANDROOT:=true}
90
90
91 # Keyboard settings
91 # Keyboard settings
92 XKB_MODEL=${XKB_MODEL:=""}
92 XKB_MODEL=${XKB_MODEL:=""}
93 XKB_LAYOUT=${XKB_LAYOUT:=""}
93 XKB_LAYOUT=${XKB_LAYOUT:=""}
94 XKB_VARIANT=${XKB_VARIANT:=""}
94 XKB_VARIANT=${XKB_VARIANT:=""}
95 XKB_OPTIONS=${XKB_OPTIONS:=""}
95 XKB_OPTIONS=${XKB_OPTIONS:=""}
96
96
97 # Network settings (DHCP)
97 # Network settings (DHCP)
98 ENABLE_DHCP=${ENABLE_DHCP:=true}
98 ENABLE_DHCP=${ENABLE_DHCP:=true}
99
99
100 # Network settings (static)
100 # Network settings (static)
101 NET_ADDRESS=${NET_ADDRESS:=""}
101 NET_ADDRESS=${NET_ADDRESS:=""}
102 NET_GATEWAY=${NET_GATEWAY:=""}
102 NET_GATEWAY=${NET_GATEWAY:=""}
103 NET_DNS_1=${NET_DNS_1:=""}
103 NET_DNS_1=${NET_DNS_1:=""}
104 NET_DNS_2=${NET_DNS_2:=""}
104 NET_DNS_2=${NET_DNS_2:=""}
105 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
105 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
106 NET_NTP_1=${NET_NTP_1:=""}
106 NET_NTP_1=${NET_NTP_1:=""}
107 NET_NTP_2=${NET_NTP_2:=""}
107 NET_NTP_2=${NET_NTP_2:=""}
108
108
109 # APT settings
109 # APT settings
110 APT_PROXY=${APT_PROXY:=""}
110 APT_PROXY=${APT_PROXY:=""}
111 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
111 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
112
112
113 # Feature settings
113 # Feature settings
114 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
114 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
115 ENABLE_I2C=${ENABLE_I2C:=false}
115 ENABLE_I2C=${ENABLE_I2C:=false}
116 ENABLE_SPI=${ENABLE_SPI:=false}
116 ENABLE_SPI=${ENABLE_SPI:=false}
117 ENABLE_IPV6=${ENABLE_IPV6:=true}
117 ENABLE_IPV6=${ENABLE_IPV6:=true}
118 ENABLE_SSHD=${ENABLE_SSHD:=true}
118 ENABLE_SSHD=${ENABLE_SSHD:=true}
119 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
119 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
120 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
120 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
121 ENABLE_SOUND=${ENABLE_SOUND:=true}
121 ENABLE_SOUND=${ENABLE_SOUND:=true}
122 ENABLE_DBUS=${ENABLE_DBUS:=true}
122 ENABLE_DBUS=${ENABLE_DBUS:=true}
123 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
123 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
124 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
124 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
125 ENABLE_XORG=${ENABLE_XORG:=false}
125 ENABLE_XORG=${ENABLE_XORG:=false}
126 ENABLE_WM=${ENABLE_WM:=""}
126 ENABLE_WM=${ENABLE_WM:=""}
127 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
127 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
128 ENABLE_USER=${ENABLE_USER:=true}
128 ENABLE_USER=${ENABLE_USER:=true}
129 USER_NAME=${USER_NAME:="pi"}
129 USER_NAME=${USER_NAME:="pi"}
130 ENABLE_ROOT=${ENABLE_ROOT:=false}
130 ENABLE_ROOT=${ENABLE_ROOT:=false}
131 ENABLE_QEMU=${ENABLE_QEMU:=false}
131 ENABLE_QEMU=${ENABLE_QEMU:=false}
132 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
132 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
133
133
134 # SSH settings
134 # SSH settings
135 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
135 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
136 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
136 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
137 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
137 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
138 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
138 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
139 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
139 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
140
140
141 # Advanced settings
141 # Advanced settings
142 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
142 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
143 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
143 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
144 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
144 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
145 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
145 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
146 ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false}
146 ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false}
147 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
147 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
148 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=true}
148 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=true}
149 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
149 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
150 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
150 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
151 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
151 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
152 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
152 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
153 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
153 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
154 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
154 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
155 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
155 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
156 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
156 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
157
157
158 # Kernel compilation settings
158 # Kernel compilation settings
159 BUILD_KERNEL=${BUILD_KERNEL:=true}
159 BUILD_KERNEL=${BUILD_KERNEL:=true}
160 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
160 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
161 KERNEL_THREADS=${KERNEL_THREADS:=1}
161 KERNEL_THREADS=${KERNEL_THREADS:=1}
162 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
162 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
163 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
163 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
164 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
164 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
165 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
165 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
166 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
166 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
167
167
168 # Kernel compilation from source directory settings
168 # Kernel compilation from source directory settings
169 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
169 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
170 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
170 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
171 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
171 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
172 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
172 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
173
173
174 # Reduce disk usage settings
174 # Reduce disk usage settings
175 REDUCE_APT=${REDUCE_APT:=true}
175 REDUCE_APT=${REDUCE_APT:=true}
176 REDUCE_DOC=${REDUCE_DOC:=true}
176 REDUCE_DOC=${REDUCE_DOC:=true}
177 REDUCE_MAN=${REDUCE_MAN:=true}
177 REDUCE_MAN=${REDUCE_MAN:=true}
178 REDUCE_VIM=${REDUCE_VIM:=false}
178 REDUCE_VIM=${REDUCE_VIM:=false}
179 REDUCE_BASH=${REDUCE_BASH:=false}
179 REDUCE_BASH=${REDUCE_BASH:=false}
180 REDUCE_HWDB=${REDUCE_HWDB:=true}
180 REDUCE_HWDB=${REDUCE_HWDB:=true}
181 REDUCE_SSHD=${REDUCE_SSHD:=true}
181 REDUCE_SSHD=${REDUCE_SSHD:=true}
182 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
182 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
183
183
184 # Encrypted filesystem settings
184 # Encrypted filesystem settings
185 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
185 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
186 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
186 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
187 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
187 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
188 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
188 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
189 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
189 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
190
190
191 # Chroot scripts directory
191 # Chroot scripts directory
192 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
192 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
193
193
194 # Packages required in the chroot build environment
194 # Packages required in the chroot build environment
195 APT_INCLUDES=${APT_INCLUDES:=""}
195 APT_INCLUDES=${APT_INCLUDES:=""}
196 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup"
196 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup"
197
197
198 #Packages to exclude from chroot build environment
199 APT_EXCLUDES=${APT_EXCLUDES:=""}
200
198 # Packages required for bootstrapping
201 # Packages required for bootstrapping
199 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt"
202 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt"
200 MISSING_PACKAGES=""
203 MISSING_PACKAGES=""
201
204
202 # Packages installed for c/c++ build environment in chroot (keep empty)
205 # Packages installed for c/c++ build environment in chroot (keep empty)
203 COMPILER_PACKAGES=""
206 COMPILER_PACKAGES=""
204
207
208 #If init and systemd-sysv are wanted e.g. halt/reboot/shutdown scripts
209 if [ "$ENABLE_SYSVINIT" = false ] ; then
210 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
211 fi
212
213 #Check if apt-cacher-ng has its default port open on and set APT_PROXY
214 if [ -n "$(lsof -i :3142)" ] ; then
215 HTTP_PROXY=http://127.0.0.1:3142/
216 fi
217
205 #ipinfo=$(curl ipinfo.io | grep country )
218 #ipinfo=$(curl ipinfo.io | grep country )
206 #grep -o '\"[^"]*\"' $ipinfo | tr -d '"'
219 #grep -o '\"[^"]*\"' $ipinfo | tr -d '"'
207 #grep -Po '"country":.*?[^\\]",' $(curl ipinfo.io | grep country )
220 #grep -Po '"country":.*?[^\\]",' $(curl ipinfo.io | grep country )
208 #sed -i "s,http:,https:,g" "${ETC_DIR}/apt/sources.list"
221 #sed -i "s,http:,https:,g" "${ETC_DIR}/apt/sources.list"
209 #autconfigure best apt server to not spam ftp.debian.org
222 #autconfigure best apt server to not spam ftp.debian.org
210 #rm files/apt/sources.list
223 #rm files/apt/sources.list
211 #netselect-apt does not know buster yet
224 #netselect-apt does not know buster yet
212 if [ "$RELEASE" = "buster" ] ; then
225 if [ "$RELEASE" = "buster" ] ; then
213 RLS=testing
226 RLS=testing
214 else
227 else
215 RLS="$RELEASE"
228 RLS="$RELEASE"
216 fi
229 fi
217
230
218 if [ -f "$(pwd)/files/apt/sources.list" ] ; then
231 if [ -f "$(pwd)/files/apt/sources.list" ] ; then
219 rm "$(pwd)/files/apt/sources.list"
232 rm "$(pwd)/files/apt/sources.list"
220 fi
233 fi
221
234
222 if [ "$ENABLE_NONFREE" = true ] ; then
235 if [ "$ENABLE_NONFREE" = true ] ; then
223 netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --nonfree --outfile "$(pwd)/files/apt/sources.list" -d "$RLS"
236 netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --nonfree --outfile "$(pwd)/files/apt/sources.list" -d "$RLS"
224 else
237 else
225 netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS"
238 netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS"
226 fi
239 fi
227
240
228 #sed and cut the result string so we can use it as APT_SERVER
241 #sed and cut the result string so we can use it as APT_SERVER
229 APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3)
242 APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3)
230 APT_SERVER=${APT_SERVER::-1}
243 APT_SERVER=${APT_SERVER::-1}
231
244
232 #make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go!
245 #make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go!
233 if [ -n "$SET_ARCH" ] ; then
246 if [ -n "$SET_ARCH" ] ; then
234 echo "Setting Architecture specific settings"
247 echo "Setting Architecture specific settings"
235 ##################################
248 ##################################
236 # 64 bit config
249 # 64 bit config
237 ##################################
250 ##################################
238 if [ "$SET_ARCH" = 64 ] ; then
251 if [ "$SET_ARCH" = 64 ] ; then
239 echo "64 bit mode selected - Setting up enviroment"
252 echo "64 bit mode selected - Setting up enviroment"
240 # 64 bit depended settings
253 # 64 bit depended settings
241 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
254 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
242 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
255 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
243 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
256 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
244
257
245 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
258 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
246 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
259 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
247 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
260 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
248 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
261 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
249 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
262 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
250 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
263 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
251 else
264 else
252 echo "error: At the moment Raspberry PI 3 and 3B+ are the only Models which support 64bit"
265 echo "error: Only Raspberry PI 3 and 3B+ support 64bit"
253 exit 1
266 exit 1
254 fi
267 fi
255 fi
268 fi
256
269
257 ##################################
270 ##################################
258 # 32 bit config
271 # 32 bit config
259 ##################################
272 ##################################
260 if [ "$SET_ARCH" = 32 ] ; then
273 if [ "$SET_ARCH" = 32 ] ; then
261 echo "32 bit mode selected - Setting up enviroment"
274 echo "32 bit mode selected - Setting up enviroment"
262 #General 32bit configuration
275 #General 32bit configuration
263 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
276 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
264 KERNEL_ARCH=${KERNEL_ARCH:=arm}
277 KERNEL_ARCH=${KERNEL_ARCH:=arm}
265 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
278 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
266
279
267 #Raspberry setting grouped by board compability
280 #Raspberry setting grouped by board compability
268 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
281 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
269 echo "Setting settings for bcm2835 Raspberry PI boards"
282 echo "Setting settings for bcm2835 Raspberry PI boards"
270 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
283 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
271 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
284 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
272 RELEASE_ARCH=${RELEASE_ARCH:=armel}
285 RELEASE_ARCH=${RELEASE_ARCH:=armel}
273 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
286 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
274 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
287 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
275 fi
288 fi
276 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
289 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
277 echo "Setting settings for bcm2837 Raspberry PI boards"
290 echo "Setting settings for bcm2837 Raspberry PI boards"
278 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
291 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
279 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
292 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
280 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
293 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
281 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
294 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
282 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
295 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
283 fi
296 fi
284 fi
297 fi
285 #SET_ARCH not set
298 #SET_ARCH not set
286 else
299 else
287 echo "error: Please set '32' or '64' as value for SET_ARCH"
300 echo "error: Please set '32' or '64' as value for SET_ARCH"
288 exit 1
301 exit 1
289 fi
302 fi
290
303
291 #Device specific configuration
304 #Device specific configuration
292 echo "Select DTB-File"
305 echo "Select DTB-File"
293 case "$RPI_MODEL" in
306 case "$RPI_MODEL" in
294 0)
307 0)
295 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
308 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
296 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
309 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
297 ;;
310 ;;
298 1)
311 1)
299 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
312 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
300 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
313 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
301 ;;
314 ;;
302 1P)
315 1P)
303 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
316 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
304 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
317 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
305 ;;
318 ;;
306 2)
319 2)
307 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
320 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
308 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
321 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
309 ;;
322 ;;
310 3)
323 3)
311 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
324 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
312 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
325 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
313 ;;
326 ;;
314 3P)
327 3P)
315 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
328 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
316 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
329 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
317 ;;
330 ;;
318 *)
331 *)
319 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
332 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
320 exit 1
333 exit 1
321 ;;
334 ;;
322 esac
335 esac
323 echo "$DTB_FILE selected"
336 echo "$DTB_FILE selected"
324
337
325 #DEBUG off
338 #DEBUG off
326 set +x
339 set +x
327
340
328 # Check if the internal wireless interface is supported by the RPi model
341 # Check if the internal wireless interface is supported by the RPi model
329 if [ "$ENABLE_WIRELESS" = true ] ; then
342 if [ "$ENABLE_WIRELESS" = true ] ; then
330 if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then
343 if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then
331 echo "error: The selected Raspberry Pi model has no internal wireless interface"
344 echo "error: The selected Raspberry Pi model has no internal wireless interface"
332 exit 1
345 exit 1
333 else
346 else
334 echo "Raspberry Pi $RPI_MODEL has WIFI support"
347 echo "Raspberry Pi $RPI_MODEL has WIFI support"
335 fi
348 fi
336 fi
349 fi
337
350
338 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
351 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
339 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
352 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
340 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
353 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
341 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
354 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
342 exit 1
355 exit 1
343 fi
356 fi
344 fi
357 fi
345
358
346 if [ "$ENABLE_VIDEOCORE" = true ] ; then
359 if [ "$ENABLE_VIDEOCORE" = true ] ; then
347 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
360 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
348 fi
361 fi
349
362
350 # Add libncurses5 to enable kernel menuconfig
363 # Add libncurses5 to enable kernel menuconfig
351 if [ "$KERNEL_MENUCONFIG" = true ] ; then
364 if [ "$KERNEL_MENUCONFIG" = true ] ; then
352 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
365 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
353 fi
366 fi
354
367
355 # Add ccache compiler cache for (faster) kernel cross (re)compilation
368 # Add ccache compiler cache for (faster) kernel cross (re)compilation
356 if [ "$KERNEL_CCACHE" = true ] ; then
369 if [ "$KERNEL_CCACHE" = true ] ; then
357 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
370 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
358 fi
371 fi
359
372
360 # Add cryptsetup package to enable filesystem encryption
373 # Add cryptsetup package to enable filesystem encryption
361 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
374 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
362 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
375 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
363 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
376 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
364
377
365 if [ -z "$CRYPTFS_PASSWORD" ] ; then
378 if [ -z "$CRYPTFS_PASSWORD" ] ; then
366 echo "error: no password defined (CRYPTFS_PASSWORD)!"
379 echo "error: no password defined (CRYPTFS_PASSWORD)!"
367 exit 1
380 exit 1
368 fi
381 fi
369 ENABLE_INITRAMFS=true
382 ENABLE_INITRAMFS=true
370 fi
383 fi
371
384
372 # Add initramfs generation tools
385 # Add initramfs generation tools
373 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
386 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
374 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
387 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
375 fi
388 fi
376
389
377 # Add device-tree-compiler required for building the U-Boot bootloader
390 # Add device-tree-compiler required for building the U-Boot bootloader
378 if [ "$ENABLE_UBOOT" = true ] ; then
391 if [ "$ENABLE_UBOOT" = true ] ; then
379 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
392 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
380 else
393 else
381 if [ "$ENABLE_UBOOTUSB" = true ] ; then
394 if [ "$ENABLE_UBOOTUSB" = true ] ; then
382 echo "error: Enabling UBOOTUSB requires u-boot to be enabled"
395 echo "error: Enabling UBOOTUSB requires u-boot to be enabled"
383 exit 1
396 exit 1
384 fi
397 fi
385 fi
398 fi
386
399
387 # Check if root SSH (v2) public key file exists
400 # Check if root SSH (v2) public key file exists
388 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
401 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
389 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
402 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
390 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
403 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
391 exit 1
404 exit 1
392 fi
405 fi
393 fi
406 fi
394
407
395 # Check if $USER_NAME SSH (v2) public key file exists
408 # Check if $USER_NAME SSH (v2) public key file exists
396 if [ -n "$SSH_USER_PUB_KEY" ] ; then
409 if [ -n "$SSH_USER_PUB_KEY" ] ; then
397 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
410 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
398 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
411 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
399 exit 1
412 exit 1
400 fi
413 fi
401 fi
414 fi
402
415
403 # Check if all required packages are installed on the build system
416 # Check if all required packages are installed on the build system
404 for package in $REQUIRED_PACKAGES ; do
417 for package in $REQUIRED_PACKAGES ; do
405 if [ "$(dpkg-query -W -f='${Status}' $package)" != "install ok installed" ] ; then
418 if [ "$(dpkg-query -W -f='${Status}' $package)" != "install ok installed" ] ; then
406 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
419 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
407 fi
420 fi
408 done
421 done
409
422
410 # If there are missing packages ask confirmation for install, or exit
423 # If there are missing packages ask confirmation for install, or exit
411 if [ -n "$MISSING_PACKAGES" ] ; then
424 if [ -n "$MISSING_PACKAGES" ] ; then
412 echo "the following packages needed by this script are not installed:"
425 echo "the following packages needed by this script are not installed:"
413 echo "$MISSING_PACKAGES"
426 echo "$MISSING_PACKAGES"
414
427
415 printf "\ndo you want to install the missing packages right now? [y/n] "
428 printf "\ndo you want to install the missing packages right now? [y/n] "
416 read -r confirm
429 read -r confirm
417 [ "$confirm" != "y" ] && exit 1
430 [ "$confirm" != "y" ] && exit 1
418
431
419 # Make sure all missing required packages are installed
432 # Make sure all missing required packages are installed
420 apt-get -qq -y install "${MISSING_PACKAGES}"
433 apt-get -qq -y install "${MISSING_PACKAGES}"
421 fi
434 fi
422
435
423 # Check if ./bootstrap.d directory exists
436 # Check if ./bootstrap.d directory exists
424 if [ ! -d "./bootstrap.d/" ] ; then
437 if [ ! -d "./bootstrap.d/" ] ; then
425 echo "error: './bootstrap.d' required directory not found!"
438 echo "error: './bootstrap.d' required directory not found!"
426 exit 1
439 exit 1
427 fi
440 fi
428
441
429 # Check if ./files directory exists
442 # Check if ./files directory exists
430 if [ ! -d "./files/" ] ; then
443 if [ ! -d "./files/" ] ; then
431 echo "error: './files' required directory not found!"
444 echo "error: './files' required directory not found!"
432 exit 1
445 exit 1
433 fi
446 fi
434
447
435 # Check if specified KERNELSRC_DIR directory exists
448 # Check if specified KERNELSRC_DIR directory exists
436 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
449 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
437 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
450 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
438 exit 1
451 exit 1
439 fi
452 fi
440
453
441 # Check if specified UBOOTSRC_DIR directory exists
454 # Check if specified UBOOTSRC_DIR directory exists
442 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
455 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
443 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
456 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
444 exit 1
457 exit 1
445 fi
458 fi
446
459
447 # Check if specified VIDEOCORESRC_DIR directory exists
460 # Check if specified VIDEOCORESRC_DIR directory exists
448 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
461 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
449 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
462 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
450 exit 1
463 exit 1
451 fi
464 fi
452
465
453 # Check if specified FBTURBOSRC_DIR directory exists
466 # Check if specified FBTURBOSRC_DIR directory exists
454 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
467 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
455 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
468 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
456 exit 1
469 exit 1
457 fi
470 fi
458
471
459 # Check if specified CHROOT_SCRIPTS directory exists
472 # Check if specified CHROOT_SCRIPTS directory exists
460 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
473 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
461 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
474 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
462 exit 1
475 exit 1
463 fi
476 fi
464
477
465 # Check if specified device mapping already exists (will be used by cryptsetup)
478 # Check if specified device mapping already exists (will be used by cryptsetup)
466 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
479 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
467 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
480 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
468 exit 1
481 exit 1
469 fi
482 fi
470
483
471 # Don't clobber an old build
484 # Don't clobber an old build
472 if [ -e "$BUILDDIR" ] ; then
485 if [ -e "$BUILDDIR" ] ; then
473 echo "error: directory ${BUILDDIR} already exists, not proceeding"
486 echo "error: directory ${BUILDDIR} already exists, not proceeding"
474 exit 1
487 exit 1
475 fi
488 fi
476
489
477 # Setup chroot directory
490 # Setup chroot directory
478 mkdir -p "${R}"
491 mkdir -p "${R}"
479
492
480 # Check if build directory has enough of free disk space >512MB
493 # Check if build directory has enough of free disk space >512MB
481 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
494 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
482 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
495 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
483 exit 1
496 exit 1
484 fi
497 fi
485
498
486 set -x
499 set -x
487
500
488 # Call "cleanup" function on various signals and errors
501 # Call "cleanup" function on various signals and errors
489 trap cleanup 0 1 2 3 6
502 trap cleanup 0 1 2 3 6
490
503
491 # Add required packages for the minbase installation
504 # Add required packages for the minbase installation
492 if [ "$ENABLE_MINBASE" = true ] ; then
505 if [ "$ENABLE_MINBASE" = true ] ; then
493 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
506 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
494 fi
507 fi
495
508
496 # Add parted package, required to get partprobe utility
509 # Add parted package, required to get partprobe utility
497 if [ "$EXPANDROOT" = true ] ; then
510 if [ "$EXPANDROOT" = true ] ; then
498 APT_INCLUDES="${APT_INCLUDES},parted"
511 APT_INCLUDES="${APT_INCLUDES},parted"
499 fi
512 fi
500
513
501 # Add dbus package, recommended if using systemd
514 # Add dbus package, recommended if using systemd
502 if [ "$ENABLE_DBUS" = true ] ; then
515 if [ "$ENABLE_DBUS" = true ] ; then
503 APT_INCLUDES="${APT_INCLUDES},dbus"
516 APT_INCLUDES="${APT_INCLUDES},dbus"
504 fi
517 fi
505
518
506 # Add iptables IPv4/IPv6 package
519 # Add iptables IPv4/IPv6 package
507 if [ "$ENABLE_IPTABLES" = true ] ; then
520 if [ "$ENABLE_IPTABLES" = true ] ; then
508 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
521 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
509 fi
522 fi
510
523
511 # Add openssh server package
524 # Add openssh server package
512 if [ "$ENABLE_SSHD" = true ] ; then
525 if [ "$ENABLE_SSHD" = true ] ; then
513 APT_INCLUDES="${APT_INCLUDES},openssh-server"
526 APT_INCLUDES="${APT_INCLUDES},openssh-server"
514 fi
527 fi
515
528
516 # Add alsa-utils package
529 # Add alsa-utils package
517 if [ "$ENABLE_SOUND" = true ] ; then
530 if [ "$ENABLE_SOUND" = true ] ; then
518 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
531 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
519 fi
532 fi
520
533
521 # Add rng-tools package
534 # Add rng-tools package
522 if [ "$ENABLE_HWRANDOM" = true ] ; then
535 if [ "$ENABLE_HWRANDOM" = true ] ; then
523 APT_INCLUDES="${APT_INCLUDES},rng-tools"
536 APT_INCLUDES="${APT_INCLUDES},rng-tools"
524 fi
537 fi
525
538
526 # Add fbturbo video driver
539 # Add fbturbo video driver
527 if [ "$ENABLE_FBTURBO" = true ] ; then
540 if [ "$ENABLE_FBTURBO" = true ] ; then
528 # Enable xorg package dependencies
541 # Enable xorg package dependencies
529 ENABLE_XORG=true
542 ENABLE_XORG=true
530 fi
543 fi
531
544
532 # Add user defined window manager package
545 # Add user defined window manager package
533 if [ -n "$ENABLE_WM" ] ; then
546 if [ -n "$ENABLE_WM" ] ; then
534 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
547 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
535
548
536 # Enable xorg package dependencies
549 # Enable xorg package dependencies
537 ENABLE_XORG=true
550 ENABLE_XORG=true
538 fi
551 fi
539
552
540 # Add xorg package
553 # Add xorg package
541 if [ "$ENABLE_XORG" = true ] ; then
554 if [ "$ENABLE_XORG" = true ] ; then
542 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
555 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
543 fi
556 fi
544
557
545 # Replace selected packages with smaller clones
558 # Replace selected packages with smaller clones
546 if [ "$ENABLE_REDUCE" = true ] ; then
559 if [ "$ENABLE_REDUCE" = true ] ; then
547 # Add levee package instead of vim-tiny
560 # Add levee package instead of vim-tiny
548 if [ "$REDUCE_VIM" = true ] ; then
561 if [ "$REDUCE_VIM" = true ] ; then
549 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
562 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
550 fi
563 fi
551
564
552 # Add dropbear package instead of openssh-server
565 # Add dropbear package instead of openssh-server
553 if [ "$REDUCE_SSHD" = true ] ; then
566 if [ "$REDUCE_SSHD" = true ] ; then
554 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
567 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
555 fi
568 fi
556 fi
569 fi
557
570
558 # Configure kernel sources if no KERNELSRC_DIR
571 # Configure kernel sources if no KERNELSRC_DIR
559 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
572 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
560 KERNELSRC_CONFIG=true
573 KERNELSRC_CONFIG=true
561 fi
574 fi
562
575
563 # Configure reduced kernel
576 # Configure reduced kernel
564 if [ "$KERNEL_REDUCE" = true ] ; then
577 if [ "$KERNEL_REDUCE" = true ] ; then
565 KERNELSRC_CONFIG=false
578 KERNELSRC_CONFIG=false
566 fi
579 fi
567
580
568 # Configure qemu compatible kernel
581 # Configure qemu compatible kernel
569 if [ "$ENABLE_QEMU" = true ] ; then
582 if [ "$ENABLE_QEMU" = true ] ; then
570 DTB_FILE=vexpress-v2p-ca15_a7.dtb
583 DTB_FILE=vexpress-v2p-ca15_a7.dtb
571 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
584 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
572 KERNEL_DEFCONFIG="vexpress_defconfig"
585 KERNEL_DEFCONFIG="vexpress_defconfig"
573 if [ "$KERNEL_MENUCONFIG" = false ] ; then
586 if [ "$KERNEL_MENUCONFIG" = false ] ; then
574 KERNEL_OLDDEFCONFIG=true
587 KERNEL_OLDDEFCONFIG=true
575 fi
588 fi
576 fi
589 fi
577
590
578 # Execute bootstrap scripts
591 # Execute bootstrap scripts
579 for SCRIPT in bootstrap.d/*.sh; do
592 for SCRIPT in bootstrap.d/*.sh; do
580 head -n 3 "$SCRIPT"
593 head -n 3 "$SCRIPT"
581 . "$SCRIPT"
594 . "$SCRIPT"
582 done
595 done
583
596
584 ## Execute custom bootstrap scripts
597 ## Execute custom bootstrap scripts
585 if [ -d "custom.d" ] ; then
598 if [ -d "custom.d" ] ; then
586 for SCRIPT in custom.d/*.sh; do
599 for SCRIPT in custom.d/*.sh; do
587 . "$SCRIPT"
600 . "$SCRIPT"
588 done
601 done
589 fi
602 fi
590
603
591 # Execute custom scripts inside the chroot
604 # Execute custom scripts inside the chroot
592 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
605 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
593 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
606 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
594 chroot_exec /bin/bash -x <<'EOF'
607 chroot_exec /bin/bash -x <<'EOF'
595 for SCRIPT in /chroot_scripts/* ; do
608 for SCRIPT in /chroot_scripts/* ; do
596 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
609 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
597 $SCRIPT
610 $SCRIPT
598 fi
611 fi
599 done
612 done
600 EOF
613 EOF
601 rm -rf "${R}/chroot_scripts"
614 rm -rf "${R}/chroot_scripts"
602 fi
615 fi
603
616
604 # Remove c/c++ build environment from the chroot
617 # Remove c/c++ build environment from the chroot
605 chroot_remove_cc
618 chroot_remove_cc
606
619
607 # Generate required machine-id
620 # Generate required machine-id
608 MACHINE_ID=$(dbus-uuidgen)
621 MACHINE_ID=$(dbus-uuidgen)
609 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
622 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
610 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
623 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
611
624
612 # APT Cleanup
625 # APT Cleanup
613 chroot_exec apt-get -y clean
626 chroot_exec apt-get -y clean
614 chroot_exec apt-get -y autoclean
627 chroot_exec apt-get -y autoclean
615 chroot_exec apt-get -y autoremove
628 chroot_exec apt-get -y autoremove
616
629
617 # Unmount mounted filesystems
630 # Unmount mounted filesystems
618 umount -l "${R}/proc"
631 umount -l "${R}/proc"
619 umount -l "${R}/sys"
632 umount -l "${R}/sys"
620
633
621 # Clean up directories
634 # Clean up directories
622 rm -rf "${R}/run/*"
635 rm -rf "${R}/run/*"
623 rm -rf "${R}/tmp/*"
636 rm -rf "${R}/tmp/*"
624
637
625 # Clean up files
638 # Clean up files
626 rm -f "${ETC_DIR}/ssh/ssh_host_*"
639 rm -f "${ETC_DIR}/ssh/ssh_host_*"
627 rm -f "${ETC_DIR}/dropbear/dropbear_*"
640 rm -f "${ETC_DIR}/dropbear/dropbear_*"
628 rm -f "${ETC_DIR}/apt/sources.list.save"
641 rm -f "${ETC_DIR}/apt/sources.list.save"
629 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
642 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
630 rm -f "${ETC_DIR}/*-"
643 rm -f "${ETC_DIR}/*-"
631 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
644 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
632 rm -f "${ETC_DIR}/resolv.conf"
645 rm -f "${ETC_DIR}/resolv.conf"
633 rm -f "${R}/root/.bash_history"
646 rm -f "${R}/root/.bash_history"
634 rm -f "${R}/var/lib/urandom/random-seed"
647 rm -f "${R}/var/lib/urandom/random-seed"
635 rm -f "${R}/initrd.img"
648 rm -f "${R}/initrd.img"
636 rm -f "${R}/vmlinuz"
649 rm -f "${R}/vmlinuz"
637 rm -f "${R}${QEMU_BINARY}"
650 rm -f "${R}${QEMU_BINARY}"
638
651
639 if [ "$ENABLE_QEMU" = true ] ; then
652 if [ "$ENABLE_QEMU" = true ] ; then
640 # Setup QEMU directory
653 # Setup QEMU directory
641 mkdir "${BASEDIR}/qemu"
654 mkdir "${BASEDIR}/qemu"
642
655
643 # Copy kernel image to QEMU directory
656 # Copy kernel image to QEMU directory
644 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
657 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
645
658
646 # Copy kernel config to QEMU directory
659 # Copy kernel config to QEMU directory
647 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
660 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
648
661
649 # Copy kernel dtbs to QEMU directory
662 # Copy kernel dtbs to QEMU directory
650 for dtb in "${BOOT_DIR}/"*.dtb ; do
663 for dtb in "${BOOT_DIR}/"*.dtb ; do
651 if [ -f "${dtb}" ] ; then
664 if [ -f "${dtb}" ] ; then
652 install_readonly "${dtb}" "${BASEDIR}/qemu/"
665 install_readonly "${dtb}" "${BASEDIR}/qemu/"
653 fi
666 fi
654 done
667 done
655
668
656 # Copy kernel overlays to QEMU directory
669 # Copy kernel overlays to QEMU directory
657 if [ -d "${BOOT_DIR}/overlays" ] ; then
670 if [ -d "${BOOT_DIR}/overlays" ] ; then
658 # Setup overlays dtbs directory
671 # Setup overlays dtbs directory
659 mkdir "${BASEDIR}/qemu/overlays"
672 mkdir "${BASEDIR}/qemu/overlays"
660
673
661 for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do
674 for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do
662 if [ -f "${dtb}" ] ; then
675 if [ -f "${dtb}" ] ; then
663 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
676 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
664 fi
677 fi
665 done
678 done
666 fi
679 fi
667
680
668 # Copy u-boot files to QEMU directory
681 # Copy u-boot files to QEMU directory
669 if [ "$ENABLE_UBOOT" = true ] ; then
682 if [ "$ENABLE_UBOOT" = true ] ; then
670 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
683 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
671 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
684 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
672 fi
685 fi
673 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
686 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
674 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
687 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
675 fi
688 fi
676 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
689 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
677 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
690 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
678 fi
691 fi
679 fi
692 fi
680
693
681 # Copy initramfs to QEMU directory
694 # Copy initramfs to QEMU directory
682 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
695 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
683 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
696 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
684 fi
697 fi
685 fi
698 fi
686
699
687 # Calculate size of the chroot directory in KB
700 # Calculate size of the chroot directory in KB
688 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
701 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
689
702
690 # Calculate the amount of needed 512 Byte sectors
703 # Calculate the amount of needed 512 Byte sectors
691 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
704 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
692 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
705 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
693 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
706 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
694
707
695 # The root partition is EXT4
708 # The root partition is EXT4
696 # This means more space than the actual used space of the chroot is used.
709 # This means more space than the actual used space of the chroot is used.
697 # As overhead for journaling and reserved blocks 35% are added.
710 # As overhead for journaling and reserved blocks 35% are added.
698 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
711 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
699
712
700 # Calculate required image size in 512 Byte sectors
713 # Calculate required image size in 512 Byte sectors
701 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
714 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
702
715
703 # Prepare image file
716 # Prepare image file
704 if [ "$ENABLE_SPLITFS" = true ] ; then
717 if [ "$ENABLE_SPLITFS" = true ] ; then
705 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
718 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
706 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
719 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
707 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
720 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
708 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
721 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
709
722
710 # Write firmware/boot partition tables
723 # Write firmware/boot partition tables
711 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
724 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
712 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
725 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
713 EOM
726 EOM
714
727
715 # Write root partition table
728 # Write root partition table
716 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
729 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
717 ${TABLE_SECTORS},${ROOT_SECTORS},83
730 ${TABLE_SECTORS},${ROOT_SECTORS},83
718 EOM
731 EOM
719
732
720 # Setup temporary loop devices
733 # Setup temporary loop devices
721 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
734 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
722 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
735 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
723 else # ENABLE_SPLITFS=false
736 else # ENABLE_SPLITFS=false
724 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
737 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
725 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
738 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
726
739
727 # Write partition table
740 # Write partition table
728 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
741 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
729 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
742 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
730 ${ROOT_OFFSET},${ROOT_SECTORS},83
743 ${ROOT_OFFSET},${ROOT_SECTORS},83
731 EOM
744 EOM
732
745
733 # Setup temporary loop devices
746 # Setup temporary loop devices
734 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
747 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
735 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
748 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
736 fi
749 fi
737
750
738 if [ "$ENABLE_CRYPTFS" = true ] ; then
751 if [ "$ENABLE_CRYPTFS" = true ] ; then
739 # Create dummy ext4 fs
752 # Create dummy ext4 fs
740 mkfs.ext4 "$ROOT_LOOP"
753 mkfs.ext4 "$ROOT_LOOP"
741
754
742 # Setup password keyfile
755 # Setup password keyfile
743 touch .password
756 touch .password
744 chmod 600 .password
757 chmod 600 .password
745 echo -n ${CRYPTFS_PASSWORD} > .password
758 echo -n ${CRYPTFS_PASSWORD} > .password
746
759
747 # Initialize encrypted partition
760 # Initialize encrypted partition
748 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
761 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
749
762
750 # Open encrypted partition and setup mapping
763 # Open encrypted partition and setup mapping
751 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
764 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
752
765
753 # Secure delete password keyfile
766 # Secure delete password keyfile
754 shred -zu .password
767 shred -zu .password
755
768
756 # Update temporary loop device
769 # Update temporary loop device
757 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
770 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
758
771
759 # Wipe encrypted partition (encryption cipher is used for randomness)
772 # Wipe encrypted partition (encryption cipher is used for randomness)
760 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
773 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
761 fi
774 fi
762
775
763 # Build filesystems
776 # Build filesystems
764 mkfs.vfat "$FRMW_LOOP"
777 mkfs.vfat "$FRMW_LOOP"
765 mkfs.ext4 "$ROOT_LOOP"
778 mkfs.ext4 "$ROOT_LOOP"
766
779
767 # Mount the temporary loop devices
780 # Mount the temporary loop devices
768 mkdir -p "$BUILDDIR/mount"
781 mkdir -p "$BUILDDIR/mount"
769 mount "$ROOT_LOOP" "$BUILDDIR/mount"
782 mount "$ROOT_LOOP" "$BUILDDIR/mount"
770
783
771 mkdir -p "$BUILDDIR/mount/boot/firmware"
784 mkdir -p "$BUILDDIR/mount/boot/firmware"
772 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
785 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
773
786
774 # Copy all files from the chroot to the loop device mount point directory
787 # Copy all files from the chroot to the loop device mount point directory
775 rsync -a "${R}/" "$BUILDDIR/mount/"
788 rsync -a "${R}/" "$BUILDDIR/mount/"
776
789
777 # Unmount all temporary loop devices and mount points
790 # Unmount all temporary loop devices and mount points
778 cleanup
791 cleanup
779
792
780 # Create block map file(s) of image(s)
793 # Create block map file(s) of image(s)
781 if [ "$ENABLE_SPLITFS" = true ] ; then
794 if [ "$ENABLE_SPLITFS" = true ] ; then
782 # Create block map files for "bmaptool"
795 # Create block map files for "bmaptool"
783 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
796 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
784 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
797 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
785
798
786 # Image was successfully created
799 # Image was successfully created
787 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
800 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
788 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
801 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
789 else
802 else
790 # Create block map file for "bmaptool"
803 # Create block map file for "bmaptool"
791 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
804 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
792
805
793 # Image was successfully created
806 # Image was successfully created
794 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
807 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
795
808
796 # Create qemu qcow2 image
809 # Create qemu qcow2 image
797 if [ "$ENABLE_QEMU" = true ] ; then
810 if [ "$ENABLE_QEMU" = true ] ; then
798 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
811 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
799 QEMU_SIZE=16G
812 QEMU_SIZE=16G
800
813
801 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
814 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
802 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
815 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
803
816
804 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
817 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
805 fi
818 fi
806 fi
819 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant