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