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