##// END OF EJS Templates
merge Ok
vidal -
r705:b9989bcfeb78
parent child
Show More
@@ -1,552 +1,580
1 # rpi23-gen-image
1 # rpi23-gen-image
2 ## Introduction
2 ## Introduction
3
3
4
4
5 `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 `jessie`, `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```).
5 `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 `jessie`, `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```).
6
6
7
7
8
8
9 ## Build dependencies
9 ## Build dependencies
10 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.
10 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.
11
11
12 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo```
12 ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo```
13
13
14 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the Raspberry 3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf/armel) cross-compiler toolchain.
14 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the Raspberry 3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf/armel) cross-compiler toolchain.
15 It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the Raspberry 3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf/armel/aarch64) cross-compiler toolchain.
15
16
16 The script has been tested using the default `crossbuild-essential-armhf` and `crossbuild-essential-armel` toolchain meta packages on Debian Linux `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
17 The script has been tested using the default `crossbuild-essential-armhf` and `crossbuild-essential-armel` toolchain meta packages on Debian Linux `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information.
17
18
18 ## Command-line parameters
19 ## Command-line parameters
19 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.
20 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.
20
21
21 ##### Command-line examples:
22 ##### Command-line examples:
22 ```shell
23 ```shell
23 ENABLE_UBOOT=true ./rpi23-gen-image.sh
24 ENABLE_UBOOT=true ./rpi23-gen-image.sh
24 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh
25 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh
25 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh
26 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh
26 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh
27 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh
27 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh
28 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh
28 ENABLE_MINBASE=true ./rpi23-gen-image.sh
29 ENABLE_MINBASE=true ./rpi23-gen-image.sh
29 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh
30 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh
30 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh
31 BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh
31 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
32 ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
32 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
33 ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh
33 RELEASE=stretch BUILD_KERNEL=true ./rpi23-gen-image.sh
34 RELEASE=stretch BUILD_KERNEL=true ./rpi23-gen-image.sh
34 RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
35 RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
35 RELEASE=stretch RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
36 RELEASE=stretch RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh
36 ```
37 ```
37
38
38 ## Configuration template files
39 ## Configuration template files
39 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.
40 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.
40
41
41 ##### Command-line examples:
42 ##### Command-line examples:
42 ```shell
43 ```shell
43 CONFIG_TEMPLATE=rpi3stretch ./rpi23-gen-image.sh
44 CONFIG_TEMPLATE=rpi3stretch ./rpi23-gen-image.sh
44 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
45 CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh
45 ```
46 ```
46
47
47 ## Supported parameters and settings
48 ## Supported parameters and settings
48 #### APT settings:
49 #### APT settings:
49 ##### `APT_SERVER`="ftp.debian.org"
50 ##### `APT_SERVER`="ftp.debian.org"
50 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.
51 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.
51
52
52 ##### `APT_PROXY`=""
53 ##### `APT_PROXY`=""
53 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.
54 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.
54
55
55 ##### `KEEP_APT_PROXY`=false
56 ##### `KEEP_APT_PROXY`=false
56 Keep the APT_PROXY settings used in the bootsrapping process in the generated image.
57 Keep the APT_PROXY settings used in the bootsrapping process in the generated image.
57
58
58 ##### `APT_INCLUDES`=""
59 ##### `APT_INCLUDES`=""
59 A comma-separated list of additional packages to be installed by debootstrap during bootstrapping.
60 A comma-separated list of additional packages to be installed by debootstrap during bootstrapping.
60
61
61 ##### `APT_INCLUDES_LATE`=""
62 ##### `APT_INCLUDES_LATE`=""
62 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.
63 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.
63
64
64 ---
65 ---
65
66
66 #### General system settings:
67 #### General system settings:
67 ##### `SET_ARCH`=32
68 ##### `SET_ARCH`=32
68 Set Architecture to default 32bit. If you want to compile 64-bit (RPI3 or RPI3+) set it to `64`. This option will set every needed cross-compiler or board specific option for a successful build.
69 Set Architecture to default 32bit. If you want to compile 64-bit (RPI3 or RPI3+) set it to `64`. This option will set every needed cross-compiler or board specific option for a successful build.
70 Set Architecture to default 32bit. If you want to compile 64-bit (RPI3/RPI3+/RPI4) set it to `64`. This option will set every needed cross-compiler or board specific option for a successful build.
69
71
70 ##### `RPI_MODEL`=2
72 ##### `RPI_MODEL`=2
71 Specify the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
73 Specify the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models:
72 - `0` = Raspberry Pi 0 and Raspberry Pi 0 W
74 - `0` = Raspberry Pi 0 and Raspberry Pi 0 W
73 - `1` = Raspberry Pi 1 model A and B
75 - `1` = Raspberry Pi 1 model A and B
74 - `1P` = Raspberry Pi 1 model B+ and A+
76 - `1P` = Raspberry Pi 1 model B+ and A+
75 - `2` = Raspberry Pi 2 model B
77 - `2` = Raspberry Pi 2 model B
76 - `3` = Raspberry Pi 3 model B
78 - `3` = Raspberry Pi 3 model B
77 - `3P` = Raspberry Pi 3 model B+
79 - `3P` = Raspberry Pi 3 model B+
80 - `4` = Raspberry Pi 4 model B
78
81
79 ##### `RELEASE`="buster"
82 ##### `RELEASE`="buster"
80 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases `stretch` and `buster`.
83 Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases `stretch` and `buster`.
81
84
82 ##### `RELEASE_ARCH`="armhf"
85 ##### `RELEASE_ARCH`="armhf"
83 Set the desired Debian release architecture.
86 Set the desired Debian release architecture.
84
87
85 ##### `HOSTNAME`="rpi$RPI_MODEL-$RELEASE"
88 ##### `HOSTNAME`="rpi$RPI_MODEL-$RELEASE"
86 Set system hostname. It's recommended that the hostname is unique in the corresponding subnet.
89 Set system hostname. It's recommended that the hostname is unique in the corresponding subnet.
87
90
88 ##### `PASSWORD`="raspberry"
91 ##### `PASSWORD`="raspberry"
89 Set system `root` password. It's **STRONGLY** recommended that you choose a custom password.
92 Set system `root` password. It's **STRONGLY** recommended that you choose a custom password.
90
93
91 ##### `USER_PASSWORD`="raspberry"
94 ##### `USER_PASSWORD`="raspberry"
92 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.
95 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.
93
96
94 ##### `DEFLOCAL`="en_US.UTF-8"
97 ##### `DEFLOCAL`="en_US.UTF-8"
95 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`.
98 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`.
96
99
97 ##### `TIMEZONE`="Europe/Berlin"
100 ##### `TIMEZONE`="Europe/Berlin"
98 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.
101 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.
99
102
100 ##### `EXPANDROOT`=true
103 ##### `EXPANDROOT`=true
101 Expand the root partition and filesystem automatically on first boot.
104 Expand the root partition and filesystem automatically on first boot.
102
105
103 ##### `ENABLE_DPHYSSWAP`=true
106 ##### `ENABLE_DPHYSSWAP`=true
104 Enable swap. The size of the swapfile is chosen relative to the size of the root partition. It'll use the `dphys-swapfile` package for that.
107 Enable swap. The size of the swapfile is chosen relative to the size of the root partition. It'll use the `dphys-swapfile` package for that.
105
108
106 ##### `ENABLE_QEMU`=false
109 ##### `ENABLE_QEMU`=false
107 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.
110 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.
108
111
109 ---
112 ---
110
113
111 #### Keyboard settings:
114 #### Keyboard settings:
112 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.
115 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.
113
116
114 ##### `XKB_MODEL`=""
117 ##### `XKB_MODEL`=""
115 Set the name of the model of your keyboard type.
118 Set the name of the model of your keyboard type.
116
119
117 ##### `XKB_LAYOUT`=""
120 ##### `XKB_LAYOUT`=""
118 Set the supported keyboard layout(s).
121 Set the supported keyboard layout(s).
119
122
120 ##### `XKB_VARIANT`=""
123 ##### `XKB_VARIANT`=""
121 Set the supported variant(s) of the keyboard layout(s).
124 Set the supported variant(s) of the keyboard layout(s).
122
125
123 ##### `XKB_OPTIONS`=""
126 ##### `XKB_OPTIONS`=""
124 Set extra xkb configuration options.
127 Set extra xkb configuration options.
125
128
126 ---
129 ---
127
130
128 #### Networking settings (DHCP):
131 #### Networking settings (DHCP):
129 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`.`
132 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`.`
130
133
131 ##### `ENABLE_DHCP`=true
134 ##### `ENABLE_DHCP`=true
132 Set the system to use DHCP. This requires an DHCP server.
135 Set the system to use DHCP. This requires an DHCP server.
133
136
134 ---
137 ---
135
138
136 #### Networking settings (static):
139 #### Networking settings (static):
137 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`.
140 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`.
138
141
139 ##### `NET_ADDRESS`=""
142 ##### `NET_ADDRESS`=""
140 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
143 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
141
144
142 ##### `NET_GATEWAY`=""
145 ##### `NET_GATEWAY`=""
143 Set the IP address for the default gateway.
146 Set the IP address for the default gateway.
144
147
145 ##### `NET_DNS_1`=""
148 ##### `NET_DNS_1`=""
146 Set the IP address for the first DNS server.
149 Set the IP address for the first DNS server.
147
150
148 ##### `NET_DNS_2`=""
151 ##### `NET_DNS_2`=""
149 Set the IP address for the second DNS server.
152 Set the IP address for the second DNS server.
150
153
151 ##### `NET_DNS_DOMAINS`=""
154 ##### `NET_DNS_DOMAINS`=""
152 Set the default DNS search domains to use for non fully qualified hostnames.
155 Set the default DNS search domains to use for non fully qualified hostnames.
153
156
154 ##### `NET_NTP_1`=""
157 ##### `NET_NTP_1`=""
155 Set the IP address for the first NTP server.
158 Set the IP address for the first NTP server.
156
159
157 ##### `NET_NTP_2`=""
160 ##### `NET_NTP_2`=""
158 Set the IP address for the second NTP server.
161 Set the IP address for the second NTP server.
159
162
160 ---
163 ---
161
164
162 #### Basic system features:
165 #### Basic system features:
163 ##### `ENABLE_CONSOLE`=true
166 ##### `ENABLE_CONSOLE`=true
164 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. On RPI `0` `3` `3P` the CPU speed is locked at lowest speed.
167 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. On RPI `0` `3` `3P` the CPU speed is locked at lowest speed.
165
168
166 ##### `ENABLE_PRINTK`=false
169 ##### `ENABLE_PRINTK`=false
167 Enables printing kernel messages to konsole. printk is `3 4 1 3` as in raspbian.
170 Enables printing kernel messages to konsole. printk is `3 4 1 3` as in raspbian.
168
171
169 ##### `ENABLE_BLUETOOTH`=false
172 ##### `ENABLE_BLUETOOTH`=false
170 Enable onboard Bluetooth interface on the RPi0/3/3P. See: [Configuring the GPIO serial port on Raspbian jessie and stretch](https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/).
173 Enable onboard Bluetooth interface on the RPi0/3/3P. See: [Configuring the GPIO serial port on Raspbian jessie and stretch](https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/).
171
174
172 ##### `ENABLE_MINIUART_OVERLAY`=false
175 ##### `ENABLE_MINIUART_OVERLAY`=false
173 Enable Bluetooth to use this. Adds overlay to swap UART0 with UART1. Enabling (slower) Bluetooth and full speed serial console. - RPI `0` `3` `3P` have a fast `hardware UART0` (ttyAMA0) and a `mini UART1` (ttyS0)! RPI `1` `1P` `2` only have a `hardware UART0`. `UART0` is considered better, because is faster and more stable than `mini UART1`. By default the Bluetooth modem is mapped to the `hardware UART0` and `mini UART` is used for console. The `mini UART` is a problem for the serial console, because its baudrate depends on the CPU frequency, which is changing on runtime. Resulting in a volatile baudrate and thus in an unusable serial console.
176 Enable Bluetooth to use this. Adds overlay to swap UART0 with UART1. Enabling (slower) Bluetooth and full speed serial console. - RPI `0` `3` `3P` have a fast `hardware UART0` (ttyAMA0) and a `mini UART1` (ttyS0)! RPI `1` `1P` `2` only have a `hardware UART0`. `UART0` is considered better, because is faster and more stable than `mini UART1`. By default the Bluetooth modem is mapped to the `hardware UART0` and `mini UART` is used for console. The `mini UART` is a problem for the serial console, because its baudrate depends on the CPU frequency, which is changing on runtime. Resulting in a volatile baudrate and thus in an unusable serial console.
174
177
175 ##### `ENABLE_TURBO`=false
178 ##### `ENABLE_TURBO`=false
176 Enable Turbo mode. This setting locks cpu at the highest frequency. As setting ENABLE_CONSOLE=true locks RPI to lowest CPU speed, this is can be used additionally to lock cpu hat max speed. Need a good power supply and probably cooling for the Raspberry PI.
179 Enable Turbo mode. This setting locks cpu at the highest frequency. As setting ENABLE_CONSOLE=true locks RPI to lowest CPU speed, this is can be used additionally to lock cpu hat max speed. Need a good power supply and probably cooling for the Raspberry PI.
177
180
178 ##### `ENABLE_I2C`=false
181 ##### `ENABLE_I2C`=false
179 Enable I2C interface on the RPi 0/1/2/3. Please check the [RPi 0/1/2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
182 Enable I2C interface on the RPi 0/1/2/3. Please check the [RPi 0/1/2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
180
183
181 ##### `ENABLE_SPI`=false
184 ##### `ENABLE_SPI`=false
182 Enable SPI interface on the RPi 0/1/2/3. Please check the [RPi 0/1/2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
185 Enable SPI interface on the RPi 0/1/2/3. Please check the [RPi 0/1/2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins.
183
186
184 ##### `ENABLE_IPV6`=true
187 ##### `ENABLE_IPV6`=true
185 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
188 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
186
189
187 ##### `ENABLE_SSHD`=true
190 ##### `ENABLE_SSHD`=true
188 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.
191 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.
189
192
190 ##### `ENABLE_NONFREE`=false
193 ##### `ENABLE_NONFREE`=false
191 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.
194 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.
192
195
193 ##### `ENABLE_WIRELESS`=false
196 ##### `ENABLE_WIRELESS`=false
194 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`.
197 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`.
195
198
196 ##### `ENABLE_RSYSLOG`=true
199 ##### `ENABLE_RSYSLOG`=true
197 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
200 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
198
201
199 ##### `ENABLE_SOUND`=true
202 ##### `ENABLE_SOUND`=true
200 Enable sound hardware and install Advanced Linux Sound Architecture.
203 Enable sound hardware and install Advanced Linux Sound Architecture.
201
204
202 ##### `ENABLE_HWRANDOM`=true
205 ##### `ENABLE_HWRANDOM`=true
203 Enable Hardware Random Number Generator. Strong random numbers are important for most network-based communications that use encryption. It's recommended to be enabled.
206 Enable Hardware Random Number Generator. Strong random numbers are important for most network-based communications that use encryption. It's recommended to be enabled.
204
207
205 ##### `ENABLE_MINGPU`=false
208 ##### `ENABLE_MINGPU`=false
206 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
209 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
207
210
208 ##### `ENABLE_DBUS`=true
211 ##### `ENABLE_DBUS`=true
209 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
212 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
210
213
211 ##### `ENABLE_XORG`=false
214 ##### `ENABLE_XORG`=false
212 Install Xorg open-source X Window System.
215 Install Xorg open-source X Window System.
213
216
214 ##### `ENABLE_WM`=""
217 ##### `ENABLE_WM`=""
215 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`.
218 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`.
216
219
217 ##### `ENABLE_SYSVINIT`=false
220 ##### `ENABLE_SYSVINIT`=false
218 Support for halt,init,poweroff,reboot,runlevel,shutdown,telinit commands
221 Support for halt,init,poweroff,reboot,runlevel,shutdown,telinit commands
219
222
220 ---
223 ---
221
224
222 #### Advanced system features:
225 #### Advanced system features:
226 ##### `ENABLE_KEYGEN`=false
227 Recover your lost codec license
228
223 ##### `ENABLE_SYSTEMDSWAP`=false
229 ##### `ENABLE_SYSTEMDSWAP`=false
224 Enables [Systemd-swap service](https://github.com/Nefelim4ag/systemd-swap). Usefull if `KERNEL_ZSWAP` is enabled.
230 Enables [Systemd-swap service](https://github.com/Nefelim4ag/systemd-swap). Usefull if `KERNEL_ZSWAP` is enabled.
225
231
226 ##### `ENABLE_MINBASE`=false
232 ##### `ENABLE_MINBASE`=false
227 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
233 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
228
234
229 ##### `ENABLE_REDUCE`=false
235 ##### `ENABLE_REDUCE`=false
230 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
236 Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information.
231
237
232 ##### `ENABLE_UBOOT`=false
238 ##### `ENABLE_UBOOT`=false
233 Replace the default RPi 0/1/2/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.
239 Replace the default RPi 0/1/2/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.
240 RPI4 needs tbd
234
241
235 ##### `UBOOTSRC_DIR`=""
242 ##### `UBOOTSRC_DIR`=""
236 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.
243 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.
237
244
238 ##### `ENABLE_FBTURBO`=false
245 ##### `ENABLE_FBTURBO`=false
239 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.
246 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.
240
247
241 ##### `FBTURBOSRC_DIR`=""
248 ##### `FBTURBOSRC_DIR`=""
242 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.
249 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.
243
250
244 ##### `ENABLE_VIDEOCORE`=false
251 ##### `ENABLE_VIDEOCORE`=false
245 Install and enable the [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.
252 Install and enable the [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.
246
253
247 ##### `VIDEOCORESRC_DIR`=""
254 ##### `VIDEOCORESRC_DIR`=""
248 Path to a directory (`userland`) of [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.
255 Path to a directory (`userland`) of [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.
249
256
250 ##### `ENABLE_NEXMON`=false
257 ##### `ENABLE_NEXMON`=false
251 Install and enable the [Source code for a C-based firmware patching framework for Broadcom/Cypress WiFi chips that enables you to write your own firmware patches, for example, to enable monitor mode with radiotap headers and frame injection](https://github.com/seemoo-lab/nexmon.git).
258 Install and enable the [Source code for a C-based firmware patching framework for Broadcom/Cypress WiFi chips that enables you to write your own firmware patches, for example, to enable monitor mode with radiotap headers and frame injection](https://github.com/seemoo-lab/nexmon.git).
252
259
253 ##### `NEXMONSRC_DIR`=""
260 ##### `NEXMONSRC_DIR`=""
254 Path to a directory (`nexmon`) 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.
261 Path to a directory (`nexmon`) 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.
255
262
256 ##### `ENABLE_IPTABLES`=false
263 ##### `ENABLE_IPTABLES`=false
257 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
264 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
258
265
259 ##### `ENABLE_USER`=true
266 ##### `ENABLE_USER`=true
260 Create non-root user with password `USER_PASSWORD`=raspberry. Unless overridden with `USER_NAME`=user, the username will be `pi`.
267 Create non-root user with password `USER_PASSWORD`=raspberry. Unless overridden with `USER_NAME`=user, the username will be `pi`.
261
268
262 ##### `USER_NAME`=pi
269 ##### `USER_NAME`=pi
263 Non-root user to create. Ignored if `ENABLE_USER`=false
270 Non-root user to create. Ignored if `ENABLE_USER`=false
264
271
265 ##### `ENABLE_ROOT`=false
272 ##### `ENABLE_ROOT`=false
266 Set root user password so root login will be enabled
273 Set root user password so root login will be enabled
267
274
268 ##### `ENABLE_HARDNET`=false
275 ##### `ENABLE_HARDNET`=false
269 Enable IPv4/IPv6 network stack hardening settings.
276 Enable IPv4/IPv6 network stack hardening settings.
270
277
271 ##### `ENABLE_SPLITFS`=false
278 ##### `ENABLE_SPLITFS`=false
272 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
279 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
273
280
274 ##### `CHROOT_SCRIPTS`=""
281 ##### `CHROOT_SCRIPTS`=""
275 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.
282 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.
276
283
277 ##### `ENABLE_INITRAMFS`=false
284 ##### `ENABLE_INITRAMFS`=false
278 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.
285 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.
279
286
280 ##### `ENABLE_IFNAMES`=true
287 ##### `ENABLE_IFNAMES`=true
281 Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names.
288 Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names.
282
289
283 ##### `ENABLE_SPLASH`=true
290 ##### `ENABLE_SPLASH`=true
284 Enable default Raspberry Pi boot up rainbow splash screen.
291 Enable default Raspberry Pi boot up rainbow splash screen.
285
292
286 ##### `ENABLE_LOGO`=true
293 ##### `ENABLE_LOGO`=true
287 Enable default Raspberry Pi console logo (image of four raspberries in the top left corner).
294 Enable default Raspberry Pi console logo (image of four raspberries in the top left corner).
288
295
289 ##### `ENABLE_SILENT_BOOT`=false
296 ##### `ENABLE_SILENT_BOOT`=false
290 Set the verbosity of console messages shown during boot up to a strict minimum.
297 Set the verbosity of console messages shown during boot up to a strict minimum.
291
298
292 ##### `DISABLE_UNDERVOLT_WARNINGS`=
299 ##### `DISABLE_UNDERVOLT_WARNINGS`=
293 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.
300 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.
294
301
295 ---
302 ---
296
303
297 #### SSH settings:
304 #### SSH settings:
298 ##### `SSH_ENABLE_ROOT`=false
305 ##### `SSH_ENABLE_ROOT`=false
299 Enable password-based root login via SSH. This may be a security risk with the default password set, use only in trusted environments. `ENABLE_ROOT` must be set to `true`.
306 Enable password-based root login via SSH. This may be a security risk with the default password set, use only in trusted environments. `ENABLE_ROOT` must be set to `true`.
300
307
301 ##### `SSH_DISABLE_PASSWORD_AUTH`=false
308 ##### `SSH_DISABLE_PASSWORD_AUTH`=false
302 Disable password-based SSH authentication. Only public key based SSH (v2) authentication will be supported.
309 Disable password-based SSH authentication. Only public key based SSH (v2) authentication will be supported.
303
310
304 ##### `SSH_LIMIT_USERS`=false
311 ##### `SSH_LIMIT_USERS`=false
305 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).
312 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).
306
313
307 ##### `SSH_ROOT_PUB_KEY`=""
314 ##### `SSH_ROOT_PUB_KEY`=""
308 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`.
315 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`.
309
316
310 ##### `SSH_USER_PUB_KEY`=""
317 ##### `SSH_USER_PUB_KEY`=""
311 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.
318 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.
312
319
313 ---
320 ---
314
321
315 #### Kernel compilation:
322 #### Kernel compilation:
316 ##### `BUILD_KERNEL`=true
323 ##### `BUILD_KERNEL`=true
317 Build and install the latest RPi 0/1/2/3 Linux kernel. Currently only the default RPi 0/1/2/3 kernel configuration is used.
324 Build and install the latest RPi 0/1/2/3 Linux kernel. Currently only the default RPi 0/1/2/3 kernel configuration is used.
325 Build and install the latest RPi 0/1/2/3/4 Linux kernel. The default RPi 0/1/2/3/ kernel configuration is used most of the time.
326 ENABLE_NEXMON - Changes Kernel Source to [https://github.com/Re4son/](Kali Linux Kernel)
327 Precompiled 32bit kernel for RPI0/1/2/3 by [https://github.com/hypriot/](hypriot)
328 Precompiled 64bit kernel for RPI3/4 by [https://github.com/sakaki-/](sakaki)
329
318
330
319 ##### `CROSS_COMPILE`="arm-linux-gnueabihf-"
331 ##### `CROSS_COMPILE`="arm-linux-gnueabihf-"
320 This sets the cross-compile environment for the compiler.
332 This sets the cross-compile environment for the compiler.
321
333
322 ##### `KERNEL_ARCH`="arm"
334 ##### `KERNEL_ARCH`="arm"
323 This sets the kernel architecture for the compiler.
335 This sets the kernel architecture for the compiler.
324
336
325 ##### `KERNEL_IMAGE`="kernel7.img"
337 ##### `KERNEL_IMAGE`="kernel7.img"
326 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.
338 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.
327
339
328 ##### `KERNEL_BRANCH`=""
340 ##### `KERNEL_BRANCH`=""
329 Name of the requested branch from the GIT location for the RPi Kernel. Default is using the current default branch from the GIT site.
341 Name of the requested branch from the GIT location for the RPi Kernel. Default is using the current default branch from the GIT site.
330
342
331 ##### `QEMU_BINARY`="/usr/bin/qemu-arm-static"
343 ##### `QEMU_BINARY`="/usr/bin/qemu-arm-static"
332 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.
344 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.
333
345
334 ##### `KERNEL_DEFCONFIG`="bcm2709_defconfig"
346 ##### `KERNEL_DEFCONFIG`="bcm2709_defconfig"
335 Sets the default config for kernel compiling. If not set, `KERNEL_DEFCONFIG` will be set to "bcmrpi3\_defconfig" automatically if building for arm64.
347 Sets the default config for kernel compiling. If not set, `KERNEL_DEFCONFIG` will be set to "bcmrpi3\_defconfig" automatically if building for arm64.
336
348
337 ##### `KERNEL_REDUCE`=false
349 ##### `KERNEL_REDUCE`=false
338 Reduce the size of the generated kernel by removing unwanted devices, network and filesystem drivers (experimental).
350 Reduce the size of the generated kernel by removing unwanted devices, network and filesystem drivers (experimental).
339
351
340 ##### `KERNEL_THREADS`=1
352 ##### `KERNEL_THREADS`=1
341 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.
353 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.
342
354
343 ##### `KERNEL_HEADERS`=true
355 ##### `KERNEL_HEADERS`=true
344 Install kernel headers with the built kernel.
356 Install kernel headers with the built kernel.
345
357
346 ##### `KERNEL_MENUCONFIG`=false
358 ##### `KERNEL_MENUCONFIG`=false
347 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
359 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
348
360
349 ##### `KERNEL_OLDDEFCONFIG`=false
361 ##### `KERNEL_OLDDEFCONFIG`=false
350 Run `make olddefconfig` to automatically set all new kernel configuration options to their recommended default values.
362 Run `make olddefconfig` to automatically set all new kernel configuration options to their recommended default values.
351
363
352 ##### `KERNEL_CCACHE`=false
364 ##### `KERNEL_CCACHE`=false
353 Compile the kernel using ccache. This speeds up kernel recompilation by caching previous compilations and detecting when the same compilation is being done again.
365 Compile the kernel using ccache. This speeds up kernel recompilation by caching previous compilations and detecting when the same compilation is being done again.
354
366
355 ##### `KERNEL_REMOVESRC`=true
367 ##### `KERNEL_REMOVESRC`=true
356 Remove all kernel sources from the generated OS image after it was built and installed.
368 Remove all kernel sources from the generated OS image after it was built and installed.
357
369
358 ##### `KERNELSRC_DIR`=""
370 ##### `KERNELSRC_DIR`=""
359 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.
371 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.
360
372
361 ##### `KERNELSRC_CLEAN`=false
373 ##### `KERNELSRC_CLEAN`=false
362 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.
374 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.
363
375
364 ##### `KERNELSRC_CONFIG`=true
376 ##### `KERNELSRC_CONFIG`=true
365 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.
377 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.
366
378
367 ##### `KERNELSRC_USRCONFIG`=""
379 ##### `KERNELSRC_USRCONFIG`=""
368 Copy own config file to kernel `.config`. If `KERNEL_MENUCONFIG`=true then running after copy.
380 Copy own config file to kernel `.config`. If `KERNEL_MENUCONFIG`=true then running after copy.
369
381
370 ##### `KERNELSRC_PREBUILT`=false
382 ##### `KERNELSRC_PREBUILT`=false
371 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.
383 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.
372
384
373 ##### `RPI_FIRMWARE_DIR`=""
385 ##### `RPI_FIRMWARE_DIR`=""
374 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.
386 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.
375
387
376 ##### `KERNEL_DEFAULT_GOV`="ONDEMAND"
388 ##### `KERNEL_DEFAULT_GOV`="ONDEMAND"
377 Set the default cpu governor at kernel compilation. Supported values are: PERFORMANCE POWERSAVE USERSPACE ONDEMAND CONSERVATIVE SCHEDUTIL
389 Set the default cpu governor at kernel compilation. Supported values are: PERFORMANCE POWERSAVE USERSPACE ONDEMAND CONSERVATIVE SCHEDUTIL
378
390
379 ##### `KERNEL_NF`=false
391 ##### `KERNEL_NF`=false
380 Enable Netfilter modules as kernel modules
392 Enable Netfilter modules as kernel modules
381
393
382 ##### `KERNEL_VIRT`=false
394 ##### `KERNEL_VIRT`=false
383 Enable Kernel KVM support (/dev/kvm)
395 Enable Kernel KVM support (/dev/kvm)
384
396
385 ##### `KERNEL_ZSWAP`=false
397 ##### `KERNEL_ZSWAP`=false
386 Enable Kernel Zswap support. Best use on high RAM load and mediocre CPU load usecases
398 Enable Kernel Zswap support. Best use on high RAM load and mediocre CPU load usecases
387
399
388 ##### `KERNEL_BPF`=true
400 ##### `KERNEL_BPF`=true
389 Allow attaching eBPF programs to a cgroup using the bpf syscall (CONFIG_BPF_SYSCALL CONFIG_CGROUP_BPF) [systemd compilations about it - File /lib/systemd/system/systemd-journald.server:36 configures an IP firewall (IPAddressDeny=all), but the local system does not support BPF/cgroup based firewalls]
401 Allow attaching eBPF programs to a cgroup using the bpf syscall (CONFIG_BPF_SYSCALL CONFIG_CGROUP_BPF) [systemd compilations about it - File /lib/systemd/system/systemd-journald.server:36 configures an IP firewall (IPAddressDeny=all), but the local system does not support BPF/cgroup based firewalls]
390
402
391 ##### `KERNEL_SECURITY`=false
403 ##### `KERNEL_SECURITY`=false
392 Enables Apparmor, integrity subsystem, auditing.
404 Enables Apparmor, integrity subsystem, auditing.
393
405
406 ##### `KERNEL_BTRFS`="false"
407 enable btrfs kernel support
408
409 ##### `KERNEL_POEHAT`="false"
410 enable Enable RPI POE HAT fan kernel support
411
412 ##### `KERNEL_NSPAWN`="false"
413 Enable per-interface network priority control - for systemd-nspawn
414
415 ##### `KERNEL_DHKEY`="true"
416 Diffie-Hellman operations on retained keys - required for >keyutils-1.6
417
394 ---
418 ---
395
419
396 #### Reduce disk usage:
420 #### Reduce disk usage:
397 The following list of parameters is ignored if `ENABLE_REDUCE`=false.
421 The following list of parameters is ignored if `ENABLE_REDUCE`=false.
398
422
399 ##### `REDUCE_APT`=true
423 ##### `REDUCE_APT`=true
400 Configure APT to use compressed package repository lists and no package caching files.
424 Configure APT to use compressed package repository lists and no package caching files.
401
425
402 ##### `REDUCE_DOC`=true
426 ##### `REDUCE_DOC`=true
403 Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
427 Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations.
404
428
405 ##### `REDUCE_MAN`=true
429 ##### `REDUCE_MAN`=true
406 Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
430 Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations.
407
431
408 ##### `REDUCE_VIM`=false
432 ##### `REDUCE_VIM`=false
409 Replace `vim-tiny` package by `levee` a tiny vim clone.
433 Replace `vim-tiny` package by `levee` a tiny vim clone.
410
434
411 ##### `REDUCE_BASH`=false
435 ##### `REDUCE_BASH`=false
412 Remove `bash` package and switch to `dash` shell (experimental).
436 Remove `bash` package and switch to `dash` shell (experimental).
413
437
414 ##### `REDUCE_HWDB`=true
438 ##### `REDUCE_HWDB`=true
415 Remove PCI related hwdb files (experimental).
439 Remove PCI related hwdb files (experimental).
416
440
417 ##### `REDUCE_SSHD`=true
441 ##### `REDUCE_SSHD`=true
418 Replace `openssh-server` with `dropbear`.
442 Replace `openssh-server` with `dropbear`.
419
443
420 ##### `REDUCE_LOCALE`=true
444 ##### `REDUCE_LOCALE`=true
421 Remove all `locale` translation files.
445 Remove all `locale` translation files.
422
446
423 ---
447 ---
424
448
425 #### Encrypted root partition:
449 #### Encrypted root partition:
426 ##### `ENABLE_CRYPTFS`=false
450 ##### `ENABLE_CRYPTFS`=false
427 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.
451 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.
428
452
429 ##### `CRYPTFS_PASSWORD`=""
453 ##### `CRYPTFS_PASSWORD`=""
430 Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true.
454 Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true.
431
455
432 ##### `CRYPTFS_MAPPING`="secure"
456 ##### `CRYPTFS_MAPPING`="secure"
433 Set name of dm-crypt managed device-mapper mapping.
457 Set name of dm-crypt managed device-mapper mapping.
434
458
435 ##### `CRYPTFS_CIPHER`="aes-xts-plain64:sha512"
459 ##### `CRYPTFS_CIPHER`="aes-xts-plain64:sha512"
460 ##### `CRYPTFS_CIPHER`="aes-xts-plain64"
436 Set cipher specification string. `aes-xts*` ciphers are strongly recommended.
461 Set cipher specification string. `aes-xts*` ciphers are strongly recommended.
437
462
463 ##### `CRYPTFS_HASH`=sha512
464 Hash function and size to be used
465
438 ##### `CRYPTFS_XTSKEYSIZE`=512
466 ##### `CRYPTFS_XTSKEYSIZE`=512
439 Sets key size in bits. The argument has to be a multiple of 8.
467 Sets key size in bits. The argument has to be a multiple of 8.
440
468
441 ##### `CRYPTFS_DROPBEAR`=false
469 ##### `CRYPTFS_DROPBEAR`=false
442 Enable Dropbear Initramfs support
470 Enable Dropbear Initramfs support
443
471
444 ##### `CRYPTFS_DROPBEAR_PUBKEY`=""
472 ##### `CRYPTFS_DROPBEAR_PUBKEY`=""
445 Provide path to dropbear Public RSA-OpenSSH Key
473 Provide path to dropbear Public RSA-OpenSSH Key
446
474
447 ---
475 ---
448
476
449 #### Build settings:
477 #### Build settings:
450 ##### `BASEDIR`=$(pwd)/images/${RELEASE}
478 ##### `BASEDIR`=$(pwd)/images/${RELEASE}
451 Set a path to a working directory used by the script to generate an image.
479 Set a path to a working directory used by the script to generate an image.
452
480
453 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}
481 ##### `IMAGE_NAME`=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}
454 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.
482 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.
455
483
456 ## Understanding the script
484 ## Understanding the script
457 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:
485 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:
458
486
459 | Script | Description |
487 | Script | Description |
460 | --- | --- |
488 | --- | --- |
461 | `10-bootstrap.sh` | Debootstrap basic system |
489 | `10-bootstrap.sh` | Debootstrap basic system |
462 | `11-apt.sh` | Setup APT repositories |
490 | `11-apt.sh` | Setup APT repositories |
463 | `12-locale.sh` | Setup Locales and keyboard settings |
491 | `12-locale.sh` | Setup Locales and keyboard settings |
464 | `13-kernel.sh` | Build and install RPi 0/1/2/3 Kernel |
492 | `13-kernel.sh` | Build and install RPi 0/1/2/3 Kernel |
465 | `14-fstab.sh` | Setup fstab and initramfs |
493 | `14-fstab.sh` | Setup fstab and initramfs |
466 | `15-rpi-config.sh` | Setup RPi 0/1/2/3 config and cmdline |
494 | `15-rpi-config.sh` | Setup RPi 0/1/2/3 config and cmdline |
467 | `20-networking.sh` | Setup Networking |
495 | `20-networking.sh` | Setup Networking |
468 | `21-firewall.sh` | Setup Firewall |
496 | `21-firewall.sh` | Setup Firewall |
469 | `30-security.sh` | Setup Users and Security settings |
497 | `30-security.sh` | Setup Users and Security settings |
470 | `31-logging.sh` | Setup Logging |
498 | `31-logging.sh` | Setup Logging |
471 | `32-sshd.sh` | Setup SSH and public keys |
499 | `32-sshd.sh` | Setup SSH and public keys |
472 | `41-uboot.sh` | Build and Setup U-Boot |
500 | `41-uboot.sh` | Build and Setup U-Boot |
473 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
501 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
474 | `43-videocore.sh` | Build and Setup videocore libraries |
502 | `43-videocore.sh` | Build and Setup videocore libraries |
475 | `50-firstboot.sh` | First boot actions |
503 | `50-firstboot.sh` | First boot actions |
476 | `99-reduce.sh` | Reduce the disk space usage |
504 | `99-reduce.sh` | Reduce the disk space usage |
477
505
478 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.
506 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.
479
507
480 | Directory | Description |
508 | Directory | Description |
481 | --- | --- |
509 | --- | --- |
482 | `apt` | APT management configuration files |
510 | `apt` | APT management configuration files |
483 | `boot` | Boot and RPi 0/1/2/3 configuration files |
511 | `boot` | Boot and RPi 0/1/2/3 configuration files |
484 | `dpkg` | Package Manager configuration |
512 | `dpkg` | Package Manager configuration |
485 | `etc` | Configuration files and rc scripts |
513 | `etc` | Configuration files and rc scripts |
486 | `firstboot` | Scripts that get executed on first boot |
514 | `firstboot` | Scripts that get executed on first boot |
487 | `initramfs` | Initramfs scripts |
515 | `initramfs` | Initramfs scripts |
488 | `iptables` | Firewall configuration files |
516 | `iptables` | Firewall configuration files |
489 | `locales` | Locales configuration |
517 | `locales` | Locales configuration |
490 | `modules` | Kernel Modules configuration |
518 | `modules` | Kernel Modules configuration |
491 | `mount` | Fstab configuration |
519 | `mount` | Fstab configuration |
492 | `network` | Networking configuration files |
520 | `network` | Networking configuration files |
493 | `sysctl.d` | Swapping and Network Hardening configuration |
521 | `sysctl.d` | Swapping and Network Hardening configuration |
494 | `xorg` | fbturbo Xorg driver configuration |
522 | `xorg` | fbturbo Xorg driver configuration |
495
523
496 ## Custom packages and scripts
524 ## Custom packages and scripts
497 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`.
525 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`.
498
526
499 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
527 Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created.
500
528
501 ## Logging of the bootstrapping process
529 ## Logging of the bootstrapping process
502 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:
530 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:
503
531
504 ```shell
532 ```shell
505 script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log
533 script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log
506 ```
534 ```
507
535
508 ## Flashing the image file
536 ## Flashing the image file
509 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 RPi 0/1/2/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`.
537 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 RPi 0/1/2/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`.
510
538
511 ##### Flashing examples:
539 ##### Flashing examples:
512 ```shell
540 ```shell
513 bmaptool copy ./images/buster/2017-01-23-rpi3-buster.img /dev/mmcblk0
541 bmaptool copy ./images/buster/2017-01-23-rpi3-buster.img /dev/mmcblk0
514 dd bs=4M if=./images/buster/2017-01-23-rpi3-buster.img of=/dev/mmcblk0
542 dd bs=4M if=./images/buster/2017-01-23-rpi3-buster.img of=/dev/mmcblk0
515 ```
543 ```
516 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
544 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
517 ```shell
545 ```shell
518 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-frmw.img /dev/mmcblk0
546 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-frmw.img /dev/mmcblk0
519 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-root.img /dev/sdc
547 bmaptool copy ./images/buster/2017-01-23-rpi3-buster-root.img /dev/sdc
520 ```
548 ```
521
549
522 ## QEMU emulation
550 ## QEMU emulation
523 Start QEMU full system emulation:
551 Start QEMU full system emulation:
524 ```shell
552 ```shell
525 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"
553 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"
526 ```
554 ```
527
555
528 Start QEMU full system emulation and output to console:
556 Start QEMU full system emulation and output to console:
529 ```shell
557 ```shell
530 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
558 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
531 ```
559 ```
532
560
533 Start QEMU full system emulation with SMP and output to console:
561 Start QEMU full system emulation with SMP and output to console:
534 ```shell
562 ```shell
535 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
563 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
536 ```
564 ```
537
565
538 Start QEMU full system emulation with cryptfs, initramfs and output to console:
566 Start QEMU full system emulation with cryptfs, initramfs and output to console:
539 ```shell
567 ```shell
540 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
568 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
541 ```
569 ```
542
570
543 ## External links and references
571 ## External links and references
544 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
572 * [Debian worldwide mirror sites](https://www.debian.org/mirror/list)
545 * [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2)
573 * [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2)
546 * [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains)
574 * [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains)
547 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
575 * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware)
548 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
576 * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux)
549 * [U-BOOT git repository](https://git.denx.de/?p=u-boot.git;a=summary)
577 * [U-BOOT git repository](https://git.denx.de/?p=u-boot.git;a=summary)
550 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
578 * [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo)
551 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm)
579 * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm)
552 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
580 * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/)
@@ -1,59 +1,69
1 #
1 #
2 # Setup APT repositories
2 # Setup APT repositories
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Install and setup APT proxy configuration
8 # Install and setup APT proxy configuration
9 if [ -z "$APT_PROXY" ] ; then
9 if [ -z "$APT_PROXY" ] ; then
10 install_readonly files/apt/10proxy "${ETC_DIR}/apt/apt.conf.d/10proxy"
10 install_readonly files/apt/10proxy "${ETC_DIR}/apt/apt.conf.d/10proxy"
11 sed -i "s/\"\"/\"${APT_PROXY}\"/" "${ETC_DIR}/apt/apt.conf.d/10proxy"
11 sed -i "s/\"\"/\"${APT_PROXY}\"/" "${ETC_DIR}/apt/apt.conf.d/10proxy"
12 fi
12 fi
13
13
14 if [ "$BUILD_KERNEL" = false ] ; then
14 if [ "$BUILD_KERNEL" = false ] ; then
15 # Install APT pinning configuration for flash-kernel package
15 # Install APT pinning configuration for flash-kernel package
16 install_readonly files/apt/flash-kernel "${ETC_DIR}/apt/preferences.d/flash-kernel"
16 install_readonly files/apt/flash-kernel "${ETC_DIR}/apt/preferences.d/flash-kernel"
17
17
18 # Install APT sources.list
18 # Install APT sources.list
19 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
19 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
20 echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETC_DIR}/apt/sources.list"
20 echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETC_DIR}/apt/sources.list"
21
21
22 # Upgrade collabora package index and install collabora keyring
22 # Upgrade collabora package index and install collabora keyring
23 chroot_exec apt-get -qq -y update
23 chroot_exec apt-get -qq -y update
24 # Removed --allow-unauthenticated as suggested after modification on _apt privileges
24 # Removed --allow-unauthenticated as suggested after modification on _apt privileges
25 chroot_exec apt-get -qq -y install collabora-obs-archive-keyring
25 chroot_exec apt-get -qq -y install collabora-obs-archive-keyring
26 else # BUILD_KERNEL=true
26 else # BUILD_KERNEL=true
27 # Install APT sources.list
27 # Install APT sources.list
28 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
28 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
29
29
30 # Use specified APT server and release
30 # Use specified APT server and release
31 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETC_DIR}/apt/sources.list"
31 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETC_DIR}/apt/sources.list"
32 sed -i "s/ jessie/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list"
32 sed -i "s/ jessie/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list"
33 fi
33 fi
34
34
35
35
36 # Use specified APT server and release
36 # Use specified APT server and release
37 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETC_DIR}/apt/sources.list"
37 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETC_DIR}/apt/sources.list"
38
39 #Fix for changing path for security updates in testing/bullseye
40 if [ "$RELEASE" = "testing" ] ; then
41 sed -i "s,stretch\\/updates,testing-security," "${ETC_DIR}/apt/sources.list"
38 sed -i "s/ stretch/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list"
42 sed -i "s/ stretch/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list"
43 fi
44
45 if [ -z "$RELEASE" ] ; then
46 # Change release in sources list
47 sed -i "s/ stretch/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list"
48 fi
39
49
40 # Upgrade package index and update all installed packages and changed dependencies
50 # Upgrade package index and update all installed packages and changed dependencies
41 chroot_exec apt-get -qq -y update
51 chroot_exec apt-get -qq -y update
42 chroot_exec apt-get -qq -y -u dist-upgrade
52 chroot_exec apt-get -qq -y -u dist-upgrade
43
53
44 # Install additional packages
54 # Install additional packages
45 if [ "$APT_INCLUDES_LATE" ] ; then
55 if [ "$APT_INCLUDES_LATE" ] ; then
46 chroot_exec apt-get -qq -y install $(echo "$APT_INCLUDES_LATE" |tr , ' ')
56 chroot_exec apt-get -qq -y install $(echo "$APT_INCLUDES_LATE" |tr , ' ')
47 fi
57 fi
48
58
49 # Install Debian custom packages
59 # Install Debian custom packages
50 if [ -d packages ] ; then
60 if [ -d packages ] ; then
51 for package in packages/*.deb ; do
61 for package in packages/*.deb ; do
52 cp "$package" "${R}"/tmp
62 cp "$package" "${R}"/tmp
53 chroot_exec dpkg --unpack /tmp/"$(basename "$package")"
63 chroot_exec dpkg --unpack /tmp/"$(basename "$package")"
54 done
64 done
55 fi
65 fi
56
66
57 chroot_exec apt-get -qq -y -f install
67 chroot_exec apt-get -qq -y -f install
58
68
59 chroot_exec apt-get -qq -y check
69 chroot_exec apt-get -qq -y check
@@ -1,116 +1,122
1 #
1 #
2 # Setup fstab and initramfs
2 # Setup fstab and initramfs
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Install and setup fstab
8 # Install and setup fstab
9 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
9 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
10
10
11 # Add usb/sda disk root partition to fstab
11 # Generate initramfs file
12 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
12 if [ "$ENABLE_INITRAMFS" = true ] ; then
13 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
13 if [ "$ENABLE_CRYPTFS" = true ] ; then
14
15 # Include initramfs scripts to auto expand encrypted root partition
16 if [ "$EXPANDROOT" = true ] ; then
17 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
18 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
19 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
14 fi
20 fi
15
21
16 # Add encrypted root partition to fstab and crypttab
17 if [ "$ENABLE_CRYPTFS" = true ] ; then
18 # Replace fstab root partition with encrypted partition mapping
22 # Replace fstab root partition with encrypted partition mapping
19 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
23 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
20
24
21 # Add encrypted partition to crypttab and fstab
25 # Add encrypted partition to crypttab and fstab
22 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
26 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
23 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab"
27 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab"
24
28
25 if [ "$ENABLE_SPLITFS" = true ] ; then
29 if [ "$ENABLE_USBBOOT" = true ] && [ "$ENABLE_SPLITFS" = false ]; then
26 # Add usb/sda1 disk to crypttab
27 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
28 fi
29 fi
30
31 if [ "$ENABLE_USBBOOT" = true ] ; then
32 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
30 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
33 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab"
34
35 # Add usb/sda2 disk to crypttab
31 # Add usb/sda2 disk to crypttab
36 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/crypttab"
32 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/crypttab"
37 fi
33 fi
38
34
39 # Generate initramfs file
35 # Add encrypted root partition to fstab and crypttab
40 if [ "$ENABLE_INITRAMFS" = true ] ; then
36 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_USBBOOT" = false ]; then
41 if [ "$ENABLE_CRYPTFS" = true ] ; then
37 # Add usb/sda1 disk to crypttab
42 # Include initramfs scripts to auto expand encrypted root partition
38 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
43 if [ "$EXPANDROOT" = true ] ; then
44 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
45 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
46 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
47 fi
39 fi
48
40
41 if [ "$CRYPTFS_DROPBEAR" = true ]; then
49 if [ "$ENABLE_DHCP" = false ] ; then
42 if [ "$ENABLE_DHCP" = false ] ; then
50 # Get cdir from NET_ADDRESS e.g. 24
43 # Get cdir from NET_ADDRESS e.g. 24
51 cdir=$(${NET_ADDRESS} | cut -d '/' -f2)
44 cdir=$(printf "%s" "${NET_ADDRESS}" | cut -d '/' -f2)
52
45
53 # Convert cdir ro netmask e.g. 24 to 255.255.255.0
46 # Convert cdir ro netmask e.g. 24 to 255.255.255.0
54 NET_MASK=$(cdr2mask "$cdir")
47 NET_MASK=$(cdr2mask "$cdir")
55
48
56 # Write static ip settings to "${ETC_DIR}"/initramfs-tools/initramfs.conf
49 # Write static ip settings to "${ETC_DIR}"/initramfs-tools/initramfs.conf
57 sed -i "\$aIP=${NET_ADDRESS}::${NET_GATEWAY}:${NET_MASK}:${HOSTNAME}:" "${ETC_DIR}"/initramfs-tools/initramfs.conf
50 # ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
58
51 sed -i "\$a\nIP=${NET_ADDRESS}::${NET_GATEWAY}:${NET_MASK}:${HOSTNAME}:" "${ETC_DIR}"/initramfs-tools/initramfs.conf
59 # Regenerate initramfs
52 else
60 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
53 sed -i "\$a\nIP=::::${HOSTNAME}::dhcp" "${ETC_DIR}"/initramfs-tools/initramfs.conf
61 fi
54 fi
62
55
63 if [ "$CRYPTFS_DROPBEAR" = true ]; then
64 if [ -n "$CRYPTFS_DROPBEAR_PUBKEY" ] && [ -f "$CRYPTFS_DROPBEAR_PUBKEY" ] ; then
56 if [ -n "$CRYPTFS_DROPBEAR_PUBKEY" ] && [ -f "$CRYPTFS_DROPBEAR_PUBKEY" ] ; then
65 install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
57 install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
66 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub >> "${ETC_DIR}"/dropbear-initramfs/authorized_keys
58 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub >> "${ETC_DIR}"/dropbear-initramfs/authorized_keys
67 else
59 else
68 # Create key
60 # Create key
69 chroot_exec /usr/bin/dropbearkey -t rsa -f /etc/dropbear-initramfs/id_rsa.dropbear
61 chroot_exec /usr/bin/dropbearkey -t rsa -f /etc/dropbear-initramfs/id_rsa.dropbear
70
62
71 # Convert dropbear key to openssh key
63 # Convert dropbear key to openssh key
72 chroot_exec /usr/lib/dropbear/dropbearconvert dropbear openssh /etc/dropbear-initramfs/id_rsa.dropbear /etc/dropbear-initramfs/id_rsa
64 chroot_exec /usr/lib/dropbear/dropbearconvert dropbear openssh /etc/dropbear-initramfs/id_rsa.dropbear /etc/dropbear-initramfs/id_rsa
73
65
74 # Get Public Key Part
66 # Get Public Key Part
75 chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub
67 chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub
76
68
77 # Delete unwanted lines
69 # Delete unwanted lines
78 sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
70 sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
79 sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
71 sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
80
72
81 # Trust the new key
73 # Trust the new key
82 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub > "${ETC_DIR}"/dropbear-initramfs/authorized_keys
74 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub > "${ETC_DIR}"/dropbear-initramfs/authorized_keys
83
75
84 # Save Keys - convert with putty from rsa/openssh to puttkey
76 # Save Keys - convert with putty from rsa/openssh to puttkey
85 cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa
77 cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa
86
78
87 # Get unlock script
79 # Get unlock script
88 install_exec files/initramfs/crypt_unlock.sh "${ETC_DIR}"/initramfs-tools/hooks/crypt_unlock.sh
80 install_exec files/initramfs/crypt_unlock.sh "${ETC_DIR}"/initramfs-tools/hooks/crypt_unlock.sh
89
81
90 # Enable Dropbear inside initramfs
82 # Enable Dropbear inside initramfs
91 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=y\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
83 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=y\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
92
84
93 # Enable Dropbear inside initramfs
85 # Enable Dropbear inside initramfs
94 sed -i "54 i sleep 5" "${R}"/usr/share/initramfs-tools/scripts/init-premount/dropbear
86 sed -i "54 i sleep 5" "${R}"/usr/share/initramfs-tools/scripts/init-premount/dropbear
95 fi
87 fi
88 # CRYPTFSDROPBEAR=false
96 else
89 else
97 # Disable SSHD inside initramfs
90 # Disable SSHD inside initramfs
98 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
91 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
99 fi
92 fi
100
93
101 # Add cryptsetup modules to initramfs
94 # Add cryptsetup modules to initramfs
102 printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
95 printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
96 #printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
103
97
104 # Dummy mapping required by mkinitramfs
98 # Dummy mapping required by mkinitramfs
105 echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
99 echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
100 echo "0 1 crypt "${CRYPTFS_CIPHER}" ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
106
101
107 # Generate initramfs with encrypted root partition support
102 # Generate initramfs with encrypted root partition support
108 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
103 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
109
104
110 # Remove dummy mapping
105 # Remove dummy mapping
111 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
106 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
107 # CRYPTFS=false
112 else
108 else
109 #USB BOOT /boot on sda1 / on sda2
110 if [ "$ENABLE_USBBOOT" = true ] ; then
111 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
112 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab"
113 fi
114
115 # Add usb/sda disk root partition to fstab
116 if [ "$ENABLE_SPLITFS" = true ] ; then
117 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
118 fi
113 # Generate initramfs without encrypted root partition support
119 # Generate initramfs without encrypted root partition support
114 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
120 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
115 fi
121 fi
116 fi
122 fi
@@ -1,300 +1,311
1 #
1 #
2 # Setup RPi2/3 config and cmdline
2 # Setup RPi2/3 config and cmdline
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
8 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
9 # Install boot binaries from local directory
9 # Install boot binaries from local directory
10 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
10 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
11 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
11 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
14 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
14 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
15 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
15 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
17 else
17 else
18 # Create temporary directory for boot binaries
18 # Create temporary directory for boot binaries
19 temp_dir=$(as_nobody mktemp -d)
19 temp_dir=$(as_nobody mktemp -d)
20
20
21 # Install latest boot binaries from raspberry/firmware github
21 # Install latest boot binaries from raspberry/firmware github
22 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
22 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
23 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
23 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
24 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
24 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
26 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
26 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
27 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
27 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
28 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
28 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
29
29
30 # Move downloaded boot binaries
30 # Move downloaded boot binaries
31 mv "${temp_dir}/"* "${BOOT_DIR}/"
31 mv "${temp_dir}/"* "${BOOT_DIR}/"
32
32
33 # Remove temporary directory for boot binaries
33 # Remove temporary directory for boot binaries
34 rm -fr "${temp_dir}"
34 rm -fr "${temp_dir}"
35
35
36 # Set permissions of the boot binaries
36 # Set permissions of the boot binaries
37 chown -R root:root "${BOOT_DIR}"
37 chown -R root:root "${BOOT_DIR}"
38 chmod -R 600 "${BOOT_DIR}"
38 chmod -R 600 "${BOOT_DIR}"
39 fi
39 fi
40
40
41 # Setup firmware boot cmdline
41 # Setup firmware boot cmdline
42 if [ "$ENABLE_USBBOOT" = true ] ; then
42 if [ "$ENABLE_USBBOOT" = true ] ; then
43 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
43 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
44 else
44 else
45 if [ "$ENABLE_SPLITFS" = true ] ; then
45 if [ "$ENABLE_SPLITFS" = true ] ; then
46 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
46 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
47 else
47 else
48 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
48 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd"
49 fi
49 fi
50 fi
50 fi
51
51
52 # Add encrypted root partition to cmdline.txt
52 # Add encrypted root partition to cmdline.txt
53 if [ "$ENABLE_CRYPTFS" = true ] ; then
53 if [ "$ENABLE_CRYPTFS" = true ] ; then
54 if [ "$ENABLE_SPLITFS" = true ] ; then
54 if [ "$ENABLE_SPLITFS" = true ] ; then
55 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
55 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
56 else
56 else
57 if [ "$ENABLE_USBBOOT" = true ] ; then
57 if [ "$ENABLE_USBBOOT" = true ] ; then
58 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/")
58 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/")
59 else
59 else
60 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
60 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
61 fi
61 fi
62 fi
62 fi
63 fi
63 fi
64
64
65 # Enable Kernel messages on standard output
65 # Enable Kernel messages on standard output
66 if [ "$ENABLE_PRINTK" = true ] ; then
66 if [ "$ENABLE_PRINTK" = true ] ; then
67 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
67 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
68 fi
68 fi
69
69
70 # Enable Kernel messages on standard output
70 # Enable Kernel messages on standard output
71 if [ "$KERNEL_SECURITY" = true ] ; then
71 if [ "$KERNEL_SECURITY" = true ] ; then
72 install_readonly files/sysctl.d/84-rpi-ASLR.conf "${ETC_DIR}/sysctl.d/84-rpi-ASLR.conf"
72 install_readonly files/sysctl.d/84-rpi-ASLR.conf "${ETC_DIR}/sysctl.d/84-rpi-ASLR.conf"
73 fi
73 fi
74
74
75 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
75 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
76 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
76 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
77
77
78 # Remove IPv6 networking support
78 # Remove IPv6 networking support
79 if [ "$ENABLE_IPV6" = false ] ; then
79 if [ "$ENABLE_IPV6" = false ] ; then
80 CMDLINE="${CMDLINE} ipv6.disable=1"
80 CMDLINE="${CMDLINE} ipv6.disable=1"
81 fi
81 fi
82
82
83 # Automatically assign predictable network interface names
83 # Automatically assign predictable network interface names
84 if [ "$ENABLE_IFNAMES" = false ] ; then
84 if [ "$ENABLE_IFNAMES" = false ] ; then
85 CMDLINE="${CMDLINE} net.ifnames=0"
85 CMDLINE="${CMDLINE} net.ifnames=0"
86 else
86 else
87 CMDLINE="${CMDLINE} net.ifnames=1"
87 CMDLINE="${CMDLINE} net.ifnames=1"
88 fi
88 fi
89
89
90 # Disable Raspberry Pi console logo
90 # Disable Raspberry Pi console logo
91 if [ "$ENABLE_LOGO" = false ] ; then
91 if [ "$ENABLE_LOGO" = false ] ; then
92 CMDLINE="${CMDLINE} logo.nologo"
92 CMDLINE="${CMDLINE} logo.nologo"
93 fi
93 fi
94
94
95 # Strictly limit verbosity of boot up console messages
95 # Strictly limit verbosity of boot up console messages
96 if [ "$ENABLE_SILENT_BOOT" = true ] ; then
96 if [ "$ENABLE_SILENT_BOOT" = true ] ; then
97 CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0"
97 CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0"
98 fi
98 fi
99
99
100 # Install firmware config
100 # Install firmware config
101 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
101 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
102
102
103 # Disable Raspberry Pi console logo
103 # Disable Raspberry Pi console logo
104 if [ "$ENABLE_SLASH" = false ] ; then
104 if [ "$ENABLE_SLASH" = false ] ; then
105 echo "disable_splash=1" >> "${BOOT_DIR}/config.txt"
105 echo "disable_splash=1" >> "${BOOT_DIR}/config.txt"
106 fi
106 fi
107
107
108 # Locks CPU frequency at maximum
108 # Locks CPU frequency at maximum
109 if [ "$ENABLE_TURBO" = true ] ; then
109 if [ "$ENABLE_TURBO" = true ] ; then
110 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
110 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
111 # helps to avoid sdcard corruption when force_turbo is enabled.
111 # helps to avoid sdcard corruption when force_turbo is enabled.
112 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
112 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
113 fi
113 fi
114
114
115 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
115 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
116 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; then
116
117
117 # Bluetooth enabled
118 # Bluetooth enabled
118 if [ "$ENABLE_BLUETOOTH" = true ] ; then
119 if [ "$ENABLE_BLUETOOTH" = true ] ; then
119 # Create temporary directory for Bluetooth sources
120 # Create temporary directory for Bluetooth sources
120 temp_dir=$(as_nobody mktemp -d)
121 temp_dir=$(as_nobody mktemp -d)
121
122
122 # Fetch Bluetooth sources
123 # Fetch Bluetooth sources
123 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
124 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
124
125
125 # Copy downloaded sources
126 # Copy downloaded sources
126 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
127 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
127
128
128 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
129 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
129 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
130 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
130 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd
131 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd
131
132
132 # Set permissions
133 # Set permissions
133 chown -R root:root "${R}/tmp/pi-bluetooth"
134 chown -R root:root "${R}/tmp/pi-bluetooth"
134
135
136 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
137 wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
138 wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd
139
135 # Install tools
140 # Install tools
136 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
141 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
137 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
142 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
138
143
139 # make scripts executable
144 # make scripts executable
140 chmod +x "${R}/usr/bin/bthelper"
145 chmod +x "${R}/usr/bin/bthelper"
141 chmod +x "${R}/usr/bin/btuart"
146 chmod +x "${R}/usr/bin/btuart"
142
147
143 # Install bluetooth udev rule
148 # Install bluetooth udev rule
144 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
149 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
145
150
146 # Install Firmware Flash file and apropiate licence
151 # Install Firmware Flash file and apropiate licence
147 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
152 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
148 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
153 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
149 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd"
154 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd"
150 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
155 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
151 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
156 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
152
157
153 # Remove temporary directories
158 # Remove temporary directories
154 rm -fr "${temp_dir}"
159 rm -fr "${temp_dir}"
155 rm -fr "${R}"/tmp/pi-bluetooth
160 rm -fr "${R}"/tmp/pi-bluetooth
156
161
157 # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0
162 # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0
158 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
163 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
159 # set overlay to swap ttyAMA0 and ttyS0
164 # set overlay to swap ttyAMA0 and ttyS0
160 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
165 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
161
166
162 if [ "$ENABLE_TURBO" = false ] ; then
167 if [ "$ENABLE_TURBO" = false ] ; then
163 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
168 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
164 fi
169 fi
165
170
166 fi
171 fi
167
172
168 # Activate services
173 # Activate services
169 chroot_exec systemctl enable pi-bluetooth.hciuart.service
174 chroot_exec systemctl enable pi-bluetooth.hciuart.service
170
175
171 else # if ENABLE_BLUETOOTH = false
176 else # if ENABLE_BLUETOOTH = false
172 # set overlay to disable bluetooth
177 # set overlay to disable bluetooth
173 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
178 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
174 fi # ENABLE_BLUETOOTH end
179 fi # ENABLE_BLUETOOTH end
175 fi
180 fi
176
181
177 # may need sudo systemctl disable hciuart
182 # may need sudo systemctl disable hciuart
178 if [ "$ENABLE_CONSOLE" = true ] ; then
183 if [ "$ENABLE_CONSOLE" = true ] ; then
179 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
184 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
180 # add string to cmdline
185 # add string to cmdline
181 CMDLINE="${CMDLINE} console=serial0,115200"
186 CMDLINE="${CMDLINE} console=serial0,115200"
182
187
183 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then
188 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then
184 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
189 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
185 if [ "$ENABLE_TURBO" = false ] ; then
190 if [ "$ENABLE_TURBO" = false ] ; then
186 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
191 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
187 fi
192 fi
188 fi
193 fi
189
194
190 # Enable serial console systemd style
195 # Enable serial console systemd style
191 chroot_exec systemctl enable serial-getty@serial0.service
196 chroot_exec systemctl enable serial-getty@serial0.service
192 else
197 else
193 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
198 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
194 fi
199 fi
195
200
196 # Disable dphys-swapfile service. Will get enabled on first boot
201 # Disable dphys-swapfile service. Will get enabled on first boot
197 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
202 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
198 chroot_exec systemctl disable dphys-swapfile
203 chroot_exec systemctl disable dphys-swapfile
199 fi
204 fi
200
205
201 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
206 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
202 # Create temporary directory for systemd-swap sources
207 # Create temporary directory for systemd-swap sources
203 temp_dir=$(as_nobody mktemp -d)
208 temp_dir=$(as_nobody mktemp -d)
204
209
205 # Fetch systemd-swap sources
210 # Fetch systemd-swap sources
206 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
211 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
207
212
208 # Copy downloaded systemd-swap sources
213 # Copy downloaded systemd-swap sources
209 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
214 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
210
215
211 # Change into downloaded src dir
216 # Change into downloaded src dir
212 cd "${R}/tmp/systemd-swap" || exit
217 cd "${R}/tmp/systemd-swap" || exit
213
218
219
220 # Get Verion
221 VERSION=$(git tag | tail -n 1)
222 #sed -i "s/DEB_NAME=.*/DEB_NAME=systemd-swap_all/g" "${R}/tmp/systemd-swap/package.sh"
223
214 # Build package
224 # Build package
215 bash ./package.sh debian
225 bash ./package.sh debian
216
226
217 # Change back into script root dir
227 # Change back into script root dir
218 cd "${WORKDIR}" || exit
228 cd "${WORKDIR}" || exit
219
229
220 # Set permissions of the systemd-swap sources
230 # Set permissions of the systemd-swap sources
221 chown -R root:root "${R}/tmp/systemd-swap"
231 chown -R root:root "${R}/tmp/systemd-swap"
222
232
223 # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR.
233 # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR.
224 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_4.0.1_any.deb
234 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_4.0.1_any.deb
235 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_"$VERSION"_all.deb
225
236
226 # Enable service
237 # Enable service
227 chroot_exec systemctl enable systemd-swap
238 chroot_exec systemctl enable systemd-swap
228
239
229 # Remove temporary directory for systemd-swap sources
240 # Remove temporary directory for systemd-swap sources
230 rm -fr "${temp_dir}"
241 rm -fr "${temp_dir}"
231 else
242 else
232 # Enable ZSWAP in cmdline if systemd-swap is not used
243 # Enable ZSWAP in cmdline if systemd-swap is not used
233 if [ "$KERNEL_ZSWAP" = true ] ; then
244 if [ "$KERNEL_ZSWAP" = true ] ; then
234 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
245 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
235 fi
246 fi
236 fi
247 fi
237 if [ "$KERNEL_SECURITY" = true ] ; then
248 if [ "$KERNEL_SECURITY" = true ] ; then
238 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
249 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
239 fi
250 fi
240
251
241 # Install firmware boot cmdline
252 # Install firmware boot cmdline
242 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
253 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
243
254
244 # Setup minimal GPU memory allocation size: 16MB (no X)
255 # Setup minimal GPU memory allocation size: 16MB (no X)
245 if [ "$ENABLE_MINGPU" = true ] ; then
256 if [ "$ENABLE_MINGPU" = true ] ; then
246 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
257 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
247 fi
258 fi
248
259
249 # Setup boot with initramfs
260 # Setup boot with initramfs
250 if [ "$ENABLE_INITRAMFS" = true ] ; then
261 if [ "$ENABLE_INITRAMFS" = true ] ; then
251 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
262 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
252 fi
263 fi
253
264
254 # Create firmware configuration and cmdline symlinks
265 # Create firmware configuration and cmdline symlinks
255 ln -sf firmware/config.txt "${R}/boot/config.txt"
266 ln -sf firmware/config.txt "${R}/boot/config.txt"
256 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
267 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
257
268
258 # Install and setup kernel modules to load at boot
269 # Install and setup kernel modules to load at boot
259 mkdir -p "${LIB_DIR}/modules-load.d/"
270 mkdir -p "${LIB_DIR}/modules-load.d/"
260 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
271 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
261
272
262 # Load hardware random module at boot
273 # Load hardware random module at boot
263 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
274 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
264 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
275 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
265 fi
276 fi
266
277
267 # Load sound module at boot
278 # Load sound module at boot
268 if [ "$ENABLE_SOUND" = true ] ; then
279 if [ "$ENABLE_SOUND" = true ] ; then
269 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
280 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
270 else
281 else
271 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
282 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
272 fi
283 fi
273
284
274 # Enable I2C interface
285 # Enable I2C interface
275 if [ "$ENABLE_I2C" = true ] ; then
286 if [ "$ENABLE_I2C" = true ] ; then
276 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
287 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
277 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
288 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
278 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
289 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
279 fi
290 fi
280
291
281 # Enable SPI interface
292 # Enable SPI interface
282 if [ "$ENABLE_SPI" = true ] ; then
293 if [ "$ENABLE_SPI" = true ] ; then
283 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
294 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
284 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
295 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
285 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
296 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
286 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
297 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
287 fi
298 fi
288 fi
299 fi
289
300
290 # Disable RPi2/3 under-voltage warnings
301 # Disable RPi2/3 under-voltage warnings
291 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
302 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
292 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
303 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
293 fi
304 fi
294
305
295 # Install kernel modules blacklist
306 # Install kernel modules blacklist
296 mkdir -p "${ETC_DIR}/modprobe.d/"
307 mkdir -p "${ETC_DIR}/modprobe.d/"
297 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
308 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
298
309
299 # Install sysctl.d configuration files
310 # Install sysctl.d configuration files
300 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
311 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
@@ -1,136 +1,137
1 #
1 #
2 # Setup Networking
2 # Setup Networking
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Install and setup hostname
8 # Install and setup hostname
9 install_readonly files/network/hostname "${ETC_DIR}/hostname"
9 install_readonly files/network/hostname "${ETC_DIR}/hostname"
10 sed -i "s/^RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hostname"
10 sed -i "s/^RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hostname"
11
11
12 # Install and setup hosts
12 # Install and setup hosts
13 install_readonly files/network/hosts "${ETC_DIR}/hosts"
13 install_readonly files/network/hosts "${ETC_DIR}/hosts"
14 sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts"
14 sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts"
15
15
16 # Setup hostname entry with static IP
16 # Setup hostname entry with static IP
17 if [ "$NET_ADDRESS" != "" ] ; then
17 if [ "$NET_ADDRESS" != "" ] ; then
18 NET_IP=$(echo "${NET_ADDRESS}" | cut -f 1 -d'/')
18 NET_IP=$(echo "${NET_ADDRESS}" | cut -f 1 -d'/')
19 sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/hosts"
19 sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/hosts"
20 fi
20 fi
21
21
22 # Remove IPv6 hosts
22 # Remove IPv6 hosts
23 if [ "$ENABLE_IPV6" = false ] ; then
23 if [ "$ENABLE_IPV6" = false ] ; then
24 sed -i -e "/::[1-9]/d" -e "/^$/d" "${ETC_DIR}/hosts"
24 sed -i -e "/::[1-9]/d" -e "/^$/d" "${ETC_DIR}/hosts"
25 fi
25 fi
26
26
27 # Install hint about network configuration
27 # Install hint about network configuration
28 install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces"
28 install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces"
29
29
30 # Install configuration for interface eth0
30 # Install configuration for interface eth0
31 install_readonly files/network/eth.network "${ETC_DIR}/systemd/network/eth.network"
31 install_readonly files/network/eth.network "${ETC_DIR}/systemd/network/eth.network"
32
32
33 if [ "$RPI_MODEL" = 3P ] ; then
33 if [ "$RPI_MODEL" = 3P ] ; then
34 printf "\n[Link]\nGenericReceiveOffload=off\nTCPSegmentationOffload=off\nGenericSegmentationOffload=off" >> "${ETC_DIR}/systemd/network/eth.network"
34 printf "\n[Link]\nGenericReceiveOffload=off\nTCPSegmentationOffload=off\nGenericSegmentationOffload=off" >> "${ETC_DIR}/systemd/network/eth.network"
35 fi
35 fi
36
36
37 # Install configuration for interface wl*
37 # Install configuration for interface wl*
38 install_readonly files/network/wlan.network "${ETC_DIR}/systemd/network/wlan.network"
38 install_readonly files/network/wlan.network "${ETC_DIR}/systemd/network/wlan.network"
39
39
40 #always with dhcp since wpa_supplicant integration is missing
40 #always with dhcp since wpa_supplicant integration is missing
41 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan.network"
41 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan.network"
42
42
43 if [ "$ENABLE_DHCP" = true ] ; then
43 if [ "$ENABLE_DHCP" = true ] ; then
44 # Enable DHCP configuration for interface eth0
44 # Enable DHCP configuration for interface eth0
45 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network"
45 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network"
46
46
47 # Set DHCP configuration to IPv4 only
47 # Set DHCP configuration to IPv4 only
48 if [ "$ENABLE_IPV6" = false ] ; then
48 if [ "$ENABLE_IPV6" = false ] ; then
49 sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network"
49 sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network"
50 fi
50 fi
51
51
52 else # ENABLE_DHCP=false
52 else # ENABLE_DHCP=false
53 # Set static network configuration for interface eth0
53 # Set static network configuration for interface eth0
54 sed -i\
54 sed -i\
55 -e "s|DHCP=.*|DHCP=no|"\
55 -e "s|DHCP=.*|DHCP=no|"\
56 -e "s|Address=\$|Address=${NET_ADDRESS}|"\
56 -e "s|Address=\$|Address=${NET_ADDRESS}|"\
57 -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\
57 -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\
58 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\
58 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\
59 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\
59 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\
60 -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\
60 -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\
61 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\
61 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\
62 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\
62 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\
63 "${ETC_DIR}/systemd/network/eth.network"
63 "${ETC_DIR}/systemd/network/eth.network"
64 fi
64 fi
65
65
66 # Remove empty settings from network configuration
66 # Remove empty settings from network configuration
67 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network"
67 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network"
68 # Remove empty settings from wlan configuration
68 # Remove empty settings from wlan configuration
69 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network"
69 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network"
70
70
71 # Move systemd network configuration if required by Debian release
71 # Move systemd network configuration if required by Debian release
72 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
72 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
73 # If WLAN is enabled copy wlan configuration too
73 # If WLAN is enabled copy wlan configuration too
74 if [ "$ENABLE_WIRELESS" = true ] ; then
74 if [ "$ENABLE_WIRELESS" = true ] ; then
75 mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network"
75 mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network"
76 fi
76 fi
77 rm -fr "${ETC_DIR}/systemd/network"
77 rm -fr "${ETC_DIR}/systemd/network"
78
78
79 # Enable systemd-networkd service
79 # Enable systemd-networkd service
80 chroot_exec systemctl enable systemd-networkd
80 chroot_exec systemctl enable systemd-networkd
81
81
82 # Install host.conf resolver configuration
82 # Install host.conf resolver configuration
83 install_readonly files/network/host.conf "${ETC_DIR}/host.conf"
83 install_readonly files/network/host.conf "${ETC_DIR}/host.conf"
84
84
85 # Enable network stack hardening
85 # Enable network stack hardening
86 if [ "$ENABLE_HARDNET" = true ] ; then
86 if [ "$ENABLE_HARDNET" = true ] ; then
87 # Install sysctl.d configuration files
87 # Install sysctl.d configuration files
88 install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf"
88 install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf"
89
89
90 # Setup resolver warnings about spoofed addresses
90 # Setup resolver warnings about spoofed addresses
91 sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf"
91 sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf"
92 fi
92 fi
93
93
94 # Enable time sync
94 # Enable time sync
95 if [ "$NET_NTP_1" != "" ] ; then
95 if [ "$NET_NTP_1" != "" ] ; then
96 chroot_exec systemctl enable systemd-timesyncd.service
96 chroot_exec systemctl enable systemd-timesyncd.service
97 fi
97 fi
98
98
99 # Download the firmware binary blob required to use the RPi3 wireless interface
99 # Download the firmware binary blob required to use the RPi3 wireless interface
100 if [ "$ENABLE_WIRELESS" = true ] ; then
100 if [ "$ENABLE_WIRELESS" = true ] ; then
101 if [ ! -d "${WLAN_FIRMWARE_DIR}" ] ; then
101 if [ ! -d "${WLAN_FIRMWARE_DIR}" ] ; then
102 mkdir -p "${WLAN_FIRMWARE_DIR}"
102 mkdir -p "${WLAN_FIRMWARE_DIR}"
103 fi
103 fi
104
104
105 # Create temporary directory for firmware binary blob
105 # Create temporary directory for firmware binary blob
106 temp_dir=$(as_nobody mktemp -d)
106 temp_dir=$(as_nobody mktemp -d)
107
107
108 # Fetch firmware binary blob for RPI3B+
108 # Fetch firmware binary blob for RPI3B+
109 if [ "$RPI_MODEL" = 3P ] ; then
109 if [ "$RPI_MODEL" = 3P ] ; then
110 if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
110 # Fetch firmware binary blob for RPi3P
111 # Fetch firmware binary blob for RPi3P
111 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin"
112 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin"
112 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt"
113 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt"
113 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob"
114 as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob"
114
115
115 # Move downloaded firmware binary blob
116 # Move downloaded firmware binary blob
116 mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/"
117 mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/"
117
118
118 # Set permissions of the firmware binary blob
119 # Set permissions of the firmware binary blob
119 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
120 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
120 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
121 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."*
121 elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then
122 elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then
122 # Fetch firmware binary blob for RPi3
123 # Fetch firmware binary blob for RPi3
123 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin"
124 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin"
124 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt"
125 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt"
125
126
126 # Move downloaded firmware binary blob
127 # Move downloaded firmware binary blob
127 mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/"
128 mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/"
128
129
129 # Set permissions of the firmware binary blob
130 # Set permissions of the firmware binary blob
130 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
131 chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
131 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
132 chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."*
132 fi
133 fi
133
134
134 # Remove temporary directory for firmware binary blob
135 # Remove temporary directory for firmware binary blob
135 rm -fr "${temp_dir}"
136 rm -fr "${temp_dir}"
136 fi
137 fi
@@ -1,56 +1,58
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 videocore sources
11 # Copy local videocore sources
12 cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp/userland"
12 cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp/userland"
13 else
13 else
14 # Create temporary directory for videocore sources
14 # Create temporary directory for videocore sources
15 temp_dir=$(as_nobody mktemp -d)
15 temp_dir=$(as_nobody mktemp -d)
16
16
17 # Fetch videocore sources
17 # Fetch videocore 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 videocore sources
20 # Copy downloaded videocore 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 # Create build dir
30 # Create build dir
31 mkdir "${R}"/tmp/userland/build
31 mkdir "${R}"/tmp/userland/build
32
32
33 # push us to build directory
33 # push us to build directory
34 cd "${R}"/tmp/userland/build
34 cd "${R}"/tmp/userland/build
35
35
36 if [ "$RELEASE_ARCH" = "arm64" ] ; then
36 if [ "$RELEASE_ARCH" = "arm64" ] ; then
37 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}" "${R}/tmp/userland"
37 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}" "${R}/tmp/userland"
38 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/aarch64-linux-gnu.cmake -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}" "${R}/tmp/userland"
38 fi
39 fi
39
40
40 if [ "$RELEASE_ARCH" = "armel" ] ; then
41 if [ "$RELEASE_ARCH" = "armel" ] ; then
41 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}" "${R}/tmp/userland"
42 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}" "${R}/tmp/userland"
43 cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -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}" "${R}/tmp/userland"
42 fi
44 fi
43
45
44 if [ "$RELEASE_ARCH" = "armhf" ] ; then
46 if [ "$RELEASE_ARCH" = "armhf" ] ; then
45 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}" "${R}/tmp/userland"
47 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}" "${R}/tmp/userland"
46 fi
48 fi
47
49
48 #build userland
50 #build userland
49 make -j "$(nproc)"
51 make -j "$(nproc)"
50
52
51 #back to root of scriptdir
53 #back to root of scriptdir
52 cd "${WORKDIR}"
54 cd "${WORKDIR}"
53
55
54 # Remove videocore sources
56 # Remove videocore sources
55 rm -fr "${R}"/tmp/userland/
57 rm -fr "${R}"/tmp/userland/
56 fi
58 fi
@@ -1,97 +1,98
1 #!/bin/sh
1 #!/bin/sh
2 #
2 #
3 # Build and Setup nexmon with monitor mode patch
3 # Build and Setup nexmon with monitor mode patch
4 #
4 #
5
5
6 # Load utility functions
6 # Load utility functions
7 . ./functions.sh
7 . ./functions.sh
8
8
9 if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then
9 if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then
10 # Copy existing nexmon sources into chroot directory
10 # Copy existing nexmon sources into chroot directory
11 if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then
11 if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then
12 # Copy local U-Boot sources
12 # Copy local U-Boot sources
13 cp -r "${NEXMONSRC_DIR}" "${R}/tmp"
13 cp -r "${NEXMONSRC_DIR}" "${R}/tmp"
14 else
14 else
15 # Create temporary directory for nexmon sources
15 # Create temporary directory for nexmon sources
16 temp_dir=$(as_nobody mktemp -d)
16 temp_dir=$(as_nobody mktemp -d)
17
17
18 # Fetch nexmon sources
18 # Fetch nexmon sources
19 as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}"
19 as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}"
20
20
21 # Copy downloaded nexmon sources
21 # Copy downloaded nexmon sources
22 mv "${temp_dir}/nexmon" "${R}"/tmp/
22 mv "${temp_dir}/nexmon" "${R}"/tmp/
23
23
24 # Set permissions of the nexmon sources
24 # Set permissions of the nexmon sources
25 chown -R root:root "${R}"/tmp/nexmon
25 chown -R root:root "${R}"/tmp/nexmon
26
26
27 # Remove temporary directory for nexmon sources
27 # Remove temporary directory for nexmon sources
28 rm -fr "${temp_dir}"
28 rm -fr "${temp_dir}"
29 fi
29 fi
30
30
31 # Set script Root
31 # Set script Root
32 export NEXMON_ROOT="${R}"/tmp/nexmon
32 export NEXMON_ROOT="${R}"/tmp/nexmon
33
33
34 # Build nexmon firmware outside the build system, if we can.
34 # Build nexmon firmware outside the build system, if we can.
35 cd "${NEXMON_ROOT}" || exit
35 cd "${NEXMON_ROOT}" || exit
36
36
37 # Make ancient isl build
37 # Make ancient isl build
38 cd buildtools/isl-0.10 || exit
38 cd buildtools/isl-0.10 || exit
39 ./configure
39 ./configure
40 make
40 make
41 cd ../.. || exit
41 cd ../.. || exit
42
42
43 # Disable statistics
43 # Disable statistics
44 touch DISABLE_STATISTICS
44 touch DISABLE_STATISTICS
45
45
46 # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh
46 # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh
47 export KERNEL="${KERNEL_IMAGE}"
47 export KERNEL="${KERNEL_IMAGE}"
48 export ARCH=arm
48 export ARCH=arm
49 export SUBARCH=arm
49 export SUBARCH=arm
50 export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
50 export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
51 export CC="${CC}"gcc
51 export CC="${CC}"gcc
52 export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so
52 export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so
53 export ZLIBFLATE="zlib-flate -compress"
53 export ZLIBFLATE="zlib-flate -compress"
54 export Q=@
54 export Q=@
55 export NEXMON_SETUP_ENV=1
55 export NEXMON_SETUP_ENV=1
56 export HOSTUNAME=$(uname -s)
56 export HOSTUNAME=$(uname -s)
57 export PLATFORMUNAME=$(uname -m)
57 export PLATFORMUNAME=$(uname -m)
58
58
59 # Make nexmon
59 # Make nexmon
60 make
60 make
61
61
62 # build patches
62 # build patches
63 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then
63 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then
64 cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit
64 cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit
65 sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile
65 sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile
66 make clean
66 make clean
67
67
68 # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems.
68 # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems.
69 LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
69 LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
70
70
71 # copy RPi0W & RPi3 firmware
71 # copy RPi0W & RPi3 firmware
72 mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin
72 mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin
73 cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin
73 cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin
74 cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin
74 cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin
75 fi
75 fi
76
76
77 if [ "$RPI_MODEL" = 3P ] ; then
77 if [ "$RPI_MODEL" = 3P ] ; then
78 if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
78 cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit
79 cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit
79 sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile
80 sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile
80 make clean
81 make clean
81
82
82 # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems.
83 # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems.
83 LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
84 LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi-
84
85
85 # RPi3B+ firmware
86 # RPi3B+ firmware
86 mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin
87 mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin
87 cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin
88 cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin
88 cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin
89 cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin
89 fi
90 fi
90
91
91 #Revert to previous directory
92 #Revert to previous directory
92 cd "${WORKDIR}" || exit
93 cd "${WORKDIR}" || exit
93
94
94 # Remove nexmon sources
95 # Remove nexmon sources
95 rm -fr "${NEXMON_ROOT}"
96 rm -fr "${NEXMON_ROOT}"
96
97
97 fi
98 fi
@@ -1,883 +1,908
1 #!/bin/sh
1 #!/bin/sh
2 ########################################################################
2 ########################################################################
3 # rpi23-gen-image.sh 2015-2017
3 # rpi23-gen-image.sh 2015-2017
4 #
4 #
5 # Advanced Debian "stretch" and "buster" bootstrap script for Raspberry Pi
5 # Advanced Debian "stretch" and "buster" bootstrap script for Raspberry Pi
6 #
6 #
7 # This program is free software; you can redistribute it and/or
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
10 # of the License, or (at your option) any later version.
11 #
11 #
12 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
12 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
13 #
13 #
14 # Big thanks for patches and enhancements by 20+ github contributors!
14 # Big thanks for patches and enhancements by 20+ github contributors!
15 ########################################################################
15 ########################################################################
16
16
17 # Are we running as root?
17 # Are we running as root?
18 if [ "$(id -u)" -ne "0" ] ; then
18 if [ "$(id -u)" -ne "0" ] ; then
19 echo "error: this script must be executed with root privileges!"
19 echo "error: this script must be executed with root privileges!"
20 exit 1
20 exit 1
21 fi
21 fi
22
22
23 # Check if ./functions.sh script exists
23 # Check if ./functions.sh script exists
24 if [ ! -r "./functions.sh" ] ; then
24 if [ ! -r "./functions.sh" ] ; then
25 echo "error: './functions.sh' required script not found!"
25 echo "error: './functions.sh' required script not found!"
26 exit 1
26 exit 1
27 fi
27 fi
28
28
29 # Load utility functions
29 # Load utility functions
30 . ./functions.sh
30 . ./functions.sh
31
31
32 # Load parameters from configuration template file
32 # Load parameters from configuration template file
33 if [ -n "$CONFIG_TEMPLATE" ] ; then
33 if [ -n "$CONFIG_TEMPLATE" ] ; then
34 use_template
34 use_template
35 fi
35 fi
36
36
37 # Introduce settings
37 # Introduce settings
38 set -e
38 set -e
39 echo -n -e "\n#\n# RPi 0/1/2/3 Bootstrap Settings\n#\n"
39 echo -n -e "\n#\n# RPi 0/1/2/3 Bootstrap Settings\n#\n"
40 set -x
40 set -x
41
41
42 # Raspberry Pi model configuration
42 # Raspberry Pi model configuration
43 RPI_MODEL=${RPI_MODEL:=2}
43 RPI_MODEL=${RPI_MODEL:=2}
44
44
45 # Debian release
45 # Debian release
46 RELEASE=${RELEASE:=buster}
46 RELEASE=${RELEASE:=buster}
47 if [ $RELEASE = "bullseye" ] ; then
48 RELEASE=testing
49 fi
47
50
48 # Kernel Branch
51 # Kernel Branch
49 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
52 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
50
53
51 # URLs
54 # URLs
52 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
55 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
53 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
56 FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot}
54 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
57 WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm}
55 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
58 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
56 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
59 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
57 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
60 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
58 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
61 VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland}
59 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
62 BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git}
60 NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git}
63 NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git}
61 SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git}
64 SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git}
62
65
63 # Kernel deb packages for 32bit kernel
66 # Kernel deb packages for 32bit kernel
64 RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb}
67 RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb}
65 RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb}
68 RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb}
66 # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used
69 # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used
67 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz}
70 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz}
71 RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.19.80.20191022/bcmrpi3-kernel-bis-4.19.80.20191022.tar.xz}
68 # Default precompiled 64bit kernel
72 # Default precompiled 64bit kernel
69 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz}
73 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz}
74 RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.19.80.20191022/bcmrpi3-kernel-4.19.80.20191022.tar.xz}
75 # Sakaki BIS Kernel RPI4 - https://github.com/sakaki-/bcm2711-kernel-bis
76 RPI4_64_BIS_KERNEL_URL=${RPI4_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
77 # Default precompiled 64bit kernel - https://github.com/sakaki-/bcm2711-kernel
78 RPI4_64_DEF_KERNEL_URL=${RPI4_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz}
70 # Generic
79 # Generic
71 RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL}
80 RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL}
81 RPI4_64_KERNEL_URL=${RPI4_64_KERNEL_URL:=$RPI4_64_DEF_KERNEL_URL}
72 # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul)
82 # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul)
73 KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git}
83 KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git}
74
84
75 # Build directories
85 # Build directories
76 WORKDIR=$(pwd)
86 WORKDIR=$(pwd)
77 BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}}
87 BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}}
78 BUILDDIR="${BASEDIR}/build"
88 BUILDDIR="${BASEDIR}/build"
79
89
80 # Chroot directories
90 # Chroot directories
81 R="${BUILDDIR}/chroot"
91 R="${BUILDDIR}/chroot"
82 ETC_DIR="${R}/etc"
92 ETC_DIR="${R}/etc"
83 LIB_DIR="${R}/lib"
93 LIB_DIR="${R}/lib"
84 BOOT_DIR="${R}/boot/firmware"
94 BOOT_DIR="${R}/boot/firmware"
85 KERNEL_DIR="${R}/usr/src/linux"
95 KERNEL_DIR="${R}/usr/src/linux"
86 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
96 WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm"
87 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
97 BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt"
88
98
89 # Firmware directory: Blank if download from github
99 # Firmware directory: Blank if download from github
90 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
100 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
91
101
92 # General settings
102 # General settings
93 SET_ARCH=${SET_ARCH:=32}
103 SET_ARCH=${SET_ARCH:=32}
94 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
104 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
95 PASSWORD=${PASSWORD:=raspberry}
105 PASSWORD=${PASSWORD:=raspberry}
96 USER_PASSWORD=${USER_PASSWORD:=raspberry}
106 USER_PASSWORD=${USER_PASSWORD:=raspberry}
97 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
107 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
98 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
108 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
99 EXPANDROOT=${EXPANDROOT:=true}
109 EXPANDROOT=${EXPANDROOT:=true}
100 ENABLE_DPHYSSWAP=${ENABLE_DPHYSSWAP:=true}
110 ENABLE_DPHYSSWAP=${ENABLE_DPHYSSWAP:=true}
101
111
102 # Keyboard settings
112 # Keyboard settings
103 XKB_MODEL=${XKB_MODEL:=""}
113 XKB_MODEL=${XKB_MODEL:=""}
104 XKB_LAYOUT=${XKB_LAYOUT:=""}
114 XKB_LAYOUT=${XKB_LAYOUT:=""}
105 XKB_VARIANT=${XKB_VARIANT:=""}
115 XKB_VARIANT=${XKB_VARIANT:=""}
106 XKB_OPTIONS=${XKB_OPTIONS:=""}
116 XKB_OPTIONS=${XKB_OPTIONS:=""}
107
117
108 # Network settings (DHCP)
118 # Network settings (DHCP)
109 ENABLE_DHCP=${ENABLE_DHCP:=true}
119 ENABLE_DHCP=${ENABLE_DHCP:=true}
110
120
111 # Network settings (static)
121 # Network settings (static)
112 NET_ADDRESS=${NET_ADDRESS:=""}
122 NET_ADDRESS=${NET_ADDRESS:=""}
113 NET_GATEWAY=${NET_GATEWAY:=""}
123 NET_GATEWAY=${NET_GATEWAY:=""}
114 NET_DNS_1=${NET_DNS_1:=""}
124 NET_DNS_1=${NET_DNS_1:=""}
115 NET_DNS_2=${NET_DNS_2:=""}
125 NET_DNS_2=${NET_DNS_2:=""}
116 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
126 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
117 NET_NTP_1=${NET_NTP_1:=""}
127 NET_NTP_1=${NET_NTP_1:=""}
118 NET_NTP_2=${NET_NTP_2:=""}
128 NET_NTP_2=${NET_NTP_2:=""}
119
129
120 # APT settings
130 # APT settings
121 APT_PROXY=${APT_PROXY:=""}
131 APT_PROXY=${APT_PROXY:=""}
122 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
132 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
123 KEEP_APT_PROXY=${KEEP_APT_PROXY:=false}
133 KEEP_APT_PROXY=${KEEP_APT_PROXY:=false}
124
134
125 # Feature settings
135 # Feature settings
126 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
136 ENABLE_PRINTK=${ENABLE_PRINTK:=false}
127 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
137 ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false}
128 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
138 ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false}
129 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
139 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
130 ENABLE_I2C=${ENABLE_I2C:=false}
140 ENABLE_I2C=${ENABLE_I2C:=false}
131 ENABLE_SPI=${ENABLE_SPI:=false}
141 ENABLE_SPI=${ENABLE_SPI:=false}
132 ENABLE_IPV6=${ENABLE_IPV6:=true}
142 ENABLE_IPV6=${ENABLE_IPV6:=true}
133 ENABLE_SSHD=${ENABLE_SSHD:=true}
143 ENABLE_SSHD=${ENABLE_SSHD:=true}
134 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
144 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
135 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
145 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
136 ENABLE_SOUND=${ENABLE_SOUND:=true}
146 ENABLE_SOUND=${ENABLE_SOUND:=true}
137 ENABLE_DBUS=${ENABLE_DBUS:=true}
147 ENABLE_DBUS=${ENABLE_DBUS:=true}
138 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
148 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
139 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
149 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
140 ENABLE_XORG=${ENABLE_XORG:=false}
150 ENABLE_XORG=${ENABLE_XORG:=false}
141 ENABLE_WM=${ENABLE_WM:=""}
151 ENABLE_WM=${ENABLE_WM:=""}
142 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
152 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
143 ENABLE_USER=${ENABLE_USER:=true}
153 ENABLE_USER=${ENABLE_USER:=true}
144 USER_NAME=${USER_NAME:="pi"}
154 USER_NAME=${USER_NAME:="pi"}
145 ENABLE_ROOT=${ENABLE_ROOT:=false}
155 ENABLE_ROOT=${ENABLE_ROOT:=false}
146 ENABLE_QEMU=${ENABLE_QEMU:=false}
156 ENABLE_QEMU=${ENABLE_QEMU:=false}
147 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
157 ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false}
148
158
149 # SSH settings
159 # SSH settings
150 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
160 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
151 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
161 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
152 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
162 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
153 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
163 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
154 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
164 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
155
165
156 # Advanced settings
166 # Advanced settings
157 ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false}
167 ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false}
158 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
168 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
159 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
169 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
160 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
170 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
161 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
171 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
162 ENABLE_USBBOOT=${ENABLE_USBBOOT=false}
172 ENABLE_USBBOOT=${ENABLE_USBBOOT=false}
163 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
173 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
164 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false}
174 ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false}
165 ENABLE_NEXMON=${ENABLE_NEXMON:=false}
175 ENABLE_NEXMON=${ENABLE_NEXMON:=false}
166 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
176 VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""}
167 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
177 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
168 NEXMONSRC_DIR=${NEXMONSRC_DIR:=""}
178 NEXMONSRC_DIR=${NEXMONSRC_DIR:=""}
169 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
179 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
170 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
180 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
171 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
181 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
172 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
182 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
173 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
183 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
174 ENABLE_SPLASH=${ENABLE_SPLASH:=true}
184 ENABLE_SPLASH=${ENABLE_SPLASH:=true}
175 ENABLE_LOGO=${ENABLE_LOGO:=true}
185 ENABLE_LOGO=${ENABLE_LOGO:=true}
176 ENABLE_SILENT_BOOT=${ENABLE_SILENT_BOOT=false}
186 ENABLE_SILENT_BOOT=${ENABLE_SILENT_BOOT=false}
177 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
187 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
178
188
179 # Kernel compilation settings
189 # Kernel compilation settings
180 BUILD_KERNEL=${BUILD_KERNEL:=true}
190 BUILD_KERNEL=${BUILD_KERNEL:=true}
181 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
191 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
182 KERNEL_THREADS=${KERNEL_THREADS:=1}
192 KERNEL_THREADS=${KERNEL_THREADS:=1}
183 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
193 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
184 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
194 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
185 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
195 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
186 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
196 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
187 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
197 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
188 KERNEL_ZSWAP=${KERNEL_ZSWAP:=false}
198 KERNEL_ZSWAP=${KERNEL_ZSWAP:=false}
189 KERNEL_VIRT=${KERNEL_VIRT:=false}
199 KERNEL_VIRT=${KERNEL_VIRT:=false}
190 KERNEL_BPF=${KERNEL_BPF:=false}
200 KERNEL_BPF=${KERNEL_BPF:=false}
191 KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=ondemand}
201 KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=ondemand}
192 KERNEL_SECURITY=${KERNEL_SECURITY:=false}
202 KERNEL_SECURITY=${KERNEL_SECURITY:=false}
193 KERNEL_NF=${KERNEL_NF:=false}
203 KERNEL_NF=${KERNEL_NF:=false}
204 KERNEL_DHKEY=${KERNEL_DHKEY:=true}
205 KERNEL_BTRFS=${KERNEL_BTRFS:=false}
206 KERNEL_NSPAN=${KERNEL_NSPAN:=false}
207 KERNEL_POEHAT=${KERNEL_POEHAT:=false}
194
208
195 # Kernel compilation from source directory settings
209 # Kernel compilation from source directory settings
196 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
210 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
197 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
211 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
198 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
212 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
199 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
213 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
200
214
201 # Reduce disk usage settings
215 # Reduce disk usage settings
202 REDUCE_APT=${REDUCE_APT:=true}
216 REDUCE_APT=${REDUCE_APT:=true}
203 REDUCE_DOC=${REDUCE_DOC:=true}
217 REDUCE_DOC=${REDUCE_DOC:=true}
204 REDUCE_MAN=${REDUCE_MAN:=true}
218 REDUCE_MAN=${REDUCE_MAN:=true}
205 REDUCE_VIM=${REDUCE_VIM:=false}
219 REDUCE_VIM=${REDUCE_VIM:=false}
206 REDUCE_BASH=${REDUCE_BASH:=false}
220 REDUCE_BASH=${REDUCE_BASH:=false}
207 REDUCE_HWDB=${REDUCE_HWDB:=true}
221 REDUCE_HWDB=${REDUCE_HWDB:=true}
208 REDUCE_SSHD=${REDUCE_SSHD:=true}
222 REDUCE_SSHD=${REDUCE_SSHD:=true}
209 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
223 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
210
224
211 # Encrypted filesystem settings
225 # Encrypted filesystem settings
212 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
226 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
213 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
227 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
214 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
228 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
215 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
229 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
230 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64"}
231 CRYPTFS_HASH=${CRYPTFS_HASH:="sha512"}
216 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
232 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
217 #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup
233 #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup
218 CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false}
234 CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false}
219 #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated
235 #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated
220 CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""}
236 CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""}
221
237
222 # Chroot scripts directory
238 # Chroot scripts directory
223 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
239 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
224
240
225 # Packages required in the chroot build environment
241 # Packages required in the chroot build environment
226 APT_INCLUDES=${APT_INCLUDES:=""}
242 APT_INCLUDES=${APT_INCLUDES:=""}
227 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
243 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
244 APT_INCLUDES="${APT_INCLUDES},flex,bison,libssl-dev,apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd"
228
245
229 # Packages to exclude from chroot build environment
246 # Packages to exclude from chroot build environment
230 APT_EXCLUDES=${APT_EXCLUDES:=""}
247 APT_EXCLUDES=${APT_EXCLUDES:=""}
231
248
232 # Packages required for bootstrapping
249 # Packages required for bootstrapping
233 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo"
250 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo"
251 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus bison flex libssl-dev sudo"
234 MISSING_PACKAGES=""
252 MISSING_PACKAGES=""
235
253
236 # Packages installed for c/c++ build environment in chroot (keep empty)
254 # Packages installed for c/c++ build environment in chroot (keep empty)
237 COMPILER_PACKAGES=""
255 COMPILER_PACKAGES=""
238
256
239 # Check if apt-cacher-ng has port 3142 open and set APT_PROXY
257 # Check if apt-cacher-ng has port 3142 open and set APT_PROXY
240 APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d')
258 APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d')
241 if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then
259 if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then
242 APT_PROXY=http://127.0.0.1:3142/
260 APT_PROXY=http://127.0.0.1:3142/
243 fi
261 fi
244
262
245 # Setup architecture specific settings
263 # Setup architecture specific settings
246 if [ -n "$SET_ARCH" ] ; then
264 if [ -n "$SET_ARCH" ] ; then
247 # 64-bit configuration
265 # 64-bit configuration
248 if [ "$SET_ARCH" = 64 ] ; then
266 if [ "$SET_ARCH" = 64 ] ; then
249 # General 64-bit depended settings
267 # General 64-bit depended settings
250 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
268 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
251 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
269 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
252 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
270 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
253
271
254 # Raspberry Pi model specific settings
272 # Raspberry Pi model specific settings
255 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
273 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
256 if [ "$RPI_MODEL" != 4 ] ; then
274 if [ "$RPI_MODEL" != 4 ] ; then
257 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
275 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
258 else
276 else
259 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
277 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
260 fi
278 fi
261
279
262 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
280 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
263 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
281 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
264 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
282 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
265 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
283 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
266 else
284 else
267 echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit"
285 echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit"
268 exit 1
286 exit 1
269 fi
287 fi
270 fi
288 fi
271
289
272 # 32-bit configuration
290 # 32-bit configuration
273 if [ "$SET_ARCH" = 32 ] ; then
291 if [ "$SET_ARCH" = 32 ] ; then
274 # General 32-bit dependend settings
292 # General 32-bit dependend settings
275 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
293 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
276 KERNEL_ARCH=${KERNEL_ARCH:=arm}
294 KERNEL_ARCH=${KERNEL_ARCH:=arm}
277 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
295 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
278
296
279 # Raspberry Pi model specific settings
297 # Raspberry Pi model specific settings
280 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
298 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
281 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
299 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
282 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
300 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
283 RELEASE_ARCH=${RELEASE_ARCH:=armel}
301 RELEASE_ARCH=${RELEASE_ARCH:=armel}
284 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
302 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
285 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
303 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
286 fi
304 fi
287
305
288 # Raspberry Pi model specific settings
306 # Raspberry Pi model specific settings
289 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
307 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
290 if [ "$RPI_MODEL" != 4 ] ; then
308 if [ "$RPI_MODEL" != 4 ] ; then
291 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
309 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
310 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
292 else
311 else
293 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
312 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig}
313 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7l.img}
294 fi
314 fi
295
315
296 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
316 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
297 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
317 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
298 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
318 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
319
299 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
320 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
300 fi
321 fi
301 fi
322 fi
302 # SET_ARCH not set
323 # SET_ARCH not set
303 else
324 else
304 echo "error: Please set '32' or '64' as value for SET_ARCH"
325 echo "error: Please set '32' or '64' as value for SET_ARCH"
305 exit 1
326 exit 1
306 fi
327 fi
307 # Device specific configuration and U-Boot configuration
328 # Device specific configuration and U-Boot configuration
308 case "$RPI_MODEL" in
329 case "$RPI_MODEL" in
309 0)
330 0)
310 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
331 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
311 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
332 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
312 ;;
333 ;;
313 1)
334 1)
314 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
335 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
315 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
336 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
316 ;;
337 ;;
317 1P)
338 1P)
318 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
339 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
319 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
340 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
320 ;;
341 ;;
321 2)
342 2)
322 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
343 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
323 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
344 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
324 ;;
345 ;;
325 3)
346 3)
326 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
347 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
327 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
348 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
328 ;;
349 ;;
329 3P)
350 3P)
330 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
351 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
331 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
352 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
332 ;;
353 ;;
333 4)
354 4)
334 DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb}
355 DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb}
335 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig}
356 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig}
336 ;;
357 ;;
337 *)
358 *)
338 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
359 echo "error: Raspberry Pi model $RPI_MODEL is not supported!"
339 exit 1
360 exit 1
340 ;;
361 ;;
341 esac
362 esac
342
363
343 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
364 # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard
344 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
365 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then
345 # Include bluetooth packages on supported boards
366 # Include bluetooth packages on supported boards
346 if [ "$ENABLE_BLUETOOTH" = true ] ; then
367 if [ "$ENABLE_BLUETOOTH" = true ] ; then
347 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
368 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
348 fi
369 fi
349 if [ "$ENABLE_WIRELESS" = true ] ; then
370 if [ "$ENABLE_WIRELESS" = true ] ; then
350 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb"
371 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb"
351 fi
372 fi
352 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
373 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
353 # Check if the internal wireless interface is not supported by the RPi model
374 # Check if the internal wireless interface is not supported by the RPi model
354 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
375 if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then
355 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
376 echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth"
356 exit 1
377 exit 1
357 fi
378 fi
358 fi
379 fi
359
380
360 if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then
381 if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then
361 echo "error: You have to compile kernel sources, if you want to enable nexmon"
382 echo "error: You have to compile kernel sources, if you want to enable nexmon"
362 exit 1
383 exit 1
363 fi
384 fi
364
385
365 # Prepare date string for default image file name
386 # Prepare date string for default image file name
366 DATE="$(date +%Y-%m-%d)"
387 DATE="$(date +%Y-%m-%d)"
367 if [ -z "$KERNEL_BRANCH" ] ; then
388 if [ -z "$KERNEL_BRANCH" ] ; then
368 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
389 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
369 else
390 else
370 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
391 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
371 fi
392 fi
372
393
373 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
394 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
374 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
395 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
375 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
396 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
376 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
397 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
377 exit 1
398 exit 1
378 fi
399 fi
379 fi
400 fi
380
401
381 # Add cmake to compile videocore sources
402 # Add cmake to compile videocore sources
382 if [ "$ENABLE_VIDEOCORE" = true ] ; then
403 if [ "$ENABLE_VIDEOCORE" = true ] ; then
383 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
404 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake"
384 fi
405 fi
385
406
386 # Add deps for nexmon
407 # Add deps for nexmon
387 if [ "$ENABLE_NEXMON" = true ] ; then
408 if [ "$ENABLE_NEXMON" = true ] ; then
388 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool"
409 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool"
410 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf make autoconf automake build-essential libtool"
389 fi
411 fi
390
412
391 # Add libncurses5 to enable kernel menuconfig
413 # Add libncurses5 to enable kernel menuconfig
392 if [ "$KERNEL_MENUCONFIG" = true ] ; then
414 if [ "$KERNEL_MENUCONFIG" = true ] ; then
393 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
415 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev"
394 fi
416 fi
395
417
396 # Add ccache compiler cache for (faster) kernel cross (re)compilation
418 # Add ccache compiler cache for (faster) kernel cross (re)compilation
397 if [ "$KERNEL_CCACHE" = true ] ; then
419 if [ "$KERNEL_CCACHE" = true ] ; then
398 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
420 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
399 fi
421 fi
400
422
401 # Add cryptsetup package to enable filesystem encryption
423 # Add cryptsetup package to enable filesystem encryption
402 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
424 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
403 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
425 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
404 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
426 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
427 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup,cryptsetup-initramfs"
405
428
406 # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package
429 # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package
407 if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then
430 if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then
408 APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs"
431 APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs"
409 fi
432 fi
410
433
411 if [ -z "$CRYPTFS_PASSWORD" ] ; then
434 if [ -z "$CRYPTFS_PASSWORD" ] ; then
412 echo "error: no password defined (CRYPTFS_PASSWORD)!"
435 echo "error: no password defined (CRYPTFS_PASSWORD)!"
413 exit 1
436 exit 1
414 fi
437 fi
415 ENABLE_INITRAMFS=true
438 ENABLE_INITRAMFS=true
416 fi
439 fi
417
440
418 # Add initramfs generation tools
441 # Add initramfs generation tools
419 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
442 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
420 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
443 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
421 fi
444 fi
422
445
423 # Add device-tree-compiler required for building the U-Boot bootloader
446 # Add device-tree-compiler required for building the U-Boot bootloader
424 if [ "$ENABLE_UBOOT" = true ] ; then
447 if [ "$ENABLE_UBOOT" = true ] ; then
425 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
448 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc"
426 fi
449 fi
427
450
428 if [ "$ENABLE_USBBOOT" = true ] ; then
451 if [ "$ENABLE_USBBOOT" = true ] ; then
429 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then
452 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then
430 echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P"
453 echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P"
431 exit 1
454 exit 1
432 fi
455 fi
433 fi
456 fi
434
457
435 # Check if root SSH (v2) public key file exists
458 # Check if root SSH (v2) public key file exists
436 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
459 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
437 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
460 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
438 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
461 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
439 exit 1
462 exit 1
440 fi
463 fi
441 fi
464 fi
442
465
443 # Check if $USER_NAME SSH (v2) public key file exists
466 # Check if $USER_NAME SSH (v2) public key file exists
444 if [ -n "$SSH_USER_PUB_KEY" ] ; then
467 if [ -n "$SSH_USER_PUB_KEY" ] ; then
445 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
468 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
446 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
469 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
447 exit 1
470 exit 1
448 fi
471 fi
449 fi
472 fi
450
473
451 if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then
474 if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then
452 echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON"
475 echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON"
453 exit 1
476 exit 1
454 fi
477 fi
455
478
456 # Check if all required packages are installed on the build system
479 # Check if all required packages are installed on the build system
457 for package in $REQUIRED_PACKAGES ; do
480 for package in $REQUIRED_PACKAGES ; do
458 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
481 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
459 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
482 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
460 fi
483 fi
461 done
484 done
462
485
463 # If there are missing packages ask confirmation for install, or exit
486 # If there are missing packages ask confirmation for install, or exit
464 if [ -n "$MISSING_PACKAGES" ] ; then
487 if [ -n "$MISSING_PACKAGES" ] ; then
465 echo "the following packages needed by this script are not installed:"
488 echo "the following packages needed by this script are not installed:"
466 echo "$MISSING_PACKAGES"
489 echo "$MISSING_PACKAGES"
467
490
468 printf "\ndo you want to install the missing packages right now? [y/n] "
491 printf "\ndo you want to install the missing packages right now? [y/n] "
469 read -r confirm
492 read -r confirm
470 [ "$confirm" != "y" ] && exit 1
493 [ "$confirm" != "y" ] && exit 1
471
494
472 # Make sure all missing required packages are installed
495 # Make sure all missing required packages are installed
473 apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
496 apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
497 apt-get update && apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"`
474 fi
498 fi
475
499
476 # Check if ./bootstrap.d directory exists
500 # Check if ./bootstrap.d directory exists
477 if [ ! -d "./bootstrap.d/" ] ; then
501 if [ ! -d "./bootstrap.d/" ] ; then
478 echo "error: './bootstrap.d' required directory not found!"
502 echo "error: './bootstrap.d' required directory not found!"
479 exit 1
503 exit 1
480 fi
504 fi
481
505
482 # Check if ./files directory exists
506 # Check if ./files directory exists
483 if [ ! -d "./files/" ] ; then
507 if [ ! -d "./files/" ] ; then
484 echo "error: './files' required directory not found!"
508 echo "error: './files' required directory not found!"
485 exit 1
509 exit 1
486 fi
510 fi
487
511
488 # Check if specified KERNELSRC_DIR directory exists
512 # Check if specified KERNELSRC_DIR directory exists
489 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
513 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
490 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
514 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
491 exit 1
515 exit 1
492 fi
516 fi
493
517
494 # Check if specified UBOOTSRC_DIR directory exists
518 # Check if specified UBOOTSRC_DIR directory exists
495 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
519 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
496 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
520 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
497 exit 1
521 exit 1
498 fi
522 fi
499
523
500 # Check if specified VIDEOCORESRC_DIR directory exists
524 # Check if specified VIDEOCORESRC_DIR directory exists
501 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
525 if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then
502 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
526 echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!"
503 exit 1
527 exit 1
504 fi
528 fi
505
529
506 # Check if specified FBTURBOSRC_DIR directory exists
530 # Check if specified FBTURBOSRC_DIR directory exists
507 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
531 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
508 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
532 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
509 exit 1
533 exit 1
510 fi
534 fi
511
535
512 # Check if specified NEXMONSRC_DIR directory exists
536 # Check if specified NEXMONSRC_DIR directory exists
513 if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then
537 if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then
514 echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!"
538 echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!"
515 exit 1
539 exit 1
516 fi
540 fi
517
541
518 # Check if specified CHROOT_SCRIPTS directory exists
542 # Check if specified CHROOT_SCRIPTS directory exists
519 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
543 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
520 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
544 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
521 exit 1
545 exit 1
522 fi
546 fi
523
547
524 # Check if specified device mapping already exists (will be used by cryptsetup)
548 # Check if specified device mapping already exists (will be used by cryptsetup)
525 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
549 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
526 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
550 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
527 exit 1
551 exit 1
528 fi
552 fi
529
553
530 # Don't clobber an old build
554 # Don't clobber an old build
531 if [ -e "$BUILDDIR" ] ; then
555 if [ -e "$BUILDDIR" ] ; then
532 echo "error: directory ${BUILDDIR} already exists, not proceeding"
556 echo "error: directory ${BUILDDIR} already exists, not proceeding"
533 exit 1
557 exit 1
534 fi
558 fi
535
559
536 # Setup chroot directory
560 # Setup chroot directory
537 mkdir -p "${R}"
561 mkdir -p "${R}"
538
562
539 # Check if build directory has enough of free disk space >512MB
563 # Check if build directory has enough of free disk space >512MB
540 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
564 if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then
541 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
565 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
542 exit 1
566 exit 1
543 fi
567 fi
544
568
545 set -x
569 set -x
546
570
547 # Call "cleanup" function on various signals and errors
571 # Call "cleanup" function on various signals and errors
548 trap cleanup 0 1 2 3 6
572 trap cleanup 0 1 2 3 6
549
573
550 # Add required packages for the minbase installation
574 # Add required packages for the minbase installation
551 if [ "$ENABLE_MINBASE" = true ] ; then
575 if [ "$ENABLE_MINBASE" = true ] ; then
552 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
576 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
553 fi
577 fi
554
578
555 # Add parted package, required to get partprobe utility
579 # Add parted package, required to get partprobe utility
556 if [ "$EXPANDROOT" = true ] ; then
580 if [ "$EXPANDROOT" = true ] ; then
557 APT_INCLUDES="${APT_INCLUDES},parted"
581 APT_INCLUDES="${APT_INCLUDES},parted"
558 fi
582 fi
559
583
560 # Add dphys-swapfile package, required to enable swap
584 # Add dphys-swapfile package, required to enable swap
561 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
585 if [ "$ENABLE_DPHYSSWAP" = true ] ; then
562 APT_INCLUDES="${APT_INCLUDES},dphys-swapfile"
586 APT_INCLUDES="${APT_INCLUDES},dphys-swapfile"
563 fi
587 fi
564
588
565 # Add dbus package, recommended if using systemd
589 # Add dbus package, recommended if using systemd
566 if [ "$ENABLE_DBUS" = true ] ; then
590 if [ "$ENABLE_DBUS" = true ] ; then
567 APT_INCLUDES="${APT_INCLUDES},dbus"
591 APT_INCLUDES="${APT_INCLUDES},dbus"
568 fi
592 fi
569
593
570 # Add iptables IPv4/IPv6 package
594 # Add iptables IPv4/IPv6 package
571 if [ "$ENABLE_IPTABLES" = true ] ; then
595 if [ "$ENABLE_IPTABLES" = true ] ; then
572 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
596 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
573 fi
597 fi
574 # Add apparmor for KERNEL_SECURITY
598 # Add apparmor for KERNEL_SECURITY
575 if [ "$KERNEL_SECURITY" = true ] ; then
599 if [ "$KERNEL_SECURITY" = true ] ; then
576 APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl"
600 APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl"
577 fi
601 fi
578
602
579 # Add openssh server package
603 # Add openssh server package
580 if [ "$ENABLE_SSHD" = true ] ; then
604 if [ "$ENABLE_SSHD" = true ] ; then
581 APT_INCLUDES="${APT_INCLUDES},openssh-server"
605 APT_INCLUDES="${APT_INCLUDES},openssh-server"
582 fi
606 fi
583
607
584 # Add alsa-utils package
608 # Add alsa-utils package
585 if [ "$ENABLE_SOUND" = true ] ; then
609 if [ "$ENABLE_SOUND" = true ] ; then
586 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
610 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
587 fi
611 fi
588
612
589 # Add rng-tools package
613 # Add rng-tools package
590 if [ "$ENABLE_HWRANDOM" = true ] ; then
614 if [ "$ENABLE_HWRANDOM" = true ] ; then
591 APT_INCLUDES="${APT_INCLUDES},rng-tools"
615 APT_INCLUDES="${APT_INCLUDES},rng-tools"
592 fi
616 fi
593
617
594 # Add fbturbo video driver
618 # Add fbturbo video driver
595 if [ "$ENABLE_FBTURBO" = true ] ; then
619 if [ "$ENABLE_FBTURBO" = true ] ; then
596 # Enable xorg package dependencies
620 # Enable xorg package dependencies
597 ENABLE_XORG=true
621 ENABLE_XORG=true
598 fi
622 fi
599
623
600 # Add user defined window manager package
624 # Add user defined window manager package
601 if [ -n "$ENABLE_WM" ] ; then
625 if [ -n "$ENABLE_WM" ] ; then
602 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
626 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
603
627
604 # Enable xorg package dependencies
628 # Enable xorg package dependencies
605 ENABLE_XORG=true
629 ENABLE_XORG=true
606 fi
630 fi
607
631
608 # Add xorg package
632 # Add xorg package
609 if [ "$ENABLE_XORG" = true ] ; then
633 if [ "$ENABLE_XORG" = true ] ; then
610 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
634 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
611 fi
635 fi
612
636
613 # Replace selected packages with smaller clones
637 # Replace selected packages with smaller clones
614 if [ "$ENABLE_REDUCE" = true ] ; then
638 if [ "$ENABLE_REDUCE" = true ] ; then
615 # Add levee package instead of vim-tiny
639 # Add levee package instead of vim-tiny
616 if [ "$REDUCE_VIM" = true ] ; then
640 if [ "$REDUCE_VIM" = true ] ; then
617 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
641 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
618 fi
642 fi
619
643
620 # Add dropbear package instead of openssh-server
644 # Add dropbear package instead of openssh-server
621 if [ "$REDUCE_SSHD" = true ] ; then
645 if [ "$REDUCE_SSHD" = true ] ; then
622 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
646 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
623 fi
647 fi
624 fi
648 fi
625
649
626 # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available
650 # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available
627 if [ "$ENABLE_SYSVINIT" = false ] ; then
651 if [ "$ENABLE_SYSVINIT" = false ] ; then
628 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
652 APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv"
629 fi
653 fi
630
654
631 # Configure kernel sources if no KERNELSRC_DIR
655 # Configure kernel sources if no KERNELSRC_DIR
632 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
656 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
633 KERNELSRC_CONFIG=true
657 KERNELSRC_CONFIG=true
634 fi
658 fi
635
659
636 # Configure reduced kernel
660 # Configure reduced kernel
637 if [ "$KERNEL_REDUCE" = true ] ; then
661 if [ "$KERNEL_REDUCE" = true ] ; then
638 KERNELSRC_CONFIG=false
662 KERNELSRC_CONFIG=false
639 fi
663 fi
640
664
641 # Configure qemu compatible kernel
665 # Configure qemu compatible kernel
642 if [ "$ENABLE_QEMU" = true ] ; then
666 if [ "$ENABLE_QEMU" = true ] ; then
643 DTB_FILE=vexpress-v2p-ca15_a7.dtb
667 DTB_FILE=vexpress-v2p-ca15_a7.dtb
644 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
668 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
645 KERNEL_DEFCONFIG="vexpress_defconfig"
669 KERNEL_DEFCONFIG="vexpress_defconfig"
646 if [ "$KERNEL_MENUCONFIG" = false ] ; then
670 if [ "$KERNEL_MENUCONFIG" = false ] ; then
647 KERNEL_OLDDEFCONFIG=true
671 KERNEL_OLDDEFCONFIG=true
648 fi
672 fi
649 fi
673 fi
650
674
651 # Execute bootstrap scripts
675 # Execute bootstrap scripts
652 for SCRIPT in bootstrap.d/*.sh; do
676 for SCRIPT in bootstrap.d/*.sh; do
653 head -n 3 "$SCRIPT"
677 head -n 3 "$SCRIPT"
654 . "$SCRIPT"
678 . "$SCRIPT"
655 done
679 done
656
680
657 ## Execute custom bootstrap scripts
681 ## Execute custom bootstrap scripts
658 if [ -d "custom.d" ] ; then
682 if [ -d "custom.d" ] ; then
659 for SCRIPT in custom.d/*.sh; do
683 for SCRIPT in custom.d/*.sh; do
660 . "$SCRIPT"
684 . "$SCRIPT"
661 done
685 done
662 fi
686 fi
663
687
664 # Execute custom scripts inside the chroot
688 # Execute custom scripts inside the chroot
665 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
689 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
666 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
690 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
667 chroot_exec /bin/bash -x <<'EOF'
691 chroot_exec /bin/bash -x <<'EOF'
668 for SCRIPT in /chroot_scripts/* ; do
692 for SCRIPT in /chroot_scripts/* ; do
669 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
693 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
670 $SCRIPT
694 $SCRIPT
671 fi
695 fi
672 done
696 done
673 EOF
697 EOF
674 rm -rf "${R}/chroot_scripts"
698 rm -rf "${R}/chroot_scripts"
675 fi
699 fi
676
700
677 # Remove c/c++ build environment from the chroot
701 # Remove c/c++ build environment from the chroot
678 chroot_remove_cc
702 chroot_remove_cc
679
703
680 # Generate required machine-id
704 # Generate required machine-id
681 MACHINE_ID=$(dbus-uuidgen)
705 MACHINE_ID=$(dbus-uuidgen)
682 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
706 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
683 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
707 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
684
708
685 # APT Cleanup
709 # APT Cleanup
686 chroot_exec apt-get -y clean
710 chroot_exec apt-get -y clean
687 chroot_exec apt-get -y autoclean
711 chroot_exec apt-get -y autoclean
688 chroot_exec apt-get -y autoremove
712 chroot_exec apt-get -y autoremove
689
713
690 # Unmount mounted filesystems
714 # Unmount mounted filesystems
691 umount -l "${R}/proc"
715 umount -l "${R}/proc"
692 umount -l "${R}/sys"
716 umount -l "${R}/sys"
693
717
694 # Clean up directories
718 # Clean up directories
695 rm -rf "${R}/run/*"
719 rm -rf "${R}/run/*"
696 rm -rf "${R}/tmp/*"
720 rm -rf "${R}/tmp/*"
697
721
698 # Clean up APT proxy settings
722 # Clean up APT proxy settings
699 if [ "$KEEP_APT_PROXY" = false ] ; then
723 if [ "$KEEP_APT_PROXY" = false ] ; then
700 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
724 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
701 fi
725 fi
702
726
703 # Clean up files
727 # Clean up files
704 rm -f "${ETC_DIR}/ssh/ssh_host_*"
728 rm -f "${ETC_DIR}/ssh/ssh_host_*"
705 rm -f "${ETC_DIR}/dropbear/dropbear_*"
729 rm -f "${ETC_DIR}/dropbear/dropbear_*"
706 rm -f "${ETC_DIR}/apt/sources.list.save"
730 rm -f "${ETC_DIR}/apt/sources.list.save"
707 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
731 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
708 rm -f "${ETC_DIR}/*-"
732 rm -f "${ETC_DIR}/*-"
709 rm -f "${ETC_DIR}/resolv.conf"
733 rm -f "${ETC_DIR}/resolv.conf"
710 rm -f "${R}/root/.bash_history"
734 rm -f "${R}/root/.bash_history"
711 rm -f "${R}/var/lib/urandom/random-seed"
735 rm -f "${R}/var/lib/urandom/random-seed"
712 rm -f "${R}/initrd.img"
736 rm -f "${R}/initrd.img"
713 rm -f "${R}/vmlinuz"
737 rm -f "${R}/vmlinuz"
714 rm -f "${R}${QEMU_BINARY}"
738 rm -f "${R}${QEMU_BINARY}"
715
739
716 if [ "$ENABLE_QEMU" = true ] ; then
740 if [ "$ENABLE_QEMU" = true ] ; then
717 # Setup QEMU directory
741 # Setup QEMU directory
718 mkdir "${BASEDIR}/qemu"
742 mkdir "${BASEDIR}/qemu"
719
743
720 # Copy kernel image to QEMU directory
744 # Copy kernel image to QEMU directory
721 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
745 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
722
746
723 # Copy kernel config to QEMU directory
747 # Copy kernel config to QEMU directory
724 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
748 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
725
749
726 # Copy kernel dtbs to QEMU directory
750 # Copy kernel dtbs to QEMU directory
727 for dtb in "${BOOT_DIR}/"*.dtb ; do
751 for dtb in "${BOOT_DIR}/"*.dtb ; do
728 if [ -f "${dtb}" ] ; then
752 if [ -f "${dtb}" ] ; then
729 install_readonly "${dtb}" "${BASEDIR}/qemu/"
753 install_readonly "${dtb}" "${BASEDIR}/qemu/"
730 fi
754 fi
731 done
755 done
732
756
733 # Copy kernel overlays to QEMU directory
757 # Copy kernel overlays to QEMU directory
734 if [ -d "${BOOT_DIR}/overlays" ] ; then
758 if [ -d "${BOOT_DIR}/overlays" ] ; then
735 # Setup overlays dtbs directory
759 # Setup overlays dtbs directory
736 mkdir "${BASEDIR}/qemu/overlays"
760 mkdir "${BASEDIR}/qemu/overlays"
737
761
738 for dtb in "${BOOT_DIR}/overlays/"*.dtbo ; do
762 for dtb in "${BOOT_DIR}/overlays/"*.dtbo ; do
739 if [ -f "${dtb}" ] ; then
763 if [ -f "${dtb}" ] ; then
740 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
764 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
741 fi
765 fi
742 done
766 done
743 fi
767 fi
744
768
745 # Copy u-boot files to QEMU directory
769 # Copy u-boot files to QEMU directory
746 if [ "$ENABLE_UBOOT" = true ] ; then
770 if [ "$ENABLE_UBOOT" = true ] ; then
747 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
771 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
748 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
772 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
749 fi
773 fi
750 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
774 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
751 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
775 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
752 fi
776 fi
753 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
777 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
754 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
778 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
755 fi
779 fi
756 fi
780 fi
757
781
758 # Copy initramfs to QEMU directory
782 # Copy initramfs to QEMU directory
759 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
783 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
760 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
784 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
761 fi
785 fi
762 fi
786 fi
763
787
764 # Calculate size of the chroot directory in KB
788 # Calculate size of the chroot directory in KB
765 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
789 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
766
790
767 # Calculate the amount of needed 512 Byte sectors
791 # Calculate the amount of needed 512 Byte sectors
768 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
792 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
769 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
793 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
770 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
794 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
771
795
772 # The root partition is EXT4
796 # The root partition is EXT4
773 # This means more space than the actual used space of the chroot is used.
797 # This means more space than the actual used space of the chroot is used.
774 # As overhead for journaling and reserved blocks 35% are added.
798 # As overhead for journaling and reserved blocks 35% are added.
775 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
799 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
776
800
777 # Calculate required image size in 512 Byte sectors
801 # Calculate required image size in 512 Byte sectors
778 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
802 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
779
803
780 # Prepare image file
804 # Prepare image file
781 if [ "$ENABLE_SPLITFS" = true ] ; then
805 if [ "$ENABLE_SPLITFS" = true ] ; then
782 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
806 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
783 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
807 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
784 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
808 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
785 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
809 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
786
810
787 # Write firmware/boot partition tables
811 # Write firmware/boot partition tables
788 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
812 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
789 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
813 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
790 EOM
814 EOM
791
815
792 # Write root partition table
816 # Write root partition table
793 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
817 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
794 ${TABLE_SECTORS},${ROOT_SECTORS},83
818 ${TABLE_SECTORS},${ROOT_SECTORS},83
795 EOM
819 EOM
796
820
797 # Setup temporary loop devices
821 # Setup temporary loop devices
798 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
822 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
799 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
823 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
800 else # ENABLE_SPLITFS=false
824 else # ENABLE_SPLITFS=false
801 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
825 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
802 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
826 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
803
827
804 # Write partition table
828 # Write partition table
805 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
829 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
806 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
830 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
807 ${ROOT_OFFSET},${ROOT_SECTORS},83
831 ${ROOT_OFFSET},${ROOT_SECTORS},83
808 EOM
832 EOM
809
833
810 # Setup temporary loop devices
834 # Setup temporary loop devices
811 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
835 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
812 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
836 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
813 fi
837 fi
814
838
815 if [ "$ENABLE_CRYPTFS" = true ] ; then
839 if [ "$ENABLE_CRYPTFS" = true ] ; then
816 # Create dummy ext4 fs
840 # Create dummy ext4 fs
817 mkfs.ext4 "$ROOT_LOOP"
841 mkfs.ext4 "$ROOT_LOOP"
818
842
819 # Setup password keyfile
843 # Setup password keyfile
820 touch .password
844 touch .password
821 chmod 600 .password
845 chmod 600 .password
822 echo -n ${CRYPTFS_PASSWORD} > .password
846 echo -n ${CRYPTFS_PASSWORD} > .password
823
847
824 # Initialize encrypted partition
848 # Initialize encrypted partition
825 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
849 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
850 cryptsetup --verbose --debug -q luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -h "${CRYPTFS_HASH}" -s "${CRYPTFS_XTSKEYSIZE}" .password
826
851
827 # Open encrypted partition and setup mapping
852 # Open encrypted partition and setup mapping
828 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
853 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
829
854
830 # Secure delete password keyfile
855 # Secure delete password keyfile
831 shred -zu .password
856 shred -zu .password
832
857
833 # Update temporary loop device
858 # Update temporary loop device
834 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
859 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
835
860
836 # Wipe encrypted partition (encryption cipher is used for randomness)
861 # Wipe encrypted partition (encryption cipher is used for randomness)
837 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
862 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
838 fi
863 fi
839
864
840 # Build filesystems
865 # Build filesystems
841 mkfs.vfat "$FRMW_LOOP"
866 mkfs.vfat "$FRMW_LOOP"
842 mkfs.ext4 "$ROOT_LOOP"
867 mkfs.ext4 "$ROOT_LOOP"
843
868
844 # Mount the temporary loop devices
869 # Mount the temporary loop devices
845 mkdir -p "$BUILDDIR/mount"
870 mkdir -p "$BUILDDIR/mount"
846 mount "$ROOT_LOOP" "$BUILDDIR/mount"
871 mount "$ROOT_LOOP" "$BUILDDIR/mount"
847
872
848 mkdir -p "$BUILDDIR/mount/boot/firmware"
873 mkdir -p "$BUILDDIR/mount/boot/firmware"
849 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
874 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
850
875
851 # Copy all files from the chroot to the loop device mount point directory
876 # Copy all files from the chroot to the loop device mount point directory
852 rsync -a "${R}/" "$BUILDDIR/mount/"
877 rsync -a "${R}/" "$BUILDDIR/mount/"
853
878
854 # Unmount all temporary loop devices and mount points
879 # Unmount all temporary loop devices and mount points
855 cleanup
880 cleanup
856
881
857 # Create block map file(s) of image(s)
882 # Create block map file(s) of image(s)
858 if [ "$ENABLE_SPLITFS" = true ] ; then
883 if [ "$ENABLE_SPLITFS" = true ] ; then
859 # Create block map files for "bmaptool"
884 # Create block map files for "bmaptool"
860 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
885 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
861 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
886 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
862
887
863 # Image was successfully created
888 # Image was successfully created
864 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
889 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
865 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
890 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
866 else
891 else
867 # Create block map file for "bmaptool"
892 # Create block map file for "bmaptool"
868 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
893 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
869
894
870 # Image was successfully created
895 # Image was successfully created
871 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
896 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
872
897
873 # Create qemu qcow2 image
898 # Create qemu qcow2 image
874 if [ "$ENABLE_QEMU" = true ] ; then
899 if [ "$ENABLE_QEMU" = true ] ; then
875 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
900 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
876 QEMU_SIZE=16G
901 QEMU_SIZE=16G
877
902
878 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
903 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
879 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
904 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
880
905
881 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
906 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
882 fi
907 fi
883 fi
908 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant