@@ -1,225 +1,235 | |||||
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 binfmt-support 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 | BUILD_KERNEL=true KERNEL_SRCDIR=/tmp/linux ./rpi2-gen-image.sh | |||
22 | ``` |
|
23 | ``` | |
23 |
|
24 | |||
24 | #### APT settings: |
|
25 | #### APT settings: | |
25 | ##### `APT_SERVER`="ftp.debian.org" |
|
26 | ##### `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. |
|
27 | 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 |
|
28 | |||
28 | ##### `APT_PROXY`="" |
|
29 | ##### `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. |
|
30 | 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 |
|
31 | |||
31 | ##### `APT_INCLUDES`="" |
|
32 | ##### `APT_INCLUDES`="" | |
32 | A comma seperated list of additional packages to be installed during bootstrapping. |
|
33 | A comma seperated list of additional packages to be installed during bootstrapping. | |
33 |
|
34 | |||
34 | #### General system settings: |
|
35 | #### General system settings: | |
35 | ##### `HOSTNAME`="rpi2-jessie" |
|
36 | ##### `HOSTNAME`="rpi2-jessie" | |
36 | Set system host name. It's recommended that the host name is unique in the corresponding subnet. |
|
37 | Set system host name. It's recommended that the host name is unique in the corresponding subnet. | |
37 |
|
38 | |||
38 | ##### `PASSWORD`="raspberry" |
|
39 | ##### `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. |
|
40 | 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 |
|
41 | |||
41 | ##### `DEFLOCAL`="en_US.UTF-8" |
|
42 | ##### `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`. |
|
43 | 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 |
|
44 | |||
44 | ##### `TIMEZONE`="Europe/Berlin" |
|
45 | ##### `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. |
|
46 | 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 |
|
47 | |||
47 | ##### `EXPANDROOT`=true |
|
48 | ##### `EXPANDROOT`=true | |
48 | Expand the root partition and filesystem automatically on first boot. |
|
49 | Expand the root partition and filesystem automatically on first boot. | |
49 |
|
50 | |||
50 | #### Keyboard settings: |
|
51 | #### 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. |
|
52 | 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 |
|
53 | |||
53 | ##### `XKB_MODEL`="" |
|
54 | ##### `XKB_MODEL`="" | |
54 | Set the name of the model of your keyboard type. |
|
55 | Set the name of the model of your keyboard type. | |
55 |
|
56 | |||
56 | ##### `XKB_LAYOUT`="" |
|
57 | ##### `XKB_LAYOUT`="" | |
57 | Set the supported keyboard layout(s). |
|
58 | Set the supported keyboard layout(s). | |
58 |
|
59 | |||
59 | ##### `XKB_VARIANT`="" |
|
60 | ##### `XKB_VARIANT`="" | |
60 | Set the supported variant(s) of the keyboard layout(s). |
|
61 | Set the supported variant(s) of the keyboard layout(s). | |
61 |
|
62 | |||
62 | ##### `XKB_OPTIONS`="" |
|
63 | ##### `XKB_OPTIONS`="" | |
63 | Set extra xkb configuration options. |
|
64 | Set extra xkb configuration options. | |
64 |
|
65 | |||
65 | #### Networking settings (DHCP): |
|
66 | #### Networking settings (DHCP): | |
66 | This setting is used to set up networking auto configuration in `/etc/systemd/network/eth.network`. |
|
67 | This setting is used to set up networking auto configuration in `/etc/systemd/network/eth.network`. | |
67 |
|
68 | |||
68 | #####`ENABLE_DHCP`=true |
|
69 | #####`ENABLE_DHCP`=true | |
69 | Set the system to use DHCP. This requires an DHCP server. |
|
70 | Set the system to use DHCP. This requires an DHCP server. | |
70 |
|
71 | |||
71 | #### Networking settings (static): |
|
72 | #### 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`. |
|
73 | 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 |
|
74 | |||
74 | #####`NET_ADDRESS`="" |
|
75 | #####`NET_ADDRESS`="" | |
75 | Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24". |
|
76 | Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24". | |
76 |
|
77 | |||
77 | #####`NET_GATEWAY`="" |
|
78 | #####`NET_GATEWAY`="" | |
78 | Set the IP address for the default gateway. |
|
79 | Set the IP address for the default gateway. | |
79 |
|
80 | |||
80 | #####`NET_DNS_1`="" |
|
81 | #####`NET_DNS_1`="" | |
81 | Set the IP address for the first DNS server. |
|
82 | Set the IP address for the first DNS server. | |
82 |
|
83 | |||
83 | #####`NET_DNS_2`="" |
|
84 | #####`NET_DNS_2`="" | |
84 | Set the IP address for the second DNS server. |
|
85 | Set the IP address for the second DNS server. | |
85 |
|
86 | |||
86 | #####`NET_DNS_DOMAINS`="" |
|
87 | #####`NET_DNS_DOMAINS`="" | |
87 | Set the default DNS search domains to use for non fully qualified host names. |
|
88 | Set the default DNS search domains to use for non fully qualified host names. | |
88 |
|
89 | |||
89 | #####`NET_NTP_1`="" |
|
90 | #####`NET_NTP_1`="" | |
90 | Set the IP address for the first NTP server. |
|
91 | Set the IP address for the first NTP server. | |
91 |
|
92 | |||
92 | #####`NET_NTP_2`="" |
|
93 | #####`NET_NTP_2`="" | |
93 | Set the IP address for the second NTP server. |
|
94 | Set the IP address for the second NTP server. | |
94 |
|
95 | |||
95 | #### Basic system features: |
|
96 | #### Basic system features: | |
96 | ##### `ENABLE_CONSOLE`=true |
|
97 | ##### `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. |
|
98 | 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 |
|
99 | |||
99 | ##### `ENABLE_IPV6`=true |
|
100 | ##### `ENABLE_IPV6`=true | |
100 | Enable IPv6 support. The network interface configuration is managed via systemd-networkd. |
|
101 | Enable IPv6 support. The network interface configuration is managed via systemd-networkd. | |
101 |
|
102 | |||
102 | ##### `ENABLE_SSHD`=true |
|
103 | ##### `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. |
|
104 | 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 |
|
105 | |||
105 | ##### `ENABLE_RSYSLOG`=true |
|
106 | ##### `ENABLE_RSYSLOG`=true | |
106 | If set to false, disable and uninstall rsyslog (so logs will be available only |
|
107 | If set to false, disable and uninstall rsyslog (so logs will be available only | |
107 | in journal files) |
|
108 | in journal files) | |
108 |
|
109 | |||
109 | ##### `ENABLE_SOUND`=true |
|
110 | ##### `ENABLE_SOUND`=true | |
110 | Enable sound hardware and install Advanced Linux Sound Architecture. |
|
111 | Enable sound hardware and install Advanced Linux Sound Architecture. | |
111 |
|
112 | |||
112 | ##### `ENABLE_HWRANDOM`=true |
|
113 | ##### `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. |
|
114 | 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 |
|
115 | |||
115 | ##### `ENABLE_MINGPU`=false |
|
116 | ##### `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. |
|
117 | Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU. | |
117 |
|
118 | |||
118 | ##### `ENABLE_DBUS`=true |
|
119 | ##### `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. |
|
120 | Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled. | |
120 |
|
121 | |||
121 | ##### `ENABLE_XORG`=false |
|
122 | ##### `ENABLE_XORG`=false | |
122 | Install Xorg open-source X Window System. |
|
123 | Install Xorg open-source X Window System. | |
123 |
|
124 | |||
124 | ##### `ENABLE_WM`="" |
|
125 | ##### `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`. |
|
126 | 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 |
|
127 | |||
127 | #### Advanced system features: |
|
128 | #### Advanced system features: | |
128 | ##### `ENABLE_MINBASE`=false |
|
129 | ##### `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. |
|
130 | Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB. | |
130 |
|
131 | |||
131 | ##### `ENABLE_UBOOT`=false |
|
132 | ##### `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. |
|
133 | 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 |
|
134 | |||
134 | ##### `ENABLE_FBTURBO`=false |
|
135 | ##### `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. |
|
136 | 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 |
|
137 | |||
137 | ##### `ENABLE_IPTABLES`=false |
|
138 | ##### `ENABLE_IPTABLES`=false | |
138 | Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service. |
|
139 | Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service. | |
139 |
|
140 | |||
140 | ##### `ENABLE_USER`=true |
|
141 | ##### `ENABLE_USER`=true | |
141 | Create pi user with password raspberry |
|
142 | Create pi user with password raspberry | |
142 |
|
143 | |||
143 | ##### `ENABLE_ROOT`=true |
|
144 | ##### `ENABLE_ROOT`=true | |
144 | Set root user password so root login will be enabled |
|
145 | Set root user password so root login will be enabled | |
145 |
|
146 | |||
146 | ##### `ENABLE_ROOT_SSH`=true |
|
147 | ##### `ENABLE_ROOT_SSH`=true | |
147 | Enable password root login via SSH. May be a security risk with default |
|
148 | Enable password root login via SSH. May be a security risk with default | |
148 | password, use only in trusted environments. |
|
149 | password, use only in trusted environments. | |
149 |
|
150 | |||
150 | ##### `ENABLE_HARDNET`=false |
|
151 | ##### `ENABLE_HARDNET`=false | |
151 | Enable IPv4/IPv6 network stack hardening settings. |
|
152 | Enable IPv4/IPv6 network stack hardening settings. | |
152 |
|
153 | |||
153 | ##### `ENABLE_SPLITFS`=false |
|
154 | ##### `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 `/`. |
|
155 | Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`. | |
155 |
|
156 | |||
156 | ##### `CHROOT_SCRIPTS`="" |
|
157 | ##### `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. |
|
158 | 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 |
|
159 | |||
159 | #### Kernel compilation: |
|
160 | #### Kernel compilation: | |
160 | ##### `BUILD_KERNEL`=false |
|
161 | ##### `BUILD_KERNEL`=false | |
161 |
Build and install the latest RPi2 |
|
162 | 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. | |
|
163 | ||||
|
164 | ##### `KERNEL_SRCDIR`="" | |||
|
165 | Path to a directory of [RaspberryPi Linux kernel] sources (https://github.com/raspberrypi/linux) that will be copied, configured, build and installed inside the chroot. | |||
162 |
|
166 | |||
163 | ##### `KERNEL_THREADS`=1 |
|
167 | ##### `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. |
|
168 | 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 |
|
169 | |||
166 | ##### `KERNEL_HEADERS`=true |
|
170 | ##### `KERNEL_HEADERS`=true | |
167 | Install kernel headers with built kernel. |
|
171 | Install kernel headers with built kernel. | |
168 |
|
172 | |||
169 | ##### `KERNEL_MENUCONFIG`=false |
|
173 | ##### `KERNEL_MENUCONFIG`=false | |
170 | Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated. |
|
174 | Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated. | |
171 |
|
175 | |||
|
176 | ##### `KERNEL_CONFIGSRC`=true | |||
|
177 | Run `make bcm2709_defconfig` (and optional `make menuconfig`) to configure the kernel sources before building. This setting is automatically set to `true` if no existing kernel sources directory was specified using `KERNEL_SRCDIR`. | |||
|
178 | ||||
|
179 | ##### `KERNEL_CLEANSRC`=false | |||
|
180 | Clean the existing kernel sources directory `KERNEL_SRCDIR` (using `make mrproper`) after it was copied to the chroot and before the compilation of the kernel has started. This setting will be ignored if no `KERNEL_SRCDIR` was specified. | |||
|
181 | ||||
172 | ##### `KERNEL_RMSRC`=true |
|
182 | ##### `KERNEL_RMSRC`=true | |
173 |
Remove all kernel sources from the generated OS image after |
|
183 | Remove all kernel sources from the generated OS image after it was built and installed. | |
174 |
|
184 | |||
175 | ## Understanding the script |
|
185 | ## Understanding the script | |
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: |
|
186 | 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: | |
177 |
|
187 | |||
178 | | Script | Description | |
|
188 | | Script | Description | | |
179 | | --- | --- | |
|
189 | | --- | --- | | |
180 | | `10-bootstrap.sh` | Debootstrap basic system | |
|
190 | | `10-bootstrap.sh` | Debootstrap basic system | | |
181 | | `11-apt.sh` | Setup APT repositories | |
|
191 | | `11-apt.sh` | Setup APT repositories | | |
182 | | `12-locale.sh` | Setup Locales and keyboard settings | |
|
192 | | `12-locale.sh` | Setup Locales and keyboard settings | | |
183 | | `13-kernel.sh` | Build and install RPi2 Kernel | |
|
193 | | `13-kernel.sh` | Build and install RPi2 Kernel | | |
184 | | `20-networking.sh` | Setup Networking | |
|
194 | | `20-networking.sh` | Setup Networking | | |
185 | | `21-firewall.sh` | Setup Firewall | |
|
195 | | `21-firewall.sh` | Setup Firewall | | |
186 | | `30-security.sh` | Setup Users and Security settings | |
|
196 | | `30-security.sh` | Setup Users and Security settings | | |
187 | | `31-logging.sh` | Setup Logging | |
|
197 | | `31-logging.sh` | Setup Logging | | |
188 | | `41-uboot.sh` | Build and Setup U-Boot | |
|
198 | | `41-uboot.sh` | Build and Setup U-Boot | | |
189 | | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver | |
|
199 | | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver | | |
190 | | `50-firstboot.sh` | First boot actions | |
|
200 | | `50-firstboot.sh` | First boot actions | | |
191 |
|
201 | |||
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. |
|
202 | 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. | |
193 |
|
203 | |||
194 | | Directory | Description | |
|
204 | | Directory | Description | | |
195 | | --- | --- | |
|
205 | | --- | --- | | |
196 | | `boot` | Boot and RPi2 configuration files | |
|
206 | | `boot` | Boot and RPi2 configuration files | | |
197 | | `firstboot` | Scripts that get executed on first boot | |
|
207 | | `firstboot` | Scripts that get executed on first boot | | |
198 | | `iptables` | Firewall configuration files | |
|
208 | | `iptables` | Firewall configuration files | | |
199 | | `locales` | Locales configuration | |
|
209 | | `locales` | Locales configuration | | |
200 | | `modules` | Kernel Modules configuration | |
|
210 | | `modules` | Kernel Modules configuration | | |
201 | | `mount` | Fstab configuration | |
|
211 | | `mount` | Fstab configuration | | |
202 | | `network` | Networking configuration files | |
|
212 | | `network` | Networking configuration files | | |
203 | | `sysctl.d` | Swapping and Network Hardening configuration | |
|
213 | | `sysctl.d` | Swapping and Network Hardening configuration | | |
204 | | `xorg` | fbturbo Xorg driver configuration | |
|
214 | | `xorg` | fbturbo Xorg driver configuration | | |
205 |
|
215 | |||
206 | ## Logging of the bootstrapping process |
|
216 | ## Logging of the bootstrapping process | |
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: |
|
217 | 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: | |
208 |
|
218 | |||
209 | ```shell |
|
219 | ```shell | |
210 | script -c 'APT_SERVER=ftp.de.debian.org ./rpi2-gen-image.sh' ./build.log |
|
220 | script -c 'APT_SERVER=ftp.de.debian.org ./rpi2-gen-image.sh' ./build.log | |
211 | ``` |
|
221 | ``` | |
212 |
|
222 | |||
213 | ## Flashing the image file |
|
223 | ## Flashing the image file | |
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`. |
|
224 | 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`. | |
215 |
|
225 | |||
216 | #####Flashing examples: |
|
226 | #####Flashing examples: | |
217 | ```shell |
|
227 | ```shell | |
218 | bmaptool copy ./images/jessie/2015-12-13-debian-jessie.img /dev/mmcblk0 |
|
228 | bmaptool copy ./images/jessie/2015-12-13-debian-jessie.img /dev/mmcblk0 | |
219 | dd bs=4M if=./images/jessie/2015-12-13-debian-jessie.img of=/dev/mmcblk0 |
|
229 | dd bs=4M if=./images/jessie/2015-12-13-debian-jessie.img of=/dev/mmcblk0 | |
220 | ``` |
|
230 | ``` | |
221 | If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive: |
|
231 | If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive: | |
222 | ```shell |
|
232 | ```shell | |
223 | bmaptool copy ./images/jessie/2015-12-13-debian-jessie-frmw.img /dev/mmcblk0 |
|
233 | bmaptool copy ./images/jessie/2015-12-13-debian-jessie-frmw.img /dev/mmcblk0 | |
224 | bmaptool copy ./images/jessie/2015-12-13-debian-jessie-root.img /dev/sdc |
|
234 | bmaptool copy ./images/jessie/2015-12-13-debian-jessie-root.img /dev/sdc | |
225 | ``` |
|
235 | ``` |
@@ -1,29 +1,30 | |||||
1 | # |
|
1 | # | |
2 | # Setup APT repositories |
|
2 | # Setup APT repositories | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Install and setup APT proxy configuration |
|
8 | # Install and setup APT proxy configuration | |
9 | if [ -z "$APT_PROXY" ] ; then |
|
9 | if [ -z "$APT_PROXY" ] ; then | |
10 | install_readonly files/apt/10proxy $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 | # Install APT pinning configuration for flash-kernel package |
|
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 | # Install APT 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 | |
|
30 | chroot_exec apt-get -qq -y check |
@@ -1,125 +1,148 | |||||
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 | # Setup source directory | |
11 | git -C $R/usr/src clone --depth=1 https://github.com/raspberrypi/linux |
|
11 | mkdir -p $R/usr/src | |
12 |
|
12 | |||
13 | # Load default raspberry kernel configuration |
|
13 | # Copy existing kernel sources into chroot directory | |
14 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} bcm2709_defconfig |
|
14 | if [ -n "$KERNEL_SRCDIR" ] && [ -d "$KERNEL_SRCDIR" ] ; then | |
|
15 | # Copy kernel sources | |||
|
16 | cp -r "${KERNEL_SRCDIR}" "${R}/usr/src" | |||
|
17 | ||||
|
18 | # Clean the kernel sources | |||
|
19 | if [ "$KERNEL_CLEANSRC" = true ] ; then | |||
|
20 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} mrproper | |||
|
21 | fi | |||
|
22 | else # KERNEL_SRCDIR="" | |||
|
23 | # Fetch current raspberrypi kernel sources | |||
|
24 | git -C $R/usr/src clone --depth=1 https://github.com/raspberrypi/linux | |||
|
25 | fi | |||
15 |
|
26 | |||
16 | # Calculate optimal number of kernel building threads |
|
27 | # Calculate optimal number of kernel building threads | |
17 | if [ "$KERNEL_THREADS" = 1 ] ; then |
|
28 | if [ "$KERNEL_THREADS" = "1" ] ; then | |
18 |
if [ - |
|
29 | if [ -r /proc/cpuinfo ] ; then | |
19 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) |
|
30 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) | |
20 | fi |
|
31 | fi | |
21 | fi |
|
32 | fi | |
22 |
|
33 | |||
23 | # Start menu-driven kernel configuration (interactive) |
|
34 | if [ "$KERNEL_CONFIGSRC" = true ] ; then | |
24 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
35 | # Load default raspberry kernel configuration | |
25 |
make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} |
|
36 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} ${KERNEL_DEFCONFIG} | |
|
37 | ||||
|
38 | # Start menu-driven kernel configuration (interactive) | |||
|
39 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |||
|
40 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} menuconfig | |||
|
41 | fi | |||
26 | fi |
|
42 | fi | |
27 |
|
43 | |||
28 | # Cross compile kernel and modules |
|
44 | # Cross compile kernel and modules | |
29 | make -C $R/usr/src/linux -j${KERNEL_THREADS} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} zImage modules dtbs |
|
45 | make -C $R/usr/src/linux -j${KERNEL_THREADS} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} zImage modules dtbs | |
30 |
|
46 | |||
|
47 | # Check if kernel compilation was successful | |||
|
48 | if [ ! -r $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/zImage ] ; then | |||
|
49 | echo "error: kernel compilation failed!" | |||
|
50 | cleanup | |||
|
51 | exit 1 | |||
|
52 | fi | |||
|
53 | ||||
31 | # Install kernel modules |
|
54 | # Install kernel modules | |
32 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_MOD_PATH=../../.. modules_install |
|
55 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_MOD_PATH=../../.. modules_install | |
33 |
|
56 | |||
34 | # Install kernel headers |
|
57 | # Install kernel headers | |
35 | if [ "$KERNEL_HEADERS" = true ]; then |
|
58 | if [ "$KERNEL_HEADERS" = true ] ; then | |
36 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_HDR_PATH=../.. headers_install |
|
59 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_HDR_PATH=../.. headers_install | |
37 | fi |
|
60 | fi | |
38 |
|
61 | |||
39 | # Copy and rename compiled kernel to boot directory |
|
62 | # Copy and rename compiled kernel to boot directory | |
40 | mkdir $R/boot/firmware/ |
|
63 | mkdir $R/boot/firmware/ | |
41 | $R/usr/src/linux/scripts/mkknlimg $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/zImage $R/boot/firmware/kernel7.img |
|
64 | $R/usr/src/linux/scripts/mkknlimg $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/zImage $R/boot/firmware/kernel7.img | |
42 |
|
65 | |||
43 | # Copy dts and dtb device definitions |
|
66 | # Copy dts and dtb device definitions | |
44 | mkdir $R/boot/firmware/overlays/ |
|
67 | mkdir $R/boot/firmware/overlays/ | |
45 | cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/*.dtb $R/boot/firmware/ |
|
68 | cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/*.dtb $R/boot/firmware/ | |
46 | cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/*.dtb* $R/boot/firmware/overlays/ |
|
69 | cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/*.dtb* $R/boot/firmware/overlays/ | |
47 | cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/README $R/boot/firmware/overlays/ |
|
70 | cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/README $R/boot/firmware/overlays/ | |
48 |
|
71 | |||
49 | # Remove kernel sources |
|
72 | # Remove kernel sources | |
50 | if [ "$KERNEL_RMSRC" = true ]; then |
|
73 | if [ "$KERNEL_RMSRC" = true ] ; then | |
51 | rm -fr $R/usr/src/linux |
|
74 | rm -fr $R/usr/src/linux | |
52 | fi |
|
75 | fi | |
53 |
|
76 | |||
54 | # Install raspberry bootloader and flash-kernel packages |
|
77 | # Install raspberry bootloader and flash-kernel packages | |
55 | chroot_exec apt-get -qq -y --no-install-recommends install raspberrypi-bootloader-nokernel |
|
78 | chroot_exec apt-get -qq -y --no-install-recommends install raspberrypi-bootloader-nokernel | |
56 | else # BUILD_KERNEL=false |
|
79 | else # BUILD_KERNEL=false | |
57 | # Kernel installation |
|
80 | # Kernel installation | |
58 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${COLLABORA_KERNEL} raspberrypi-bootloader-nokernel |
|
81 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${COLLABORA_KERNEL} raspberrypi-bootloader-nokernel | |
59 |
|
82 | |||
60 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot |
|
83 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot | |
61 | chroot_exec apt-get -qq -y install flash-kernel |
|
84 | chroot_exec apt-get -qq -y install flash-kernel | |
62 |
|
85 | |||
63 | VMLINUZ="$(ls -1 $R/boot/vmlinuz-* | sort | tail -n 1)" |
|
86 | VMLINUZ="$(ls -1 $R/boot/vmlinuz-* | sort | tail -n 1)" | |
64 | [ -z "$VMLINUZ" ] && exit 1 |
|
87 | [ -z "$VMLINUZ" ] && exit 1 | |
65 | cp $VMLINUZ $R/boot/firmware/kernel7.img |
|
88 | cp $VMLINUZ $R/boot/firmware/kernel7.img | |
66 | fi |
|
89 | fi | |
67 |
|
90 | |||
68 | # Setup firmware boot cmdline |
|
91 | # Setup firmware boot cmdline | |
69 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
92 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
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}" |
|
93 | 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}" | |
71 | else |
|
94 | else | |
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}" |
|
95 | 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}" | |
73 | fi |
|
96 | fi | |
74 |
|
97 | |||
75 | # Add serial console support |
|
98 | # Add serial console support | |
76 | if [ "$ENABLE_CONSOLE" = true ] ; then |
|
99 | if [ "$ENABLE_CONSOLE" = true ] ; then | |
77 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" |
|
100 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" | |
78 | fi |
|
101 | fi | |
79 |
|
102 | |||
80 | # Remove IPv6 networking support |
|
103 | # Remove IPv6 networking support | |
81 | if [ "$ENABLE_IPV6" = false ] ; then |
|
104 | if [ "$ENABLE_IPV6" = false ] ; then | |
82 | CMDLINE="${CMDLINE} ipv6.disable=1" |
|
105 | CMDLINE="${CMDLINE} ipv6.disable=1" | |
83 | fi |
|
106 | fi | |
84 |
|
107 | |||
85 | # Install firmware boot cmdline |
|
108 | # Install firmware boot cmdline | |
86 | echo "${CMDLINE}" >$R/boot/firmware/cmdline.txt |
|
109 | echo "${CMDLINE}" >$R/boot/firmware/cmdline.txt | |
87 |
|
110 | |||
88 | # Install firmware config |
|
111 | # Install firmware config | |
89 | install_readonly files/boot/config.txt $R/boot/firmware/config.txt |
|
112 | install_readonly files/boot/config.txt $R/boot/firmware/config.txt | |
90 |
|
113 | |||
91 | # Setup minimal GPU memory allocation size: 16MB (no X) |
|
114 | # Setup minimal GPU memory allocation size: 16MB (no X) | |
92 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
115 | if [ "$ENABLE_MINGPU" = true ] ; then | |
93 | echo "gpu_mem=16" >>$R/boot/firmware/config.txt |
|
116 | echo "gpu_mem=16" >>$R/boot/firmware/config.txt | |
94 | fi |
|
117 | fi | |
95 |
|
118 | |||
96 | # Create firmware configuration and cmdline symlinks |
|
119 | # Create firmware configuration and cmdline symlinks | |
97 | ln -sf firmware/config.txt $R/boot/config.txt |
|
120 | ln -sf firmware/config.txt $R/boot/config.txt | |
98 | ln -sf firmware/cmdline.txt $R/boot/cmdline.txt |
|
121 | ln -sf firmware/cmdline.txt $R/boot/cmdline.txt | |
99 |
|
122 | |||
100 | # Install and setup kernel modules to load at boot |
|
123 | # Install and setup kernel modules to load at boot | |
101 | mkdir -p $R/lib/modules-load.d/ |
|
124 | mkdir -p $R/lib/modules-load.d/ | |
102 | install_readonly files/modules/rpi2.conf $R/lib/modules-load.d/rpi2.conf |
|
125 | install_readonly files/modules/rpi2.conf $R/lib/modules-load.d/rpi2.conf | |
103 |
|
126 | |||
104 | # Load hardware random module at boot |
|
127 | # Load hardware random module at boot | |
105 | if [ "$ENABLE_HWRANDOM" = true ] ; then |
|
128 | if [ "$ENABLE_HWRANDOM" = true ] ; then | |
106 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" $R/lib/modules-load.d/rpi2.conf |
|
129 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" $R/lib/modules-load.d/rpi2.conf | |
107 | fi |
|
130 | fi | |
108 |
|
131 | |||
109 | # Load sound module at boot |
|
132 | # Load sound module at boot | |
110 | if [ "$ENABLE_SOUND" = true ] ; then |
|
133 | if [ "$ENABLE_SOUND" = true ] ; then | |
111 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" $R/lib/modules-load.d/rpi2.conf |
|
134 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" $R/lib/modules-load.d/rpi2.conf | |
112 | fi |
|
135 | fi | |
113 |
|
136 | |||
114 | # Install kernel modules blacklist |
|
137 | # Install kernel modules blacklist | |
115 | mkdir -p $R/etc/modprobe.d/ |
|
138 | mkdir -p $R/etc/modprobe.d/ | |
116 | install_readonly files/modules/raspi-blacklist.conf $R/etc/modprobe.d/raspi-blacklist.conf |
|
139 | install_readonly files/modules/raspi-blacklist.conf $R/etc/modprobe.d/raspi-blacklist.conf | |
117 |
|
140 | |||
118 | # Install and setup fstab |
|
141 | # Install and setup fstab | |
119 | install_readonly files/mount/fstab $R/etc/fstab |
|
142 | install_readonly files/mount/fstab $R/etc/fstab | |
120 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
143 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
121 | sed -i 's/mmcblk0p2/sda1/' $R/etc/fstab |
|
144 | sed -i 's/mmcblk0p2/sda1/' $R/etc/fstab | |
122 | fi |
|
145 | fi | |
123 |
|
146 | |||
124 | # Install sysctl.d configuration files |
|
147 | # Install sysctl.d configuration files | |
125 | install_readonly files/sysctl.d/81-rpi-vm.conf $R/etc/sysctl.d/81-rpi-vm.conf |
|
148 | install_readonly files/sysctl.d/81-rpi-vm.conf $R/etc/sysctl.d/81-rpi-vm.conf |
@@ -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 | # Setup 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 | # Setup 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,13 +1,13 | |||||
1 | # |
|
1 | # | |
2 | # Setup Logging |
|
2 | # Setup Logging | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Disable rsyslog |
|
8 | # Disable rsyslog | |
9 | if [ "$ENABLE_RSYSLOG" = false ]; then |
|
9 | if [ "$ENABLE_RSYSLOG" = false ] ; then | |
10 | sed -i "s|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g" $R/etc/systemd/journald.conf |
|
10 | sed -i "s|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g" $R/etc/systemd/journald.conf | |
11 | chroot_exec systemctl disable rsyslog |
|
11 | chroot_exec systemctl disable rsyslog | |
12 |
chroot_exec apt-get |
|
12 | chroot_exec apt-get -qq -y --force-yes purge rsyslog | |
13 | fi |
|
13 | fi |
@@ -1,31 +1,31 | |||||
1 | # |
|
1 | # | |
2 | # Build and Setup U-Boot |
|
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 |
|
10 | chroot_exec apt-get -q -y --force-yes --no-install-recommends install 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 | # Install and setup 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 bootloader image |
|
29 | # Generate U-Boot bootloader image | |
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 |
|
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 |
|
13 | chroot_exec apt-get -q -y --no-install-recommends install 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 | # Install fbturbo driver 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 |
|
28 | chroot_exec apt-get -qq -y --auto-remove purge 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 - |
|
33 | chroot_exec apt-get -qq -y --auto-remove purge 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,361 +1,417 | |||||
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 | # Check if ./functions.sh script exists | |||
|
19 | if [ ! -r "./functions.sh" ] ; then | |||
|
20 | echo "error: './functions.sh' required script not found. please reinstall the latest script version!" | |||
|
21 | exit 1 | |||
|
22 | fi | |||
|
23 | ||||
18 | # Load utility functions |
|
24 | # Load utility functions | |
19 | . ./functions.sh |
|
25 | . ./functions.sh | |
20 |
|
26 | |||
21 | # Introduce settings |
|
27 | # Introduce settings | |
22 | set -e |
|
28 | set -e | |
23 | echo -n -e "\n#\n# RPi2 Bootstrap Settings\n#\n" |
|
29 | echo -n -e "\n#\n# RPi2 Bootstrap Settings\n#\n" | |
24 | set -x |
|
30 | set -x | |
25 |
|
31 | |||
26 | # Debian release |
|
32 | # Debian release | |
27 | RELEASE=${RELEASE:=jessie} |
|
33 | RELEASE=${RELEASE:=jessie} | |
28 | KERNEL_ARCH=${KERNEL_ARCH:=arm} |
|
34 | KERNEL_ARCH=${KERNEL_ARCH:=arm} | |
29 | RELEASE_ARCH=${RELEASE_ARCH:=armhf} |
|
35 | RELEASE_ARCH=${RELEASE_ARCH:=armhf} | |
30 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} |
|
36 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} | |
31 | COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2} |
|
37 | COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2} | |
|
38 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} | |||
32 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} |
|
39 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} | |
33 |
|
40 | |||
34 | # Build settings |
|
41 | # Build settings | |
35 | BASEDIR=$(pwd)/images/${RELEASE} |
|
42 | BASEDIR=$(pwd)/images/${RELEASE} | |
36 | BUILDDIR=${BASEDIR}/build |
|
43 | BUILDDIR=${BASEDIR}/build | |
37 |
|
44 | |||
38 | # General settings |
|
45 | # General settings | |
39 | HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}} |
|
46 | HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}} | |
40 | PASSWORD=${PASSWORD:=raspberry} |
|
47 | PASSWORD=${PASSWORD:=raspberry} | |
41 | DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} |
|
48 | DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} | |
42 | TIMEZONE=${TIMEZONE:="Europe/Berlin"} |
|
49 | TIMEZONE=${TIMEZONE:="Europe/Berlin"} | |
43 | EXPANDROOT=${EXPANDROOT:=true} |
|
50 | EXPANDROOT=${EXPANDROOT:=true} | |
44 |
|
51 | |||
45 | # Keyboard settings |
|
52 | # Keyboard settings | |
46 | XKB_MODEL=${XKB_MODEL:=""} |
|
53 | XKB_MODEL=${XKB_MODEL:=""} | |
47 | XKB_LAYOUT=${XKB_LAYOUT:=""} |
|
54 | XKB_LAYOUT=${XKB_LAYOUT:=""} | |
48 | XKB_VARIANT=${XKB_VARIANT:=""} |
|
55 | XKB_VARIANT=${XKB_VARIANT:=""} | |
49 | XKB_OPTIONS=${XKB_OPTIONS:=""} |
|
56 | XKB_OPTIONS=${XKB_OPTIONS:=""} | |
50 |
|
57 | |||
51 | # Network settings (DHCP) |
|
58 | # Network settings (DHCP) | |
52 | ENABLE_DHCP=${ENABLE_DHCP:=true} |
|
59 | ENABLE_DHCP=${ENABLE_DHCP:=true} | |
53 |
|
60 | |||
54 | # Network settings (static) |
|
61 | # Network settings (static) | |
55 | # only used on ENABLE_DHCP=false |
|
62 | # only used on ENABLE_DHCP=false | |
56 | NET_ADDRESS=${NET_ADDRESS:=""} |
|
63 | NET_ADDRESS=${NET_ADDRESS:=""} | |
57 | NET_GATEWAY=${NET_GATEWAY:=""} |
|
64 | NET_GATEWAY=${NET_GATEWAY:=""} | |
58 | NET_DNS_1=${NET_DNS_1:=""} |
|
65 | NET_DNS_1=${NET_DNS_1:=""} | |
59 | NET_DNS_2=${NET_DNS_2:=""} |
|
66 | NET_DNS_2=${NET_DNS_2:=""} | |
60 | NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} |
|
67 | NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} | |
61 | NET_NTP_1=${NET_NTP_1:=""} |
|
68 | NET_NTP_1=${NET_NTP_1:=""} | |
62 | NET_NTP_2=${NET_NTP_2:=""} |
|
69 | NET_NTP_2=${NET_NTP_2:=""} | |
63 |
|
70 | |||
64 | # APT settings |
|
71 | # APT settings | |
65 | APT_PROXY=${APT_PROXY:=""} |
|
72 | APT_PROXY=${APT_PROXY:=""} | |
66 | APT_SERVER=${APT_SERVER:="ftp.debian.org"} |
|
73 | APT_SERVER=${APT_SERVER:="ftp.debian.org"} | |
67 |
|
74 | |||
68 | # Feature settings |
|
75 | # Feature settings | |
69 | ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} |
|
76 | ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} | |
70 | ENABLE_IPV6=${ENABLE_IPV6:=true} |
|
77 | ENABLE_IPV6=${ENABLE_IPV6:=true} | |
71 | ENABLE_SSHD=${ENABLE_SSHD:=true} |
|
78 | ENABLE_SSHD=${ENABLE_SSHD:=true} | |
72 | ENABLE_SOUND=${ENABLE_SOUND:=true} |
|
79 | ENABLE_SOUND=${ENABLE_SOUND:=true} | |
73 | ENABLE_DBUS=${ENABLE_DBUS:=true} |
|
80 | ENABLE_DBUS=${ENABLE_DBUS:=true} | |
74 | ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} |
|
81 | ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} | |
75 | ENABLE_MINGPU=${ENABLE_MINGPU:=false} |
|
82 | ENABLE_MINGPU=${ENABLE_MINGPU:=false} | |
76 | ENABLE_XORG=${ENABLE_XORG:=false} |
|
83 | ENABLE_XORG=${ENABLE_XORG:=false} | |
77 | ENABLE_WM=${ENABLE_WM:=""} |
|
84 | ENABLE_WM=${ENABLE_WM:=""} | |
78 | ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} |
|
85 | ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} | |
79 | ENABLE_USER=${ENABLE_USER:=true} |
|
86 | ENABLE_USER=${ENABLE_USER:=true} | |
80 | ENABLE_ROOT=${ENABLE_ROOT:=false} |
|
87 | ENABLE_ROOT=${ENABLE_ROOT:=false} | |
81 | ENABLE_ROOT_SSH=${ENABLE_ROOT_SSH:=false} |
|
88 | ENABLE_ROOT_SSH=${ENABLE_ROOT_SSH:=false} | |
82 |
|
89 | |||
83 | # Advanced settings |
|
90 | # Advanced settings | |
84 | ENABLE_MINBASE=${ENABLE_MINBASE:=false} |
|
91 | ENABLE_MINBASE=${ENABLE_MINBASE:=false} | |
85 | ENABLE_UBOOT=${ENABLE_UBOOT:=false} |
|
92 | ENABLE_UBOOT=${ENABLE_UBOOT:=false} | |
86 | ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} |
|
93 | ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} | |
87 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} |
|
94 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} | |
88 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} |
|
95 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} | |
89 | ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} |
|
96 | ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} | |
90 |
|
97 | |||
91 | # Kernel compilation settings |
|
98 | # Kernel compilation settings | |
92 | BUILD_KERNEL=${BUILD_KERNEL:=false} |
|
99 | BUILD_KERNEL=${BUILD_KERNEL:=false} | |
|
100 | KERNEL_SRCDIR=${KERNEL_SRCDIR:=""} | |||
93 | KERNEL_THREADS=${KERNEL_THREADS:=1} |
|
101 | KERNEL_THREADS=${KERNEL_THREADS:=1} | |
94 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} |
|
102 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} | |
95 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} |
|
103 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} | |
|
104 | KERNEL_CLEANSRC=${KERNEL_CLEANSRC:=false} | |||
|
105 | KERNEL_CONFIGSRC=${KERNEL_CONFIGSRC:=true} | |||
96 | KERNEL_RMSRC=${KERNEL_RMSRC:=true} |
|
106 | KERNEL_RMSRC=${KERNEL_RMSRC:=true} | |
97 |
|
107 | |||
98 | # Image chroot path |
|
108 | # Image chroot path | |
99 | R=${BUILDDIR}/chroot |
|
109 | R=${BUILDDIR}/chroot | |
100 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} |
|
110 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} | |
101 |
|
111 | |||
102 | # Packages required for bootstrapping |
|
112 | # Packages required for bootstrapping | |
103 | REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git-core" |
|
113 | REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git-core" | |
104 |
|
114 | |||
105 | # Missing packages that need to be installed |
|
115 | # Missing packages that need to be installed | |
106 | MISSING_PACKAGES="" |
|
116 | MISSING_PACKAGES="" | |
107 |
|
117 | |||
108 | # Packages required in the chroot build environment |
|
118 | # Packages required in the chroot build environment | |
109 | APT_INCLUDES=${APT_INCLUDES:=""} |
|
119 | APT_INCLUDES=${APT_INCLUDES:=""} | |
110 | APT_INCLUDES="${APT_INCLUDES},apt-transport-https,ca-certificates,debian-archive-keyring,dialog,sudo" |
|
120 | APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo" | |
111 |
|
121 | |||
112 | set +x |
|
122 | set +x | |
113 |
|
123 | |||
114 | # Are we running as root? |
|
124 | # Are we running as root? | |
115 | if [ "$(id -u)" -ne "0" ] ; then |
|
125 | if [ "$(id -u)" -ne "0" ] ; then | |
116 | echo "this script must be executed with root privileges" |
|
126 | echo "error: this script must be executed with root privileges!" | |
117 | exit 1 |
|
127 | exit 1 | |
118 | fi |
|
128 | fi | |
119 |
|
129 | |||
|
130 | # Check if ./bootstrap.d directory exists | |||
|
131 | if [ ! -d "./bootstrap.d/" ] ; then | |||
|
132 | echo "error: './bootstrap.d' required directory not found. please reinstall the latest script version!" | |||
|
133 | exit 1 | |||
|
134 | fi | |||
|
135 | ||||
|
136 | # Check if ./files directory exists | |||
|
137 | if [ ! -d "./files/" ] ; then | |||
|
138 | echo "error: './files' required directory not found. please reinstall the latest script version!" | |||
|
139 | exit 1 | |||
|
140 | fi | |||
|
141 | ||||
|
142 | # Check if specified KERNEL_SRCDIR directory exists | |||
|
143 | if [ -n "$KERNEL_SRCDIR" ] && [ ! -d "$KERNEL_SRCDIR" ] ; then | |||
|
144 | echo "error: ${KERNEL_SRCDIR} (KERNEL_SRCDIR) specified directory not found!" | |||
|
145 | exit 1 | |||
|
146 | fi | |||
|
147 | ||||
|
148 | # Check if specified CHROOT_SCRIPTS directory exists | |||
|
149 | if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then | |||
|
150 | echo "error: ${CHROOT_SCRIPTS} (CHROOT_SCRIPTS) specified directory not found!" | |||
|
151 | exit 1 | |||
|
152 | fi | |||
|
153 | ||||
120 | # Add packages required for kernel cross compilation |
|
154 | # Add packages required for kernel cross compilation | |
121 | if [ "$BUILD_KERNEL" = true ] ; then |
|
155 | if [ "$BUILD_KERNEL" = true ] ; then | |
122 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" |
|
156 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" | |
123 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
157 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |
124 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ncurses-dev" |
|
158 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ncurses-dev" | |
125 | fi |
|
159 | fi | |
126 | fi |
|
160 | fi | |
127 |
|
161 | |||
128 | # Check if all required packages are installed |
|
162 | # Check if all required packages are installed | |
129 | for package in $REQUIRED_PACKAGES ; do |
|
163 | for package in $REQUIRED_PACKAGES ; do | |
130 | if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then |
|
164 | if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then | |
131 | MISSING_PACKAGES="$MISSING_PACKAGES $package" |
|
165 | MISSING_PACKAGES="$MISSING_PACKAGES $package" | |
132 | fi |
|
166 | fi | |
133 | done |
|
167 | done | |
134 |
|
168 | |||
135 | # Ask if missing packages should get installed right now |
|
169 | # Ask if missing packages should get installed right now | |
136 | if [ -n "$MISSING_PACKAGES" ] ; then |
|
170 | if [ -n "$MISSING_PACKAGES" ] ; then | |
137 | echo "the following packages needed by this script are not installed:" |
|
171 | echo "the following packages needed by this script are not installed:" | |
138 | echo "$MISSING_PACKAGES" |
|
172 | echo "$MISSING_PACKAGES" | |
139 |
|
173 | |||
140 | echo -n "\ndo you want to install the missing packages right now? [y/n] " |
|
174 | echo -n "\ndo you want to install the missing packages right now? [y/n] " | |
141 | read confirm |
|
175 | read confirm | |
142 | if [ "$confirm" != "y" ] ; then |
|
176 | if [ "$confirm" != "y" ] ; then | |
143 | exit 1 |
|
177 | exit 1 | |
144 | fi |
|
178 | fi | |
145 | fi |
|
179 | fi | |
146 |
|
180 | |||
147 | # Make sure all required packages are installed |
|
181 | # Make sure all required packages are installed | |
148 | apt-get -qq -y install ${REQUIRED_PACKAGES} |
|
182 | apt-get -qq -y install ${REQUIRED_PACKAGES} | |
149 |
|
183 | |||
150 | # Don't clobber an old build |
|
184 | # Don't clobber an old build | |
151 | if [ -e "$BUILDDIR" ]; then |
|
185 | if [ -e "$BUILDDIR" ] ; then | |
152 | echo "directory $BUILDDIR already exists, not proceeding" |
|
186 | echo "error: directory ${BUILDDIR} already exists, not proceeding" | |
|
187 | exit 1 | |||
|
188 | fi | |||
|
189 | ||||
|
190 | # Check if build directory has enough of free disk space >512MB | |||
|
191 | if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then | |||
|
192 | echo "error: ${BUILDDIR} not enough space left on this partition to generate the output image!" | |||
153 | exit 1 |
|
193 | exit 1 | |
154 | fi |
|
194 | fi | |
155 |
|
195 | |||
|
196 | # Warn if build directory has low free disk space <1024MB | |||
|
197 | if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "1048576" ] ; then | |||
|
198 | echo `df -h --output=avail ${BUILDDIR} | sed "1 s|.*Avail|warning: $partition is low on free space:|"` | |||
|
199 | fi | |||
|
200 | ||||
156 | set -x |
|
201 | set -x | |
157 |
|
202 | |||
158 | # Call "cleanup" function on various signals and errors |
|
203 | # Call "cleanup" function on various signals and errors | |
159 | trap cleanup 0 1 2 3 6 |
|
204 | trap cleanup 0 1 2 3 6 | |
160 |
|
205 | |||
161 | # Setup chroot directory |
|
206 | # Setup chroot directory | |
162 | mkdir -p $R |
|
207 | mkdir -p $R | |
163 |
|
208 | |||
164 | # Add required packages for the minbase installation |
|
209 | # Add required packages for the minbase installation | |
165 | if [ "$ENABLE_MINBASE" = true ] ; then |
|
210 | if [ "$ENABLE_MINBASE" = true ] ; then | |
166 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools" |
|
211 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools" | |
167 | else |
|
212 | else | |
168 | APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup" |
|
213 | APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup" | |
169 | fi |
|
214 | fi | |
170 |
|
215 | |||
171 | # Add parted package, required to get partprobe utility |
|
216 | # Add parted package, required to get partprobe utility | |
172 | if [ "$EXPANDROOT" = true ] ; then |
|
217 | if [ "$EXPANDROOT" = true ] ; then | |
173 | APT_INCLUDES="${APT_INCLUDES},parted" |
|
218 | APT_INCLUDES="${APT_INCLUDES},parted" | |
174 | fi |
|
219 | fi | |
175 |
|
220 | |||
176 | # Add dbus package, recommended if using systemd |
|
221 | # Add dbus package, recommended if using systemd | |
177 | if [ "$ENABLE_DBUS" = true ] ; then |
|
222 | if [ "$ENABLE_DBUS" = true ] ; then | |
178 | APT_INCLUDES="${APT_INCLUDES},dbus" |
|
223 | APT_INCLUDES="${APT_INCLUDES},dbus" | |
179 | fi |
|
224 | fi | |
180 |
|
225 | |||
181 | # Add iptables IPv4/IPv6 package |
|
226 | # Add iptables IPv4/IPv6 package | |
182 | if [ "$ENABLE_IPTABLES" = true ] ; then |
|
227 | if [ "$ENABLE_IPTABLES" = true ] ; then | |
183 | APT_INCLUDES="${APT_INCLUDES},iptables" |
|
228 | APT_INCLUDES="${APT_INCLUDES},iptables" | |
184 | fi |
|
229 | fi | |
185 |
|
230 | |||
186 | # Add openssh server package |
|
231 | # Add openssh server package | |
187 | if [ "$ENABLE_SSHD" = true ] ; then |
|
232 | if [ "$ENABLE_SSHD" = true ] ; then | |
188 | APT_INCLUDES="${APT_INCLUDES},openssh-server" |
|
233 | APT_INCLUDES="${APT_INCLUDES},openssh-server" | |
189 | fi |
|
234 | fi | |
190 |
|
235 | |||
191 | # Add alsa-utils package |
|
236 | # Add alsa-utils package | |
192 | if [ "$ENABLE_SOUND" = true ] ; then |
|
237 | if [ "$ENABLE_SOUND" = true ] ; then | |
193 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" |
|
238 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" | |
194 | fi |
|
239 | fi | |
195 |
|
240 | |||
196 | # Add rng-tools package |
|
241 | # Add rng-tools package | |
197 | if [ "$ENABLE_HWRANDOM" = true ] ; then |
|
242 | if [ "$ENABLE_HWRANDOM" = true ] ; then | |
198 | APT_INCLUDES="${APT_INCLUDES},rng-tools" |
|
243 | APT_INCLUDES="${APT_INCLUDES},rng-tools" | |
199 | fi |
|
244 | fi | |
200 |
|
245 | |||
201 | if [ "$ENABLE_USER" = true ]; then |
|
|||
202 | APT_INCLUDES="${APT_INCLUDES},sudo" |
|
|||
203 | fi |
|
|||
204 |
|
||||
205 | # Add fbturbo video driver |
|
246 | # Add fbturbo video driver | |
206 | if [ "$ENABLE_FBTURBO" = true ] ; then |
|
247 | if [ "$ENABLE_FBTURBO" = true ] ; then | |
207 | # Enable xorg package dependencies |
|
248 | # Enable xorg package dependencies | |
208 | ENABLE_XORG=true |
|
249 | ENABLE_XORG=true | |
209 | fi |
|
250 | fi | |
210 |
|
251 | |||
211 | # Add user defined window manager package |
|
252 | # Add user defined window manager package | |
212 | if [ -n "$ENABLE_WM" ] ; then |
|
253 | if [ -n "$ENABLE_WM" ] ; then | |
213 | APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" |
|
254 | APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" | |
214 |
|
255 | |||
215 | # Enable xorg package dependencies |
|
256 | # Enable xorg package dependencies | |
216 | ENABLE_XORG=true |
|
257 | ENABLE_XORG=true | |
217 | fi |
|
258 | fi | |
218 |
|
259 | |||
219 | # Add xorg package |
|
260 | # Add xorg package | |
220 | if [ "$ENABLE_XORG" = true ] ; then |
|
261 | if [ "$ENABLE_XORG" = true ] ; then | |
221 | APT_INCLUDES="${APT_INCLUDES},xorg" |
|
262 | APT_INCLUDES="${APT_INCLUDES},xorg" | |
222 | fi |
|
263 | fi | |
223 |
|
264 | |||
224 | ## Main bootstrap |
|
265 | # Set KERNEL_CONFIGSRC=true | |
225 | for i in bootstrap.d/*.sh; do |
|
266 | if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNEL_SRCDIR" ] ; then | |
226 | head -n 3 $i |
|
267 | KERNEL_CONFIGSRC=true | |
227 | . $i |
|
268 | fi | |
|
269 | ||||
|
270 | ## MAIN bootstrap | |||
|
271 | for SCRIPT in bootstrap.d/*.sh; do | |||
|
272 | # Execute bootstrap scripts (lexicographical order) | |||
|
273 | head -n 3 $SCRIPT | |||
|
274 | . $SCRIPT | |||
228 | done |
|
275 | done | |
229 |
|
276 | |||
230 | ## Custom bootstrap scripts |
|
277 | ## Custom bootstrap scripts | |
231 | if [ -d "custom.d" ]; then |
|
278 | if [ -d "custom.d" ] ; then | |
232 | for i in custom.d/*.sh; do |
|
279 | # Execute custom bootstrap scripts (lexicographical order) | |
233 | . $i |
|
280 | for SCRIPT in custom.d/*.sh; do | |
|
281 | . $SCRIPT | |||
234 | done |
|
282 | done | |
235 | fi |
|
283 | fi | |
236 |
|
284 | |||
237 | # Invoke custom scripts |
|
285 | # Invoke custom scripts | |
238 |
if [ -n "$ |
|
286 | if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then | |
239 | cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" |
|
287 | cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" | |
240 | LANG=C chroot $R bash -c 'for SCRIPT in /chroot_scripts/*; do if [ -f $SCRIPT -a -x $SCRIPT ]; then $SCRIPT; fi done;' |
|
288 | # Execute scripts inside the chroot (lexicographical order) | |
|
289 | chroot_exec /bin/bash -x <<'EOF' | |||
|
290 | for SCRIPT in /chroot_scripts/* ; do | |||
|
291 | if [ -f $SCRIPT -a -x $SCRIPT ] ; then | |||
|
292 | $SCRIPT | |||
|
293 | fi | |||
|
294 | done | |||
|
295 | EOF | |||
241 | rm -rf "${R}/chroot_scripts" |
|
296 | rm -rf "${R}/chroot_scripts" | |
242 | fi |
|
297 | fi | |
243 |
|
298 | |||
244 | ## Cleanup |
|
299 | ## Cleanup | |
|
300 | chroot_exec apt-get purge -q -y --force-yes apt-utils | |||
245 | chroot_exec apt-get -y clean |
|
301 | chroot_exec apt-get -y clean | |
246 | chroot_exec apt-get -y autoclean |
|
302 | chroot_exec apt-get -y autoclean | |
247 | chroot_exec apt-get -y autoremove |
|
303 | chroot_exec apt-get -y autoremove | |
248 |
|
304 | |||
249 | # Unmount mounted filesystems |
|
305 | # Unmount mounted filesystems | |
250 | umount -l $R/proc |
|
306 | umount -l $R/proc | |
251 | umount -l $R/sys |
|
307 | umount -l $R/sys | |
252 |
|
308 | |||
253 | # Clean up files |
|
309 | # Clean up files | |
254 | rm -f $R/etc/apt/sources.list.save |
|
310 | rm -f $R/etc/apt/sources.list.save | |
255 | rm -f $R/etc/resolvconf/resolv.conf.d/original |
|
311 | rm -f $R/etc/resolvconf/resolv.conf.d/original | |
256 | rm -rf $R/run |
|
312 | rm -rf $R/run | |
257 | mkdir -p $R/run |
|
313 | mkdir -p $R/run | |
258 | rm -f $R/etc/*- |
|
314 | rm -f $R/etc/*- | |
259 | rm -f $R/root/.bash_history |
|
315 | rm -f $R/root/.bash_history | |
260 | rm -rf $R/tmp/* |
|
316 | rm -rf $R/tmp/* | |
261 | rm -f $R/var/lib/urandom/random-seed |
|
317 | rm -f $R/var/lib/urandom/random-seed | |
262 | [ -L $R/var/lib/dbus/machine-id ] || rm -f $R/var/lib/dbus/machine-id |
|
318 | [ -L $R/var/lib/dbus/machine-id ] || rm -f $R/var/lib/dbus/machine-id | |
263 | rm -f $R/etc/machine-id |
|
319 | rm -f $R/etc/machine-id | |
264 | rm -fr $R/etc/apt/apt.conf.d/10proxy |
|
320 | rm -fr $R/etc/apt/apt.conf.d/10proxy | |
265 | rm -f $R/etc/resolv.conf |
|
321 | rm -f $R/etc/resolv.conf | |
266 |
|
322 | |||
267 | # Calculate size of the chroot directory in KB |
|
323 | # Calculate size of the chroot directory in KB | |
268 | CHROOT_SIZE=$(expr `du -s $R | awk '{ print $1 }'`) |
|
324 | CHROOT_SIZE=$(expr `du -s $R | awk '{ print $1 }'`) | |
269 |
|
325 | |||
270 | # Calculate the amount of needed 512 Byte sectors |
|
326 | # Calculate the amount of needed 512 Byte sectors | |
271 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) |
|
327 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) | |
272 | FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512) |
|
328 | FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512) | |
273 | ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS}) |
|
329 | ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS}) | |
274 |
|
330 | |||
275 | # The root partition is EXT4 |
|
331 | # The root partition is EXT4 | |
276 | # This means more space than the actual used space of the chroot is used. |
|
332 | # This means more space than the actual used space of the chroot is used. | |
277 | # As overhead for journaling and reserved blocks 20% are added. |
|
333 | # As overhead for journaling and reserved blocks 20% are added. | |
278 | ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 20) \* 1024 \/ 512) |
|
334 | ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 20) \* 1024 \/ 512) | |
279 |
|
335 | |||
280 | # Calculate required image size in 512 Byte sectors |
|
336 | # Calculate required image size in 512 Byte sectors | |
281 | IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS}) |
|
337 | IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS}) | |
282 |
|
338 | |||
283 | # Prepare date string for image file name |
|
339 | # Prepare date string for image file name | |
284 | DATE="$(date +%Y-%m-%d)" |
|
340 | DATE="$(date +%Y-%m-%d)" | |
285 |
|
341 | |||
286 | # Prepare image file |
|
342 | # Prepare image file | |
287 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
343 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
288 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=${TABLE_SECTORS} |
|
344 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=${TABLE_SECTORS} | |
289 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS} |
|
345 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS} | |
290 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=${TABLE_SECTORS} |
|
346 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=${TABLE_SECTORS} | |
291 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=0 seek=${ROOT_SECTORS} |
|
347 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}-root.img" bs=512 count=0 seek=${ROOT_SECTORS} | |
292 | # Write partition tables |
|
348 | # Write partition tables | |
293 | sfdisk -q -L -f "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" <<EOM |
|
349 | sfdisk -q -L -f "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" <<EOM | |
294 | unit: sectors |
|
350 | unit: sectors | |
295 |
|
351 | |||
296 | 1 : start= ${TABLE_SECTORS}, size= ${FRMW_SECTORS}, Id= c, bootable |
|
352 | 1 : start= ${TABLE_SECTORS}, size= ${FRMW_SECTORS}, Id= c, bootable | |
297 | 2 : start= 0, size= 0, Id= 0 |
|
353 | 2 : start= 0, size= 0, Id= 0 | |
298 | 3 : start= 0, size= 0, Id= 0 |
|
354 | 3 : start= 0, size= 0, Id= 0 | |
299 | 4 : start= 0, size= 0, Id= 0 |
|
355 | 4 : start= 0, size= 0, Id= 0 | |
300 | EOM |
|
356 | EOM | |
301 | sfdisk -q -L -f "$BASEDIR/${DATE}-debian-${RELEASE}-root.img" <<EOM |
|
357 | sfdisk -q -L -f "$BASEDIR/${DATE}-debian-${RELEASE}-root.img" <<EOM | |
302 | unit: sectors |
|
358 | unit: sectors | |
303 |
|
359 | |||
304 | 1 : start= ${TABLE_SECTORS}, size= ${ROOT_SECTORS}, Id=83 |
|
360 | 1 : start= ${TABLE_SECTORS}, size= ${ROOT_SECTORS}, Id=83 | |
305 | 2 : start= 0, size= 0, Id= 0 |
|
361 | 2 : start= 0, size= 0, Id= 0 | |
306 | 3 : start= 0, size= 0, Id= 0 |
|
362 | 3 : start= 0, size= 0, Id= 0 | |
307 | 4 : start= 0, size= 0, Id= 0 |
|
363 | 4 : start= 0, size= 0, Id= 0 | |
308 | EOM |
|
364 | EOM | |
309 | # Setup temporary loop devices |
|
365 | # Setup temporary loop devices | |
310 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-frmw.img)" |
|
366 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-frmw.img)" | |
311 | ROOT_LOOP="$(losetup -o 1M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-root.img)" |
|
367 | ROOT_LOOP="$(losetup -o 1M -f --show $BASEDIR/${DATE}-debian-${RELEASE}-root.img)" | |
312 | else |
|
368 | else | |
313 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=${TABLE_SECTORS} |
|
369 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=${TABLE_SECTORS} | |
314 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=0 seek=${IMAGE_SECTORS} |
|
370 | dd if=/dev/zero of="$BASEDIR/${DATE}-debian-${RELEASE}.img" bs=512 count=0 seek=${IMAGE_SECTORS} | |
315 | # Write partition table |
|
371 | # Write partition table | |
316 | sfdisk -q -f "$BASEDIR/${DATE}-debian-${RELEASE}.img" <<EOM |
|
372 | sfdisk -q -f "$BASEDIR/${DATE}-debian-${RELEASE}.img" <<EOM | |
317 | unit: sectors |
|
373 | unit: sectors | |
318 |
|
374 | |||
319 | 1 : start= ${TABLE_SECTORS}, size= ${FRMW_SECTORS}, Id= c, bootable |
|
375 | 1 : start= ${TABLE_SECTORS}, size= ${FRMW_SECTORS}, Id= c, bootable | |
320 | 2 : start= ${ROOT_OFFSET}, size= ${ROOT_SECTORS}, Id=83 |
|
376 | 2 : start= ${ROOT_OFFSET}, size= ${ROOT_SECTORS}, Id=83 | |
321 | 3 : start= 0, size= 0, Id= 0 |
|
377 | 3 : start= 0, size= 0, Id= 0 | |
322 | 4 : start= 0, size= 0, Id= 0 |
|
378 | 4 : start= 0, size= 0, Id= 0 | |
323 | EOM |
|
379 | EOM | |
324 | # Setup temporary loop devices |
|
380 | # Setup temporary loop devices | |
325 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)" |
|
381 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)" | |
326 | ROOT_LOOP="$(losetup -o 65M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)" |
|
382 | ROOT_LOOP="$(losetup -o 65M -f --show $BASEDIR/${DATE}-debian-${RELEASE}.img)" | |
327 | fi |
|
383 | fi | |
328 |
|
384 | |||
329 | # Build filesystems |
|
385 | # Build filesystems | |
330 | mkfs.vfat "$FRMW_LOOP" |
|
386 | mkfs.vfat "$FRMW_LOOP" | |
331 | mkfs.ext4 "$ROOT_LOOP" |
|
387 | mkfs.ext4 "$ROOT_LOOP" | |
332 |
|
388 | |||
333 | # Mount the temporary loop devices |
|
389 | # Mount the temporary loop devices | |
334 | mkdir -p "$BUILDDIR/mount" |
|
390 | mkdir -p "$BUILDDIR/mount" | |
335 | mount "$ROOT_LOOP" "$BUILDDIR/mount" |
|
391 | mount "$ROOT_LOOP" "$BUILDDIR/mount" | |
336 |
|
392 | |||
337 | mkdir -p "$BUILDDIR/mount/boot/firmware" |
|
393 | mkdir -p "$BUILDDIR/mount/boot/firmware" | |
338 | mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" |
|
394 | mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" | |
339 |
|
395 | |||
340 | # Copy all files from the chroot to the loop device mount point directory |
|
396 | # Copy all files from the chroot to the loop device mount point directory | |
341 | rsync -a "$R/" "$BUILDDIR/mount/" |
|
397 | rsync -a "$R/" "$BUILDDIR/mount/" | |
342 |
|
398 | |||
343 | # Unmount all temporary loop devices and mount points |
|
399 | # Unmount all temporary loop devices and mount points | |
344 | cleanup |
|
400 | cleanup | |
345 |
|
401 | |||
346 | # Create block map file(s) of image(s) |
|
402 | # Create block map file(s) of image(s) | |
347 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
403 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
348 | # Create block map files for "bmaptool" |
|
404 | # Create block map files for "bmaptool" | |
349 | bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" |
|
405 | bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img" | |
350 | bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-root.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-root.img" |
|
406 | bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}-root.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}-root.img" | |
351 |
|
407 | |||
352 | # Image was successfully created |
|
408 | # Image was successfully created | |
353 | echo "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
409 | echo "$BASEDIR/${DATE}-debian-${RELEASE}-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_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" |
|
410 | echo "$BASEDIR/${DATE}-debian-${RELEASE}-root.img ($(expr \( ${TABLE_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
355 | else |
|
411 | else | |
356 | # Create block map file for "bmaptool" |
|
412 | # Create block map file for "bmaptool" | |
357 | bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}.img" |
|
413 | bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}.img" | |
358 |
|
414 | |||
359 | # Image was successfully created |
|
415 | # Image was successfully created | |
360 | echo "$BASEDIR/${DATE}-debian-${RELEASE}.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
416 | echo "$BASEDIR/${DATE}-debian-${RELEASE}.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
361 | fi |
|
417 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant