@@ -19,7 +19,7 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi2-gen-image.sh | |||||
19 | APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi2-gen-image.sh |
|
19 | APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi2-gen-image.sh | |
20 | ENABLE_MINBASE=true ./rpi2-gen-image.sh |
|
20 | ENABLE_MINBASE=true ./rpi2-gen-image.sh | |
21 | BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi2-gen-image.sh |
|
21 | BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi2-gen-image.sh | |
22 |
BUILD_KERNEL=true KERNEL |
|
22 | BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi2-gen-image.sh | |
23 | ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi2-gen-image.sh |
|
23 | ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi2-gen-image.sh | |
24 | ``` |
|
24 | ``` | |
25 |
|
25 | |||
@@ -165,9 +165,6 Path to a directory with scripts that should be run in the chroot before the ima | |||||
165 | ##### `BUILD_KERNEL`=false |
|
165 | ##### `BUILD_KERNEL`=false | |
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. |
|
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. | |
167 |
|
167 | |||
168 | ##### `KERNEL_SRCDIR`="" |
|
|||
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. |
|
|||
170 |
|
||||
171 | ##### `KERNEL_THREADS`=1 |
|
168 | ##### `KERNEL_THREADS`=1 | |
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 | 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. | |
173 |
|
170 | |||
@@ -177,14 +174,20 Install kernel headers with built kernel. | |||||
177 | ##### `KERNEL_MENUCONFIG`=false |
|
174 | ##### `KERNEL_MENUCONFIG`=false | |
178 | Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated. |
|
175 | Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated. | |
179 |
|
176 | |||
180 |
##### `KERNEL_ |
|
177 | ##### `KERNEL_REMOVESRC`=true | |
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 | Remove all kernel sources from the generated OS image after it was built and installed. | |
182 |
|
179 | |||
183 |
##### `KERNEL |
|
180 | ##### `KERNELSRC_DIR`="" | |
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 | 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. | |
185 |
|
182 | |||
186 |
##### `KERNEL |
|
183 | ##### `KERNELSRC_CLEAN`=false | |
187 | Remove all kernel sources from the generated OS image after it was built and installed. |
|
184 | Clean the existing kernel sources directory `KERNELSRC_DIR` (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 `KERNELSRC_DIR` was specified or if `KERNELSRC_PREBUILT`=true. | |
|
185 | ||||
|
186 | ##### `KERNELSRC_CONFIG`=true | |||
|
187 | 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 `KERNELSRC_DIR`. This settings is ignored if `KERNELSRC_PREBUILT`=true. | |||
|
188 | ||||
|
189 | ##### `KERNELSRC_PREBUILT`=false | |||
|
190 | With this parameter set to true the script expects the existing kernel sources directory to be already successfully cross-compiled. The parameters `KERNELSRC_CLEAN`, `KERNELSRC_CONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed. | |||
188 |
|
191 | |||
189 | ## Understanding the script |
|
192 | ## Understanding the script | |
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: |
|
193 | 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: |
@@ -7,22 +7,22 | |||||
7 |
|
7 | |||
8 | # Base debootstrap (unpack only) |
|
8 | # Base debootstrap (unpack only) | |
9 | if [ "$ENABLE_MINBASE" = true ] ; then |
|
9 | if [ "$ENABLE_MINBASE" = true ] ; then | |
10 | http_proxy=${APT_PROXY} debootstrap --arch=${RELEASE_ARCH} --variant=minbase --foreign --include=${APT_INCLUDES} ${RELEASE} $R http://${APT_SERVER}/debian |
|
10 | http_proxy=${APT_PROXY} debootstrap --arch="${RELEASE_ARCH}" --variant=minbase --foreign --include="${APT_INCLUDES}" "${RELEASE}" "$R" "http://${APT_SERVER}/debian" | |
11 | else |
|
11 | else | |
12 | http_proxy=${APT_PROXY} debootstrap --arch=${RELEASE_ARCH} --foreign --include=${APT_INCLUDES} ${RELEASE} $R http://${APT_SERVER}/debian |
|
12 | http_proxy=${APT_PROXY} debootstrap --arch="${RELEASE_ARCH}" --foreign --include="${APT_INCLUDES}" "${RELEASE}" "$R" "http://${APT_SERVER}/debian" | |
13 | fi |
|
13 | fi | |
14 |
|
14 | |||
15 | # Copy qemu emulator binary to chroot |
|
15 | # Copy qemu emulator binary to chroot | |
16 | cp ${QEMU_BINARY} $R/usr/bin |
|
16 | cp "${QEMU_BINARY}" "$R/usr/bin" | |
17 |
|
17 | |||
18 | # Copy debian-archive-keyring.pgp |
|
18 | # Copy debian-archive-keyring.pgp | |
19 | mkdir -p $R/usr/share/keyrings |
|
19 | mkdir -p "$R/usr/share/keyrings" | |
20 | cp /usr/share/keyrings/debian-archive-keyring.gpg $R/usr/share/keyrings/debian-archive-keyring.gpg |
|
20 | cp /usr/share/keyrings/debian-archive-keyring.gpg "$R/usr/share/keyrings/debian-archive-keyring.gpg" | |
21 |
|
21 | |||
22 | # Complete the bootstrapping process |
|
22 | # Complete the bootstrapping process | |
23 | chroot_exec /debootstrap/debootstrap --second-stage |
|
23 | chroot_exec /debootstrap/debootstrap --second-stage | |
24 |
|
24 | |||
25 | # Mount required filesystems |
|
25 | # Mount required filesystems | |
26 | mount -t proc none $R/proc |
|
26 | mount -t proc none "$R/proc" | |
27 | mount -t sysfs none $R/sys |
|
27 | mount -t sysfs none "$R/sys" | |
28 | mount --bind /dev/pts $R/dev/pts |
|
28 | mount --bind /dev/pts "$R/dev/pts" |
@@ -7,22 +7,22 | |||||
7 |
|
7 | |||
8 | # Install and setup APT proxy configuration |
|
8 | # Install and setup APT proxy configuration | |
9 | if [ -z "$APT_PROXY" ] ; then |
|
9 | if [ -z "$APT_PROXY" ] ; then | |
10 | install_readonly files/apt/10proxy $R/etc/apt/apt.conf.d/10proxy |
|
10 | install_readonly files/apt/10proxy "$R/etc/apt/apt.conf.d/10proxy" | |
11 | sed -i "s/\"\"/\"${APT_PROXY}\"/" $R/etc/apt/apt.conf.d/10proxy |
|
11 | sed -i "s/\"\"/\"${APT_PROXY}\"/" "$R/etc/apt/apt.conf.d/10proxy" | |
12 | fi |
|
12 | fi | |
13 |
|
13 | |||
14 | # Install APT pinning configuration for flash-kernel package |
|
14 | # Install APT pinning configuration for flash-kernel package | |
15 | install_readonly files/apt/flash-kernel $R/etc/apt/preferences.d/flash-kernel |
|
15 | install_readonly files/apt/flash-kernel "$R/etc/apt/preferences.d/flash-kernel" | |
16 |
|
16 | |||
17 | # Upgrade collabora package index and install collabora keyring |
|
17 | # Upgrade collabora package index and install collabora keyring | |
18 | echo "deb https://repositories.collabora.co.uk/debian ${RELEASE} rpi2" >$R/etc/apt/sources.list |
|
18 | echo "deb https://repositories.collabora.co.uk/debian ${RELEASE} rpi2" > "$R/etc/apt/sources.list" | |
19 | chroot_exec apt-get -qq -y update |
|
19 | chroot_exec apt-get -qq -y update | |
20 | chroot_exec apt-get -qq -y --force-yes install collabora-obs-archive-keyring |
|
20 | chroot_exec apt-get -qq -y --force-yes install collabora-obs-archive-keyring | |
21 |
|
21 | |||
22 | # Install APT sources.list |
|
22 | # Install APT sources.list | |
23 | install_readonly files/apt/sources.list $R/etc/apt/sources.list |
|
23 | install_readonly files/apt/sources.list "$R/etc/apt/sources.list" | |
24 | sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" $R/etc/apt/sources.list |
|
24 | sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "$R/etc/apt/sources.list" | |
25 | sed -i "s/ jessie/ ${RELEASE}/" $R/etc/apt/sources.list |
|
25 | sed -i "s/ jessie/ ${RELEASE}/" "$R/etc/apt/sources.list" | |
26 |
|
26 | |||
27 | # Upgrade package index and update all installed packages and changed dependencies |
|
27 | # Upgrade package index and update all installed packages and changed dependencies | |
28 | chroot_exec apt-get -qq -y update |
|
28 | chroot_exec apt-get -qq -y update |
@@ -6,7 +6,7 | |||||
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Install and setup timezone |
|
8 | # Install and setup timezone | |
9 | echo ${TIMEZONE} >$R/etc/timezone |
|
9 | echo ${TIMEZONE} > "$R/etc/timezone" | |
10 | chroot_exec dpkg-reconfigure -f noninteractive tzdata |
|
10 | chroot_exec dpkg-reconfigure -f noninteractive tzdata | |
11 |
|
11 | |||
12 | # Install and setup default locale and keyboard configuration |
|
12 | # Install and setup default locale and keyboard configuration | |
@@ -19,40 +19,40 if [ "$ENABLE_MINBASE" = false ] ; then | |||||
19 | else |
|
19 | else | |
20 | # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale |
|
20 | # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale | |
21 | chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections |
|
21 | chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections | |
22 | sed -i "/en_US.UTF-8/s/^#//" $R/etc/locale.gen |
|
22 | sed -i "/en_US.UTF-8/s/^#//" "$R/etc/locale.gen" | |
23 | fi |
|
23 | fi | |
24 |
|
24 | |||
25 | sed -i "/${DEFLOCAL}/s/^#//" $R/etc/locale.gen |
|
25 | sed -i "/${DEFLOCAL}/s/^#//" "$R/etc/locale.gen" | |
26 | chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections |
|
26 | chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections | |
27 | chroot_exec locale-gen |
|
27 | chroot_exec locale-gen | |
28 | chroot_exec update-locale LANG=${DEFLOCAL} |
|
28 | chroot_exec update-locale LANG="${DEFLOCAL}" | |
29 |
|
29 | |||
30 | # Install and setup default keyboard configuration |
|
30 | # Install and setup default keyboard configuration | |
31 | if [ "$XKB_MODEL" != "" ] ; then |
|
31 | if [ "$XKB_MODEL" != "" ] ; then | |
32 | sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" $R/etc/default/keyboard |
|
32 | sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" "$R/etc/default/keyboard" | |
33 | fi |
|
33 | fi | |
34 | if [ "$XKB_LAYOUT" != "" ] ; then |
|
34 | if [ "$XKB_LAYOUT" != "" ] ; then | |
35 | sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" $R/etc/default/keyboard |
|
35 | sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" "$R/etc/default/keyboard" | |
36 | fi |
|
36 | fi | |
37 | if [ "$XKB_VARIANT" != "" ] ; then |
|
37 | if [ "$XKB_VARIANT" != "" ] ; then | |
38 | sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" $R/etc/default/keyboard |
|
38 | sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" "$R/etc/default/keyboard" | |
39 | fi |
|
39 | fi | |
40 | if [ "$XKB_OPTIONS" != "" ] ; then |
|
40 | if [ "$XKB_OPTIONS" != "" ] ; then | |
41 | sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" $R/etc/default/keyboard |
|
41 | sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" "$R/etc/default/keyboard" | |
42 | fi |
|
42 | fi | |
43 | chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration |
|
43 | chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration | |
44 |
|
44 | |||
45 | # Install and setup font console |
|
45 | # Install and setup font console | |
46 | case "${DEFLOCAL}" in |
|
46 | case "${DEFLOCAL}" in | |
47 | *UTF-8) |
|
47 | *UTF-8) | |
48 | sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' $R/etc/default/console-setup |
|
48 | sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' "$R/etc/default/console-setup" | |
49 | ;; |
|
49 | ;; | |
50 | *) |
|
50 | *) | |
51 | sed -i 's/^CHARMAP.*/CHARMAP="guess"/' $R/etc/default/console-setup |
|
51 | sed -i 's/^CHARMAP.*/CHARMAP="guess"/' "$R/etc/default/console-setup" | |
52 | ;; |
|
52 | ;; | |
53 | esac |
|
53 | esac | |
54 | chroot_exec dpkg-reconfigure -f noninteractive console-setup |
|
54 | chroot_exec dpkg-reconfigure -f noninteractive console-setup | |
55 | else # ENABLE_MINBASE=true |
|
55 | else # ENABLE_MINBASE=true | |
56 | # Install POSIX default locale |
|
56 | # Install POSIX default locale | |
57 | install_readonly files/locales/locale $R/etc/default/locale |
|
57 | install_readonly files/locales/locale "$R/etc/default/locale" | |
58 | fi |
|
58 | fi |
@@ -8,88 +8,99 | |||||
8 | # Fetch and build latest raspberry kernel |
|
8 | # Fetch and build latest raspberry kernel | |
9 | if [ "$BUILD_KERNEL" = true ] ; then |
|
9 | if [ "$BUILD_KERNEL" = true ] ; then | |
10 | # Setup source directory |
|
10 | # Setup source directory | |
11 | mkdir -p $R/usr/src |
|
11 | mkdir -p "$R/usr/src" | |
12 |
|
12 | |||
13 | # Copy existing kernel sources into chroot directory |
|
13 | # Copy existing kernel sources into chroot directory | |
14 |
if [ -n "$KERNEL |
|
14 | if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then | |
15 | # Copy kernel sources |
|
15 | # Copy kernel sources | |
16 |
cp -r "${KERNEL |
|
16 | cp -r "${KERNELSRC_DIR}" "${R}/usr/src" | |
17 |
|
17 | |||
18 | # Clean the kernel sources |
|
18 | # Clean the kernel sources | |
19 |
if [ "$KERNEL_CLEAN |
|
19 | if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then | |
20 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} mrproper |
|
20 | make -C "$R/usr/src/linux" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper | |
21 | fi |
|
21 | fi | |
22 |
else # KERNEL |
|
22 | else # KERNELSRC_DIR="" | |
23 | # Fetch current raspberrypi kernel sources |
|
23 | # Fetch current raspberrypi kernel sources | |
24 | git -C $R/usr/src clone --depth=1 https://github.com/raspberrypi/linux |
|
24 | git -C "$R/usr/src" clone --depth=1 https://github.com/raspberrypi/linux | |
25 | fi |
|
25 | fi | |
26 |
|
26 | |||
27 | # Calculate optimal number of kernel building threads |
|
27 | # Calculate optimal number of kernel building threads | |
28 | if [ "$KERNEL_THREADS" = "1" ] ; then |
|
28 | if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then | |
29 | if [ -r /proc/cpuinfo ] ; then |
|
|||
30 |
|
|
29 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) | |
31 |
|
|
30 | fi | |
32 | fi |
|
|||
33 |
|
31 | |||
34 |
if [ "$KERNEL |
|
32 | if [ "$KERNELSRC_PREBUILT" = false ] ; then | |
|
33 | if [ "$KERNELSRC_CONFIG" = true ] ; then | |||
35 | # Load default raspberry kernel configuration |
|
34 | # Load default raspberry kernel configuration | |
36 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} ${KERNEL_DEFCONFIG} |
|
35 | make -C "$R/usr/src/linux" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" | |
37 |
|
36 | |||
38 | # Start menu-driven kernel configuration (interactive) |
|
37 | # Start menu-driven kernel configuration (interactive) | |
39 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
38 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |
40 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} menuconfig |
|
39 | make -C "$R/usr/src/linux" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig | |
41 | fi |
|
40 | fi | |
42 | fi |
|
41 | fi | |
43 |
|
42 | |||
44 | # Cross compile kernel and modules |
|
43 | # Cross compile kernel and modules | |
45 | make -C $R/usr/src/linux -j${KERNEL_THREADS} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} zImage modules dtbs |
|
44 | make -C "$R/usr/src/linux" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs | |
|
45 | fi | |||
46 |
|
46 | |||
47 | # Check if kernel compilation was successful |
|
47 | # Check if kernel compilation was successful | |
48 | if [ ! -r $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/zImage ] ; then |
|
48 | if [ ! -r "$R/usr/src/linux/arch/${KERNEL_ARCH}/boot/zImage" ] ; then | |
49 | echo "error: kernel compilation failed!" |
|
49 | echo "error: kernel compilation failed! (zImage not found)" | |
50 | cleanup |
|
50 | cleanup | |
51 | exit 1 |
|
51 | exit 1 | |
52 | fi |
|
52 | fi | |
53 |
|
53 | |||
54 | # Install kernel modules |
|
54 | # Install kernel modules | |
55 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
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 |
|
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 |
|
57 | else | |
58 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_MOD_PATH=../../.. modules_install |
|
58 | make -C "$R/usr/src/linux" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install | |
|
59 | ||||
|
60 | # Install kernel firmware | |||
|
61 | make -C "$R/usr/src/linux" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install | |||
59 | fi |
|
62 | fi | |
60 |
|
63 | |||
61 | # Install kernel headers |
|
64 | # Install kernel headers | |
62 | if [ "$KERNEL_HEADERS" = true ] ; then |
|
65 | if [ "$KERNEL_HEADERS" = true ] ; then | |
63 | make -C $R/usr/src/linux ARCH=${KERNEL_ARCH} CROSS_COMPILE=${CROSS_COMPILE} INSTALL_HDR_PATH=../.. headers_install |
|
66 | make -C "$R/usr/src/linux" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install | |
64 | fi |
|
67 | fi | |
65 |
|
68 | |||
66 | # Copy and rename compiled kernel to boot directory |
|
69 | # Prepare boot (firmware) directory | |
67 | mkdir $R/boot/firmware/ |
|
70 | mkdir "$R/boot/firmware/" | |
68 | $R/usr/src/linux/scripts/mkknlimg $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/zImage $R/boot/firmware/kernel7.img |
|
71 | ||
|
72 | # Get kernel release version | |||
|
73 | KERNEL_VERSION=`cat "$R/usr/src/linux/include/config/kernel.release"` | |||
|
74 | ||||
|
75 | # Copy kernel configuration file to the boot directory | |||
|
76 | cp "$R/usr/src/linux/.config" "$R/boot/config-${KERNEL_VERSION}" | |||
|
77 | ||||
|
78 | # Copy dts and dtb device tree sources and binaries | |||
|
79 | mkdir "$R/boot/firmware/overlays/" | |||
|
80 | cp "$R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "$R/boot/firmware/" | |||
|
81 | cp "$R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "$R/boot/firmware/overlays/" | |||
|
82 | cp "$R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "$R/boot/firmware/overlays/" | |||
69 |
|
83 | |||
70 | # Copy dts and dtb device definitions |
|
84 | # Convert kernel zImage and copy it to the boot directory | |
71 | mkdir $R/boot/firmware/overlays/ |
|
85 | "$R/usr/src/linux/scripts/mkknlimg" "$R/usr/src/linux/arch/${KERNEL_ARCH}/boot/zImage" "$R/boot/firmware/kernel7.img" | |
72 | cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/*.dtb $R/boot/firmware/ |
|
|||
73 | cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/*.dtb* $R/boot/firmware/overlays/ |
|
|||
74 | cp $R/usr/src/linux/arch/${KERNEL_ARCH}/boot/dts/overlays/README $R/boot/firmware/overlays/ |
|
|||
75 |
|
86 | |||
76 | # Remove kernel sources |
|
87 | # Remove kernel sources | |
77 | if [ "$KERNEL_RMSRC" = true ] ; then |
|
88 | if [ "$KERNEL_REMOVESRC" = true ] ; then | |
78 | rm -fr $R/usr/src/linux |
|
89 | rm -fr "$R/usr/src/linux" | |
79 | fi |
|
90 | fi | |
80 |
|
91 | |||
81 | # Install raspberry bootloader and flash-kernel packages |
|
92 | # Install raspberry bootloader and flash-kernel packages | |
82 | chroot_exec apt-get -qq -y --no-install-recommends install raspberrypi-bootloader-nokernel |
|
93 | chroot_exec apt-get -qq -y --no-install-recommends install raspberrypi-bootloader-nokernel | |
83 | else # BUILD_KERNEL=false |
|
94 | else # BUILD_KERNEL=false | |
84 | # Kernel installation |
|
95 | # Kernel installation | |
85 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${COLLABORA_KERNEL} raspberrypi-bootloader-nokernel |
|
96 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel | |
86 |
|
97 | |||
87 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot |
|
98 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot | |
88 | chroot_exec apt-get -qq -y install flash-kernel |
|
99 | chroot_exec apt-get -qq -y install flash-kernel | |
89 |
|
100 | |||
90 | VMLINUZ="$(ls -1 $R/boot/vmlinuz-* | sort | tail -n 1)" |
|
101 | VMLINUZ="$(ls -1 $R/boot/vmlinuz-* | sort | tail -n 1)" | |
91 | [ -z "$VMLINUZ" ] && exit 1 |
|
102 | [ -z "$VMLINUZ" ] && exit 1 | |
92 | cp $VMLINUZ $R/boot/firmware/kernel7.img |
|
103 | cp "$VMLINUZ" "$R/boot/firmware/kernel7.img" | |
93 | fi |
|
104 | fi | |
94 |
|
105 | |||
95 | # Setup firmware boot cmdline |
|
106 | # Setup firmware boot cmdline | |
@@ -110,43 +121,43 if [ "$ENABLE_IPV6" = false ] ; then | |||||
110 | fi |
|
121 | fi | |
111 |
|
122 | |||
112 | # Install firmware boot cmdline |
|
123 | # Install firmware boot cmdline | |
113 | echo "${CMDLINE}" >$R/boot/firmware/cmdline.txt |
|
124 | echo "${CMDLINE}" > "$R/boot/firmware/cmdline.txt" | |
114 |
|
125 | |||
115 | # Install firmware config |
|
126 | # Install firmware config | |
116 | install_readonly files/boot/config.txt $R/boot/firmware/config.txt |
|
127 | install_readonly files/boot/config.txt "$R/boot/firmware/config.txt" | |
117 |
|
128 | |||
118 | # Setup minimal GPU memory allocation size: 16MB (no X) |
|
129 | # Setup minimal GPU memory allocation size: 16MB (no X) | |
119 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
130 | if [ "$ENABLE_MINGPU" = true ] ; then | |
120 | echo "gpu_mem=16" >>$R/boot/firmware/config.txt |
|
131 | echo "gpu_mem=16" >> "$R/boot/firmware/config.txt" | |
121 | fi |
|
132 | fi | |
122 |
|
133 | |||
123 | # Create firmware configuration and cmdline symlinks |
|
134 | # Create firmware configuration and cmdline symlinks | |
124 | ln -sf firmware/config.txt $R/boot/config.txt |
|
135 | ln -sf firmware/config.txt "$R/boot/config.txt" | |
125 | ln -sf firmware/cmdline.txt $R/boot/cmdline.txt |
|
136 | ln -sf firmware/cmdline.txt "$R/boot/cmdline.txt" | |
126 |
|
137 | |||
127 | # Install and setup kernel modules to load at boot |
|
138 | # Install and setup kernel modules to load at boot | |
128 | mkdir -p $R/lib/modules-load.d/ |
|
139 | mkdir -p "$R/lib/modules-load.d/" | |
129 | install_readonly files/modules/rpi2.conf $R/lib/modules-load.d/rpi2.conf |
|
140 | install_readonly files/modules/rpi2.conf "$R/lib/modules-load.d/rpi2.conf" | |
130 |
|
141 | |||
131 | # Load hardware random module at boot |
|
142 | # Load hardware random module at boot | |
132 | if [ "$ENABLE_HWRANDOM" = true ] ; then |
|
143 | if [ "$ENABLE_HWRANDOM" = true ] ; then | |
133 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" $R/lib/modules-load.d/rpi2.conf |
|
144 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "$R/lib/modules-load.d/rpi2.conf" | |
134 | fi |
|
145 | fi | |
135 |
|
146 | |||
136 | # Load sound module at boot |
|
147 | # Load sound module at boot | |
137 | if [ "$ENABLE_SOUND" = true ] ; then |
|
148 | if [ "$ENABLE_SOUND" = true ] ; then | |
138 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" $R/lib/modules-load.d/rpi2.conf |
|
149 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "$R/lib/modules-load.d/rpi2.conf" | |
139 | fi |
|
150 | fi | |
140 |
|
151 | |||
141 | # Install kernel modules blacklist |
|
152 | # Install kernel modules blacklist | |
142 | mkdir -p $R/etc/modprobe.d/ |
|
153 | mkdir -p "$R/etc/modprobe.d/" | |
143 | install_readonly files/modules/raspi-blacklist.conf $R/etc/modprobe.d/raspi-blacklist.conf |
|
154 | install_readonly files/modules/raspi-blacklist.conf "$R/etc/modprobe.d/raspi-blacklist.conf" | |
144 |
|
155 | |||
145 | # Install and setup fstab |
|
156 | # Install and setup fstab | |
146 | install_readonly files/mount/fstab $R/etc/fstab |
|
157 | install_readonly files/mount/fstab "$R/etc/fstab" | |
147 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
158 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
148 | sed -i 's/mmcblk0p2/sda1/' $R/etc/fstab |
|
159 | sed -i 's/mmcblk0p2/sda1/' "$R/etc/fstab" | |
149 | fi |
|
160 | fi | |
150 |
|
161 | |||
151 | # Install sysctl.d configuration files |
|
162 | # Install sysctl.d configuration files | |
152 | install_readonly files/sysctl.d/81-rpi-vm.conf $R/etc/sysctl.d/81-rpi-vm.conf |
|
163 | install_readonly files/sysctl.d/81-rpi-vm.conf "$R/etc/sysctl.d/81-rpi-vm.conf" |
@@ -6,37 +6,37 | |||||
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Install and setup hostname |
|
8 | # Install and setup hostname | |
9 | install_readonly files/network/hostname $R/etc/hostname |
|
9 | install_readonly files/network/hostname "$R/etc/hostname" | |
10 | sed -i "s/^rpi2-jessie/${HOSTNAME}/" $R/etc/hostname |
|
10 | sed -i "s/^rpi2-jessie/${HOSTNAME}/" "$R/etc/hostname" | |
11 |
|
11 | |||
12 | # Install and setup hosts |
|
12 | # Install and setup hosts | |
13 | install_readonly files/network/hosts $R/etc/hosts |
|
13 | install_readonly files/network/hosts "$R/etc/hosts" | |
14 | sed -i "s/rpi2-jessie/${HOSTNAME}/" $R/etc/hosts |
|
14 | sed -i "s/rpi2-jessie/${HOSTNAME}/" "$R/etc/hosts" | |
15 |
|
15 | |||
16 | # Setup hostname entry with static IP |
|
16 | # Setup hostname entry with static IP | |
17 | if [ "$NET_ADDRESS" != "" ] ; then |
|
17 | if [ "$NET_ADDRESS" != "" ] ; then | |
18 | NET_IP=$(echo ${NET_ADDRESS} | cut -f 1 -d'/') |
|
18 | NET_IP=$(echo "${NET_ADDRESS}" | cut -f 1 -d'/') | |
19 | sed -i "s/^127.0.1.1/${NET_IP}/" $R/etc/hosts |
|
19 | sed -i "s/^127.0.1.1/${NET_IP}/" "$R/etc/hosts" | |
20 | fi |
|
20 | fi | |
21 |
|
21 | |||
22 | # Remove IPv6 hosts |
|
22 | # Remove IPv6 hosts | |
23 | if [ "$ENABLE_IPV6" = false ] ; then |
|
23 | if [ "$ENABLE_IPV6" = false ] ; then | |
24 | sed -i -e "/::[1-9]/d" -e "/^$/d" $R/etc/hosts |
|
24 | sed -i -e "/::[1-9]/d" -e "/^$/d" "$R/etc/hosts" | |
25 | fi |
|
25 | fi | |
26 |
|
26 | |||
27 | # Install hint about network configuration |
|
27 | # Install hint about network configuration | |
28 | install_readonly files/network/interfaces $R/etc/network/interfaces |
|
28 | install_readonly files/network/interfaces "$R/etc/network/interfaces" | |
29 |
|
29 | |||
30 | # Install configuration for interface eth0 |
|
30 | # Install configuration for interface eth0 | |
31 | install_readonly files/network/eth.network $R/etc/systemd/network/eth.network |
|
31 | install_readonly files/network/eth.network "$R/etc/systemd/network/eth.network" | |
32 |
|
32 | |||
33 | if [ "$ENABLE_DHCP" = true ] ; then |
|
33 | if [ "$ENABLE_DHCP" = true ] ; then | |
34 | # Enable DHCP configuration for interface eth0 |
|
34 | # Enable DHCP configuration for interface eth0 | |
35 | sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" $R/etc/systemd/network/eth.network |
|
35 | sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "$R/etc/systemd/network/eth.network" | |
36 |
|
36 | |||
37 | # Set DHCP configuration to IPv4 only |
|
37 | # Set DHCP configuration to IPv4 only | |
38 | if [ "$ENABLE_IPV6" = false ] ; then |
|
38 | if [ "$ENABLE_IPV6" = false ] ; then | |
39 | sed -i "s/DHCP=.*/DHCP=v4/" $R/etc/systemd/network/eth.network |
|
39 | sed -i "s/DHCP=.*/DHCP=v4/" "$R/etc/systemd/network/eth.network" | |
40 | fi |
|
40 | fi | |
41 |
|
41 | |||
42 | else # ENABLE_DHCP=false |
|
42 | else # ENABLE_DHCP=false | |
@@ -50,23 +50,23 else # ENABLE_DHCP=false | |||||
50 | -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\ |
|
50 | -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\ | |
51 | -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\ |
|
51 | -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\ | |
52 | -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\ |
|
52 | -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\ | |
53 | $R/etc/systemd/network/eth.network |
|
53 | "$R/etc/systemd/network/eth.network" | |
54 | fi |
|
54 | fi | |
55 |
|
55 | |||
56 | # Remove empty settings from network configuration |
|
56 | # Remove empty settings from network configuration | |
57 | sed -i "/.*=\$/d" $R/etc/systemd/network/eth.network |
|
57 | sed -i "/.*=\$/d" "$R/etc/systemd/network/eth.network" | |
58 |
|
58 | |||
59 | # Enable systemd-networkd service |
|
59 | # Enable systemd-networkd service | |
60 | chroot_exec systemctl enable systemd-networkd |
|
60 | chroot_exec systemctl enable systemd-networkd | |
61 |
|
61 | |||
62 | # Install host.conf resolver configuration |
|
62 | # Install host.conf resolver configuration | |
63 | install_readonly files/network/host.conf $R/etc/host.conf |
|
63 | install_readonly files/network/host.conf "$R/etc/host.conf" | |
64 |
|
64 | |||
65 | # Enable network stack hardening |
|
65 | # Enable network stack hardening | |
66 | if [ "$ENABLE_HARDNET" = true ] ; then |
|
66 | if [ "$ENABLE_HARDNET" = true ] ; then | |
67 | # Install sysctl.d configuration files |
|
67 | # Install sysctl.d configuration files | |
68 | install_readonly files/sysctl.d/82-rpi-net-hardening.conf $R/etc/sysctl.d/82-rpi-net-hardening.conf |
|
68 | install_readonly files/sysctl.d/82-rpi-net-hardening.conf "$R/etc/sysctl.d/82-rpi-net-hardening.conf" | |
69 |
|
69 | |||
70 | # Setup resolver warnings about spoofed addresses |
|
70 | # Setup resolver warnings about spoofed addresses | |
71 | sed -i "s/^# spoof warn/spoof warn/" $R/etc/host.conf |
|
71 | sed -i "s/^# spoof warn/spoof warn/" "$R/etc/host.conf" | |
72 | fi |
|
72 | fi |
@@ -10,13 +10,13 if [ "$ENABLE_IPTABLES" = true ] ; then | |||||
10 | mkdir -p "$R/etc/iptables" |
|
10 | mkdir -p "$R/etc/iptables" | |
11 |
|
11 | |||
12 | # Install iptables systemd service |
|
12 | # Install iptables systemd service | |
13 | install_readonly files/iptables/iptables.service $R/etc/systemd/system/iptables.service |
|
13 | install_readonly files/iptables/iptables.service "$R/etc/systemd/system/iptables.service" | |
14 |
|
14 | |||
15 | # Install flush-table script called by iptables service |
|
15 | # Install flush-table script called by iptables service | |
16 | install_exec files/iptables/flush-iptables.sh $R/etc/iptables/flush-iptables.sh |
|
16 | install_exec files/iptables/flush-iptables.sh "$R/etc/iptables/flush-iptables.sh" | |
17 |
|
17 | |||
18 | # Install iptables rule file |
|
18 | # Install iptables rule file | |
19 | install_readonly files/iptables/iptables.rules $R/etc/iptables/iptables.rules |
|
19 | install_readonly files/iptables/iptables.rules "$R/etc/iptables/iptables.rules" | |
20 |
|
20 | |||
21 | # Reload systemd configuration and enable iptables service |
|
21 | # Reload systemd configuration and enable iptables service | |
22 | chroot_exec systemctl daemon-reload |
|
22 | chroot_exec systemctl daemon-reload | |
@@ -24,12 +24,12 if [ "$ENABLE_IPTABLES" = true ] ; then | |||||
24 |
|
24 | |||
25 | if [ "$ENABLE_IPV6" = true ] ; then |
|
25 | if [ "$ENABLE_IPV6" = true ] ; then | |
26 | # Install ip6tables systemd service |
|
26 | # Install ip6tables systemd service | |
27 | install_readonly files/iptables/ip6tables.service $R/etc/systemd/system/ip6tables.service |
|
27 | install_readonly files/iptables/ip6tables.service "$R/etc/systemd/system/ip6tables.service" | |
28 |
|
28 | |||
29 | # Install ip6tables file |
|
29 | # Install ip6tables file | |
30 | install_exec files/iptables/flush-ip6tables.sh $R/etc/iptables/flush-ip6tables.sh |
|
30 | install_exec files/iptables/flush-ip6tables.sh "$R/etc/iptables/flush-ip6tables.sh" | |
31 |
|
31 | |||
32 | install_readonly files/iptables/ip6tables.rules $R/etc/iptables/ip6tables.rules |
|
32 | install_readonly files/iptables/ip6tables.rules "$R/etc/iptables/ip6tables.rules" | |
33 |
|
33 | |||
34 | # Reload systemd configuration and enable iptables service |
|
34 | # Reload systemd configuration and enable iptables service | |
35 | chroot_exec systemctl daemon-reload |
|
35 | chroot_exec systemctl daemon-reload | |
@@ -39,6 +39,6 fi | |||||
39 |
|
39 | |||
40 | if [ "$ENABLE_SSHD" = false ] ; then |
|
40 | if [ "$ENABLE_SSHD" = false ] ; then | |
41 | # Remove SSHD related iptables rules |
|
41 | # Remove SSHD related iptables rules | |
42 | sed -i "/^#/! {/SSH/ s/^/# /}" $R/etc/iptables/iptables.rules 2> /dev/null |
|
42 | sed -i "/^#/! {/SSH/ s/^/# /}" "$R/etc/iptables/iptables.rules" 2> /dev/null | |
43 | sed -i "/^#/! {/SSH/ s/^/# /}" $R/etc/iptables/ip6tables.rules 2> /dev/null |
|
43 | sed -i "/^#/! {/SSH/ s/^/# /}" "$R/etc/iptables/ip6tables.rules" 2> /dev/null | |
44 | fi |
|
44 | fi |
@@ -6,7 +6,7 | |||||
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Generate crypt(3) password string |
|
8 | # Generate crypt(3) password string | |
9 | ENCRYPTED_PASSWORD=`mkpasswd -m sha-512 ${PASSWORD}` |
|
9 | ENCRYPTED_PASSWORD=`mkpasswd -m sha-512 "${PASSWORD}"` | |
10 |
|
10 | |||
11 | # Setup default user |
|
11 | # Setup default user | |
12 | if [ "$ENABLE_USER" = true ] ; then |
|
12 | if [ "$ENABLE_USER" = true ] ; then | |
@@ -19,7 +19,7 if [ "$ENABLE_ROOT" = true ] ; then | |||||
19 | chroot_exec usermod -p "${ENCRYPTED_PASSWORD}" root |
|
19 | chroot_exec usermod -p "${ENCRYPTED_PASSWORD}" root | |
20 |
|
20 | |||
21 | if [ "$ENABLE_ROOT_SSH" = true ] ; then |
|
21 | if [ "$ENABLE_ROOT_SSH" = true ] ; then | |
22 | sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin yes|g" $R/etc/ssh/sshd_config |
|
22 | sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin yes|g" "$R/etc/ssh/sshd_config" | |
23 | fi |
|
23 | fi | |
24 | else |
|
24 | else | |
25 | # Set no root password to disable root login |
|
25 | # Set no root password to disable root login |
@@ -7,7 +7,7 | |||||
7 |
|
7 | |||
8 | # Disable rsyslog |
|
8 | # Disable rsyslog | |
9 | if [ "$ENABLE_RSYSLOG" = false ] ; then |
|
9 | if [ "$ENABLE_RSYSLOG" = false ] ; then | |
10 | sed -i "s|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g" $R/etc/systemd/journald.conf |
|
10 | sed -i "s|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g" "$R/etc/systemd/journald.conf" | |
11 | chroot_exec systemctl disable rsyslog |
|
11 | chroot_exec systemctl disable rsyslog | |
12 | chroot_exec apt-get -qq -y --force-yes purge rsyslog |
|
12 | chroot_exec apt-get -qq -y --force-yes purge rsyslog | |
13 | fi |
|
13 | fi |
@@ -13,19 +13,19 fi | |||||
13 | # Fetch and build U-Boot bootloader |
|
13 | # Fetch and build U-Boot bootloader | |
14 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
14 | if [ "$ENABLE_UBOOT" = true ] ; then | |
15 | # Fetch U-Boot bootloader sources |
|
15 | # Fetch U-Boot bootloader sources | |
16 | git -C $R/tmp clone git://git.denx.de/u-boot.git |
|
16 | git -C "$R/tmp" clone git://git.denx.de/u-boot.git | |
17 |
|
17 | |||
18 | # Build and install U-Boot inside chroot |
|
18 | # Build and install U-Boot inside chroot | |
19 | chroot_exec make -C /tmp/u-boot/ rpi_2_defconfig all |
|
19 | chroot_exec make -C /tmp/u-boot/ rpi_2_defconfig all | |
20 |
|
20 | |||
21 | # Copy compiled bootloader binary and set config.txt to load it |
|
21 | # Copy compiled bootloader binary and set config.txt to load it | |
22 | cp $R/tmp/u-boot/u-boot.bin $R/boot/firmware/ |
|
22 | cp "$R/tmp/u-boot/u-boot.bin" "$R/boot/firmware/" | |
23 | printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> $R/boot/firmware/config.txt |
|
23 | printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "$R/boot/firmware/config.txt" | |
24 |
|
24 | |||
25 | # Install and setup U-Boot command file |
|
25 | # Install and setup U-Boot command file | |
26 | install_readonly files/boot/uboot.mkimage $R/boot/firmware/uboot.mkimage |
|
26 | install_readonly files/boot/uboot.mkimage "$R/boot/firmware/uboot.mkimage" | |
27 | printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat $R/boot/firmware/uboot.mkimage)" > $R/boot/firmware/uboot.mkimage |
|
27 | printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat $R/boot/firmware/uboot.mkimage)" > "$R/boot/firmware/uboot.mkimage" | |
28 |
|
28 | |||
29 | # Generate U-Boot bootloader image |
|
29 | # Generate U-Boot bootloader image | |
30 | chroot_exec /tmp/u-boot/tools/mkimage -A ${KERNEL_ARCH} -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n RPi2 -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr |
|
30 | chroot_exec /tmp/u-boot/tools/mkimage -A "${KERNEL_ARCH}" -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n RPi2 -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr | |
31 | fi |
|
31 | fi |
@@ -7,7 +7,7 | |||||
7 |
|
7 | |||
8 | if [ "$ENABLE_FBTURBO" = true ] ; then |
|
8 | if [ "$ENABLE_FBTURBO" = true ] ; then | |
9 | # Fetch fbturbo driver sources |
|
9 | # Fetch fbturbo driver sources | |
10 | git -C $R/tmp clone https://github.com/ssvb/xf86-video-fbturbo.git |
|
10 | git -C "$R/tmp" clone https://github.com/ssvb/xf86-video-fbturbo.git | |
11 |
|
11 | |||
12 | # Install Xorg build dependencies |
|
12 | # Install Xorg build dependencies | |
13 | chroot_exec apt-get -q -y --no-install-recommends install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev |
|
13 | chroot_exec apt-get -q -y --no-install-recommends install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev | |
@@ -22,7 +22,7 make install | |||||
22 | EOF |
|
22 | EOF | |
23 |
|
23 | |||
24 | # Install fbturbo driver Xorg configuration |
|
24 | # Install fbturbo driver Xorg configuration | |
25 | install_readonly files/xorg/99-fbturbo.conf $R/usr/share/X11/xorg.conf.d/99-fbturbo.conf |
|
25 | install_readonly files/xorg/99-fbturbo.conf "$R/usr/share/X11/xorg.conf.d/99-fbturbo.conf" | |
26 |
|
26 | |||
27 | # Remove Xorg build dependencies |
|
27 | # Remove Xorg build dependencies | |
28 | chroot_exec apt-get -qq -y --auto-remove purge xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev |
|
28 | chroot_exec apt-get -qq -y --auto-remove purge xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev |
@@ -6,30 +6,30 | |||||
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Prepare rc.firstboot script |
|
8 | # Prepare rc.firstboot script | |
9 | cat files/firstboot/10-begin.sh > $R/etc/rc.firstboot |
|
9 | cat files/firstboot/10-begin.sh > "$R/etc/rc.firstboot" | |
10 |
|
10 | |||
11 | # Ensure openssh server host keys are regenerated on first boot |
|
11 | # Ensure openssh server host keys are regenerated on first boot | |
12 | if [ "$ENABLE_SSHD" = true ] ; then |
|
12 | if [ "$ENABLE_SSHD" = true ] ; then | |
13 | cat files/firstboot/21-generate-ssh-keys.sh >> $R/etc/rc.firstboot |
|
13 | cat files/firstboot/21-generate-ssh-keys.sh >> "$R/etc/rc.firstboot" | |
14 | rm -f $R/etc/ssh/ssh_host_* |
|
14 | rm -f "$R/etc/ssh/ssh_host_*" | |
15 | fi |
|
15 | fi | |
16 |
|
16 | |||
17 | # Prepare filesystem auto expand |
|
17 | # Prepare filesystem auto expand | |
18 | if [ "$EXPANDROOT" = true ] ; then |
|
18 | if [ "$EXPANDROOT" = true ] ; then | |
19 | cat files/firstboot/22-expandroot.sh >> $R/etc/rc.firstboot |
|
19 | cat files/firstboot/22-expandroot.sh >> "$R/etc/rc.firstboot" | |
20 | fi |
|
20 | fi | |
21 |
|
21 | |||
22 | # Ensure that dbus machine-id exists |
|
22 | # Ensure that dbus machine-id exists | |
23 | cat files/firstboot/23-generate-machineid.sh >> $R/etc/rc.firstboot |
|
23 | cat files/firstboot/23-generate-machineid.sh >> "$R/etc/rc.firstboot" | |
24 |
|
24 | |||
25 | # Create /etc/resolv.conf symlink |
|
25 | # Create /etc/resolv.conf symlink | |
26 | cat files/firstboot/24-create-resolv-symlink.sh >> $R/etc/rc.firstboot |
|
26 | cat files/firstboot/24-create-resolv-symlink.sh >> "$R/etc/rc.firstboot" | |
27 |
|
27 | |||
28 | # Finalize rc.firstboot script |
|
28 | # Finalize rc.firstboot script | |
29 | cat files/firstboot/99-finish.sh >> $R/etc/rc.firstboot |
|
29 | cat files/firstboot/99-finish.sh >> "$R/etc/rc.firstboot" | |
30 | chmod +x $R/etc/rc.firstboot |
|
30 | chmod +x "$R/etc/rc.firstboot" | |
31 |
|
31 | |||
32 | # Add rc.firstboot script to rc.local |
|
32 | # Add rc.firstboot script to rc.local | |
33 | sed -i '/exit 0/d' $R/etc/rc.local |
|
33 | sed -i '/exit 0/d' "$R/etc/rc.local" | |
34 | echo /etc/rc.firstboot >> $R/etc/rc.local |
|
34 | echo /etc/rc.firstboot >> "$R/etc/rc.local" | |
35 | echo exit 0 >> $R/etc/rc.local |
|
35 | echo exit 0 >> "$R/etc/rc.local" |
@@ -98,13 +98,16 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} | |||||
98 |
|
98 | |||
99 | # Kernel compilation settings |
|
99 | # Kernel compilation settings | |
100 | BUILD_KERNEL=${BUILD_KERNEL:=false} |
|
100 | BUILD_KERNEL=${BUILD_KERNEL:=false} | |
101 | KERNEL_SRCDIR=${KERNEL_SRCDIR:=""} |
|
|||
102 | KERNEL_THREADS=${KERNEL_THREADS:=1} |
|
101 | KERNEL_THREADS=${KERNEL_THREADS:=1} | |
103 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} |
|
102 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} | |
104 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} |
|
103 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} | |
105 |
KERNEL_ |
|
104 | KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} | |
106 | KERNEL_CONFIGSRC=${KERNEL_CONFIGSRC:=true} |
|
105 | ||
107 | KERNEL_RMSRC=${KERNEL_RMSRC:=true} |
|
106 | # Kernel compilation from source directory settings | |
|
107 | KERNELSRC_DIR=${KERNELSRC_DIR:=""} | |||
|
108 | KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} | |||
|
109 | KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} | |||
|
110 | KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} | |||
108 |
|
111 | |||
109 | # Image chroot path |
|
112 | # Image chroot path | |
110 | R=${BUILDDIR}/chroot |
|
113 | R=${BUILDDIR}/chroot | |
@@ -140,9 +143,9 if [ ! -d "./files/" ] ; then | |||||
140 | exit 1 |
|
143 | exit 1 | |
141 | fi |
|
144 | fi | |
142 |
|
145 | |||
143 |
# Check if specified KERNEL |
|
146 | # Check if specified KERNELSRC_DIR directory exists | |
144 |
if [ -n "$KERNEL |
|
147 | if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then | |
145 |
echo "error: ${KERNEL |
|
148 | echo "error: ${KERNELSRC_DIR} (KERNELSRC_DIR) specified directory not found!" | |
146 | exit 1 |
|
149 | exit 1 | |
147 | fi |
|
150 | fi | |
148 |
|
151 | |||
@@ -155,6 +158,7 fi | |||||
155 | # Add packages required for kernel cross compilation |
|
158 | # Add packages required for kernel cross compilation | |
156 | if [ "$BUILD_KERNEL" = true ] ; then |
|
159 | if [ "$BUILD_KERNEL" = true ] ; then | |
157 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" |
|
160 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" | |
|
161 | ||||
158 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
162 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |
159 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ncurses-dev" |
|
163 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ncurses-dev" | |
160 | fi |
|
164 | fi | |
@@ -163,7 +167,7 fi | |||||
163 | # Check if all required packages are installed |
|
167 | # Check if all required packages are installed | |
164 | for package in $REQUIRED_PACKAGES ; do |
|
168 | for package in $REQUIRED_PACKAGES ; do | |
165 | if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then |
|
169 | if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then | |
166 | MISSING_PACKAGES="$MISSING_PACKAGES $package" |
|
170 | MISSING_PACKAGES="${MISSING_PACKAGES} $package" | |
167 | fi |
|
171 | fi | |
168 | done |
|
172 | done | |
169 |
|
173 | |||
@@ -188,6 +192,9 if [ -e "$BUILDDIR" ] ; then | |||||
188 | exit 1 |
|
192 | exit 1 | |
189 | fi |
|
193 | fi | |
190 |
|
194 | |||
|
195 | # Setup chroot directory | |||
|
196 | mkdir -p "$R" | |||
|
197 | ||||
191 | # Check if build directory has enough of free disk space >512MB |
|
198 | # Check if build directory has enough of free disk space >512MB | |
192 | if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then |
|
199 | if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then | |
193 | echo "error: ${BUILDDIR} not enough space left on this partition to generate the output image!" |
|
200 | echo "error: ${BUILDDIR} not enough space left on this partition to generate the output image!" | |
@@ -204,9 +211,6 set -x | |||||
204 | # Call "cleanup" function on various signals and errors |
|
211 | # Call "cleanup" function on various signals and errors | |
205 | trap cleanup 0 1 2 3 6 |
|
212 | trap cleanup 0 1 2 3 6 | |
206 |
|
213 | |||
207 | # Setup chroot directory |
|
|||
208 | mkdir -p $R |
|
|||
209 |
|
||||
210 | # Add required packages for the minbase installation |
|
214 | # Add required packages for the minbase installation | |
211 | if [ "$ENABLE_MINBASE" = true ] ; then |
|
215 | if [ "$ENABLE_MINBASE" = true ] ; then | |
212 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools" |
|
216 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools" | |
@@ -263,23 +267,23 if [ "$ENABLE_XORG" = true ] ; then | |||||
263 | APT_INCLUDES="${APT_INCLUDES},xorg" |
|
267 | APT_INCLUDES="${APT_INCLUDES},xorg" | |
264 | fi |
|
268 | fi | |
265 |
|
269 | |||
266 |
# Set KERNEL_CONFIG |
|
270 | # Set KERNELSRC_CONFIG=true | |
267 |
if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNEL |
|
271 | if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then | |
268 |
KERNEL_CONFIG |
|
272 | KERNELSRC_CONFIG=true | |
269 | fi |
|
273 | fi | |
270 |
|
274 | |||
271 | ## MAIN bootstrap |
|
275 | ## MAIN bootstrap | |
272 | for SCRIPT in bootstrap.d/*.sh; do |
|
276 | for SCRIPT in bootstrap.d/*.sh; do | |
273 | # Execute bootstrap scripts (lexicographical order) |
|
277 | # Execute bootstrap scripts (lexicographical order) | |
274 | head -n 3 $SCRIPT |
|
278 | head -n 3 "$SCRIPT" | |
275 | . $SCRIPT |
|
279 | . "$SCRIPT" | |
276 | done |
|
280 | done | |
277 |
|
281 | |||
278 | ## Custom bootstrap scripts |
|
282 | ## Custom bootstrap scripts | |
279 | if [ -d "custom.d" ] ; then |
|
283 | if [ -d "custom.d" ] ; then | |
280 | # Execute custom bootstrap scripts (lexicographical order) |
|
284 | # Execute custom bootstrap scripts (lexicographical order) | |
281 | for SCRIPT in custom.d/*.sh; do |
|
285 | for SCRIPT in custom.d/*.sh; do | |
282 | . $SCRIPT |
|
286 | . "$SCRIPT" | |
283 | done |
|
287 | done | |
284 | fi |
|
288 | fi | |
285 |
|
289 | |||
@@ -294,7 +298,7 for SCRIPT in /chroot_scripts/* ; do | |||||
294 | fi |
|
298 | fi | |
295 | done |
|
299 | done | |
296 | EOF |
|
300 | EOF | |
297 |
rm -rf "$ |
|
301 | rm -rf "$R/chroot_scripts" | |
298 | fi |
|
302 | fi | |
299 |
|
303 | |||
300 | # Remove apt-utils |
|
304 | # Remove apt-utils | |
@@ -303,34 +307,35 chroot_exec apt-get purge -qq -y --force-yes apt-utils | |||||
303 | # Reduce the image size by removing and compressing |
|
307 | # Reduce the image size by removing and compressing | |
304 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
308 | if [ "$ENABLE_REDUCE" = true ] ; then | |
305 | # Install dpkg configuration fragment file |
|
309 | # Install dpkg configuration fragment file | |
306 | install_readonly files/dpkg/01nodoc $R/etc/dpkg/dpkg.cfg.d/01nodoc |
|
310 | install_readonly files/dpkg/01nodoc "$R/etc/dpkg/dpkg.cfg.d/01nodoc" | |
307 |
|
311 | |||
308 | # Install APT configuration fragment files |
|
312 | # Install APT configuration fragment files | |
309 | install_readonly files/apt/02nocache $R/etc/apt/apt.conf.d/02nocache |
|
313 | 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 |
|
314 | 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 |
|
315 | install_readonly files/apt/04norecommends "$R/etc/apt/apt.conf.d/04norecommends" | |
312 |
|
316 | |||
313 | # Remove APT cache files |
|
317 | # Remove APT cache files | |
314 | rm -fr $R/var/cache/apt/pkgcache.bin |
|
318 | rm -fr "$R/var/cache/apt/pkgcache.bin" | |
315 | rm -fr $R/var/cache/apt/srcpkgcache.bin |
|
319 | rm -fr "$R/var/cache/apt/srcpkgcache.bin" | |
316 |
|
320 | |||
317 | # Remove all doc and man files |
|
321 | # Remove all doc and man files | |
318 | find $R/usr/share/doc -depth -type f ! -name copyright | xargs rm || true |
|
322 | find "$R/usr/share/doc" -depth -type f ! -name copyright | xargs rm || true | |
319 | find $R/usr/share/doc -empty | xargs rmdir || true |
|
323 | 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 |
|
324 | 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 |
|
325 | |||
322 | # Remove all translation files |
|
326 | # Remove all translation files | |
323 | find $R/usr/share/locale -mindepth 1 -maxdepth 1 ! -name 'en' | xargs rm -r |
|
327 | find "$R/usr/share/locale" -mindepth 1 -maxdepth 1 ! -name 'en' | xargs rm -r | |
324 |
|
328 | |||
325 | # Clean APT list of repositories |
|
329 | # Clean APT list of repositories | |
326 | rm -fr $R/var/lib/apt/lists/* |
|
330 | rm -fr "$R/var/lib/apt/lists/*" | |
327 | chroot_exec apt-get -qq -y update |
|
331 | chroot_exec apt-get -qq -y update | |
328 |
|
332 | |||
|
333 | # Remove GPU kernels | |||
329 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
334 | if [ "$ENABLE_MINGPU" = true ] ; then | |
330 | rm -f $R/boot/firmware/start.elf |
|
335 | rm -f "$R/boot/firmware/start.elf" | |
331 | rm -f $R/boot/firmware/fixup.dat |
|
336 | rm -f "$R/boot/firmware/fixup.dat" | |
332 | rm -f $R/boot/firmware/start_x.elf |
|
337 | rm -f "$R/boot/firmware/start_x.elf" | |
333 | rm -f $R/boot/firmware/fixup_x.dat |
|
338 | rm -f "$R/boot/firmware/fixup_x.dat" | |
334 | fi |
|
339 | fi | |
335 | fi |
|
340 | fi | |
336 |
|
341 | |||
@@ -340,27 +345,27 chroot_exec apt-get -y autoclean | |||||
340 | chroot_exec apt-get -y autoremove |
|
345 | chroot_exec apt-get -y autoremove | |
341 |
|
346 | |||
342 | # Unmount mounted filesystems |
|
347 | # Unmount mounted filesystems | |
343 | umount -l $R/proc |
|
348 | umount -l "$R/proc" | |
344 | umount -l $R/sys |
|
349 | umount -l "$R/sys" | |
345 |
|
350 | |||
346 | # Clean up directories |
|
351 | # Clean up directories | |
347 | rm -rf $R/run |
|
352 | rm -rf "$R/run" | |
348 | rm -rf $R/tmp/* |
|
353 | rm -rf "$R/tmp/*" | |
349 |
|
354 | |||
350 | # Clean up files |
|
355 | # Clean up files | |
351 | rm -f $R/etc/apt/sources.list.save |
|
356 | rm -f "$R/etc/apt/sources.list.save" | |
352 | rm -f $R/etc/resolvconf/resolv.conf.d/original |
|
357 | rm -f "$R/etc/resolvconf/resolv.conf.d/original" | |
353 | rm -f $R/etc/*- |
|
358 | rm -f "$R/etc/*-" | |
354 | rm -f $R/root/.bash_history |
|
359 | rm -f "$R/root/.bash_history" | |
355 | rm -f $R/var/lib/urandom/random-seed |
|
360 | rm -f "$R/var/lib/urandom/random-seed" | |
356 | rm -f $R/var/lib/dbus/machine-id |
|
361 | rm -f "$R/var/lib/dbus/machine-id" | |
357 | rm -f $R/etc/machine-id |
|
362 | rm -f "$R/etc/machine-id" | |
358 | rm -f $R/etc/apt/apt.conf.d/10proxy |
|
363 | rm -f "$R/etc/apt/apt.conf.d/10proxy" | |
359 | rm -f $R/etc/resolv.conf |
|
364 | rm -f "$R/etc/resolv.conf" | |
360 | rm -f "${R}${QEMU_BINARY}" |
|
365 | rm -f "${R}${QEMU_BINARY}" | |
361 |
|
366 | |||
362 | # Calculate size of the chroot directory in KB |
|
367 | # Calculate size of the chroot directory in KB | |
363 | CHROOT_SIZE=$(expr `du -s $R | awk '{ print $1 }'`) |
|
368 | CHROOT_SIZE=$(expr `du -s "$R" | awk '{ print $1 }'`) | |
364 |
|
369 | |||
365 | # Calculate the amount of needed 512 Byte sectors |
|
370 | # Calculate the amount of needed 512 Byte sectors | |
366 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) |
|
371 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant