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