@@ -1,172 +1,172 | |||||
1 | # |
|
1 | # | |
2 | # Build and Setup RPi2/3 Kernel |
|
2 | # Build and Setup RPi2/3 Kernel | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Fetch and build latest raspberry kernel |
|
8 | # Fetch and build latest raspberry kernel | |
9 | if [ "$BUILD_KERNEL" = true ] ; then |
|
9 | if [ "$BUILD_KERNEL" = true ] ; then | |
10 | # Setup source directory |
|
10 | # Setup source directory | |
11 | mkdir -p "${R}/usr/src" |
|
11 | mkdir -p "${R}/usr/src" | |
12 |
|
12 | |||
13 | # Copy existing kernel sources into chroot directory |
|
13 | # Copy existing kernel sources into chroot directory | |
14 | if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then |
|
14 | if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then | |
15 | # Copy kernel sources |
|
15 | # Copy kernel sources | |
16 | cp -r "${KERNELSRC_DIR}" "${R}/usr/src" |
|
16 | cp -r "${KERNELSRC_DIR}" "${R}/usr/src" | |
17 |
|
17 | |||
18 | # Clean the kernel sources |
|
18 | # Clean the kernel sources | |
19 | if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then |
|
19 | if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then | |
20 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper |
|
20 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper | |
21 | fi |
|
21 | fi | |
22 | else # KERNELSRC_DIR="" |
|
22 | else # KERNELSRC_DIR="" | |
23 | # Create temporary directory for kernel sources |
|
23 | # Create temporary directory for kernel sources | |
24 |
temp_dir=$( |
|
24 | temp_dir=$(as_nobody mktemp -d) | |
25 |
|
25 | |||
26 | # Fetch current RPi2/3 kernel sources |
|
26 | # Fetch current RPi2/3 kernel sources | |
27 |
|
|
27 | as_nobody git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" | |
28 |
|
28 | |||
29 | # Copy downloaded kernel sources |
|
29 | # Copy downloaded kernel sources | |
30 | mv "${temp_dir}/linux" "${R}/usr/src/" |
|
30 | mv "${temp_dir}/linux" "${R}/usr/src/" | |
31 |
|
31 | |||
32 | # Remove temporary directory for kernel sources |
|
32 | # Remove temporary directory for kernel sources | |
33 | rm -fr "${temp_dir}" |
|
33 | rm -fr "${temp_dir}" | |
34 |
|
34 | |||
35 | # Set permissions of the kernel sources |
|
35 | # Set permissions of the kernel sources | |
36 | chown -R root:root "${R}/usr/src" |
|
36 | chown -R root:root "${R}/usr/src" | |
37 | fi |
|
37 | fi | |
38 |
|
38 | |||
39 | # Calculate optimal number of kernel building threads |
|
39 | # Calculate optimal number of kernel building threads | |
40 | if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then |
|
40 | if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then | |
41 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) |
|
41 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) | |
42 | fi |
|
42 | fi | |
43 |
|
43 | |||
44 | # Configure and build kernel |
|
44 | # Configure and build kernel | |
45 | if [ "$KERNELSRC_PREBUILT" = false ] ; then |
|
45 | if [ "$KERNELSRC_PREBUILT" = false ] ; then | |
46 | # Remove device, network and filesystem drivers from kernel configuration |
|
46 | # Remove device, network and filesystem drivers from kernel configuration | |
47 | if [ "$KERNEL_REDUCE" = true ] ; then |
|
47 | if [ "$KERNEL_REDUCE" = true ] ; then | |
48 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" |
|
48 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" | |
49 | sed -i\ |
|
49 | sed -i\ | |
50 | -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\ |
|
50 | -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\ | |
51 | -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\ |
|
51 | -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\ | |
52 | -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\ |
|
52 | -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\ | |
53 | -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\ |
|
53 | -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\ | |
54 | -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\ |
|
54 | -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\ | |
55 | -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\ |
|
55 | -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\ | |
56 | -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\ |
|
56 | -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\ | |
57 | -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\ |
|
57 | -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\ | |
58 | -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\ |
|
58 | -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\ | |
59 | -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\ |
|
59 | -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\ | |
60 | -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\ |
|
60 | -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\ | |
61 | -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\ |
|
61 | -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\ | |
62 | -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\ |
|
62 | -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\ | |
63 | -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\ |
|
63 | -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\ | |
64 | -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\ |
|
64 | -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\ | |
65 | -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\ |
|
65 | -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\ | |
66 | -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\ |
|
66 | -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\ | |
67 | -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\ |
|
67 | -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\ | |
68 | -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\ |
|
68 | -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\ | |
69 | -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\ |
|
69 | -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\ | |
70 | -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\ |
|
70 | -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\ | |
71 | -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\ |
|
71 | -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\ | |
72 | -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\ |
|
72 | -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\ | |
73 | -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\ |
|
73 | -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\ | |
74 | -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\ |
|
74 | -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\ | |
75 | -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\ |
|
75 | -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\ | |
76 | -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\ |
|
76 | -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\ | |
77 | -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\ |
|
77 | -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\ | |
78 | -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\ |
|
78 | -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\ | |
79 | "${KERNEL_DIR}/.config" |
|
79 | "${KERNEL_DIR}/.config" | |
80 | fi |
|
80 | fi | |
81 |
|
81 | |||
82 | if [ "$KERNELSRC_CONFIG" = true ] ; then |
|
82 | if [ "$KERNELSRC_CONFIG" = true ] ; then | |
83 | # Load default raspberry kernel configuration |
|
83 | # Load default raspberry kernel configuration | |
84 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" |
|
84 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" | |
85 |
|
85 | |||
86 | if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then |
|
86 | if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then | |
87 | cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config |
|
87 | cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config | |
88 | fi |
|
88 | fi | |
89 |
|
89 | |||
90 | # Start menu-driven kernel configuration (interactive) |
|
90 | # Start menu-driven kernel configuration (interactive) | |
91 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
91 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |
92 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig |
|
92 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig | |
93 | fi |
|
93 | fi | |
94 | fi |
|
94 | fi | |
95 |
|
95 | |||
96 | # Cross compile kernel and modules |
|
96 | # Cross compile kernel and modules | |
97 | make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs |
|
97 | make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" zImage modules dtbs | |
98 | fi |
|
98 | fi | |
99 |
|
99 | |||
100 | # Check if kernel compilation was successful |
|
100 | # Check if kernel compilation was successful | |
101 | if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" ] ; then |
|
101 | if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" ] ; then | |
102 | echo "error: kernel compilation failed! (zImage not found)" |
|
102 | echo "error: kernel compilation failed! (zImage not found)" | |
103 | cleanup |
|
103 | cleanup | |
104 | exit 1 |
|
104 | exit 1 | |
105 | fi |
|
105 | fi | |
106 |
|
106 | |||
107 | # Install kernel modules |
|
107 | # Install kernel modules | |
108 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
108 | if [ "$ENABLE_REDUCE" = true ] ; then | |
109 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install |
|
109 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install | |
110 | else |
|
110 | else | |
111 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install |
|
111 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install | |
112 |
|
112 | |||
113 | # Install kernel firmware |
|
113 | # Install kernel firmware | |
114 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install |
|
114 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install | |
115 | fi |
|
115 | fi | |
116 |
|
116 | |||
117 | # Install kernel headers |
|
117 | # Install kernel headers | |
118 | if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then |
|
118 | if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then | |
119 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install |
|
119 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install | |
120 | fi |
|
120 | fi | |
121 |
|
121 | |||
122 | # Prepare boot (firmware) directory |
|
122 | # Prepare boot (firmware) directory | |
123 | mkdir "${BOOT_DIR}" |
|
123 | mkdir "${BOOT_DIR}" | |
124 |
|
124 | |||
125 | # Get kernel release version |
|
125 | # Get kernel release version | |
126 | KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"` |
|
126 | KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"` | |
127 |
|
127 | |||
128 | # Copy kernel configuration file to the boot directory |
|
128 | # Copy kernel configuration file to the boot directory | |
129 | install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}" |
|
129 | install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}" | |
130 |
|
130 | |||
131 | # Copy dts and dtb device tree sources and binaries |
|
131 | # Copy dts and dtb device tree sources and binaries | |
132 | mkdir "${BOOT_DIR}/overlays" |
|
132 | mkdir "${BOOT_DIR}/overlays" | |
133 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/" |
|
133 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb "${BOOT_DIR}/" | |
134 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/" |
|
134 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb* "${BOOT_DIR}/overlays/" | |
135 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README" |
|
135 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README" | |
136 |
|
136 | |||
137 | if [ "$ENABLE_UBOOT" = false ] ; then |
|
137 | if [ "$ENABLE_UBOOT" = false ] ; then | |
138 | # Convert and copy zImage kernel to the boot directory |
|
138 | # Convert and copy zImage kernel to the boot directory | |
139 | "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
139 | "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}" | |
140 | else |
|
140 | else | |
141 | # Copy zImage kernel to the boot directory |
|
141 | # Copy zImage kernel to the boot directory | |
142 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
142 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/zImage" "${BOOT_DIR}/${KERNEL_IMAGE}" | |
143 | fi |
|
143 | fi | |
144 |
|
144 | |||
145 | # Remove kernel sources |
|
145 | # Remove kernel sources | |
146 | if [ "$KERNEL_REMOVESRC" = true ] ; then |
|
146 | if [ "$KERNEL_REMOVESRC" = true ] ; then | |
147 | rm -fr "${KERNEL_DIR}" |
|
147 | rm -fr "${KERNEL_DIR}" | |
148 | else |
|
148 | else | |
149 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare |
|
149 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare | |
150 |
|
150 | |||
151 | # Create symlinks for kernel modules |
|
151 | # Create symlinks for kernel modules | |
152 | ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/build" |
|
152 | ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/build" | |
153 | ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/source" |
|
153 | ln -sf "${KERNEL_DIR}" "${R}/lib/modules/${KERNEL_VERSION}/source" | |
154 | fi |
|
154 | fi | |
155 |
|
155 | |||
156 | else # BUILD_KERNEL=false |
|
156 | else # BUILD_KERNEL=false | |
157 | # Kernel installation |
|
157 | # Kernel installation | |
158 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel |
|
158 | chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel | |
159 |
|
159 | |||
160 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot |
|
160 | # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot | |
161 | chroot_exec apt-get -qq -y install flash-kernel |
|
161 | chroot_exec apt-get -qq -y install flash-kernel | |
162 |
|
162 | |||
163 | # Check if kernel installation was successful |
|
163 | # Check if kernel installation was successful | |
164 | VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)" |
|
164 | VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)" | |
165 | if [ -z "$VMLINUZ" ] ; then |
|
165 | if [ -z "$VMLINUZ" ] ; then | |
166 | echo "error: kernel installation failed! (/boot/vmlinuz-* not found)" |
|
166 | echo "error: kernel installation failed! (/boot/vmlinuz-* not found)" | |
167 | cleanup |
|
167 | cleanup | |
168 | exit 1 |
|
168 | exit 1 | |
169 | fi |
|
169 | fi | |
170 | # Copy vmlinuz kernel to the boot directory |
|
170 | # Copy vmlinuz kernel to the boot directory | |
171 | install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
171 | install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}" | |
172 | fi |
|
172 | fi |
@@ -1,151 +1,151 | |||||
1 | # |
|
1 | # | |
2 | # Setup RPi2/3 config and cmdline |
|
2 | # Setup RPi2/3 config and cmdline | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | if [ "$BUILD_KERNEL" = true ] ; then |
|
8 | if [ "$BUILD_KERNEL" = true ] ; then | |
9 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then |
|
9 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then | |
10 | # Install boot binaries from local directory |
|
10 | # Install boot binaries from local directory | |
11 | cp ${RPI_FIRMWARE_DIR}/boot/bootcode.bin ${BOOT_DIR}/bootcode.bin |
|
11 | cp ${RPI_FIRMWARE_DIR}/boot/bootcode.bin ${BOOT_DIR}/bootcode.bin | |
12 | cp ${RPI_FIRMWARE_DIR}/boot/fixup.dat ${BOOT_DIR}/fixup.dat |
|
12 | cp ${RPI_FIRMWARE_DIR}/boot/fixup.dat ${BOOT_DIR}/fixup.dat | |
13 | cp ${RPI_FIRMWARE_DIR}/boot/fixup_cd.dat ${BOOT_DIR}/fixup_cd.dat |
|
13 | cp ${RPI_FIRMWARE_DIR}/boot/fixup_cd.dat ${BOOT_DIR}/fixup_cd.dat | |
14 | cp ${RPI_FIRMWARE_DIR}/boot/fixup_x.dat ${BOOT_DIR}/fixup_x.dat |
|
14 | cp ${RPI_FIRMWARE_DIR}/boot/fixup_x.dat ${BOOT_DIR}/fixup_x.dat | |
15 | cp ${RPI_FIRMWARE_DIR}/boot/start.elf ${BOOT_DIR}/start.elf |
|
15 | cp ${RPI_FIRMWARE_DIR}/boot/start.elf ${BOOT_DIR}/start.elf | |
16 | cp ${RPI_FIRMWARE_DIR}/boot/start_cd.elf ${BOOT_DIR}/start_cd.elf |
|
16 | cp ${RPI_FIRMWARE_DIR}/boot/start_cd.elf ${BOOT_DIR}/start_cd.elf | |
17 | cp ${RPI_FIRMWARE_DIR}/boot/start_x.elf ${BOOT_DIR}/start_x.elf |
|
17 | cp ${RPI_FIRMWARE_DIR}/boot/start_x.elf ${BOOT_DIR}/start_x.elf | |
18 | else |
|
18 | else | |
19 | # Create temporary directory for boot binaries |
|
19 | # Create temporary directory for boot binaries | |
20 |
temp_dir=$( |
|
20 | temp_dir=$(as_nobody mktemp -d) | |
21 |
|
21 | |||
22 | # Install latest boot binaries from raspberry/firmware github |
|
22 | # Install latest boot binaries from raspberry/firmware github | |
23 |
|
|
23 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" | |
24 |
|
|
24 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" | |
25 |
|
|
25 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" | |
26 |
|
|
26 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" | |
27 |
|
|
27 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" | |
28 |
|
|
28 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" | |
29 |
|
|
29 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" | |
30 |
|
30 | |||
31 | # Move downloaded boot binaries |
|
31 | # Move downloaded boot binaries | |
32 | mv "${temp_dir}/"* "${BOOT_DIR}/" |
|
32 | mv "${temp_dir}/"* "${BOOT_DIR}/" | |
33 |
|
33 | |||
34 | # Remove temporary directory for boot binaries |
|
34 | # Remove temporary directory for boot binaries | |
35 | rm -fr "${temp_dir}" |
|
35 | rm -fr "${temp_dir}" | |
36 |
|
36 | |||
37 | # Set permissions of the boot binaries |
|
37 | # Set permissions of the boot binaries | |
38 | chown -R root:root "${BOOT_DIR}" |
|
38 | chown -R root:root "${BOOT_DIR}" | |
39 | chmod -R 600 "${BOOT_DIR}" |
|
39 | chmod -R 600 "${BOOT_DIR}" | |
40 | fi |
|
40 | fi | |
41 | fi |
|
41 | fi | |
42 |
|
42 | |||
43 | # Setup firmware boot cmdline |
|
43 | # Setup firmware boot cmdline | |
44 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
44 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
45 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
45 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
46 | else |
|
46 | else | |
47 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
47 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
48 | fi |
|
48 | fi | |
49 |
|
49 | |||
50 | # Add encrypted root partition to cmdline.txt |
|
50 | # Add encrypted root partition to cmdline.txt | |
51 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
51 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
52 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
52 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
53 | CMDLINE=$(echo ${CMDLINE} | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") |
|
53 | CMDLINE=$(echo ${CMDLINE} | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") | |
54 | else |
|
54 | else | |
55 | CMDLINE=$(echo ${CMDLINE} | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") |
|
55 | CMDLINE=$(echo ${CMDLINE} | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") | |
56 | fi |
|
56 | fi | |
57 | fi |
|
57 | fi | |
58 |
|
58 | |||
59 | # Add serial console support |
|
59 | # Add serial console support | |
60 | if [ "$ENABLE_CONSOLE" = true ] ; then |
|
60 | if [ "$ENABLE_CONSOLE" = true ] ; then | |
61 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" |
|
61 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" | |
62 | fi |
|
62 | fi | |
63 |
|
63 | |||
64 | # Remove IPv6 networking support |
|
64 | # Remove IPv6 networking support | |
65 | if [ "$ENABLE_IPV6" = false ] ; then |
|
65 | if [ "$ENABLE_IPV6" = false ] ; then | |
66 | CMDLINE="${CMDLINE} ipv6.disable=1" |
|
66 | CMDLINE="${CMDLINE} ipv6.disable=1" | |
67 | fi |
|
67 | fi | |
68 |
|
68 | |||
69 | # Automatically assign predictable network interface names |
|
69 | # Automatically assign predictable network interface names | |
70 | if [ "$ENABLE_IFNAMES" = false ] ; then |
|
70 | if [ "$ENABLE_IFNAMES" = false ] ; then | |
71 | CMDLINE="${CMDLINE} net.ifnames=0" |
|
71 | CMDLINE="${CMDLINE} net.ifnames=0" | |
72 | else |
|
72 | else | |
73 | CMDLINE="${CMDLINE} net.ifnames=1" |
|
73 | CMDLINE="${CMDLINE} net.ifnames=1" | |
74 | fi |
|
74 | fi | |
75 |
|
75 | |||
76 | # Set init to systemd if required by Debian release |
|
76 | # Set init to systemd if required by Debian release | |
77 | if [ "$RELEASE" = "stretch" ] ; then |
|
77 | if [ "$RELEASE" = "stretch" ] ; then | |
78 | CMDLINE="${CMDLINE} init=/bin/systemd" |
|
78 | CMDLINE="${CMDLINE} init=/bin/systemd" | |
79 | fi |
|
79 | fi | |
80 |
|
80 | |||
81 | # Install firmware boot cmdline |
|
81 | # Install firmware boot cmdline | |
82 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" |
|
82 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" | |
83 |
|
83 | |||
84 | # Install firmware config |
|
84 | # Install firmware config | |
85 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" |
|
85 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" | |
86 |
|
86 | |||
87 | # Setup minimal GPU memory allocation size: 16MB (no X) |
|
87 | # Setup minimal GPU memory allocation size: 16MB (no X) | |
88 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
88 | if [ "$ENABLE_MINGPU" = true ] ; then | |
89 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" |
|
89 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" | |
90 | fi |
|
90 | fi | |
91 |
|
91 | |||
92 | # Setup boot with initramfs |
|
92 | # Setup boot with initramfs | |
93 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
93 | if [ "$ENABLE_INITRAMFS" = true ] ; then | |
94 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" |
|
94 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" | |
95 | fi |
|
95 | fi | |
96 |
|
96 | |||
97 | # Disable RPi3 Bluetooth and restore ttyAMA0 serial device |
|
97 | # Disable RPi3 Bluetooth and restore ttyAMA0 serial device | |
98 | if [ "$RPI_MODEL" = 3 ] ; then |
|
98 | if [ "$RPI_MODEL" = 3 ] ; then | |
99 | if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then |
|
99 | if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then | |
100 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" |
|
100 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" | |
101 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" |
|
101 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" | |
102 | fi |
|
102 | fi | |
103 | fi |
|
103 | fi | |
104 |
|
104 | |||
105 | # Create firmware configuration and cmdline symlinks |
|
105 | # Create firmware configuration and cmdline symlinks | |
106 | ln -sf firmware/config.txt "${R}/boot/config.txt" |
|
106 | ln -sf firmware/config.txt "${R}/boot/config.txt" | |
107 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" |
|
107 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" | |
108 |
|
108 | |||
109 | # Install and setup kernel modules to load at boot |
|
109 | # Install and setup kernel modules to load at boot | |
110 | mkdir -p "${R}/lib/modules-load.d/" |
|
110 | mkdir -p "${R}/lib/modules-load.d/" | |
111 | install_readonly files/modules/rpi2.conf "${R}/lib/modules-load.d/rpi2.conf" |
|
111 | install_readonly files/modules/rpi2.conf "${R}/lib/modules-load.d/rpi2.conf" | |
112 |
|
112 | |||
113 | # Load hardware random module at boot |
|
113 | # Load hardware random module at boot | |
114 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then |
|
114 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then | |
115 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${R}/lib/modules-load.d/rpi2.conf" |
|
115 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${R}/lib/modules-load.d/rpi2.conf" | |
116 | fi |
|
116 | fi | |
117 |
|
117 | |||
118 | # Load sound module at boot |
|
118 | # Load sound module at boot | |
119 | if [ "$ENABLE_SOUND" = true ] ; then |
|
119 | if [ "$ENABLE_SOUND" = true ] ; then | |
120 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" |
|
120 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" | |
121 | else |
|
121 | else | |
122 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" |
|
122 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" | |
123 | fi |
|
123 | fi | |
124 |
|
124 | |||
125 | # Enable I2C interface |
|
125 | # Enable I2C interface | |
126 | if [ "$ENABLE_I2C" = true ] ; then |
|
126 | if [ "$ENABLE_I2C" = true ] ; then | |
127 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" |
|
127 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" | |
128 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${R}/lib/modules-load.d/rpi2.conf" |
|
128 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${R}/lib/modules-load.d/rpi2.conf" | |
129 | sed -i "s/^# i2c-dev/i2c-dev/" "${R}/lib/modules-load.d/rpi2.conf" |
|
129 | sed -i "s/^# i2c-dev/i2c-dev/" "${R}/lib/modules-load.d/rpi2.conf" | |
130 | fi |
|
130 | fi | |
131 |
|
131 | |||
132 | # Enable SPI interface |
|
132 | # Enable SPI interface | |
133 | if [ "$ENABLE_SPI" = true ] ; then |
|
133 | if [ "$ENABLE_SPI" = true ] ; then | |
134 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" |
|
134 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" | |
135 | echo "spi-bcm2708" >> "${R}/lib/modules-load.d/rpi2.conf" |
|
135 | echo "spi-bcm2708" >> "${R}/lib/modules-load.d/rpi2.conf" | |
136 | if [ "$RPI_MODEL" = 3 ] ; then |
|
136 | if [ "$RPI_MODEL" = 3 ] ; then | |
137 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" |
|
137 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${R}/lib/modules-load.d/rpi2.conf" | |
138 | fi |
|
138 | fi | |
139 | fi |
|
139 | fi | |
140 |
|
140 | |||
141 | # Disable RPi2/3 under-voltage warnings |
|
141 | # Disable RPi2/3 under-voltage warnings | |
142 | if [ ! -z "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
142 | if [ ! -z "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
143 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" |
|
143 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" | |
144 | fi |
|
144 | fi | |
145 |
|
145 | |||
146 | # Install kernel modules blacklist |
|
146 | # Install kernel modules blacklist | |
147 | mkdir -p "${ETC_DIR}/modprobe.d/" |
|
147 | mkdir -p "${ETC_DIR}/modprobe.d/" | |
148 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" |
|
148 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" | |
149 |
|
149 | |||
150 | # Install sysctl.d configuration files |
|
150 | # Install sysctl.d configuration files | |
151 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
|
151 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
@@ -1,107 +1,107 | |||||
1 | # |
|
1 | # | |
2 | # Setup Networking |
|
2 | # Setup Networking | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Install and setup hostname |
|
8 | # Install and setup hostname | |
9 | install_readonly files/network/hostname "${ETC_DIR}/hostname" |
|
9 | install_readonly files/network/hostname "${ETC_DIR}/hostname" | |
10 | sed -i "s/^rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/hostname" |
|
10 | sed -i "s/^rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/hostname" | |
11 |
|
11 | |||
12 | # Install and setup hosts |
|
12 | # Install and setup hosts | |
13 | install_readonly files/network/hosts "${ETC_DIR}/hosts" |
|
13 | install_readonly files/network/hosts "${ETC_DIR}/hosts" | |
14 | sed -i "s/rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/hosts" |
|
14 | sed -i "s/rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/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}/" "${ETC_DIR}/hosts" |
|
19 | sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/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" "${ETC_DIR}/hosts" |
|
24 | sed -i -e "/::[1-9]/d" -e "/^$/d" "${ETC_DIR}/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 "${ETC_DIR}/network/interfaces" |
|
28 | install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces" | |
29 |
|
29 | |||
30 | # Install configuration for interface eth0 |
|
30 | # Install configuration for interface eth0 | |
31 | install_readonly files/network/eth.network "${ETC_DIR}/systemd/network/eth.network" |
|
31 | install_readonly files/network/eth.network "${ETC_DIR}/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" "${ETC_DIR}/systemd/network/eth.network" |
|
35 | sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/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/" "${ETC_DIR}/systemd/network/eth.network" |
|
39 | sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network" | |
40 | fi |
|
40 | fi | |
41 |
|
41 | |||
42 | else # ENABLE_DHCP=false |
|
42 | else # ENABLE_DHCP=false | |
43 | # Set static network configuration for interface eth0 |
|
43 | # Set static network configuration for interface eth0 | |
44 | sed -i\ |
|
44 | sed -i\ | |
45 | -e "s|DHCP=.*|DHCP=no|"\ |
|
45 | -e "s|DHCP=.*|DHCP=no|"\ | |
46 | -e "s|Address=\$|Address=${NET_ADDRESS}|"\ |
|
46 | -e "s|Address=\$|Address=${NET_ADDRESS}|"\ | |
47 | -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\ |
|
47 | -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\ | |
48 | -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\ |
|
48 | -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\ | |
49 | -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\ |
|
49 | -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\ | |
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 | "${ETC_DIR}/systemd/network/eth.network" |
|
53 | "${ETC_DIR}/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" "${ETC_DIR}/systemd/network/eth.network" |
|
57 | sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network" | |
58 |
|
58 | |||
59 | # Move systemd network configuration if required by Debian release |
|
59 | # Move systemd network configuration if required by Debian release | |
60 | if [ "$RELEASE" = "stretch" ] ; then |
|
60 | if [ "$RELEASE" = "stretch" ] ; then | |
61 | mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network" |
|
61 | mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network" | |
62 | rm -fr "${ETC_DIR}/systemd/network" |
|
62 | rm -fr "${ETC_DIR}/systemd/network" | |
63 | fi |
|
63 | fi | |
64 |
|
64 | |||
65 | # Enable systemd-networkd service |
|
65 | # Enable systemd-networkd service | |
66 | chroot_exec systemctl enable systemd-networkd |
|
66 | chroot_exec systemctl enable systemd-networkd | |
67 |
|
67 | |||
68 | # Install host.conf resolver configuration |
|
68 | # Install host.conf resolver configuration | |
69 | install_readonly files/network/host.conf "${ETC_DIR}/host.conf" |
|
69 | install_readonly files/network/host.conf "${ETC_DIR}/host.conf" | |
70 |
|
70 | |||
71 | # Enable network stack hardening |
|
71 | # Enable network stack hardening | |
72 | if [ "$ENABLE_HARDNET" = true ] ; then |
|
72 | if [ "$ENABLE_HARDNET" = true ] ; then | |
73 | # Install sysctl.d configuration files |
|
73 | # Install sysctl.d configuration files | |
74 | install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf" |
|
74 | install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf" | |
75 |
|
75 | |||
76 | # Setup resolver warnings about spoofed addresses |
|
76 | # Setup resolver warnings about spoofed addresses | |
77 | sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf" |
|
77 | sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf" | |
78 | fi |
|
78 | fi | |
79 |
|
79 | |||
80 | # Enable time sync |
|
80 | # Enable time sync | |
81 | if [ "NET_NTP_1" != "" ] ; then |
|
81 | if [ "NET_NTP_1" != "" ] ; then | |
82 | chroot_exec systemctl enable systemd-timesyncd.service |
|
82 | chroot_exec systemctl enable systemd-timesyncd.service | |
83 | fi |
|
83 | fi | |
84 |
|
84 | |||
85 | # Download the firmware binary blob required to use the RPi3 wireless interface |
|
85 | # Download the firmware binary blob required to use the RPi3 wireless interface | |
86 | if [ "$ENABLE_WIRELESS" = true ] ; then |
|
86 | if [ "$ENABLE_WIRELESS" = true ] ; then | |
87 | if [ ! -d ${WLAN_FIRMWARE_DIR} ] ; then |
|
87 | if [ ! -d ${WLAN_FIRMWARE_DIR} ] ; then | |
88 | mkdir -p ${WLAN_FIRMWARE_DIR} |
|
88 | mkdir -p ${WLAN_FIRMWARE_DIR} | |
89 | fi |
|
89 | fi | |
90 |
|
90 | |||
91 | # Create temporary directory for firmware binary blob |
|
91 | # Create temporary directory for firmware binary blob | |
92 |
temp_dir=$( |
|
92 | temp_dir=$(as_nobody mktemp -d) | |
93 |
|
93 | |||
94 | # Fetch firmware binary blob |
|
94 | # Fetch firmware binary blob | |
95 |
|
|
95 | as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin" | |
96 |
|
|
96 | as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt" | |
97 |
|
97 | |||
98 | # Move downloaded firmware binary blob |
|
98 | # Move downloaded firmware binary blob | |
99 | mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/" |
|
99 | mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/" | |
100 |
|
100 | |||
101 | # Remove temporary directory for firmware binary blob |
|
101 | # Remove temporary directory for firmware binary blob | |
102 | rm -fr "${temp_dir}" |
|
102 | rm -fr "${temp_dir}" | |
103 |
|
103 | |||
104 | # Set permissions of the firmware binary blob |
|
104 | # Set permissions of the firmware binary blob | |
105 | chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* |
|
105 | chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* | |
106 | chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* |
|
106 | chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* | |
107 | fi |
|
107 | fi |
@@ -1,83 +1,83 | |||||
1 | # |
|
1 | # | |
2 | # Build and Setup U-Boot |
|
2 | # Build and Setup U-Boot | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Fetch and build U-Boot bootloader |
|
8 | # Fetch and build U-Boot bootloader | |
9 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
9 | if [ "$ENABLE_UBOOT" = true ] ; then | |
10 | # Install c/c++ build environment inside the chroot |
|
10 | # Install c/c++ build environment inside the chroot | |
11 | chroot_install_cc |
|
11 | chroot_install_cc | |
12 |
|
12 | |||
13 | # Copy existing U-Boot sources into chroot directory |
|
13 | # Copy existing U-Boot sources into chroot directory | |
14 | if [ -n "$UBOOTSRC_DIR" ] && [ -d "$UBOOTSRC_DIR" ] ; then |
|
14 | if [ -n "$UBOOTSRC_DIR" ] && [ -d "$UBOOTSRC_DIR" ] ; then | |
15 | # Copy local U-Boot sources |
|
15 | # Copy local U-Boot sources | |
16 | cp -r "${UBOOTSRC_DIR}" "${R}/tmp" |
|
16 | cp -r "${UBOOTSRC_DIR}" "${R}/tmp" | |
17 | else |
|
17 | else | |
18 | # Create temporary directory for U-Boot sources |
|
18 | # Create temporary directory for U-Boot sources | |
19 |
temp_dir=$( |
|
19 | temp_dir=$(as_nobody mktemp -d) | |
20 |
|
20 | |||
21 | # Fetch U-Boot sources |
|
21 | # Fetch U-Boot sources | |
22 |
|
|
22 | as_nobody git -C "${temp_dir}" clone "${UBOOT_URL}" | |
23 |
|
23 | |||
24 | # Copy downloaded U-Boot sources |
|
24 | # Copy downloaded U-Boot sources | |
25 | mv "${temp_dir}/u-boot" "${R}/tmp/" |
|
25 | mv "${temp_dir}/u-boot" "${R}/tmp/" | |
26 |
|
26 | |||
27 | # Set permissions of the U-Boot sources |
|
27 | # Set permissions of the U-Boot sources | |
28 | chown -R root:root "${R}/tmp/u-boot" |
|
28 | chown -R root:root "${R}/tmp/u-boot" | |
29 |
|
29 | |||
30 | # Remove temporary directory for U-Boot sources |
|
30 | # Remove temporary directory for U-Boot sources | |
31 | rm -fr "${temp_dir}" |
|
31 | rm -fr "${temp_dir}" | |
32 | fi |
|
32 | fi | |
33 |
|
33 | |||
34 | # Build and install U-Boot inside chroot |
|
34 | # Build and install U-Boot inside chroot | |
35 | chroot_exec make -j${KERNEL_THREADS} -C /tmp/u-boot/ ${UBOOT_CONFIG} all |
|
35 | chroot_exec make -j${KERNEL_THREADS} -C /tmp/u-boot/ ${UBOOT_CONFIG} all | |
36 |
|
36 | |||
37 | # Copy compiled bootloader binary and set config.txt to load it |
|
37 | # Copy compiled bootloader binary and set config.txt to load it | |
38 | install_exec "${R}/tmp/u-boot/tools/mkimage" "${R}/usr/sbin/mkimage" |
|
38 | install_exec "${R}/tmp/u-boot/tools/mkimage" "${R}/usr/sbin/mkimage" | |
39 | install_readonly "${R}/tmp/u-boot/u-boot.bin" "${BOOT_DIR}/u-boot.bin" |
|
39 | install_readonly "${R}/tmp/u-boot/u-boot.bin" "${BOOT_DIR}/u-boot.bin" | |
40 | printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "${BOOT_DIR}/config.txt" |
|
40 | printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "${BOOT_DIR}/config.txt" | |
41 |
|
41 | |||
42 | # Install and setup U-Boot command file |
|
42 | # Install and setup U-Boot command file | |
43 | install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage" |
|
43 | install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage" | |
44 | printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" |
|
44 | printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" | |
45 |
|
45 | |||
46 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
46 | if [ "$ENABLE_INITRAMFS" = true ] ; then | |
47 | # Convert generated initramfs for U-Boot using mkimage |
|
47 | # Convert generated initramfs for U-Boot using mkimage | |
48 | chroot_exec /usr/sbin/mkimage -A "${KERNEL_ARCH}" -T ramdisk -C none -n "initramfs-${KERNEL_VERSION}" -d "/boot/firmware/initramfs-${KERNEL_VERSION}" "/boot/firmware/initramfs-${KERNEL_VERSION}.uboot" |
|
48 | chroot_exec /usr/sbin/mkimage -A "${KERNEL_ARCH}" -T ramdisk -C none -n "initramfs-${KERNEL_VERSION}" -d "/boot/firmware/initramfs-${KERNEL_VERSION}" "/boot/firmware/initramfs-${KERNEL_VERSION}.uboot" | |
49 |
|
49 | |||
50 | # Remove original initramfs file |
|
50 | # Remove original initramfs file | |
51 | rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" |
|
51 | rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" | |
52 |
|
52 | |||
53 | # Configure U-Boot to load generated initramfs |
|
53 | # Configure U-Boot to load generated initramfs | |
54 | printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" |
|
54 | printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" | |
55 | printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
55 | printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" | |
56 | else # ENABLE_INITRAMFS=false |
|
56 | else # ENABLE_INITRAMFS=false | |
57 | # Remove initramfs from U-Boot mkfile |
|
57 | # Remove initramfs from U-Boot mkfile | |
58 | sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage" |
|
58 | sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage" | |
59 |
|
59 | |||
60 | if [ "$BUILD_KERNEL" = false ] ; then |
|
60 | if [ "$BUILD_KERNEL" = false ] ; then | |
61 | # Remove dtbfile from U-Boot mkfile |
|
61 | # Remove dtbfile from U-Boot mkfile | |
62 | sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage" |
|
62 | sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage" | |
63 | printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
63 | printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" | |
64 | else |
|
64 | else | |
65 | printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" |
|
65 | printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" | |
66 | fi |
|
66 | fi | |
67 | fi |
|
67 | fi | |
68 |
|
68 | |||
69 | # Set mkfile to use the correct dtb file |
|
69 | # Set mkfile to use the correct dtb file | |
70 | sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage" |
|
70 | sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage" | |
71 |
|
71 | |||
72 | # Set mkfile to use kernel image |
|
72 | # Set mkfile to use kernel image | |
73 | sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage" |
|
73 | sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage" | |
74 |
|
74 | |||
75 | # Remove all leading blank lines |
|
75 | # Remove all leading blank lines | |
76 | sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage" |
|
76 | sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage" | |
77 |
|
77 | |||
78 | # Generate U-Boot bootloader image |
|
78 | # Generate U-Boot bootloader image | |
79 | chroot_exec /usr/sbin/mkimage -A "${KERNEL_ARCH}" -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n "RPi${RPI_MODEL}" -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr |
|
79 | chroot_exec /usr/sbin/mkimage -A "${KERNEL_ARCH}" -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n "RPi${RPI_MODEL}" -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr | |
80 |
|
80 | |||
81 | # Remove U-Boot sources |
|
81 | # Remove U-Boot sources | |
82 | rm -fr "${R}/tmp/u-boot" |
|
82 | rm -fr "${R}/tmp/u-boot" | |
83 | fi |
|
83 | fi |
@@ -1,51 +1,51 | |||||
1 | # |
|
1 | # | |
2 | # Build and Setup fbturbo Xorg driver |
|
2 | # Build and Setup fbturbo Xorg driver | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | if [ "$ENABLE_FBTURBO" = true ] ; then |
|
8 | if [ "$ENABLE_FBTURBO" = true ] ; then | |
9 | # Install c/c++ build environment inside the chroot |
|
9 | # Install c/c++ build environment inside the chroot | |
10 | chroot_install_cc |
|
10 | chroot_install_cc | |
11 |
|
11 | |||
12 | # Copy existing fbturbo sources into chroot directory |
|
12 | # Copy existing fbturbo sources into chroot directory | |
13 | if [ -n "$FBTURBOSRC_DIR" ] && [ -d "$FBTURBOSRC_DIR" ] ; then |
|
13 | if [ -n "$FBTURBOSRC_DIR" ] && [ -d "$FBTURBOSRC_DIR" ] ; then | |
14 | # Copy local fbturbo sources |
|
14 | # Copy local fbturbo sources | |
15 | cp -r "${FBTURBOSRC_DIR}" "${R}/tmp" |
|
15 | cp -r "${FBTURBOSRC_DIR}" "${R}/tmp" | |
16 | else |
|
16 | else | |
17 | # Create temporary directory for fbturbo sources |
|
17 | # Create temporary directory for fbturbo sources | |
18 |
temp_dir=$( |
|
18 | temp_dir=$(as_nobody mktemp -d) | |
19 |
|
19 | |||
20 | # Fetch fbturbo sources |
|
20 | # Fetch fbturbo sources | |
21 |
|
|
21 | as_nobody git -C "${temp_dir}" clone "${FBTURBO_URL}" | |
22 |
|
22 | |||
23 | # Move downloaded fbturbo sources |
|
23 | # Move downloaded fbturbo sources | |
24 | mv "${temp_dir}/xf86-video-fbturbo" "${R}/tmp/" |
|
24 | mv "${temp_dir}/xf86-video-fbturbo" "${R}/tmp/" | |
25 |
|
25 | |||
26 | # Remove temporary directory for fbturbo sources |
|
26 | # Remove temporary directory for fbturbo sources | |
27 | rm -fr "${temp_dir}" |
|
27 | rm -fr "${temp_dir}" | |
28 | fi |
|
28 | fi | |
29 |
|
29 | |||
30 | # Install Xorg build dependencies |
|
30 | # Install Xorg build dependencies | |
31 | if [ "$RELEASE" = "jessie" ] ; then |
|
31 | if [ "$RELEASE" = "jessie" ] ; then | |
32 | chroot_exec apt-get -q -y --no-install-recommends install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev |
|
32 | chroot_exec apt-get -q -y --no-install-recommends install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev | |
33 | elif [ "$RELEASE" = "stretch" ] ; then |
|
33 | elif [ "$RELEASE" = "stretch" ] ; then | |
34 | chroot_exec apt-get -q -y --no-install-recommends --allow-unauthenticated install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev |
|
34 | chroot_exec apt-get -q -y --no-install-recommends --allow-unauthenticated install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev | |
35 | fi |
|
35 | fi | |
36 |
|
36 | |||
37 | # Build and install fbturbo driver inside chroot |
|
37 | # Build and install fbturbo driver inside chroot | |
38 | chroot_exec /bin/bash -x <<'EOF' |
|
38 | chroot_exec /bin/bash -x <<'EOF' | |
39 | cd /tmp/xf86-video-fbturbo |
|
39 | cd /tmp/xf86-video-fbturbo | |
40 | autoreconf -vi |
|
40 | autoreconf -vi | |
41 | ./configure --prefix=/usr |
|
41 | ./configure --prefix=/usr | |
42 | make |
|
42 | make | |
43 | make install |
|
43 | make install | |
44 | EOF |
|
44 | EOF | |
45 |
|
45 | |||
46 | # Install fbturbo driver Xorg configuration |
|
46 | # Install fbturbo driver Xorg configuration | |
47 | install_readonly files/xorg/99-fbturbo.conf "${R}/usr/share/X11/xorg.conf.d/99-fbturbo.conf" |
|
47 | install_readonly files/xorg/99-fbturbo.conf "${R}/usr/share/X11/xorg.conf.d/99-fbturbo.conf" | |
48 |
|
48 | |||
49 | # Remove Xorg build dependencies |
|
49 | # Remove Xorg build dependencies | |
50 | chroot_exec apt-get -qq -y --auto-remove purge xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev |
|
50 | chroot_exec apt-get -qq -y --auto-remove purge xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev | |
51 | fi |
|
51 | fi |
@@ -1,76 +1,81 | |||||
1 | # This file contains utility functions used by rpi23-gen-image.sh |
|
1 | # This file contains utility functions used by rpi23-gen-image.sh | |
2 |
|
2 | |||
3 | cleanup (){ |
|
3 | cleanup (){ | |
4 | set +x |
|
4 | set +x | |
5 | set +e |
|
5 | set +e | |
6 |
|
6 | |||
7 | # Identify and kill all processes still using files |
|
7 | # Identify and kill all processes still using files | |
8 | echo "killing processes using mount point ..." |
|
8 | echo "killing processes using mount point ..." | |
9 | fuser -k "${R}" |
|
9 | fuser -k "${R}" | |
10 | sleep 3 |
|
10 | sleep 3 | |
11 | fuser -9 -k -v "${R}" |
|
11 | fuser -9 -k -v "${R}" | |
12 |
|
12 | |||
13 | # Clean up temporary .password file |
|
13 | # Clean up temporary .password file | |
14 | if [ -r ".password" ] ; then |
|
14 | if [ -r ".password" ] ; then | |
15 | shred -zu .password |
|
15 | shred -zu .password | |
16 | fi |
|
16 | fi | |
17 |
|
17 | |||
18 | # Clean up all temporary mount points |
|
18 | # Clean up all temporary mount points | |
19 | echo "removing temporary mount points ..." |
|
19 | echo "removing temporary mount points ..." | |
20 | umount -l "${R}/proc" 2> /dev/null |
|
20 | umount -l "${R}/proc" 2> /dev/null | |
21 | umount -l "${R}/sys" 2> /dev/null |
|
21 | umount -l "${R}/sys" 2> /dev/null | |
22 | umount -l "${R}/dev/pts" 2> /dev/null |
|
22 | umount -l "${R}/dev/pts" 2> /dev/null | |
23 | umount "$BUILDDIR/mount/boot/firmware" 2> /dev/null |
|
23 | umount "$BUILDDIR/mount/boot/firmware" 2> /dev/null | |
24 | umount "$BUILDDIR/mount" 2> /dev/null |
|
24 | umount "$BUILDDIR/mount" 2> /dev/null | |
25 | cryptsetup close "${CRYPTFS_MAPPING}" 2> /dev/null |
|
25 | cryptsetup close "${CRYPTFS_MAPPING}" 2> /dev/null | |
26 | losetup -d "$ROOT_LOOP" 2> /dev/null |
|
26 | losetup -d "$ROOT_LOOP" 2> /dev/null | |
27 | losetup -d "$FRMW_LOOP" 2> /dev/null |
|
27 | losetup -d "$FRMW_LOOP" 2> /dev/null | |
28 | trap - 0 1 2 3 6 |
|
28 | trap - 0 1 2 3 6 | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | chroot_exec() { |
|
31 | chroot_exec() { | |
32 | # Exec command in chroot |
|
32 | # Exec command in chroot | |
33 | LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot ${R} $* |
|
33 | LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot ${R} $* | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
|
36 | as_nobody() { | |||
|
37 | # Exec command as user nobody | |||
|
38 | sudo -u nobody LANG=C LC_ALL=C $* | |||
|
39 | } | |||
|
40 | ||||
36 | install_readonly() { |
|
41 | install_readonly() { | |
37 | # Install file with user read-only permissions |
|
42 | # Install file with user read-only permissions | |
38 | install -o root -g root -m 644 $* |
|
43 | install -o root -g root -m 644 $* | |
39 | } |
|
44 | } | |
40 |
|
45 | |||
41 | install_exec() { |
|
46 | install_exec() { | |
42 | # Install file with root exec permissions |
|
47 | # Install file with root exec permissions | |
43 | install -o root -g root -m 744 $* |
|
48 | install -o root -g root -m 744 $* | |
44 | } |
|
49 | } | |
45 |
|
50 | |||
46 | use_template () { |
|
51 | use_template () { | |
47 | # Test if configuration template file exists |
|
52 | # Test if configuration template file exists | |
48 | if [ ! -r "./templates/${CONFIG_TEMPLATE}" ] ; then |
|
53 | if [ ! -r "./templates/${CONFIG_TEMPLATE}" ] ; then | |
49 | echo "error: configuration template ${CONFIG_TEMPLATE} not found" |
|
54 | echo "error: configuration template ${CONFIG_TEMPLATE} not found" | |
50 | exit 1 |
|
55 | exit 1 | |
51 | fi |
|
56 | fi | |
52 |
|
57 | |||
53 | # Load template configuration parameters |
|
58 | # Load template configuration parameters | |
54 | . "./templates/${CONFIG_TEMPLATE}" |
|
59 | . "./templates/${CONFIG_TEMPLATE}" | |
55 | } |
|
60 | } | |
56 |
|
61 | |||
57 | chroot_install_cc() { |
|
62 | chroot_install_cc() { | |
58 | # Install c/c++ build environment inside the chroot |
|
63 | # Install c/c++ build environment inside the chroot | |
59 | if [ -z "${COMPILER_PACKAGES}" ] ; then |
|
64 | if [ -z "${COMPILER_PACKAGES}" ] ; then | |
60 | COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }') |
|
65 | COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }') | |
61 |
|
66 | |||
62 | if [ "$RELEASE" = "jessie" ] ; then |
|
67 | if [ "$RELEASE" = "jessie" ] ; then | |
63 | chroot_exec apt-get -q -y --no-install-recommends install ${COMPILER_PACKAGES} |
|
68 | chroot_exec apt-get -q -y --no-install-recommends install ${COMPILER_PACKAGES} | |
64 | elif [ "$RELEASE" = "stretch" ] ; then |
|
69 | elif [ "$RELEASE" = "stretch" ] ; then | |
65 | chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES} |
|
70 | chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES} | |
66 | fi |
|
71 | fi | |
67 | fi |
|
72 | fi | |
68 | } |
|
73 | } | |
69 |
|
74 | |||
70 | chroot_remove_cc() { |
|
75 | chroot_remove_cc() { | |
71 | # Remove c/c++ build environment from the chroot |
|
76 | # Remove c/c++ build environment from the chroot | |
72 | if [ ! -z "${COMPILER_PACKAGES}" ] ; then |
|
77 | if [ ! -z "${COMPILER_PACKAGES}" ] ; then | |
73 | chroot_exec apt-get -qq -y --auto-remove purge ${COMPILER_PACKAGES} |
|
78 | chroot_exec apt-get -qq -y --auto-remove purge ${COMPILER_PACKAGES} | |
74 | COMPILER_PACKAGES="" |
|
79 | COMPILER_PACKAGES="" | |
75 | fi |
|
80 | fi | |
76 | } |
|
81 | } |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant