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