##// END OF EJS Templates
comment-cleanup, net-cleanup, size-calc-fix, split-more, menuconfig
Jan Wagner -
r71:b855bcffebe1
parent child
Show More
@@ -0,0 +1,5
1 # bcm2708_rng
2 # snd_bcm2835
3 # i2c-bcm2708
4 # i2c-dev
5 # rtc-ds1307
@@ -1,222 +1,225
1 # rpi2-gen-image
1 # rpi2-gen-image
2 ## Introduction
2 ## Introduction
3 `rpi2-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for the Raspberry 2 (RPi2) computer. The script at this time only supports the bootstrapping of the current stable Debian 8 "jessie" release.
3 `rpi2-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for the Raspberry 2 (RPi2) computer. The script at this time only supports the bootstrapping of the current stable Debian 8 "jessie" release.
4
4
5 ## 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 dosfstools rsync bmap-tools whois git-core```
8 ```debootstrap debian-archive-keyring qemu-user-static dosfstools rsync bmap-tools whois git-core```
9
9
10 ## Command-line parameters
10 ## Command-line parameters
11 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi2-gen-image.sh` script via (simple) shell-variables. Unlike environment shell-variables (simple) shell-variables are defined at the beginning of the command-line call of the `rpi2-gen-image.sh` script.
11 The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi2-gen-image.sh` script via (simple) shell-variables. Unlike environment shell-variables (simple) shell-variables are defined at the beginning of the command-line call of the `rpi2-gen-image.sh` script.
12
12
13 #####Command-line examples:
13 #####Command-line examples:
14 ```shell
14 ```shell
15 ENABLE_UBOOT=true ./rpi2-gen-image.sh
15 ENABLE_UBOOT=true ./rpi2-gen-image.sh
16 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi2-gen-image.sh
16 ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi2-gen-image.sh
17 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi2-gen-image.sh
17 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi2-gen-image.sh
18 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi2-gen-image.sh
18 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi2-gen-image.sh
19 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi2-gen-image.sh
19 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi2-gen-image.sh
20 ENABLE_MINBASE=true ./rpi2-gen-image.sh
20 ENABLE_MINBASE=true ./rpi2-gen-image.sh
21 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi2-gen-image.sh
21 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi2-gen-image.sh
22 ```
22 ```
23
23
24 #### APT settings:
24 #### APT settings:
25 ##### `APT_SERVER`="ftp.debian.org"
25 ##### `APT_SERVER`="ftp.debian.org"
26 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.
26 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.
27
27
28 ##### `APT_PROXY`=""
28 ##### `APT_PROXY`=""
29 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.
29 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.
30
30
31 ##### `APT_INCLUDES`=""
31 ##### `APT_INCLUDES`=""
32 A comma seperated list of additional packages to be installed during bootstrapping.
32 A comma seperated list of additional packages to be installed during bootstrapping.
33
33
34 #### General system settings:
34 #### General system settings:
35 ##### `HOSTNAME`="rpi2-jessie"
35 ##### `HOSTNAME`="rpi2-jessie"
36 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
36 Set system host name. It's recommended that the host name is unique in the corresponding subnet.
37
37
38 ##### `PASSWORD`="raspberry"
38 ##### `PASSWORD`="raspberry"
39 Set system `root` password. The same password is used for the created user `pi`. It's **STRONGLY** recommended that you choose a custom password.
39 Set system `root` password. The same password is used for the created user `pi`. It's **STRONGLY** recommended that you choose a custom password.
40
40
41 ##### `DEFLOCAL`="en_US.UTF-8"
41 ##### `DEFLOCAL`="en_US.UTF-8"
42 Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. The script variant `minbase` (ENABLE_MINBASE=true) doesn't install `locales`.
42 Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. The script variant `minbase` (ENABLE_MINBASE=true) doesn't install `locales`.
43
43
44 ##### `TIMEZONE`="Europe/Berlin"
44 ##### `TIMEZONE`="Europe/Berlin"
45 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.
45 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.
46
46
47 ##### `EXPANDROOT`=true
47 ##### `EXPANDROOT`=true
48 Expand the root partition and filesystem automatically on first boot.
48 Expand the root partition and filesystem automatically on first boot.
49
49
50 #### Keyboard settings:
50 #### Keyboard settings:
51 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.
51 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.
52
52
53 ##### `XKB_MODEL`=""
53 ##### `XKB_MODEL`=""
54 Set the name of the model of your keyboard type.
54 Set the name of the model of your keyboard type.
55
55
56 ##### `XKB_LAYOUT`=""
56 ##### `XKB_LAYOUT`=""
57 Set the supported keyboard layout(s).
57 Set the supported keyboard layout(s).
58
58
59 ##### `XKB_VARIANT`=""
59 ##### `XKB_VARIANT`=""
60 Set the supported variant(s) of the keyboard layout(s).
60 Set the supported variant(s) of the keyboard layout(s).
61
61
62 ##### `XKB_OPTIONS`=""
62 ##### `XKB_OPTIONS`=""
63 Set extra xkb configuration options.
63 Set extra xkb configuration options.
64
64
65 #### Networking settings (DHCP):
65 #### Networking settings (DHCP):
66 This setting is used to set up networking auto configuration in `/etc/systemd/network/eth.network`.
66 This setting is used to set up networking auto configuration in `/etc/systemd/network/eth.network`.
67
67
68 #####`ENABLE_DHCP`=true
68 #####`ENABLE_DHCP`=true
69 Set the system to use DHCP. This requires an DHCP server.
69 Set the system to use DHCP. This requires an DHCP server.
70
70
71 #### Networking settings (static):
71 #### Networking settings (static):
72 These settings are used to set up a static networking configuration in /etc/systemd/network/eth.network. The following static networking settings are only supported if `ENABLE_DHCP` was set to `false`.
72 These settings are used to set up a static networking configuration in /etc/systemd/network/eth.network. The following static networking settings are only supported if `ENABLE_DHCP` was set to `false`.
73
73
74 #####`NET_ADDRESS`=""
74 #####`NET_ADDRESS`=""
75 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
75 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
76
76
77 #####`NET_GATEWAY`=""
77 #####`NET_GATEWAY`=""
78 Set the IP address for the default gateway.
78 Set the IP address for the default gateway.
79
79
80 #####`NET_DNS_1`=""
80 #####`NET_DNS_1`=""
81 Set the IP address for the first DNS server.
81 Set the IP address for the first DNS server.
82
82
83 #####`NET_DNS_2`=""
83 #####`NET_DNS_2`=""
84 Set the IP address for the second DNS server.
84 Set the IP address for the second DNS server.
85
85
86 #####`NET_DNS_DOMAINS`=""
86 #####`NET_DNS_DOMAINS`=""
87 Set the default DNS search domains to use for non fully qualified host names.
87 Set the default DNS search domains to use for non fully qualified host names.
88
88
89 #####`NET_NTP_1`=""
89 #####`NET_NTP_1`=""
90 Set the IP address for the first NTP server.
90 Set the IP address for the first NTP server.
91
91
92 #####`NET_NTP_2`=""
92 #####`NET_NTP_2`=""
93 Set the IP address for the second NTP server.
93 Set the IP address for the second NTP server.
94
94
95 #### Basic system features:
95 #### Basic system features:
96 ##### `ENABLE_CONSOLE`=true
96 ##### `ENABLE_CONSOLE`=true
97 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
97 Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
98
98
99 ##### `ENABLE_IPV6`=true
99 ##### `ENABLE_IPV6`=true
100 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
100 Enable IPv6 support. The network interface configuration is managed via systemd-networkd.
101
101
102 ##### `ENABLE_SSHD`=true
102 ##### `ENABLE_SSHD`=true
103 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.
103 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.
104
104
105 ##### `ENABLE_RSYSLOG`=true
105 ##### `ENABLE_RSYSLOG`=true
106 If set to false, disable and uninstall rsyslog (so logs will be available only
106 If set to false, disable and uninstall rsyslog (so logs will be available only
107 in journal files)
107 in journal files)
108
108
109 ##### `ENABLE_SOUND`=true
109 ##### `ENABLE_SOUND`=true
110 Enable sound hardware and install Advanced Linux Sound Architecture.
110 Enable sound hardware and install Advanced Linux Sound Architecture.
111
111
112 ##### `ENABLE_HWRANDOM`=true
112 ##### `ENABLE_HWRANDOM`=true
113 Enable Hardware Random Number Generator. Strong random numbers are important for most network based communications that use encryption. It's recommended to be enabled.
113 Enable Hardware Random Number Generator. Strong random numbers are important for most network based communications that use encryption. It's recommended to be enabled.
114
114
115 ##### `ENABLE_MINGPU`=false
115 ##### `ENABLE_MINGPU`=false
116 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
116 Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU.
117
117
118 ##### `ENABLE_DBUS`=true
118 ##### `ENABLE_DBUS`=true
119 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
119 Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled.
120
120
121 ##### `ENABLE_XORG`=false
121 ##### `ENABLE_XORG`=false
122 Install Xorg open-source X Window System.
122 Install Xorg open-source X Window System.
123
123
124 ##### `ENABLE_WM`=""
124 ##### `ENABLE_WM`=""
125 Install a user defined window manager for the X Window System. To make sure all X related package dependencies are getting installed `ENABLE_XORG` will automatically get enabled if `ENABLE_WM` is used. The `rpi2-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
125 Install a user defined window manager for the X Window System. To make sure all X related package dependencies are getting installed `ENABLE_XORG` will automatically get enabled if `ENABLE_WM` is used. The `rpi2-gen-image.sh` script has been tested with the following list of window managers: `blackbox`, `openbox`, `fluxbox`, `jwm`, `dwm`, `xfce4`, `awesome`.
126
126
127 #### Advanced system features:
127 #### Advanced system features:
128 ##### `ENABLE_MINBASE`=false
128 ##### `ENABLE_MINBASE`=false
129 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
129 Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB.
130
130
131 ##### `ENABLE_UBOOT`=false
131 ##### `ENABLE_UBOOT`=false
132 Replace default RPi2 second stage bootloader (bootcode.bin) with U-Boot bootloader. U-Boot can boot images via the network using the BOOTP/TFTP protocol.
132 Replace default RPi2 second stage bootloader (bootcode.bin) with U-Boot bootloader. U-Boot can boot images via the network using the BOOTP/TFTP protocol.
133
133
134 ##### `ENABLE_FBTURBO`=false
134 ##### `ENABLE_FBTURBO`=false
135 Install and enable the hardware accelerated Xorg video driver `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
135 Install and enable the hardware accelerated Xorg video driver `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling.
136
136
137 ##### `ENABLE_IPTABLES`=false
137 ##### `ENABLE_IPTABLES`=false
138 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
138 Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.
139
139
140 ##### `ENABLE_USER`=true
140 ##### `ENABLE_USER`=true
141 Create pi user with password raspberry
141 Create pi user with password raspberry
142
142
143 ##### `ENABLE_ROOT`=true
143 ##### `ENABLE_ROOT`=true
144 Set root user password so root login will be enabled
144 Set root user password so root login will be enabled
145
145
146 ##### `ENABLE_ROOT_SSH`=true
146 ##### `ENABLE_ROOT_SSH`=true
147 Enable password root login via SSH. May be a security risk with default
147 Enable password root login via SSH. May be a security risk with default
148 password, use only in trusted environments.
148 password, use only in trusted environments.
149
149
150 ##### `ENABLE_HARDNET`=false
150 ##### `ENABLE_HARDNET`=false
151 Enable IPv4/IPv6 network stack hardening settings.
151 Enable IPv4/IPv6 network stack hardening settings.
152
152
153 ##### `ENABLE_SPLITFS`=false
153 ##### `ENABLE_SPLITFS`=false
154 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
154 Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`.
155
155
156 ##### `CHROOT_SCRIPTS`=""
156 ##### `CHROOT_SCRIPTS`=""
157 Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this direcory is run in lexicographical order.
157 Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this direcory is run in lexicographical order.
158
158
159 #### Kernel compilation:
159 #### Kernel compilation:
160 ##### `BUILD_KERNEL`=false
160 ##### `BUILD_KERNEL`=false
161 Build and install the latest RPi2 linux kernel. Currently only the default RPi2 kernel configuration is used. Detailed configuration parameters for customizing the kernel and minor bug fixes still need to get implemented. feel free to help.
161 Build and install the latest RPi2 linux kernel. Currently only the default RPi2 kernel configuration is used. Detailed configuration parameters for customizing the kernel and minor bug fixes still need to get implemented. feel free to help.
162
162
163 ##### `KERNEL_THREADS`=1
163 ##### `KERNEL_THREADS`=1
164 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.
164 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.
165
165
166 ##### `KERNEL_HEADERS`=true
166 ##### `KERNEL_HEADERS`=true
167 Install kernel headers with built kernel.
167 Install kernel headers with built kernel.
168
168
169 ##### `KERNEL_MENUCONFIG`=false
170 Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated.
171
169 ##### `KERNEL_RMSRC`=true
172 ##### `KERNEL_RMSRC`=true
170 Remove all kernel sources from the generated OS image after building.
173 Remove all kernel sources from the generated OS image after building.
171
174
172 ## Understanding the script
175 ## Understanding the script
173 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:
176 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:
174
177
175 | Script | Description |
178 | Script | Description |
176 | --- | --- |
179 | --- | --- |
177 | `10-bootstrap.sh` | Debootstrap basic system |
180 | `10-bootstrap.sh` | Debootstrap basic system |
178 | `11-apt.sh` | Setup APT repositories |
181 | `11-apt.sh` | Setup APT repositories |
179 | `12-locale.sh` | Setup Locales and keyboard settings |
182 | `12-locale.sh` | Setup Locales and keyboard settings |
180 | `13-kernel.sh` | Build and install RPi2 Kernel |
183 | `13-kernel.sh` | Build and install RPi2 Kernel |
181 | `20-networking.sh` | Setup Networking |
184 | `20-networking.sh` | Setup Networking |
182 | `21-firewall.sh` | Setup Firewall |
185 | `21-firewall.sh` | Setup Firewall |
183 | `30-security.sh` | Setup Users and Security settings |
186 | `30-security.sh` | Setup Users and Security settings |
184 | `31-logging.sh` | Setup Logging |
187 | `31-logging.sh` | Setup Logging |
185 | `41-uboot.sh` | Build and Setup Uboot |
188 | `41-uboot.sh` | Build and Setup U-Boot |
186 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
189 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
187 | `50-firstboot.sh` | First boot actions |
190 | `50-firstboot.sh` | First boot actions |
188
191
189 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.
192 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.
190
193
191 | Directory | Description |
194 | Directory | Description |
192 | --- | --- |
195 | --- | --- |
193 | `boot` | Boot and RPi2 configuration files |
196 | `boot` | Boot and RPi2 configuration files |
194 | `firstboot` | Scripts that get executed on first boot |
197 | `firstboot` | Scripts that get executed on first boot |
195 | `iptables` | Firewall configuration files |
198 | `iptables` | Firewall configuration files |
196 | `locales` | Locales configuration |
199 | `locales` | Locales configuration |
197 | `modprobe.d` | Kernel Module Blacklist configuration |
200 | `modules` | Kernel Modules configuration |
198 | `mount` | Fstab configuration |
201 | `mount` | Fstab configuration |
199 | `network` | Networking configuration files |
202 | `network` | Networking configuration files |
200 | `sysctl.d` | Swapping and Network Hardening configuration |
203 | `sysctl.d` | Swapping and Network Hardening configuration |
201 | `xorg` | fbturbo Xorg driver configuration |
204 | `xorg` | fbturbo Xorg driver configuration |
202
205
203 ## Logging of the bootstrapping process
206 ## Logging of the bootstrapping process
204 All information related to the bootstrapping process and the commands executed by the `rpi2-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
207 All information related to the bootstrapping process and the commands executed by the `rpi2-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
205
208
206 ```shell
209 ```shell
207 script -c 'APT_SERVER=ftp.de.debian.org ./rpi2-gen-image.sh' ./build.log
210 script -c 'APT_SERVER=ftp.de.debian.org ./rpi2-gen-image.sh' ./build.log
208 ```
211 ```
209
212
210 ## Flashing the image file
213 ## Flashing the image file
211 After the image file was successfully created by the `rpi2-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2 computer. This can be performed by using the tools `bmaptool` or `dd`. Using `bmaptool` will probably speed-up the copy process because `bmaptool` copies more wisely than `dd`.
214 After the image file was successfully created by the `rpi2-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi2 computer. This can be performed by using the tools `bmaptool` or `dd`. Using `bmaptool` will probably speed-up the copy process because `bmaptool` copies more wisely than `dd`.
212
215
213 #####Flashing examples:
216 #####Flashing examples:
214 ```shell
217 ```shell
215 bmaptool copy ./images/jessie/2015-12-13-debian-jessie.img /dev/mmcblk0
218 bmaptool copy ./images/jessie/2015-12-13-debian-jessie.img /dev/mmcblk0
216 dd bs=4M if=./images/jessie/2015-12-13-debian-jessie.img of=/dev/mmcblk0
219 dd bs=4M if=./images/jessie/2015-12-13-debian-jessie.img of=/dev/mmcblk0
217 ```
220 ```
218 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
221 If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive:
219 ```shell
222 ```shell
220 bmaptool copy ./images/jessie/2015-12-13-debian-jessie-frmw.img /dev/mmcblk0
223 bmaptool copy ./images/jessie/2015-12-13-debian-jessie-frmw.img /dev/mmcblk0
221 bmaptool copy ./images/jessie/2015-12-13-debian-jessie-root.img /dev/sdc
224 bmaptool copy ./images/jessie/2015-12-13-debian-jessie-root.img /dev/sdc
222 ```
225 ```
@@ -1,28 +1,28
1 #
1 #
2 # Debootstrap basic system
2 # Debootstrap basic system
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Base debootstrap (unpack only)
8 # Base debootstrap (unpack only)
9 if [ "$ENABLE_MINBASE" = true ] ; then
9 if [ "$ENABLE_MINBASE" = true ] ; then
10 http_proxy=${APT_PROXY} debootstrap --arch=armhf --variant=minbase --foreign --include=${APT_INCLUDES} $RELEASE $R http://${APT_SERVER}/debian
10 http_proxy=${APT_PROXY} debootstrap --arch=${RELEASE_ARCH} --variant=minbase --foreign --include=${APT_INCLUDES} ${RELEASE} $R http://${APT_SERVER}/debian
11 else
11 else
12 http_proxy=${APT_PROXY} debootstrap --arch=armhf --foreign --include=${APT_INCLUDES} $RELEASE $R http://${APT_SERVER}/debian
12 http_proxy=${APT_PROXY} debootstrap --arch=${RELEASE_ARCH} --foreign --include=${APT_INCLUDES} ${RELEASE} $R http://${APT_SERVER}/debian
13 fi
13 fi
14
14
15 # Copy qemu emulator binary to chroot
15 # Copy qemu emulator binary to chroot
16 cp /usr/bin/qemu-arm-static $R/usr/bin
16 cp ${QEMU_BINARY} $R/usr/bin
17
17
18 # Copy debian-archive-keyring.pgp
18 # Copy debian-archive-keyring.pgp
19 mkdir -p $R/usr/share/keyrings
19 mkdir -p $R/usr/share/keyrings
20 cp /usr/share/keyrings/debian-archive-keyring.gpg $R/usr/share/keyrings/debian-archive-keyring.gpg
20 cp /usr/share/keyrings/debian-archive-keyring.gpg $R/usr/share/keyrings/debian-archive-keyring.gpg
21
21
22 # Complete the bootstrapping process
22 # Complete the bootstrapping process
23 chroot_exec /debootstrap/debootstrap --second-stage
23 chroot_exec /debootstrap/debootstrap --second-stage
24
24
25 # Mount required filesystems
25 # Mount required filesystems
26 mount -t proc none $R/proc
26 mount -t proc none $R/proc
27 mount -t sysfs none $R/sys
27 mount -t sysfs none $R/sys
28 mount --bind /dev/pts $R/dev/pts
28 mount --bind /dev/pts $R/dev/pts
@@ -1,29 +1,29
1 #
1 #
2 # Setup APT repositories
2 # Setup APT repositories
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Use proxy inside chroot
8 # Install and setup APT proxy configuration
9 if [ -z "$APT_PROXY" ] ; then
9 if [ -z "$APT_PROXY" ] ; then
10 install_readonly files/apt/10proxy $R/etc/apt/apt.conf.d/10proxy
10 install_readonly files/apt/10proxy $R/etc/apt/apt.conf.d/10proxy
11 sed -i "s/\"\"/\"${APT_PROXY}\"/" $R/etc/apt/apt.conf.d/10proxy
11 sed -i "s/\"\"/\"${APT_PROXY}\"/" $R/etc/apt/apt.conf.d/10proxy
12 fi
12 fi
13
13
14 # Pin package flash-kernel to repositories.collabora.co.uk
14 # Install APT pinning configuration for flash-kernel package
15 install_readonly files/apt/flash-kernel $R/etc/apt/preferences.d/flash-kernel
15 install_readonly files/apt/flash-kernel $R/etc/apt/preferences.d/flash-kernel
16
16
17 # Upgrade collabora package index and install collabora keyring
17 # Upgrade collabora package index and install collabora keyring
18 echo "deb https://repositories.collabora.co.uk/debian ${RELEASE} rpi2" >$R/etc/apt/sources.list
18 echo "deb https://repositories.collabora.co.uk/debian ${RELEASE} rpi2" >$R/etc/apt/sources.list
19 chroot_exec apt-get -qq -y update
19 chroot_exec apt-get -qq -y update
20 chroot_exec apt-get -qq -y --force-yes install collabora-obs-archive-keyring
20 chroot_exec apt-get -qq -y --force-yes install collabora-obs-archive-keyring
21
21
22 # Set up initial sources.list
22 # Install APT sources.list
23 install_readonly files/apt/sources.list $R/etc/apt/sources.list
23 install_readonly files/apt/sources.list $R/etc/apt/sources.list
24 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" $R/etc/apt/sources.list
24 sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" $R/etc/apt/sources.list
25 sed -i "s/ jessie/ ${RELEASE}/" $R/etc/apt/sources.list
25 sed -i "s/ jessie/ ${RELEASE}/" $R/etc/apt/sources.list
26
26
27 # Upgrade package index and update all installed packages and changed dependencies
27 # Upgrade package index and update all installed packages and changed dependencies
28 chroot_exec apt-get -qq -y update
28 chroot_exec apt-get -qq -y update
29 chroot_exec apt-get -qq -y -u dist-upgrade
29 chroot_exec apt-get -qq -y -u dist-upgrade
@@ -1,58 +1,58
1 #
1 #
2 # Setup Locales and keyboard settings
2 # Setup Locales and keyboard settings
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Set up timezone
8 # Install and setup timezone
9 echo ${TIMEZONE} >$R/etc/timezone
9 echo ${TIMEZONE} >$R/etc/timezone
10 chroot_exec dpkg-reconfigure -f noninteractive tzdata
10 chroot_exec dpkg-reconfigure -f noninteractive tzdata
11
11
12 # Set up default locale and keyboard configuration
12 # Install and setup default locale and keyboard configuration
13 if [ "$ENABLE_MINBASE" = false ] ; then
13 if [ "$ENABLE_MINBASE" = false ] ; then
14 # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug
14 # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug
15 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957
15 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957
16 # ... so we have to set locales manually
16 # ... so we have to set locales manually
17 if [ "$DEFLOCAL" = "en_US.UTF-8" ] ; then
17 if [ "$DEFLOCAL" = "en_US.UTF-8" ] ; then
18 chroot_exec echo "locales locales/locales_to_be_generated multiselect ${DEFLOCAL} UTF-8" | debconf-set-selections
18 chroot_exec echo "locales locales/locales_to_be_generated multiselect ${DEFLOCAL} UTF-8" | debconf-set-selections
19 else
19 else
20 # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale
20 # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale
21 chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections
21 chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections
22 sed -i "/en_US.UTF-8/s/^#//" $R/etc/locale.gen
22 sed -i "/en_US.UTF-8/s/^#//" $R/etc/locale.gen
23 fi
23 fi
24
24
25 sed -i "/${DEFLOCAL}/s/^#//" $R/etc/locale.gen
25 sed -i "/${DEFLOCAL}/s/^#//" $R/etc/locale.gen
26 chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections
26 chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections
27 chroot_exec locale-gen
27 chroot_exec locale-gen
28 chroot_exec update-locale LANG=${DEFLOCAL}
28 chroot_exec update-locale LANG=${DEFLOCAL}
29
29
30 # Keyboard configuration, if requested
30 # Install and setup default keyboard configuration
31 if [ "$XKB_MODEL" != "" ] ; then
31 if [ "$XKB_MODEL" != "" ] ; then
32 sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" $R/etc/default/keyboard
32 sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" $R/etc/default/keyboard
33 fi
33 fi
34 if [ "$XKB_LAYOUT" != "" ] ; then
34 if [ "$XKB_LAYOUT" != "" ] ; then
35 sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" $R/etc/default/keyboard
35 sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" $R/etc/default/keyboard
36 fi
36 fi
37 if [ "$XKB_VARIANT" != "" ] ; then
37 if [ "$XKB_VARIANT" != "" ] ; then
38 sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" $R/etc/default/keyboard
38 sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" $R/etc/default/keyboard
39 fi
39 fi
40 if [ "$XKB_OPTIONS" != "" ] ; then
40 if [ "$XKB_OPTIONS" != "" ] ; then
41 sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" $R/etc/default/keyboard
41 sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" $R/etc/default/keyboard
42 fi
42 fi
43 chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration
43 chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration
44
44
45 # Set up font console
45 # Install and setup font console
46 case "${DEFLOCAL}" in
46 case "${DEFLOCAL}" in
47 *UTF-8)
47 *UTF-8)
48 sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' $R/etc/default/console-setup
48 sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' $R/etc/default/console-setup
49 ;;
49 ;;
50 *)
50 *)
51 sed -i 's/^CHARMAP.*/CHARMAP="guess"/' $R/etc/default/console-setup
51 sed -i 's/^CHARMAP.*/CHARMAP="guess"/' $R/etc/default/console-setup
52 ;;
52 ;;
53 esac
53 esac
54 chroot_exec dpkg-reconfigure -f noninteractive console-setup
54 chroot_exec dpkg-reconfigure -f noninteractive console-setup
55 else # ENABLE_MINBASE=true
55 else # ENABLE_MINBASE=true
56 # Set POSIX default locales
56 # Install POSIX default locale
57 install_readonly files/locales/locale $R/etc/default/locale
57 install_readonly files/locales/locale $R/etc/default/locale
58 fi
58 fi
@@ -1,122 +1,125
1 #
1 #
2 # Build and Setup RPi2 Kernel
2 # Build and Setup RPi2 Kernel
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Fetch and build latest raspberry kernel
8 # Fetch and build latest raspberry kernel
9 if [ "$BUILD_KERNEL" = true ] ; then
9 if [ "$BUILD_KERNEL" = true ] ; then
10 # Fetch current raspberrypi kernel sources
10 # Fetch current raspberrypi kernel sources
11 git -C $R/usr/src clone --depth=1 https://github.com/raspberrypi/linux
11 git -C $R/usr/src clone --depth=1 https://github.com/raspberrypi/linux
12
12
13 # Load default raspberry kernel configuration
13 # Load default raspberry kernel configuration
14 make -C $R/usr/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
14 make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} bcm2709_defconfig
15
15
16 # Calculate optimal number of kernel building threads
16 # Calculate optimal number of kernel building threads
17 if [ "KERNEL_THREADS" = 1 ] ; then
17 if [ "$KERNEL_THREADS" = 1 ] ; then
18 if [ -f /proc/cpuinfo ] ; then
18 if [ -f /proc/cpuinfo ] ; then
19 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
19 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
20 fi
20 fi
21 fi
21 fi
22
22
23 # Start menu-driven kernel configuration (interactive)
24 if [ "$KERNEL_MENUCONFIG" = true ] ; then
25 make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} menuconfig
26 fi
27
23 # Cross compile kernel and modules
28 # Cross compile kernel and modules
24 make -C $R/usr/src/linux -j${KERNEL_THREADS} ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs
29 make -C $R/usr/src/linux -j${KERNEL_THREADS} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} zImage modules dtbs
25
30
26 # Install kernel modules
31 # Install kernel modules
27 make -C $R/usr/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../../.. modules_install
32 make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_MOD_PATH=../../.. modules_install
28
33
29 # Install kernel headers
34 # Install kernel headers
30 if [ "$KERNEL_HEADERS" = true ]; then
35 if [ "$KERNEL_HEADERS" = true ]; then
31 make -C $R/usr/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_HDR_PATH=../.. headers_install
36 make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_HDR_PATH=../.. headers_install
32 fi
37 fi
33
38
34 # Copy and rename compiled kernel to boot directory
39 # Copy and rename compiled kernel to boot directory
35 mkdir $R/boot/firmware/
40 mkdir $R/boot/firmware/
36 $R/usr/src/linux/scripts/mkknlimg $R/usr/src/linux/arch/arm/boot/zImage $R/boot/firmware/kernel7.img
41 $R/usr/src/linux/scripts/mkknlimg $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/zImage $R/boot/firmware/kernel7.img
37
42
38 # Copy dts and dtb device definitions
43 # Copy dts and dtb device definitions
39 mkdir $R/boot/firmware/overlays/
44 mkdir $R/boot/firmware/overlays/
40 cp $R/usr/src/linux/arch/arm/boot/dts/*.dtb $R/boot/firmware/
45 cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/*.dtb $R/boot/firmware/
41 cp $R/usr/src/linux/arch/arm/boot/dts/overlays/*.dtb* $R/boot/firmware/overlays/
46 cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/*.dtb* $R/boot/firmware/overlays/
42 cp $R/usr/src/linux/arch/arm/boot/dts/overlays/README $R/boot/firmware/overlays/
47 cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/README $R/boot/firmware/overlays/
43
48
44 # Remove kernel sources
49 # Remove kernel sources
45 if [ "$KERNEL_RMSRC" = true ]; then
50 if [ "$KERNEL_RMSRC" = true ]; then
46 rm -fr $R/usr/src/linux
51 rm -fr $R/usr/src/linux
47 fi
52 fi
48
53
49 # Install raspberry bootloader and flash-kernel
54 # Install raspberry bootloader and flash-kernel packages
50 chroot_exec apt-get -qq -y --no-install-recommends install raspberrypi-bootloader-nokernel
55 chroot_exec apt-get -qq -y --no-install-recommends install raspberrypi-bootloader-nokernel
51 else # BUILD_KERNEL=false
56 else # BUILD_KERNEL=false
52 # Kernel installation
57 # Kernel installation
53 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${COLLABORA_KERNEL} raspberrypi-bootloader-nokernel
58 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${COLLABORA_KERNEL} raspberrypi-bootloader-nokernel
54
59
55 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
60 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
56 chroot_exec apt-get -qq -y install flash-kernel
61 chroot_exec apt-get -qq -y install flash-kernel
57
62
58 VMLINUZ="$(ls -1 $R/boot/vmlinuz-* | sort | tail -n 1)"
63 VMLINUZ="$(ls -1 $R/boot/vmlinuz-* | sort | tail -n 1)"
59 [ -z "$VMLINUZ" ] && exit 1
64 [ -z "$VMLINUZ" ] && exit 1
60 cp $VMLINUZ $R/boot/firmware/kernel7.img
65 cp $VMLINUZ $R/boot/firmware/kernel7.img
61 fi
66 fi
62
67
63 # Set up firmware boot cmdline
68 # Setup firmware boot cmdline
64 if [ "$ENABLE_SPLITFS" = true ] ; then
69 if [ "$ENABLE_SPLITFS" = true ] ; then
65 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1 ${CMDLINE}"
70 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1 ${CMDLINE}"
66 else
71 else
67 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1 ${CMDLINE}"
72 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1 ${CMDLINE}"
68 fi
73 fi
69
74
70 # Set up serial console support (if requested)
75 # Add serial console support
71 if [ "$ENABLE_CONSOLE" = true ] ; then
76 if [ "$ENABLE_CONSOLE" = true ] ; then
72 CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
77 CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
73 fi
78 fi
74
79
75 # Set up IPv6 networking support
80 # Remove IPv6 networking support
76 if [ "$ENABLE_IPV6" = false ] ; then
81 if [ "$ENABLE_IPV6" = false ] ; then
77 CMDLINE="${CMDLINE} ipv6.disable=1"
82 CMDLINE="${CMDLINE} ipv6.disable=1"
78 fi
83 fi
79
84
85 # Install firmware boot cmdline
80 echo "${CMDLINE}" >$R/boot/firmware/cmdline.txt
86 echo "${CMDLINE}" >$R/boot/firmware/cmdline.txt
81
87
82 # Set up firmware config
88 # Install firmware config
83 install_readonly files/boot/config.txt $R/boot/firmware/config.txt
89 install_readonly files/boot/config.txt $R/boot/firmware/config.txt
84
90
85 # Load snd_bcm2835 kernel module at boot time
91 # Setup minimal GPU memory allocation size: 16MB (no X)
86 if [ "$ENABLE_SOUND" = true ] ; then
87 echo "snd_bcm2835" >>$R/etc/modules
88 fi
89
90 # Set smallest possible GPU memory allocation size: 16MB (no X)
91 if [ "$ENABLE_MINGPU" = true ] ; then
92 if [ "$ENABLE_MINGPU" = true ] ; then
92 echo "gpu_mem=16" >>$R/boot/firmware/config.txt
93 echo "gpu_mem=16" >>$R/boot/firmware/config.txt
93 fi
94 fi
94
95
95 # Create symlinks
96 # Create firmware configuration and cmdline symlinks
96 ln -sf firmware/config.txt $R/boot/config.txt
97 ln -sf firmware/config.txt $R/boot/config.txt
97 ln -sf firmware/cmdline.txt $R/boot/cmdline.txt
98 ln -sf firmware/cmdline.txt $R/boot/cmdline.txt
98
99
99 # Prepare modules-load.d directory
100 # Install and setup kernel modules to load at boot
100 mkdir -p $R/lib/modules-load.d/
101 mkdir -p $R/lib/modules-load.d/
102 install_readonly files/modules/rpi2.conf $R/lib/modules-load.d/rpi2.conf
101
103
102 # Load random module on boot
104 # Load hardware random module at boot
103 if [ "$ENABLE_HWRANDOM" = true ] ; then
105 if [ "$ENABLE_HWRANDOM" = true ] ; then
104 cat <<EOM >$R/lib/modules-load.d/rpi2.conf
106 sed -i "s/^# bcm2708_rng/bcm2708_rng/" $R/lib/modules-load.d/rpi2.conf
105 bcm2708_rng
106 EOM
107 fi
107 fi
108
108
109 # Prepare modprobe.d directory
109 # Load sound module at boot
110 mkdir -p $R/etc/modprobe.d/
110 if [ "$ENABLE_SOUND" = true ] ; then
111 sed -i "s/^# snd_bcm2835/snd_bcm2835/" $R/lib/modules-load.d/rpi2.conf
112 fi
111
113
112 # Blacklist sound modules
114 # Install kernel modules blacklist
113 install_readonly files/modprobe.d/raspi-blacklist.conf $R/etc/modprobe.d/raspi-blacklist.conf
115 mkdir -p $R/etc/modprobe.d/
116 install_readonly files/modules/raspi-blacklist.conf $R/etc/modprobe.d/raspi-blacklist.conf
114
117
115 # Create default fstab
118 # Install and setup fstab
116 install_readonly files/mount/fstab $R/etc/fstab
119 install_readonly files/mount/fstab $R/etc/fstab
117 if [ "$ENABLE_SPLITFS" = true ] ; then
120 if [ "$ENABLE_SPLITFS" = true ] ; then
118 sed -i 's/mmcblk0p2/sda1/' $R/etc/fstab
121 sed -i 's/mmcblk0p2/sda1/' $R/etc/fstab
119 fi
122 fi
120
123
121 # Avoid swapping and increase cache sizes
124 # Install sysctl.d configuration files
122 install_readonly files/sysctl.d/81-rpi-vm.conf $R/etc/sysctl.d/81-rpi-vm.conf
125 install_readonly files/sysctl.d/81-rpi-vm.conf $R/etc/sysctl.d/81-rpi-vm.conf
@@ -1,68 +1,72
1 #
1 #
2 # Setup Networking
2 # Setup Networking
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Set up IPv4 hosts
8 # Install and setup hostname
9 install_readonly files/network/hostname $R/etc/hostname
9 install_readonly files/network/hostname $R/etc/hostname
10 sed -i "s/^rpi2-jessie/${HOSTNAME}/" $R/etc/hostname
10 sed -i "s/^rpi2-jessie/${HOSTNAME}/" $R/etc/hostname
11
11
12 # Install and setup hosts
12 install_readonly files/network/hosts $R/etc/hosts
13 install_readonly files/network/hosts $R/etc/hosts
13 sed -i "s/rpi2-jessie/${HOSTNAME}/" $R/etc/hosts
14 sed -i "s/rpi2-jessie/${HOSTNAME}/" $R/etc/hosts
14
15
16 # Setup hostname entry with static IP
15 if [ "$NET_ADDRESS" != "" ] ; then
17 if [ "$NET_ADDRESS" != "" ] ; then
16 NET_IP=$(echo ${NET_ADDRESS} | cut -f 1 -d'/')
18 NET_IP=$(echo ${NET_ADDRESS} | cut -f 1 -d'/')
17 sed -i "s/^127.0.1.1/${NET_IP}/" $R/etc/hosts
19 sed -i "s/^127.0.1.1/${NET_IP}/" $R/etc/hosts
18 fi
20 fi
19
21
20 # Set up IPv6 hosts
22 # Remove IPv6 hosts
21 if [ "$ENABLE_IPV6" = true ] ; then
23 if [ "$ENABLE_IPV6" = false ] ; then
22 cat <<EOM >>$R/etc/hosts
24 sed -i -e "/::[1-9]/d" -e "/^$/d" $R/etc/hosts
23
24 ::1 localhost ip6-localhost ip6-loopback
25 ff02::1 ip6-allnodes
26 ff02::2 ip6-allrouters
27 EOM
28 fi
25 fi
29
26
30 # Place hint about network configuration
27 # Install hint about network configuration
31 install_readonly files/network/interfaces $R/etc/network/interfaces
28 install_readonly files/network/interfaces $R/etc/network/interfaces
32
29
30 # Install configuration for interface eth0
31 install_readonly files/network/eth.network $R/etc/systemd/network/eth.network
32
33 if [ "$ENABLE_DHCP" = true ] ; then
33 if [ "$ENABLE_DHCP" = true ] ; then
34 # Enable systemd-networkd DHCP configuration for interface eth0
34 # Enable DHCP configuration for interface eth0
35 install_readonly files/network/eth.network $R/etc/systemd/network/eth.network
35 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" $R/etc/systemd/network/eth.network
36
36
37 # Set DHCP configuration to IPv4 only
37 # Set DHCP configuration to IPv4 only
38 if [ "$ENABLE_IPV6" = false ] ; then
38 if [ "$ENABLE_IPV6" = false ] ; then
39 sed -i "s/^DHCP=yes/DHCP=v4/" $R/etc/systemd/network/eth.network
39 sed -i "s/DHCP=.*/DHCP=v4/" $R/etc/systemd/network/eth.network
40 fi
40 fi
41
41
42 else # ENABLE_DHCP=false
42 else # ENABLE_DHCP=false
43 cat <<EOM >$R/etc/systemd/network/eth.network
43 # Set static network configuration for interface eth0
44 [Match]
44 sed -i\
45 Name=eth0
45 -e "s|DHCP=.*|DHCP=no|"\
46
46 -e "s|Address=\$|Address=${NET_ADDRESS}|"\
47 [Network]
47 -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\
48 DHCP=no
48 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\
49 Address=${NET_ADDRESS}
49 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\
50 Gateway=${NET_GATEWAY}
50 -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\
51 DNS=${NET_DNS_1}
51 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\
52 DNS=${NET_DNS_2}
52 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\
53 Domains=${NET_DNS_DOMAINS}
53 $R/etc/systemd/network/eth.network
54 NTP=${NET_NTP_1}
55 NTP=${NET_NTP_2}
56 EOM
57 fi
54 fi
58
55
56 # Remove empty settings from network configuration
57 sed -i "/.*=\$/d" $R/etc/systemd/network/eth.network
58
59 # Enable systemd-networkd service
59 # Enable systemd-networkd service
60 chroot_exec systemctl enable systemd-networkd
60 chroot_exec systemctl enable systemd-networkd
61
61
62 # Install host.conf resolver configuration
63 install_readonly files/network/host.conf $R/etc/host.conf
64
62 # Enable network stack hardening
65 # Enable network stack hardening
63 if [ "$ENABLE_HARDNET" = true ] ; then
66 if [ "$ENABLE_HARDNET" = true ] ; then
67 # Install sysctl.d configuration files
64 install_readonly files/sysctl.d/82-rpi-net-hardening.conf $R/etc/sysctl.d/82-rpi-net-hardening.conf
68 install_readonly files/sysctl.d/82-rpi-net-hardening.conf $R/etc/sysctl.d/82-rpi-net-hardening.conf
65
69
66 # Enable resolver warnings about spoofed addresses
70 # Setup resolver warnings about spoofed addresses
67 install_readonly files/network/host.conf $R/etc/host.conf
71 sed -i "s/^# spoof warn/spoof warn/" $R/etc/host.conf
68 fi
72 fi
@@ -1,44 +1,44
1 #
1 #
2 # Setup Firewall
2 # Setup Firewall
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 if [ "$ENABLE_IPTABLES" = true ] ; then
8 if [ "$ENABLE_IPTABLES" = true ] ; then
9 # Create iptables configuration directory
9 # Create iptables configuration directory
10 mkdir -p "$R/etc/iptables"
10 mkdir -p "$R/etc/iptables"
11
11
12 # Create iptables systemd service
12 # Install iptables systemd service
13 install_readonly files/iptables/iptables.service $R/etc/systemd/system/iptables.service
13 install_readonly files/iptables/iptables.service $R/etc/systemd/system/iptables.service
14
14
15 # Create flush-table script called by iptables service
15 # Install flush-table script called by iptables service
16 install_exec files/iptables/flush-iptables.sh $R/etc/iptables/flush-iptables.sh
16 install_exec files/iptables/flush-iptables.sh $R/etc/iptables/flush-iptables.sh
17
17
18 # Create iptables rule file
18 # Install iptables rule file
19 install_readonly files/iptables/iptables.rules $R/etc/iptables/iptables.rules
19 install_readonly files/iptables/iptables.rules $R/etc/iptables/iptables.rules
20
20
21 # Reload systemd configuration and enable iptables service
21 # Reload systemd configuration and enable iptables service
22 chroot_exec systemctl daemon-reload
22 chroot_exec systemctl daemon-reload
23 chroot_exec systemctl enable iptables.service
23 chroot_exec systemctl enable iptables.service
24
24
25 if [ "$ENABLE_IPV6" = true ] ; then
25 if [ "$ENABLE_IPV6" = true ] ; then
26 # Create ip6tables systemd service
26 # Install ip6tables systemd service
27 install_readonly files/iptables/ip6tables.service $R/etc/systemd/system/ip6tables.service
27 install_readonly files/iptables/ip6tables.service $R/etc/systemd/system/ip6tables.service
28
28
29 # Create ip6tables file
29 # Install ip6tables file
30 install_exec files/iptables/flush-ip6tables.sh $R/etc/iptables/flush-ip6tables.sh
30 install_exec files/iptables/flush-ip6tables.sh $R/etc/iptables/flush-ip6tables.sh
31
31
32 install_readonly files/iptables/ip6tables.rules $R/etc/iptables/ip6tables.rules
32 install_readonly files/iptables/ip6tables.rules $R/etc/iptables/ip6tables.rules
33
33
34 # Reload systemd configuration and enable iptables service
34 # Reload systemd configuration and enable iptables service
35 chroot_exec systemctl daemon-reload
35 chroot_exec systemctl daemon-reload
36 chroot_exec systemctl enable ip6tables.service
36 chroot_exec systemctl enable ip6tables.service
37 fi
37 fi
38 fi
38 fi
39
39
40 if [ "$ENABLE_SSHD" = false ] ; then
40 if [ "$ENABLE_SSHD" = false ] ; then
41 # Remove SSHD related iptables rules
41 # Remove SSHD related iptables rules
42 sed -i "/^#/! {/SSH/ s/^/# /}" $R/etc/iptables/iptables.rules 2> /dev/null
42 sed -i "/^#/! {/SSH/ s/^/# /}" $R/etc/iptables/iptables.rules 2> /dev/null
43 sed -i "/^#/! {/SSH/ s/^/# /}" $R/etc/iptables/ip6tables.rules 2> /dev/null
43 sed -i "/^#/! {/SSH/ s/^/# /}" $R/etc/iptables/ip6tables.rules 2> /dev/null
44 fi
44 fi
@@ -1,32 +1,32
1 #
1 #
2 # Setup users and security settings
2 # Setup users and security settings
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Generate crypt(3) password string
8 # Generate crypt(3) password string
9 ENCRYPTED_PASSWORD=`mkpasswd -m sha-512 ${PASSWORD}`
9 ENCRYPTED_PASSWORD=`mkpasswd -m sha-512 ${PASSWORD}`
10
10
11 # Set up default user
11 # Setup default user
12 if [ "$ENABLE_USER" = true ] ; then
12 if [ "$ENABLE_USER" = true ] ; then
13 chroot_exec adduser --gecos pi --add_extra_groups --disabled-password pi
13 chroot_exec adduser --gecos pi --add_extra_groups --disabled-password pi
14 chroot_exec usermod -a -G sudo -p "${ENCRYPTED_PASSWORD}" pi
14 chroot_exec usermod -a -G sudo -p "${ENCRYPTED_PASSWORD}" pi
15 fi
15 fi
16
16
17 # Set up root password or not
17 # Setup root password or not
18 if [ "$ENABLE_ROOT" = true ]; then
18 if [ "$ENABLE_ROOT" = true ]; then
19 chroot_exec usermod -p "${ENCRYPTED_PASSWORD}" root
19 chroot_exec usermod -p "${ENCRYPTED_PASSWORD}" root
20
20
21 if [ "$ENABLE_ROOT_SSH" = true ]; then
21 if [ "$ENABLE_ROOT_SSH" = true ]; then
22 sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin yes|g" $R/etc/ssh/sshd_config
22 sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin yes|g" $R/etc/ssh/sshd_config
23 fi
23 fi
24 else
24 else
25 # Set no root password to disable root login
25 # Set no root password to disable root login
26 chroot_exec usermod -p \'!\' root
26 chroot_exec usermod -p \'!\' root
27 fi
27 fi
28
28
29 # Enable serial console systemd style
29 # Enable serial console systemd style
30 if [ "$ENABLE_CONSOLE" = true ] ; then
30 if [ "$ENABLE_CONSOLE" = true ] ; then
31 chroot_exec systemctl enable serial-getty\@ttyAMA0.service
31 chroot_exec systemctl enable serial-getty\@ttyAMA0.service
32 fi
32 fi
@@ -1,31 +1,31
1 #
1 #
2 # Build and Setup Uboot
2 # Build and Setup U-Boot
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Install gcc/c++ build environment inside the chroot
8 # Install gcc/c++ build environment inside the chroot
9 if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then
9 if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then
10 chroot_exec apt-get install -q -y --force-yes --no-install-recommends linux-compiler-gcc-4.9-arm g++ make bc
10 chroot_exec apt-get install -q -y --force-yes --no-install-recommends linux-compiler-gcc-4.9-arm g++ make bc
11 fi
11 fi
12
12
13 # Fetch and build U-Boot bootloader
13 # Fetch and build U-Boot bootloader
14 if [ "$ENABLE_UBOOT" = true ] ; then
14 if [ "$ENABLE_UBOOT" = true ] ; then
15 # Fetch U-Boot bootloader sources
15 # Fetch U-Boot bootloader sources
16 git -C $R/tmp clone git://git.denx.de/u-boot.git
16 git -C $R/tmp clone git://git.denx.de/u-boot.git
17
17
18 # Build and install U-Boot inside chroot
18 # Build and install U-Boot inside chroot
19 chroot_exec make -C /tmp/u-boot/ rpi_2_defconfig all
19 chroot_exec make -C /tmp/u-boot/ rpi_2_defconfig all
20
20
21 # Copy compiled bootloader binary and set config.txt to load it
21 # Copy compiled bootloader binary and set config.txt to load it
22 cp $R/tmp/u-boot/u-boot.bin $R/boot/firmware/
22 cp $R/tmp/u-boot/u-boot.bin $R/boot/firmware/
23 printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> $R/boot/firmware/config.txt
23 printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> $R/boot/firmware/config.txt
24
24
25 # Set U-Boot command file
25 # Install and setup U-Boot command file
26 install_readonly files/boot/uboot.mkimage $R/boot/firmware/uboot.mkimage
26 install_readonly files/boot/uboot.mkimage $R/boot/firmware/uboot.mkimage
27 printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat $R/boot/firmware/uboot.mkimage)" > $R/boot/firmware/uboot.mkimage
27 printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat $R/boot/firmware/uboot.mkimage)" > $R/boot/firmware/uboot.mkimage
28
28
29 # Generate U-Boot image from command file
29 # Generate U-Boot bootloader image
30 chroot_exec /tmp/u-boot/tools/mkimage -A arm -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n RPi2 -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr
30 chroot_exec /tmp/u-boot/tools/mkimage -A ${KERNEL_ARCH} -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n RPi2 -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr
31 fi
31 fi
@@ -1,34 +1,34
1 #
1 #
2 # Build and Setup fbturbo Xorg driver
2 # Build and Setup fbturbo Xorg driver
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 if [ "$ENABLE_FBTURBO" = true ] ; then
8 if [ "$ENABLE_FBTURBO" = true ] ; then
9 # Fetch fbturbo driver sources
9 # Fetch fbturbo driver sources
10 git -C $R/tmp clone https://github.com/ssvb/xf86-video-fbturbo.git
10 git -C $R/tmp clone https://github.com/ssvb/xf86-video-fbturbo.git
11
11
12 # Install Xorg build dependencies
12 # Install Xorg build dependencies
13 chroot_exec apt-get install -q -y --no-install-recommends xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev
13 chroot_exec apt-get install -q -y --no-install-recommends xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev
14
14
15 # Build and install fbturbo driver inside chroot
15 # Build and install fbturbo driver inside chroot
16 chroot_exec /bin/bash -x <<'EOF'
16 chroot_exec /bin/bash -x <<'EOF'
17 cd /tmp/xf86-video-fbturbo
17 cd /tmp/xf86-video-fbturbo
18 autoreconf -vi
18 autoreconf -vi
19 ./configure --prefix=/usr
19 ./configure --prefix=/usr
20 make
20 make
21 make install
21 make install
22 EOF
22 EOF
23
23
24 # Add fbturbo driver to Xorg configuration
24 # Install fbturbo driver Xorg configuration
25 install_readonly files/xorg/99-fbturbo.conf $R/usr/share/X11/xorg.conf.d/99-fbturbo.conf
25 install_readonly files/xorg/99-fbturbo.conf $R/usr/share/X11/xorg.conf.d/99-fbturbo.conf
26
26
27 # Remove Xorg build dependencies
27 # Remove Xorg build dependencies
28 chroot_exec apt-get -q -y purge --auto-remove xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev
28 chroot_exec apt-get -q -y purge --auto-remove xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev
29 fi
29 fi
30
30
31 # Remove gcc/c++ build environment from the chroot
31 # Remove gcc/c++ build environment from the chroot
32 if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then
32 if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then
33 chroot_exec apt-get -y -q purge --auto-remove bc binutils cpp cpp-4.9 g++ g++-4.9 gcc gcc-4.9 libasan1 libatomic1 libc-dev-bin libc6-dev libcloog-isl4 libgcc-4.9-dev libgomp1 libisl10 libmpc3 libmpfr4 libstdc++-4.9-dev libubsan0 linux-compiler-gcc-4.9-arm linux-libc-dev make
33 chroot_exec apt-get -y -q purge --auto-remove bc binutils cpp cpp-4.9 g++ g++-4.9 gcc gcc-4.9 libasan1 libatomic1 libc-dev-bin libc6-dev libcloog-isl4 libgcc-4.9-dev libgomp1 libisl10 libmpc3 libmpfr4 libstdc++-4.9-dev libubsan0 linux-compiler-gcc-4.9-arm linux-libc-dev make
34 fi
34 fi
1 NO CONTENT: file renamed from files/modprobe.d/raspi-blacklist.conf to files/modules/raspi-blacklist.conf
NO CONTENT: file renamed from files/modprobe.d/raspi-blacklist.conf to files/modules/raspi-blacklist.conf
@@ -1,5 +1,12
1 [Match]
1 [Match]
2 Name=eth0
2 Name=eth0
3
3
4 [Network]
4 [Network]
5 DHCP=yes
5 DHCP=no
6 Address=
7 Gateway=
8 DNS=
9 DNS=
10 Domains=
11 NTP=
12 NTP=
@@ -1,1 +1,2
1 spoof warn
1 # spoof warn
2 multi on
@@ -1,2 +1,6
1 127.0.0.1 localhost
1 127.0.0.1 localhost
2 127.0.1.1 rpi2-jessie
2 127.0.1.1 rpi2-jessie
3
4 ::1 localhost ip6-localhost ip6-loopback
5 ff02::1 ip6-allnodes
6 ff02::2 ip6-allrouters
@@ -1,353 +1,361
1 #!/bin/sh
1 #!/bin/sh
2
2
3 ########################################################################
3 ########################################################################
4 # rpi2-gen-image.sh ver2a 12/2015
4 # rpi2-gen-image.sh ver2a 12/2015
5 #
5 #
6 # Advanced debian "jessie" bootstrap script for RPi2
6 # Advanced debian "jessie" bootstrap script for RPi2
7 #
7 #
8 # This program is free software; you can redistribute it and/or
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
11 # of the License, or (at your option) any later version.
12 #
12 #
13 # some parts based on rpi2-build-image:
13 # some parts based on rpi2-build-image:
14 # Copyright (C) 2015 Ryan Finnie <ryan@finnie.org>
14 # Copyright (C) 2015 Ryan Finnie <ryan@finnie.org>
15 # Copyright (C) 2015 Luca Falavigna <dktrkranz@debian.org>
15 # Copyright (C) 2015 Luca Falavigna <dktrkranz@debian.org>
16 ########################################################################
16 ########################################################################
17
17
18 # Load utility functions
18 # Load utility functions
19 . ./functions.sh
19 . ./functions.sh
20
20
21 # Introduce settings
21 # Introduce settings
22 set -e
22 set -e
23 echo -n -e "\n#\n# RPi2 Bootstrap Settings\n#\n"
23 echo -n -e "\n#\n# RPi2 Bootstrap Settings\n#\n"
24 set -x
24 set -x
25
25
26 # Debian release
26 # Debian release
27 RELEASE=${RELEASE:=jessie}
27 RELEASE=${RELEASE:=jessie}
28 KERNEL_ARCH=${KERNEL_ARCH:=arm}
29 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
30 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
28 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
31 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
32 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
29
33
30 # Build settings
34 # Build settings
31 BASEDIR=$(pwd)/images/${RELEASE}
35 BASEDIR=$(pwd)/images/${RELEASE}
32 BUILDDIR=${BASEDIR}/build
36 BUILDDIR=${BASEDIR}/build
33
37
34 # General settings
38 # General settings
35 HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}}
39 HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}}
36 PASSWORD=${PASSWORD:=raspberry}
40 PASSWORD=${PASSWORD:=raspberry}
37 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
41 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
38 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
42 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
39 EXPANDROOT=${EXPANDROOT:=true}
43 EXPANDROOT=${EXPANDROOT:=true}
40
44
41 # Keyboard settings
45 # Keyboard settings
42 XKB_MODEL=${XKB_MODEL:=""}
46 XKB_MODEL=${XKB_MODEL:=""}
43 XKB_LAYOUT=${XKB_LAYOUT:=""}
47 XKB_LAYOUT=${XKB_LAYOUT:=""}
44 XKB_VARIANT=${XKB_VARIANT:=""}
48 XKB_VARIANT=${XKB_VARIANT:=""}
45 XKB_OPTIONS=${XKB_OPTIONS:=""}
49 XKB_OPTIONS=${XKB_OPTIONS:=""}
46
50
47 # Network settings (DHCP)
51 # Network settings (DHCP)
48 ENABLE_DHCP=${ENABLE_DHCP:=true}
52 ENABLE_DHCP=${ENABLE_DHCP:=true}
49
53
50 # Network settings (static)
54 # Network settings (static)
51 # only used on ENABLE_DHCP=false
55 # only used on ENABLE_DHCP=false
52 NET_ADDRESS=${NET_ADDRESS:=""}
56 NET_ADDRESS=${NET_ADDRESS:=""}
53 NET_GATEWAY=${NET_GATEWAY:=""}
57 NET_GATEWAY=${NET_GATEWAY:=""}
54 NET_DNS_1=${NET_DNS_1:=""}
58 NET_DNS_1=${NET_DNS_1:=""}
55 NET_DNS_2=${NET_DNS_2:=""}
59 NET_DNS_2=${NET_DNS_2:=""}
56 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
60 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
57 NET_NTP_1=${NET_NTP_1:=""}
61 NET_NTP_1=${NET_NTP_1:=""}
58 NET_NTP_2=${NET_NTP_2:=""}
62 NET_NTP_2=${NET_NTP_2:=""}
59
63
60 # APT settings
64 # APT settings
61 APT_PROXY=${APT_PROXY:=""}
65 APT_PROXY=${APT_PROXY:=""}
62 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
66 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
63
67
64 # Feature settings
68 # Feature settings
65 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
69 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
66 ENABLE_IPV6=${ENABLE_IPV6:=true}
70 ENABLE_IPV6=${ENABLE_IPV6:=true}
67 ENABLE_SSHD=${ENABLE_SSHD:=true}
71 ENABLE_SSHD=${ENABLE_SSHD:=true}
68 ENABLE_SOUND=${ENABLE_SOUND:=true}
72 ENABLE_SOUND=${ENABLE_SOUND:=true}
69 ENABLE_DBUS=${ENABLE_DBUS:=true}
73 ENABLE_DBUS=${ENABLE_DBUS:=true}
70 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
74 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
71 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
75 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
72 ENABLE_XORG=${ENABLE_XORG:=false}
76 ENABLE_XORG=${ENABLE_XORG:=false}
73 ENABLE_WM=${ENABLE_WM:=""}
77 ENABLE_WM=${ENABLE_WM:=""}
74 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
78 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
75 ENABLE_USER=${ENABLE_USER:=true}
79 ENABLE_USER=${ENABLE_USER:=true}
76 ENABLE_ROOT=${ENABLE_ROOT:=false}
80 ENABLE_ROOT=${ENABLE_ROOT:=false}
77 ENABLE_ROOT_SSH=${ENABLE_ROOT_SSH:=false}
81 ENABLE_ROOT_SSH=${ENABLE_ROOT_SSH:=false}
78
82
79 # Advanced settings
83 # Advanced settings
80 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
84 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
81 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
85 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
82 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
86 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
83 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
87 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
84 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
88 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
85 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
89 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
86
90
87 # Kernel compilation settings
91 # Kernel compilation settings
88 BUILD_KERNEL=${BUILD_KERNEL:=false}
92 BUILD_KERNEL=${BUILD_KERNEL:=false}
89 KERNEL_THREADS=${KERNEL_THREADS:=1}
93 KERNEL_THREADS=${KERNEL_THREADS:=1}
90 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
94 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
95 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
91 KERNEL_RMSRC=${KERNEL_RMSRC:=true}
96 KERNEL_RMSRC=${KERNEL_RMSRC:=true}
92
97
93 # Image chroot path
98 # Image chroot path
94 R=${BUILDDIR}/chroot
99 R=${BUILDDIR}/chroot
95 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
100 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
96
101
97 # Packages required for bootstrapping
102 # Packages required for bootstrapping
98 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git-core"
103 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git-core"
99
104
100 # Missing packages that need to be installed
105 # Missing packages that need to be installed
101 MISSING_PACKAGES=""
106 MISSING_PACKAGES=""
102
107
103 # Packages required in the chroot build environment
108 # Packages required in the chroot build environment
104 APT_INCLUDES=${APT_INCLUDES:=""}
109 APT_INCLUDES=${APT_INCLUDES:=""}
105 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,ca-certificates,debian-archive-keyring,dialog,sudo"
110 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,ca-certificates,debian-archive-keyring,dialog,sudo"
106
111
107 set +x
112 set +x
108
113
109 # Are we running as root?
114 # Are we running as root?
110 if [ "$(id -u)" -ne "0" ] ; then
115 if [ "$(id -u)" -ne "0" ] ; then
111 echo "this script must be executed with root privileges"
116 echo "this script must be executed with root privileges"
112 exit 1
117 exit 1
113 fi
118 fi
114
119
115 # Add packages required for kernel cross compilation
120 # Add packages required for kernel cross compilation
116 if [ "$BUILD_KERNEL" = true ] ; then
121 if [ "$BUILD_KERNEL" = true ] ; then
117 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
122 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
123 if [ "$KERNEL_MENUCONFIG" = true ] ; then
124 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ncurses-dev"
125 fi
118 fi
126 fi
119
127
120 # Check if all required packages are installed
128 # Check if all required packages are installed
121 for package in $REQUIRED_PACKAGES ; do
129 for package in $REQUIRED_PACKAGES ; do
122 if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
130 if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
123 MISSING_PACKAGES="$MISSING_PACKAGES $package"
131 MISSING_PACKAGES="$MISSING_PACKAGES $package"
124 fi
132 fi
125 done
133 done
126
134
127 # Ask if missing packages should get installed right now
135 # Ask if missing packages should get installed right now
128 if [ -n "$MISSING_PACKAGES" ] ; then
136 if [ -n "$MISSING_PACKAGES" ] ; then
129 echo "the following packages needed by this script are not installed:"
137 echo "the following packages needed by this script are not installed:"
130 echo "$MISSING_PACKAGES"
138 echo "$MISSING_PACKAGES"
131
139
132 echo -n "\ndo you want to install the missing packages right now? [y/n] "
140 echo -n "\ndo you want to install the missing packages right now? [y/n] "
133 read confirm
141 read confirm
134 if [ "$confirm" != "y" ] ; then
142 if [ "$confirm" != "y" ] ; then
135 exit 1
143 exit 1
136 fi
144 fi
137 fi
145 fi
138
146
139 # Make sure all required packages are installed
147 # Make sure all required packages are installed
140 apt-get -qq -y install ${REQUIRED_PACKAGES}
148 apt-get -qq -y install ${REQUIRED_PACKAGES}
141
149
142 # Don't clobber an old build
150 # Don't clobber an old build
143 if [ -e "$BUILDDIR" ]; then
151 if [ -e "$BUILDDIR" ]; then
144 echo "directory $BUILDDIR already exists, not proceeding"
152 echo "directory $BUILDDIR already exists, not proceeding"
145 exit 1
153 exit 1
146 fi
154 fi
147
155
148 set -x
156 set -x
149
157
150 # Call "cleanup" function on various signals and errors
158 # Call "cleanup" function on various signals and errors
151 trap cleanup 0 1 2 3 6
159 trap cleanup 0 1 2 3 6
152
160
153 # Set up chroot directory
161 # Setup chroot directory
154 mkdir -p $R
162 mkdir -p $R
155
163
156 # Add required packages for the minbase installation
164 # Add required packages for the minbase installation
157 if [ "$ENABLE_MINBASE" = true ] ; then
165 if [ "$ENABLE_MINBASE" = true ] ; then
158 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools"
166 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools"
159 else
167 else
160 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
168 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
161 fi
169 fi
162
170
163 # Add parted package, required to get partprobe utility
171 # Add parted package, required to get partprobe utility
164 if [ "$EXPANDROOT" = true ] ; then
172 if [ "$EXPANDROOT" = true ] ; then
165 APT_INCLUDES="${APT_INCLUDES},parted"
173 APT_INCLUDES="${APT_INCLUDES},parted"
166 fi
174 fi
167
175
168 # Add dbus package, recommended if using systemd
176 # Add dbus package, recommended if using systemd
169 if [ "$ENABLE_DBUS" = true ] ; then
177 if [ "$ENABLE_DBUS" = true ] ; then
170 APT_INCLUDES="${APT_INCLUDES},dbus"
178 APT_INCLUDES="${APT_INCLUDES},dbus"
171 fi
179 fi
172
180
173 # Add iptables IPv4/IPv6 package
181 # Add iptables IPv4/IPv6 package
174 if [ "$ENABLE_IPTABLES" = true ] ; then
182 if [ "$ENABLE_IPTABLES" = true ] ; then
175 APT_INCLUDES="${APT_INCLUDES},iptables"
183 APT_INCLUDES="${APT_INCLUDES},iptables"
176 fi
184 fi
177
185
178 # Add openssh server package
186 # Add openssh server package
179 if [ "$ENABLE_SSHD" = true ] ; then
187 if [ "$ENABLE_SSHD" = true ] ; then
180 APT_INCLUDES="${APT_INCLUDES},openssh-server"
188 APT_INCLUDES="${APT_INCLUDES},openssh-server"
181 fi
189 fi
182
190
183 # Add alsa-utils package
191 # Add alsa-utils package
184 if [ "$ENABLE_SOUND" = true ] ; then
192 if [ "$ENABLE_SOUND" = true ] ; then
185 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
193 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
186 fi
194 fi
187
195
188 # Add rng-tools package
196 # Add rng-tools package
189 if [ "$ENABLE_HWRANDOM" = true ] ; then
197 if [ "$ENABLE_HWRANDOM" = true ] ; then
190 APT_INCLUDES="${APT_INCLUDES},rng-tools"
198 APT_INCLUDES="${APT_INCLUDES},rng-tools"
191 fi
199 fi
192
200
193 if [ "$ENABLE_USER" = true ]; then
201 if [ "$ENABLE_USER" = true ]; then
194 APT_INCLUDES="${APT_INCLUDES},sudo"
202 APT_INCLUDES="${APT_INCLUDES},sudo"
195 fi
203 fi
196
204
197 # Add fbturbo video driver
205 # Add fbturbo video driver
198 if [ "$ENABLE_FBTURBO" = true ] ; then
206 if [ "$ENABLE_FBTURBO" = true ] ; then
199 # Enable xorg package dependencies
207 # Enable xorg package dependencies
200 ENABLE_XORG=true
208 ENABLE_XORG=true
201 fi
209 fi
202
210
203 # Add user defined window manager package
211 # Add user defined window manager package
204 if [ -n "$ENABLE_WM" ] ; then
212 if [ -n "$ENABLE_WM" ] ; then
205 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
213 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
206
214
207 # Enable xorg package dependencies
215 # Enable xorg package dependencies
208 ENABLE_XORG=true
216 ENABLE_XORG=true
209 fi
217 fi
210
218
211 # Add xorg package
219 # Add xorg package
212 if [ "$ENABLE_XORG" = true ] ; then
220 if [ "$ENABLE_XORG" = true ] ; then
213 APT_INCLUDES="${APT_INCLUDES},xorg"
221 APT_INCLUDES="${APT_INCLUDES},xorg"
214 fi
222 fi
215
223
216 ## Main bootstrap
224 ## Main bootstrap
217 for i in bootstrap.d/*.sh; do
225 for i in bootstrap.d/*.sh; do
218 head -n 3 $i
226 head -n 3 $i
219 . $i
227 . $i
220 done
228 done
221
229
222 ## Custom bootstrap scripts
230 ## Custom bootstrap scripts
223 if [ -d "custom.d" ]; then
231 if [ -d "custom.d" ]; then
224 for i in custom.d/*.sh; do
232 for i in custom.d/*.sh; do
225 . $i
233 . $i
226 done
234 done
227 fi
235 fi
228
236
229 # Invoke custom scripts
237 # Invoke custom scripts
230 if [ -n "${CHROOT_SCRIPTS}" ]; then
238 if [ -n "${CHROOT_SCRIPTS}" ]; then
231 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
239 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
232 LANG=C chroot $R bash -c 'for SCRIPT in /chroot_scripts/*; do if [ -f $SCRIPT -a -x $SCRIPT ]; then $SCRIPT; fi done;'
240 LANG=C chroot $R bash -c 'for SCRIPT in /chroot_scripts/*; do if [ -f $SCRIPT -a -x $SCRIPT ]; then $SCRIPT; fi done;'
233 rm -rf "${R}/chroot_scripts"
241 rm -rf "${R}/chroot_scripts"
234 fi
242 fi
235
243
236 ## Cleanup
244 ## Cleanup
237 chroot_exec apt-get -y clean
245 chroot_exec apt-get -y clean
238 chroot_exec apt-get -y autoclean
246 chroot_exec apt-get -y autoclean
239 chroot_exec apt-get -y autoremove
247 chroot_exec apt-get -y autoremove
240
248
241 # Unmount mounted filesystems
249 # Unmount mounted filesystems
242 umount -l $R/proc
250 umount -l $R/proc
243 umount -l $R/sys
251 umount -l $R/sys
244
252
245 # Clean up files
253 # Clean up files
246 rm -f $R/etc/apt/sources.list.save
254 rm -f $R/etc/apt/sources.list.save
247 rm -f $R/etc/resolvconf/resolv.conf.d/original
255 rm -f $R/etc/resolvconf/resolv.conf.d/original
248 rm -rf $R/run
256 rm -rf $R/run
249 mkdir -p $R/run
257 mkdir -p $R/run
250 rm -f $R/etc/*-
258 rm -f $R/etc/*-
251 rm -f $R/root/.bash_history
259 rm -f $R/root/.bash_history
252 rm -rf $R/tmp/*
260 rm -rf $R/tmp/*
253 rm -f $R/var/lib/urandom/random-seed
261 rm -f $R/var/lib/urandom/random-seed
254 [ -L $R/var/lib/dbus/machine-id ] || rm -f $R/var/lib/dbus/machine-id
262 [ -L $R/var/lib/dbus/machine-id ] || rm -f $R/var/lib/dbus/machine-id
255 rm -f $R/etc/machine-id
263 rm -f $R/etc/machine-id
256 rm -fr $R/etc/apt/apt.conf.d/10proxy
264 rm -fr $R/etc/apt/apt.conf.d/10proxy
257 rm -f $R/etc/resolv.conf
265 rm -f $R/etc/resolv.conf
258
266
259 # Calculate size of the chroot directory in KB
267 # Calculate size of the chroot directory in KB
260 CHROOT_SIZE=$(expr `du -s $R | awk '{ print $1 }'`)
268 CHROOT_SIZE=$(expr `du -s $R | awk '{ print $1 }'`)
261
269
262 # Calculate the amount of needed 512 Byte sectors
270 # Calculate the amount of needed 512 Byte sectors
263 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
271 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
264 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
272 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
265 ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS})
273 ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS})
266
274
267 # The root partition is EXT4
275 # The root partition is EXT4
268 # This means more space than the actual used space of the chroot is used.
276 # This means more space than the actual used space of the chroot is used.
269 # As overhead for journaling and reserved blocks 20% are added.
277 # As overhead for journaling and reserved blocks 20% are added.
270 ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 20) \* 1024 \/ 512)
278 ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 20) \* 1024 \/ 512)
271
279
272 # Calculate required image size in 512 Byte sectors
280 # Calculate required image size in 512 Byte sectors
273 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS})
281 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS})
274
282
275 # Prepare date string for image file name
283 # Prepare date string for image file name
276 DATE="$(date +%Y-%m-%d)"
284 DATE="$(date +%Y-%m-%d)"
277
285
278 # Prepare image file
286 # Prepare image file
279 if [ "$ENABLE_SPLITFS" = true ] ; then
287 if [ "$ENABLE_SPLITFS" = true ] ; then
280 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=${TABLE_SECTORS}
288 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=${TABLE_SECTORS}
281 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS}
289 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS}
282 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=${TABLE_SECTORS}
290 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=${TABLE_SECTORS}
283 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=0 seek=${ROOT_SECTORS}
291 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=0 seek=${ROOT_SECTORS}
284 # Write partition tables
292 # Write partition tables
285 sfdisk -q -L -f "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" <<EOM
293 sfdisk -q -L -f "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" <<EOM
286 unit: sectors
294 unit: sectors
287
295
288 1 : start= ${TABLE_SECTORS}, size= ${FRMW_SECTORS}, Id= c, bootable
296 1 : start= ${TABLE_SECTORS}, size= ${FRMW_SECTORS}, Id= c, bootable
289 2 : start= 0, size= 0, Id= 0
297 2 : start= 0, size= 0, Id= 0
290 3 : start= 0, size= 0, Id= 0
298 3 : start= 0, size= 0, Id= 0
291 4 : start= 0, size= 0, Id= 0
299 4 : start= 0, size= 0, Id= 0
292 EOM
300 EOM
293 sfdisk -q -L -f "$BASEDIR/${DATE}-debian-${RELEASE}-root.img" <<EOM
301 sfdisk -q -L -f "$BASEDIR/${DATE}-debian-${RELEASE}-root.img" <<EOM
294 unit: sectors
302 unit: sectors
295
303
296 1 : start= ${TABLE_SECTORS}, size= ${ROOT_SECTORS}, Id=83
304 1 : start= ${TABLE_SECTORS}, size= ${ROOT_SECTORS}, Id=83
297 2 : start= 0, size= 0, Id= 0
305 2 : start= 0, size= 0, Id= 0
298 3 : start= 0, size= 0, Id= 0
306 3 : start= 0, size= 0, Id= 0
299 4 : start= 0, size= 0, Id= 0
307 4 : start= 0, size= 0, Id= 0
300 EOM
308 EOM
301 # Set up temporary loop devices
309 # Setup temporary loop devices
302 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-frmw.img)"
310 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-frmw.img)"
303 ROOT_LOOP="$(losetup -o 1M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-root.img)"
311 ROOT_LOOP="$(losetup -o 1M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-root.img)"
304 else
312 else
305 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=${TABLE_SECTORS}
313 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=${TABLE_SECTORS}
306 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=0 seek=${IMAGE_SECTORS}
314 dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=0 seek=${IMAGE_SECTORS}
307 # Write partition table
315 # Write partition table
308 sfdisk -q -f "$BASEDIR/${DATE}-debian-${RELEASE}.img" <<EOM
316 sfdisk -q -f "$BASEDIR/${DATE}-debian-${RELEASE}.img" <<EOM
309 unit: sectors
317 unit: sectors
310
318
311 1 : start= ${TABLE_SECTORS}, size= ${FRMW_SECTORS}, Id= c, bootable
319 1 : start= ${TABLE_SECTORS}, size= ${FRMW_SECTORS}, Id= c, bootable
312 2 : start= ${ROOT_OFFSET}, size= ${ROOT_SECTORS}, Id=83
320 2 : start= ${ROOT_OFFSET}, size= ${ROOT_SECTORS}, Id=83
313 3 : start= 0, size= 0, Id= 0
321 3 : start= 0, size= 0, Id= 0
314 4 : start= 0, size= 0, Id= 0
322 4 : start= 0, size= 0, Id= 0
315 EOM
323 EOM
316 # Set up temporary loop devices
324 # Setup temporary loop devices
317 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
325 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
318 ROOT_LOOP="$(losetup -o 65M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
326 ROOT_LOOP="$(losetup -o 65M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)"
319 fi
327 fi
320
328
321 # Build filesystems
329 # Build filesystems
322 mkfs.vfat "$FRMW_LOOP"
330 mkfs.vfat "$FRMW_LOOP"
323 mkfs.ext4 "$ROOT_LOOP"
331 mkfs.ext4 "$ROOT_LOOP"
324
332
325 # Mount the temporary loop devices
333 # Mount the temporary loop devices
326 mkdir -p "$BUILDDIR/mount"
334 mkdir -p "$BUILDDIR/mount"
327 mount "$ROOT_LOOP" "$BUILDDIR/mount"
335 mount "$ROOT_LOOP" "$BUILDDIR/mount"
328
336
329 mkdir -p "$BUILDDIR/mount/boot/firmware"
337 mkdir -p "$BUILDDIR/mount/boot/firmware"
330 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
338 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
331
339
332 # Copy all files from the chroot to the loop device mount point directory
340 # Copy all files from the chroot to the loop device mount point directory
333 rsync -a "$R/" "$BUILDDIR/mount/"
341 rsync -a "$R/" "$BUILDDIR/mount/"
334
342
335 # Unmount all temporary loop devices and mount points
343 # Unmount all temporary loop devices and mount points
336 cleanup
344 cleanup
337
345
338 # Create block map file(s) of image(s)
346 # Create block map file(s) of image(s)
339 if [ "$ENABLE_SPLITFS" = true ] ; then
347 if [ "$ENABLE_SPLITFS" = true ] ; then
340 # Create block map files for "bmaptool"
348 # Create block map files for "bmaptool"
341 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img"
349 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img"
342 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-root.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-root.img"
350 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-root.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-root.img"
343
351
344 # Image was successfully created
352 # Image was successfully created
345 echo "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img ($(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
353 echo "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
346 echo "$BASEDIR/${DATE}-debian-${RELEASE}-root.img ($(expr ${TABLE_SECTORS} + ${ROOT_SECTORS} \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
354 echo "$BASEDIR/${DATE}-debian-${RELEASE}-root.img ($(expr \( ${TABLE_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
347 else
355 else
348 # Create block map file for "bmaptool"
356 # Create block map file for "bmaptool"
349 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}.img"
357 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}.img"
350
358
351 # Image was successfully created
359 # Image was successfully created
352 echo "$BASEDIR/${DATE}-debian-${RELEASE}.img ($(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
360 echo "$BASEDIR/${DATE}-debian-${RELEASE}.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
353 fi
361 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant