@@ -1,615 +1,623 | |||||
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 | # Need to use kali kernel src if nexmon is enabled |
|
8 | # Need to use kali kernel src if nexmon is enabled | |
9 | if [ "$ENABLE_NEXMON" = true ] ; then |
|
9 | if [ "$ENABLE_NEXMON" = true ] ; then | |
10 | KERNEL_URL="${KALI_KERNEL_URL}" |
|
10 | KERNEL_URL="${KALI_KERNEL_URL}" | |
11 | # Clear Branch and KernelSRC_DIR if using nexmon. Everyone will forget to clone kali kernel instead of nomrla kernel |
|
11 | # Clear Branch and KernelSRC_DIR if using nexmon. Everyone will forget to clone kali kernel instead of nomrla kernel | |
12 | KERNEL_BRANCH="" |
|
12 | KERNEL_BRANCH="" | |
13 | KERNELSRC_DIR="" |
|
13 | KERNELSRC_DIR="" | |
14 | fi |
|
14 | fi | |
15 |
|
15 | |||
16 | # Fetch and build latest raspberry kernel |
|
16 | # Fetch and build latest raspberry kernel | |
17 | if [ "$BUILD_KERNEL" = true ] ; then |
|
17 | if [ "$BUILD_KERNEL" = true ] ; then | |
18 | # Setup source directory |
|
18 | # Setup source directory | |
19 | mkdir -p "${KERNEL_DIR}" |
|
19 | mkdir -p "${KERNEL_DIR}" | |
20 |
|
20 | |||
21 | # Copy existing kernel sources into chroot directory |
|
21 | # Copy existing kernel sources into chroot directory | |
22 | if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then |
|
22 | if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then | |
23 | # Copy kernel sources and include hidden files |
|
23 | # Copy kernel sources and include hidden files | |
24 | cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}" |
|
24 | cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}" | |
25 |
|
25 | |||
26 | # Clean the kernel sources |
|
26 | # Clean the kernel sources | |
27 | if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then |
|
27 | if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then | |
28 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper |
|
28 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper | |
29 | fi |
|
29 | fi | |
30 | else # KERNELSRC_DIR="" |
|
30 | else # KERNELSRC_DIR="" | |
31 | # Create temporary directory for kernel sources |
|
31 | # Create temporary directory for kernel sources | |
32 | temp_dir=$(as_nobody mktemp -d) |
|
32 | temp_dir=$(as_nobody mktemp -d) | |
33 |
|
33 | |||
34 | # Fetch current RPi2/3 kernel sources |
|
34 | # Fetch current RPi2/3 kernel sources | |
35 | if [ -z "${KERNEL_BRANCH}" ] ; then |
|
35 | if [ -z "${KERNEL_BRANCH}" ] ; then | |
36 | as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux |
|
36 | as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux | |
37 | else |
|
37 | else | |
38 | as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux |
|
38 | as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux | |
39 | fi |
|
39 | fi | |
40 |
|
40 | |||
41 | # Copy downloaded kernel sources |
|
41 | # Copy downloaded kernel sources | |
42 | cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}" |
|
42 | cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}" | |
43 |
|
43 | |||
44 | # Remove temporary directory for kernel sources |
|
44 | # Remove temporary directory for kernel sources | |
45 | rm -fr "${temp_dir}" |
|
45 | rm -fr "${temp_dir}" | |
46 |
|
46 | |||
47 | # Set permissions of the kernel sources |
|
47 | # Set permissions of the kernel sources | |
48 | chown -R root:root "${R}/usr/src" |
|
48 | chown -R root:root "${R}/usr/src" | |
49 | fi |
|
49 | fi | |
50 |
|
50 | |||
51 | # Calculate optimal number of kernel building threads |
|
51 | # Calculate optimal number of kernel building threads | |
52 | if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then |
|
52 | if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then | |
53 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) |
|
53 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) | |
54 | fi |
|
54 | fi | |
55 |
|
55 | |||
56 | # Configure and build kernel |
|
56 | # Configure and build kernel | |
57 | if [ "$KERNELSRC_PREBUILT" = false ] ; then |
|
57 | if [ "$KERNELSRC_PREBUILT" = false ] ; then | |
58 | # Remove device, network and filesystem drivers from kernel configuration |
|
58 | # Remove device, network and filesystem drivers from kernel configuration | |
59 | if [ "$KERNEL_REDUCE" = true ] ; then |
|
59 | if [ "$KERNEL_REDUCE" = true ] ; then | |
60 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" |
|
60 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" | |
61 | sed -i\ |
|
61 | sed -i\ | |
62 | -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\ |
|
62 | -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\ | |
63 | -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\ |
|
63 | -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\ | |
64 | -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\ |
|
64 | -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\ | |
65 | -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\ |
|
65 | -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\ | |
66 | -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\ |
|
66 | -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\ | |
67 | -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\ |
|
67 | -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\ | |
68 | -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\ |
|
68 | -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\ | |
69 | -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\ |
|
69 | -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\ | |
70 | -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\ |
|
70 | -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\ | |
71 | -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\ |
|
71 | -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\ | |
72 | -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\ |
|
72 | -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\ | |
73 | -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\ |
|
73 | -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\ | |
74 | -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\ |
|
74 | -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\ | |
75 | -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\ |
|
75 | -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\ | |
76 | -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\ |
|
76 | -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\ | |
77 | -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\ |
|
77 | -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\ | |
78 | -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\ |
|
78 | -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\ | |
79 | -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\ |
|
79 | -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\ | |
80 | -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\ |
|
80 | -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\ | |
81 | -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\ |
|
81 | -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\ | |
82 | -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\ |
|
82 | -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\ | |
83 | -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\ |
|
83 | -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\ | |
84 | -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\ |
|
84 | -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\ | |
85 | -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\ |
|
85 | -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\ | |
86 | -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\ |
|
86 | -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\ | |
87 | -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\ |
|
87 | -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\ | |
88 | -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\ |
|
88 | -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\ | |
89 | -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\ |
|
89 | -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\ | |
90 | -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\ |
|
90 | -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\ | |
91 | "${KERNEL_DIR}/.config" |
|
91 | "${KERNEL_DIR}/.config" | |
92 | fi |
|
92 | fi | |
93 |
|
93 | |||
94 | if [ "$KERNELSRC_CONFIG" = true ] ; then |
|
94 | if [ "$KERNELSRC_CONFIG" = true ] ; then | |
95 | # Load default raspberry kernel configuration |
|
95 | # Load default raspberry kernel configuration | |
96 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" |
|
96 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" | |
97 |
|
97 | |||
98 | #Switch to KERNELSRC_DIR so we can use set_kernel_config |
|
98 | #Switch to KERNELSRC_DIR so we can use set_kernel_config | |
99 | cd "${KERNEL_DIR}" || exit |
|
99 | cd "${KERNEL_DIR}" || exit | |
100 |
|
100 | |||
101 | if [ "$KERNEL_ARCH" = arm64 ] ; then |
|
101 | if [ "$KERNEL_ARCH" = arm64 ] ; then | |
102 | #Fix SD_DRIVER upstream and downstream mess in 64bit RPIdeb_config |
|
102 | #Fix SD_DRIVER upstream and downstream mess in 64bit RPIdeb_config | |
103 | # use correct driver MMC_BCM2835_MMC instead of MMC_BCM2835_SDHOST - see https://www.raspberrypi.org/forums/viewtopic.php?t=210225 |
|
103 | # use correct driver MMC_BCM2835_MMC instead of MMC_BCM2835_SDHOST - see https://www.raspberrypi.org/forums/viewtopic.php?t=210225 | |
104 | set_kernel_config CONFIG_MMC_BCM2835 n |
|
104 | set_kernel_config CONFIG_MMC_BCM2835 n | |
105 | set_kernel_config CONFIG_MMC_SDHCI_IPROC n |
|
105 | set_kernel_config CONFIG_MMC_SDHCI_IPROC n | |
106 | set_kernel_config CONFIG_USB_DWC2 n |
|
106 | set_kernel_config CONFIG_USB_DWC2 n | |
107 | sed -i "s|depends on MMC_BCM2835_MMC && MMC_BCM2835_DMA|depends on MMC_BCM2835_MMC|" "${KERNEL_DIR}"/drivers/mmc/host/Kconfig |
|
107 | sed -i "s|depends on MMC_BCM2835_MMC && MMC_BCM2835_DMA|depends on MMC_BCM2835_MMC|" "${KERNEL_DIR}"/drivers/mmc/host/Kconfig | |
108 |
|
108 | |||
109 | #VLAN got disabled without reason in arm64bit |
|
109 | #VLAN got disabled without reason in arm64bit | |
110 | set_kernel_config CONFIG_IPVLAN m |
|
110 | set_kernel_config CONFIG_IPVLAN m | |
111 | fi |
|
111 | fi | |
112 |
|
112 | |||
113 | # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap |
|
113 | # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap | |
114 | if [ "$KERNEL_ZSWAP" = true ] ; then |
|
114 | if [ "$KERNEL_ZSWAP" = true ] ; then | |
115 | set_kernel_config CONFIG_ZPOOL y |
|
115 | set_kernel_config CONFIG_ZPOOL y | |
116 | set_kernel_config CONFIG_ZSWAP y |
|
116 | set_kernel_config CONFIG_ZSWAP y | |
117 | set_kernel_config CONFIG_ZBUD y |
|
117 | set_kernel_config CONFIG_ZBUD y | |
118 | set_kernel_config CONFIG_Z3FOLD y |
|
118 | set_kernel_config CONFIG_Z3FOLD y | |
119 | set_kernel_config CONFIG_ZSMALLOC y |
|
119 | set_kernel_config CONFIG_ZSMALLOC y | |
120 | set_kernel_config CONFIG_PGTABLE_MAPPING y |
|
120 | set_kernel_config CONFIG_PGTABLE_MAPPING y | |
121 | set_kernel_config CONFIG_LZO_COMPRESS y |
|
121 | set_kernel_config CONFIG_LZO_COMPRESS y | |
122 |
|
122 | |||
123 | fi |
|
123 | fi | |
124 |
|
124 | |||
125 | # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453 |
|
125 | # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453 | |
126 | if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then |
|
126 | if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; } ; then | |
127 | set_kernel_config CONFIG_HAVE_KVM_IRQCHIP y |
|
127 | set_kernel_config CONFIG_HAVE_KVM_IRQCHIP y | |
128 | set_kernel_config CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL y |
|
128 | set_kernel_config CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL y | |
129 | set_kernel_config CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT y |
|
129 | set_kernel_config CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT y | |
130 | set_kernel_config CONFIG_HAVE_KVM_EVENTFD y |
|
130 | set_kernel_config CONFIG_HAVE_KVM_EVENTFD y | |
131 | set_kernel_config CONFIG_HAVE_KVM_IRQFD y |
|
131 | set_kernel_config CONFIG_HAVE_KVM_IRQFD y | |
132 | set_kernel_config CONFIG_HAVE_KVM_IRQ_ROUTING y |
|
132 | set_kernel_config CONFIG_HAVE_KVM_IRQ_ROUTING y | |
133 | set_kernel_config CONFIG_HAVE_KVM_MSI y |
|
133 | set_kernel_config CONFIG_HAVE_KVM_MSI y | |
134 | set_kernel_config CONFIG_KVM y |
|
134 | set_kernel_config CONFIG_KVM y | |
135 | set_kernel_config CONFIG_KVM_ARM_HOST y |
|
135 | set_kernel_config CONFIG_KVM_ARM_HOST y | |
136 | set_kernel_config CONFIG_KVM_ARM_PMU y |
|
136 | set_kernel_config CONFIG_KVM_ARM_PMU y | |
137 | set_kernel_config CONFIG_KVM_COMPAT y |
|
137 | set_kernel_config CONFIG_KVM_COMPAT y | |
138 | set_kernel_config CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT y |
|
138 | set_kernel_config CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT y | |
139 | set_kernel_config CONFIG_KVM_MMIO y |
|
139 | set_kernel_config CONFIG_KVM_MMIO y | |
140 | set_kernel_config CONFIG_KVM_VFIO y |
|
140 | set_kernel_config CONFIG_KVM_VFIO y | |
141 | set_kernel_config CONFIG_VHOST m |
|
141 | set_kernel_config CONFIG_VHOST m | |
142 | set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y |
|
142 | set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y | |
143 | set_kernel_config CONFIG_VHOST_NET m |
|
143 | set_kernel_config CONFIG_VHOST_NET m | |
144 | set_kernel_config CONFIG_VIRTUALIZATION y |
|
144 | set_kernel_config CONFIG_VIRTUALIZATION y | |
145 |
|
145 | |||
146 | set_kernel_config CONFIG_MMU_NOTIFIER y |
|
146 | set_kernel_config CONFIG_MMU_NOTIFIER y | |
147 |
|
147 | |||
148 | # erratum |
|
148 | # erratum | |
149 | set_kernel_config ARM64_ERRATUM_834220 y |
|
149 | set_kernel_config ARM64_ERRATUM_834220 y | |
150 |
|
150 | |||
151 | # https://sourceforge.net/p/kvm/mailman/message/18440797/ |
|
151 | # https://sourceforge.net/p/kvm/mailman/message/18440797/ | |
152 | set_kernel_config CONFIG_PREEMPT_NOTIFIERS y |
|
152 | set_kernel_config CONFIG_PREEMPT_NOTIFIERS y | |
153 | fi |
|
153 | fi | |
154 |
|
154 | |||
155 | # enable apparmor,integrity audit, |
|
155 | # enable apparmor,integrity audit, | |
156 | if [ "$KERNEL_SECURITY" = true ] ; then |
|
156 | if [ "$KERNEL_SECURITY" = true ] ; then | |
157 |
|
157 | |||
158 | # security filesystem, security models and audit |
|
158 | # security filesystem, security models and audit | |
159 | set_kernel_config CONFIG_SECURITYFS y |
|
159 | set_kernel_config CONFIG_SECURITYFS y | |
160 | set_kernel_config CONFIG_SECURITY y |
|
160 | set_kernel_config CONFIG_SECURITY y | |
161 | set_kernel_config CONFIG_AUDIT y |
|
161 | set_kernel_config CONFIG_AUDIT y | |
162 |
|
162 | |||
163 | # harden strcpy and memcpy |
|
163 | # harden strcpy and memcpy | |
164 | set_kernel_config CONFIG_HARDENED_USERCOPY y |
|
164 | set_kernel_config CONFIG_HARDENED_USERCOPY y | |
165 | set_kernel_config CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR y |
|
165 | set_kernel_config CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR y | |
166 | set_kernel_config CONFIG_FORTIFY_SOURCE y |
|
166 | set_kernel_config CONFIG_FORTIFY_SOURCE y | |
167 |
|
167 | |||
168 | # integrity sub-system |
|
168 | # integrity sub-system | |
169 | set_kernel_config CONFIG_INTEGRITY y |
|
169 | set_kernel_config CONFIG_INTEGRITY y | |
170 | set_kernel_config CONFIG_INTEGRITY_ASYMMETRIC_KEYS y |
|
170 | set_kernel_config CONFIG_INTEGRITY_ASYMMETRIC_KEYS y | |
171 | set_kernel_config CONFIG_INTEGRITY_AUDIT y |
|
171 | set_kernel_config CONFIG_INTEGRITY_AUDIT y | |
172 | set_kernel_config CONFIG_INTEGRITY_SIGNATURE y |
|
172 | set_kernel_config CONFIG_INTEGRITY_SIGNATURE y | |
173 | set_kernel_config CONFIG_INTEGRITY_TRUSTED_KEYRING y |
|
173 | set_kernel_config CONFIG_INTEGRITY_TRUSTED_KEYRING y | |
174 |
|
174 | |||
175 | # This option provides support for retaining authentication tokens and access keys in the kernel. |
|
175 | # This option provides support for retaining authentication tokens and access keys in the kernel. | |
176 | set_kernel_config CONFIG_KEYS y |
|
176 | set_kernel_config CONFIG_KEYS y | |
177 | set_kernel_config CONFIG_KEYS_COMPAT y |
|
177 | set_kernel_config CONFIG_KEYS_COMPAT y | |
178 |
|
178 | |||
179 | # Apparmor |
|
179 | # Apparmor | |
180 | set_kernel_config CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE 0 |
|
180 | set_kernel_config CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE 0 | |
181 | set_kernel_config CONFIG_SECURITY_APPARMOR_HASH_DEFAULT y |
|
181 | set_kernel_config CONFIG_SECURITY_APPARMOR_HASH_DEFAULT y | |
182 | set_kernel_config CONFIG_DEFAULT_SECURITY_APPARMOR y |
|
182 | set_kernel_config CONFIG_DEFAULT_SECURITY_APPARMOR y | |
183 | set_kernel_config CONFIG_SECURITY_APPARMOR y |
|
183 | set_kernel_config CONFIG_SECURITY_APPARMOR y | |
184 | set_kernel_config CONFIG_SECURITY_APPARMOR_HASH y |
|
184 | set_kernel_config CONFIG_SECURITY_APPARMOR_HASH y | |
185 | set_kernel_config CONFIG_DEFAULT_SECURITY "apparmor" |
|
185 | set_kernel_config CONFIG_DEFAULT_SECURITY "apparmor" | |
186 |
|
186 | |||
187 | # restrictions on unprivileged users reading the kernel |
|
187 | # restrictions on unprivileged users reading the kernel | |
188 | set_kernel_config CONFIG_SECURITY_DMESG_RESTRICT y |
|
188 | set_kernel_config CONFIG_SECURITY_DMESG_RESTRICT y | |
189 |
|
189 | |||
190 | # network security hooks |
|
190 | # network security hooks | |
191 | set_kernel_config CONFIG_SECURITY_NETWORK y |
|
191 | set_kernel_config CONFIG_SECURITY_NETWORK y | |
192 | set_kernel_config CONFIG_SECURITY_NETWORK_XFRM y |
|
192 | set_kernel_config CONFIG_SECURITY_NETWORK_XFRM y | |
193 | set_kernel_config CONFIG_SECURITY_PATH y |
|
193 | set_kernel_config CONFIG_SECURITY_PATH y | |
194 | set_kernel_config CONFIG_SECURITY_YAMA n |
|
194 | set_kernel_config CONFIG_SECURITY_YAMA n | |
195 |
|
195 | |||
196 | # New Options |
|
196 | # New Options | |
197 | if [ "$KERNEL_NF" = true ] ; then |
|
197 | if [ "$KERNEL_NF" = true ] ; then | |
198 | set_kernel_config CONFIG_IP_NF_SECURITY m |
|
198 | set_kernel_config CONFIG_IP_NF_SECURITY m | |
199 | set_kernel_config CONFIG_NETLABEL y |
|
199 | set_kernel_config CONFIG_NETLABEL y | |
200 | set_kernel_config CONFIG_IP6_NF_SECURITY m |
|
200 | set_kernel_config CONFIG_IP6_NF_SECURITY m | |
201 | fi |
|
201 | fi | |
202 | set_kernel_config CONFIG_SECURITY_SELINUX n |
|
202 | set_kernel_config CONFIG_SECURITY_SELINUX n | |
203 | set_kernel_config CONFIG_SECURITY_SMACK n |
|
203 | set_kernel_config CONFIG_SECURITY_SMACK n | |
204 | set_kernel_config CONFIG_SECURITY_TOMOYO n |
|
204 | set_kernel_config CONFIG_SECURITY_TOMOYO n | |
205 | set_kernel_config CONFIG_SECURITY_APPARMOR_DEBUG n |
|
205 | set_kernel_config CONFIG_SECURITY_APPARMOR_DEBUG n | |
206 | set_kernel_config CONFIG_SECURITY_LOADPIN n |
|
206 | set_kernel_config CONFIG_SECURITY_LOADPIN n | |
207 | set_kernel_config CONFIG_HARDENED_USERCOPY_PAGESPAN n |
|
207 | set_kernel_config CONFIG_HARDENED_USERCOPY_PAGESPAN n | |
208 | set_kernel_config CONFIG_IMA n |
|
208 | set_kernel_config CONFIG_IMA n | |
209 | set_kernel_config CONFIG_EVM n |
|
209 | set_kernel_config CONFIG_EVM n | |
210 | set_kernel_config CONFIG_FANOTIFY_ACCESS_PERMISSIONS y |
|
210 | set_kernel_config CONFIG_FANOTIFY_ACCESS_PERMISSIONS y | |
211 | set_kernel_config CONFIG_NFSD_V4_SECURITY_LABEL y |
|
211 | set_kernel_config CONFIG_NFSD_V4_SECURITY_LABEL y | |
212 | set_kernel_config CONFIG_PKCS7_MESSAGE_PARSER y |
|
212 | set_kernel_config CONFIG_PKCS7_MESSAGE_PARSER y | |
213 | set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYRING y |
|
213 | set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYRING y | |
214 | set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS y |
|
214 | set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS y | |
215 | set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE y |
|
215 | set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE y | |
216 | set_kernel_config CONFIG_SECONDARY_TRUSTED_KEYRING y |
|
216 | set_kernel_config CONFIG_SECONDARY_TRUSTED_KEYRING y | |
217 | set_kernel_config CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY n |
|
217 | set_kernel_config CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY n | |
218 | set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS m |
|
218 | set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS m | |
219 | set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096 |
|
219 | set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096 | |
220 |
|
220 | |||
221 | set_kernel_config CONFIG_ARM64_CRYPTO y |
|
221 | set_kernel_config CONFIG_ARM64_CRYPTO y | |
222 | set_kernel_config CONFIG_CRYPTO_SHA256_ARM64 m |
|
222 | set_kernel_config CONFIG_CRYPTO_SHA256_ARM64 m | |
223 | set_kernel_config CONFIG_CRYPTO_SHA512_ARM64 m |
|
223 | set_kernel_config CONFIG_CRYPTO_SHA512_ARM64 m | |
224 | set_kernel_config CONFIG_CRYPTO_SHA1_ARM64_CE m |
|
224 | set_kernel_config CONFIG_CRYPTO_SHA1_ARM64_CE m | |
225 | set_kernel_config CRYPTO_GHASH_ARM64_CE m |
|
225 | set_kernel_config CRYPTO_GHASH_ARM64_CE m | |
226 | set_kernel_config CRYPTO_SHA2_ARM64_CE m |
|
226 | set_kernel_config CRYPTO_SHA2_ARM64_CE m | |
227 | set_kernel_config CONFIG_CRYPTO_CRCT10DIF_ARM64_CE m |
|
227 | set_kernel_config CONFIG_CRYPTO_CRCT10DIF_ARM64_CE m | |
228 | set_kernel_config CONFIG_CRYPTO_CRC32_ARM64_CE m |
|
228 | set_kernel_config CONFIG_CRYPTO_CRC32_ARM64_CE m | |
229 | set_kernel_config CONFIG_CRYPTO_AES_ARM64 m |
|
229 | set_kernel_config CONFIG_CRYPTO_AES_ARM64 m | |
230 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE m |
|
230 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE m | |
231 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_CCM y |
|
231 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_CCM y | |
232 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_BLK y |
|
232 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_BLK y | |
233 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_NEON_BLK m |
|
233 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_NEON_BLK m | |
234 | set_kernel_config CONFIG_CRYPTO_CHACHA20_NEON m |
|
234 | set_kernel_config CONFIG_CRYPTO_CHACHA20_NEON m | |
235 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_BS m |
|
235 | set_kernel_config CONFIG_CRYPTO_AES_ARM64_BS m | |
236 | set_kernel_config SYSTEM_TRUSTED_KEYS |
|
236 | set_kernel_config SYSTEM_TRUSTED_KEYS | |
237 | fi |
|
237 | fi | |
238 |
|
238 | |||
239 | # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406 |
|
239 | # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406 | |
240 | if [ "$KERNEL_NF" = true ] ; then |
|
240 | if [ "$KERNEL_NF" = true ] ; then | |
241 | set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m |
|
241 | set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m | |
242 | set_kernel_config CONFIG_NETFILTER_XT_TARGET_AUDIT m |
|
242 | set_kernel_config CONFIG_NETFILTER_XT_TARGET_AUDIT m | |
243 | set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m |
|
243 | set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m | |
244 | set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m |
|
244 | set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m | |
245 | set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m |
|
245 | set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m | |
246 | set_kernel_config CONFIG_NFT_FIB_INET m |
|
246 | set_kernel_config CONFIG_NFT_FIB_INET m | |
247 | set_kernel_config CONFIG_NFT_FIB_IPV4 m |
|
247 | set_kernel_config CONFIG_NFT_FIB_IPV4 m | |
248 | set_kernel_config CONFIG_NFT_FIB_IPV6 m |
|
248 | set_kernel_config CONFIG_NFT_FIB_IPV6 m | |
249 | set_kernel_config CONFIG_NFT_FIB_NETDEV m |
|
249 | set_kernel_config CONFIG_NFT_FIB_NETDEV m | |
250 | set_kernel_config CONFIG_NFT_OBJREF m |
|
250 | set_kernel_config CONFIG_NFT_OBJREF m | |
251 | set_kernel_config CONFIG_NFT_RT m |
|
251 | set_kernel_config CONFIG_NFT_RT m | |
252 | set_kernel_config CONFIG_NFT_SET_BITMAP m |
|
252 | set_kernel_config CONFIG_NFT_SET_BITMAP m | |
253 | set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y |
|
253 | set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y | |
254 | set_kernel_config CONFIG_NF_LOG_ARP m |
|
254 | set_kernel_config CONFIG_NF_LOG_ARP m | |
255 | set_kernel_config CONFIG_NF_SOCKET_IPV4 m |
|
255 | set_kernel_config CONFIG_NF_SOCKET_IPV4 m | |
256 | set_kernel_config CONFIG_NF_SOCKET_IPV6 m |
|
256 | set_kernel_config CONFIG_NF_SOCKET_IPV6 m | |
257 | set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m |
|
257 | set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m | |
258 | set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m |
|
258 | set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m | |
259 | set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m |
|
259 | set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m | |
260 | set_kernel_config CONFIG_IP6_NF_IPTABLES m |
|
260 | set_kernel_config CONFIG_IP6_NF_IPTABLES m | |
261 | set_kernel_config CONFIG_IP6_NF_MATCH_AH m |
|
261 | set_kernel_config CONFIG_IP6_NF_MATCH_AH m | |
262 | set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m |
|
262 | set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m | |
263 | set_kernel_config CONFIG_IP6_NF_NAT m |
|
263 | set_kernel_config CONFIG_IP6_NF_NAT m | |
264 | set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m |
|
264 | set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m | |
265 | set_kernel_config CONFIG_IP6_NF_TARGET_NPT m |
|
265 | set_kernel_config CONFIG_IP6_NF_TARGET_NPT m | |
266 | set_kernel_config CONFIG_IP_NF_SECURITY m |
|
266 | set_kernel_config CONFIG_IP_NF_SECURITY m | |
267 | set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m |
|
267 | set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m | |
268 | set_kernel_config CONFIG_IP_SET_BITMAP_PORT m |
|
268 | set_kernel_config CONFIG_IP_SET_BITMAP_PORT m | |
269 | set_kernel_config CONFIG_IP_SET_HASH_IP m |
|
269 | set_kernel_config CONFIG_IP_SET_HASH_IP m | |
270 | set_kernel_config CONFIG_IP_SET_HASH_IPMARK m |
|
270 | set_kernel_config CONFIG_IP_SET_HASH_IPMARK m | |
271 | set_kernel_config CONFIG_IP_SET_HASH_IPPORT m |
|
271 | set_kernel_config CONFIG_IP_SET_HASH_IPPORT m | |
272 | set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m |
|
272 | set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m | |
273 | set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m |
|
273 | set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m | |
274 | set_kernel_config CONFIG_IP_SET_HASH_MAC m |
|
274 | set_kernel_config CONFIG_IP_SET_HASH_MAC m | |
275 | set_kernel_config CONFIG_IP_SET_HASH_NET m |
|
275 | set_kernel_config CONFIG_IP_SET_HASH_NET m | |
276 | set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m |
|
276 | set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m | |
277 | set_kernel_config CONFIG_IP_SET_HASH_NETNET m |
|
277 | set_kernel_config CONFIG_IP_SET_HASH_NETNET m | |
278 | set_kernel_config CONFIG_IP_SET_HASH_NETPORT m |
|
278 | set_kernel_config CONFIG_IP_SET_HASH_NETPORT m | |
279 | set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m |
|
279 | set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m | |
280 | set_kernel_config CONFIG_IP_SET_LIST_SET m |
|
280 | set_kernel_config CONFIG_IP_SET_LIST_SET m | |
281 | set_kernel_config CONFIG_NETFILTER_XTABLES m |
|
281 | set_kernel_config CONFIG_NETFILTER_XTABLES m | |
282 | set_kernel_config CONFIG_NETFILTER_XTABLES m |
|
282 | set_kernel_config CONFIG_NETFILTER_XTABLES m | |
283 | set_kernel_config CONFIG_NFT_BRIDGE_META m |
|
283 | set_kernel_config CONFIG_NFT_BRIDGE_META m | |
284 | set_kernel_config CONFIG_NFT_BRIDGE_REJECT m |
|
284 | set_kernel_config CONFIG_NFT_BRIDGE_REJECT m | |
285 | set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m |
|
285 | set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m | |
286 | set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m |
|
286 | set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m | |
287 | set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m |
|
287 | set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m | |
288 | set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m |
|
288 | set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m | |
289 | set_kernel_config CONFIG_NFT_COMPAT m |
|
289 | set_kernel_config CONFIG_NFT_COMPAT m | |
290 | set_kernel_config CONFIG_NFT_COUNTER m |
|
290 | set_kernel_config CONFIG_NFT_COUNTER m | |
291 | set_kernel_config CONFIG_NFT_CT m |
|
291 | set_kernel_config CONFIG_NFT_CT m | |
292 | set_kernel_config CONFIG_NFT_DUP_IPV4 m |
|
292 | set_kernel_config CONFIG_NFT_DUP_IPV4 m | |
293 | set_kernel_config CONFIG_NFT_DUP_IPV6 m |
|
293 | set_kernel_config CONFIG_NFT_DUP_IPV6 m | |
294 | set_kernel_config CONFIG_NFT_DUP_NETDEV m |
|
294 | set_kernel_config CONFIG_NFT_DUP_NETDEV m | |
295 | set_kernel_config CONFIG_NFT_EXTHDR m |
|
295 | set_kernel_config CONFIG_NFT_EXTHDR m | |
296 | set_kernel_config CONFIG_NFT_FWD_NETDEV m |
|
296 | set_kernel_config CONFIG_NFT_FWD_NETDEV m | |
297 | set_kernel_config CONFIG_NFT_HASH m |
|
297 | set_kernel_config CONFIG_NFT_HASH m | |
298 | set_kernel_config CONFIG_NFT_LIMIT m |
|
298 | set_kernel_config CONFIG_NFT_LIMIT m | |
299 | set_kernel_config CONFIG_NFT_LOG m |
|
299 | set_kernel_config CONFIG_NFT_LOG m | |
300 | set_kernel_config CONFIG_NFT_MASQ m |
|
300 | set_kernel_config CONFIG_NFT_MASQ m | |
301 | set_kernel_config CONFIG_NFT_MASQ_IPV4 m |
|
301 | set_kernel_config CONFIG_NFT_MASQ_IPV4 m | |
302 | set_kernel_config CONFIG_NFT_MASQ_IPV6 m |
|
302 | set_kernel_config CONFIG_NFT_MASQ_IPV6 m | |
303 | set_kernel_config CONFIG_NFT_META m |
|
303 | set_kernel_config CONFIG_NFT_META m | |
304 | set_kernel_config CONFIG_NFT_NAT m |
|
304 | set_kernel_config CONFIG_NFT_NAT m | |
305 | set_kernel_config CONFIG_NFT_NUMGEN m |
|
305 | set_kernel_config CONFIG_NFT_NUMGEN m | |
306 | set_kernel_config CONFIG_NFT_QUEUE m |
|
306 | set_kernel_config CONFIG_NFT_QUEUE m | |
307 | set_kernel_config CONFIG_NFT_QUOTA m |
|
307 | set_kernel_config CONFIG_NFT_QUOTA m | |
308 | set_kernel_config CONFIG_NFT_REDIR m |
|
308 | set_kernel_config CONFIG_NFT_REDIR m | |
309 | set_kernel_config CONFIG_NFT_REDIR_IPV4 m |
|
309 | set_kernel_config CONFIG_NFT_REDIR_IPV4 m | |
310 | set_kernel_config CONFIG_NFT_REDIR_IPV6 m |
|
310 | set_kernel_config CONFIG_NFT_REDIR_IPV6 m | |
311 | set_kernel_config CONFIG_NFT_REJECT m |
|
311 | set_kernel_config CONFIG_NFT_REJECT m | |
312 | set_kernel_config CONFIG_NFT_REJECT_INET m |
|
312 | set_kernel_config CONFIG_NFT_REJECT_INET m | |
313 | set_kernel_config CONFIG_NFT_REJECT_IPV4 m |
|
313 | set_kernel_config CONFIG_NFT_REJECT_IPV4 m | |
314 | set_kernel_config CONFIG_NFT_REJECT_IPV6 m |
|
314 | set_kernel_config CONFIG_NFT_REJECT_IPV6 m | |
315 | set_kernel_config CONFIG_NFT_SET_HASH m |
|
315 | set_kernel_config CONFIG_NFT_SET_HASH m | |
316 | set_kernel_config CONFIG_NFT_SET_RBTREE m |
|
316 | set_kernel_config CONFIG_NFT_SET_RBTREE m | |
317 | set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m |
|
317 | set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m | |
318 | set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m |
|
318 | set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m | |
319 | set_kernel_config CONFIG_NF_DEFRAG_IPV4 m |
|
319 | set_kernel_config CONFIG_NF_DEFRAG_IPV4 m | |
320 | set_kernel_config CONFIG_NF_DEFRAG_IPV6 m |
|
320 | set_kernel_config CONFIG_NF_DEFRAG_IPV6 m | |
321 | set_kernel_config CONFIG_NF_DUP_IPV4 m |
|
321 | set_kernel_config CONFIG_NF_DUP_IPV4 m | |
322 | set_kernel_config CONFIG_NF_DUP_IPV6 m |
|
322 | set_kernel_config CONFIG_NF_DUP_IPV6 m | |
323 | set_kernel_config CONFIG_NF_DUP_NETDEV m |
|
323 | set_kernel_config CONFIG_NF_DUP_NETDEV m | |
324 | set_kernel_config CONFIG_NF_LOG_BRIDGE m |
|
324 | set_kernel_config CONFIG_NF_LOG_BRIDGE m | |
325 | set_kernel_config CONFIG_NF_LOG_IPV4 m |
|
325 | set_kernel_config CONFIG_NF_LOG_IPV4 m | |
326 | set_kernel_config CONFIG_NF_LOG_IPV6 m |
|
326 | set_kernel_config CONFIG_NF_LOG_IPV6 m | |
327 | set_kernel_config CONFIG_NF_NAT_IPV4 m |
|
327 | set_kernel_config CONFIG_NF_NAT_IPV4 m | |
328 | set_kernel_config CONFIG_NF_NAT_IPV6 m |
|
328 | set_kernel_config CONFIG_NF_NAT_IPV6 m | |
329 | set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 m |
|
329 | set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 m | |
330 | set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 m |
|
330 | set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 m | |
331 | set_kernel_config CONFIG_NF_NAT_PPTP m |
|
331 | set_kernel_config CONFIG_NF_NAT_PPTP m | |
332 | set_kernel_config CONFIG_NF_NAT_PROTO_GRE m |
|
332 | set_kernel_config CONFIG_NF_NAT_PROTO_GRE m | |
333 | set_kernel_config CONFIG_NF_NAT_REDIRECT m |
|
333 | set_kernel_config CONFIG_NF_NAT_REDIRECT m | |
334 | set_kernel_config CONFIG_NF_NAT_SIP m |
|
334 | set_kernel_config CONFIG_NF_NAT_SIP m | |
335 | set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m |
|
335 | set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m | |
336 | set_kernel_config CONFIG_NF_NAT_TFTP m |
|
336 | set_kernel_config CONFIG_NF_NAT_TFTP m | |
337 | set_kernel_config CONFIG_NF_REJECT_IPV4 m |
|
337 | set_kernel_config CONFIG_NF_REJECT_IPV4 m | |
338 | set_kernel_config CONFIG_NF_REJECT_IPV6 m |
|
338 | set_kernel_config CONFIG_NF_REJECT_IPV6 m | |
339 | set_kernel_config CONFIG_NF_TABLES m |
|
339 | set_kernel_config CONFIG_NF_TABLES m | |
340 | set_kernel_config CONFIG_NF_TABLES_ARP m |
|
340 | set_kernel_config CONFIG_NF_TABLES_ARP m | |
341 | set_kernel_config CONFIG_NF_TABLES_BRIDGE m |
|
341 | set_kernel_config CONFIG_NF_TABLES_BRIDGE m | |
342 | set_kernel_config CONFIG_NF_TABLES_INET m |
|
342 | set_kernel_config CONFIG_NF_TABLES_INET m | |
343 | set_kernel_config CONFIG_NF_TABLES_IPV4 m |
|
343 | set_kernel_config CONFIG_NF_TABLES_IPV4 m | |
344 | set_kernel_config CONFIG_NF_TABLES_IPV6 m |
|
344 | set_kernel_config CONFIG_NF_TABLES_IPV6 m | |
345 | set_kernel_config CONFIG_NF_TABLES_NETDEV m |
|
345 | set_kernel_config CONFIG_NF_TABLES_NETDEV m | |
346 | fi |
|
346 | fi | |
347 |
|
347 | |||
348 | # Enables BPF syscall for systemd-journald see https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 or https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA |
|
348 | # Enables BPF syscall for systemd-journald see https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 or https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA | |
349 | if [ "$KERNEL_BPF" = true ] ; then |
|
349 | if [ "$KERNEL_BPF" = true ] ; then | |
350 | set_kernel_config CONFIG_BPF_SYSCALL y |
|
350 | set_kernel_config CONFIG_BPF_SYSCALL y | |
351 | set_kernel_config CONFIG_BPF_EVENTS y |
|
351 | set_kernel_config CONFIG_BPF_EVENTS y | |
352 | set_kernel_config CONFIG_BPF_STREAM_PARSER y |
|
352 | set_kernel_config CONFIG_BPF_STREAM_PARSER y | |
353 | set_kernel_config CONFIG_CGROUP_BPF y |
|
353 | set_kernel_config CONFIG_CGROUP_BPF y | |
354 | fi |
|
354 | fi | |
355 |
|
355 | |||
356 | # KERNEL_DEFAULT_GOV was set by user |
|
356 | # KERNEL_DEFAULT_GOV was set by user | |
357 | if [ "$KERNEL_DEFAULT_GOV" != powersave ] && [ -n "$KERNEL_DEFAULT_GOV" ] ; then |
|
357 | if [ "$KERNEL_DEFAULT_GOV" != powersave ] && [ -n "$KERNEL_DEFAULT_GOV" ] ; then | |
358 |
|
358 | |||
359 | case "$KERNEL_DEFAULT_GOV" in |
|
359 | case "$KERNEL_DEFAULT_GOV" in | |
360 | performance) |
|
360 | performance) | |
361 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y |
|
361 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y | |
362 | ;; |
|
362 | ;; | |
363 | userspace) |
|
363 | userspace) | |
364 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE y |
|
364 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE y | |
365 | ;; |
|
365 | ;; | |
366 | ondemand) |
|
366 | ondemand) | |
367 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND y |
|
367 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND y | |
368 | ;; |
|
368 | ;; | |
369 | conservative) |
|
369 | conservative) | |
370 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE y |
|
370 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE y | |
371 | ;; |
|
371 | ;; | |
372 | shedutil) |
|
372 | shedutil) | |
373 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL y |
|
373 | set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL y | |
374 | ;; |
|
374 | ;; | |
375 | *) |
|
375 | *) | |
376 | echo "error: unsupported default cpu governor" |
|
376 | echo "error: unsupported default cpu governor" | |
377 | exit 1 |
|
377 | exit 1 | |
378 | ;; |
|
378 | ;; | |
379 | esac |
|
379 | esac | |
380 |
|
380 | |||
381 | # unset previous default governor |
|
381 | # unset previous default governor | |
382 | unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE |
|
382 | unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE | |
383 | fi |
|
383 | fi | |
384 |
|
384 | |||
385 | #Revert to previous directory |
|
385 | #Revert to previous directory | |
386 | cd "${WORKDIR}" || exit |
|
386 | cd "${WORKDIR}" || exit | |
387 |
|
387 | |||
388 | # Set kernel configuration parameters to enable qemu emulation |
|
388 | # Set kernel configuration parameters to enable qemu emulation | |
389 | if [ "$ENABLE_QEMU" = true ] ; then |
|
389 | if [ "$ENABLE_QEMU" = true ] ; then | |
390 | echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config |
|
390 | echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config | |
391 | echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config |
|
391 | echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config | |
392 |
|
392 | |||
393 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
393 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
394 | { |
|
394 | { | |
395 | echo "CONFIG_EMBEDDED=y" |
|
395 | echo "CONFIG_EMBEDDED=y" | |
396 | echo "CONFIG_EXPERT=y" |
|
396 | echo "CONFIG_EXPERT=y" | |
397 | echo "CONFIG_DAX=y" |
|
397 | echo "CONFIG_DAX=y" | |
398 | echo "CONFIG_MD=y" |
|
398 | echo "CONFIG_MD=y" | |
399 | echo "CONFIG_BLK_DEV_MD=y" |
|
399 | echo "CONFIG_BLK_DEV_MD=y" | |
400 | echo "CONFIG_MD_AUTODETECT=y" |
|
400 | echo "CONFIG_MD_AUTODETECT=y" | |
401 | echo "CONFIG_BLK_DEV_DM=y" |
|
401 | echo "CONFIG_BLK_DEV_DM=y" | |
402 | echo "CONFIG_BLK_DEV_DM_BUILTIN=y" |
|
402 | echo "CONFIG_BLK_DEV_DM_BUILTIN=y" | |
403 | echo "CONFIG_DM_CRYPT=y" |
|
403 | echo "CONFIG_DM_CRYPT=y" | |
404 | echo "CONFIG_CRYPTO_BLKCIPHER=y" |
|
404 | echo "CONFIG_CRYPTO_BLKCIPHER=y" | |
405 | echo "CONFIG_CRYPTO_CBC=y" |
|
405 | echo "CONFIG_CRYPTO_CBC=y" | |
406 | echo "CONFIG_CRYPTO_XTS=y" |
|
406 | echo "CONFIG_CRYPTO_XTS=y" | |
407 | echo "CONFIG_CRYPTO_SHA512=y" |
|
407 | echo "CONFIG_CRYPTO_SHA512=y" | |
408 | echo "CONFIG_CRYPTO_MANAGER=y" |
|
408 | echo "CONFIG_CRYPTO_MANAGER=y" | |
409 | } >> "${KERNEL_DIR}"/.config |
|
409 | } >> "${KERNEL_DIR}"/.config | |
410 | fi |
|
410 | fi | |
411 | fi |
|
411 | fi | |
412 |
|
412 | |||
413 | # Copy custom kernel configuration file |
|
413 | # Copy custom kernel configuration file | |
414 | if [ -n "$KERNELSRC_USRCONFIG" ] ; then |
|
414 | if [ -n "$KERNELSRC_USRCONFIG" ] ; then | |
415 | cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config |
|
415 | cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config | |
416 | fi |
|
416 | fi | |
417 |
|
417 | |||
418 | # Set kernel configuration parameters to their default values |
|
418 | # Set kernel configuration parameters to their default values | |
419 | if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then |
|
419 | if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then | |
420 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig |
|
420 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig | |
421 | fi |
|
421 | fi | |
422 |
|
422 | |||
423 | # Start menu-driven kernel configuration (interactive) |
|
423 | # Start menu-driven kernel configuration (interactive) | |
424 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
424 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |
425 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig |
|
425 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig | |
426 | fi |
|
426 | fi | |
427 | # end if "$KERNELSRC_CONFIG" = true |
|
427 | # end if "$KERNELSRC_CONFIG" = true | |
428 | fi |
|
428 | fi | |
429 |
|
429 | |||
430 | # Use ccache to cross compile the kernel |
|
430 | # Use ccache to cross compile the kernel | |
431 | if [ "$KERNEL_CCACHE" = true ] ; then |
|
431 | if [ "$KERNEL_CCACHE" = true ] ; then | |
432 | cc="ccache ${CROSS_COMPILE}gcc" |
|
432 | cc="ccache ${CROSS_COMPILE}gcc" | |
433 | else |
|
433 | else | |
434 | cc="${CROSS_COMPILE}gcc" |
|
434 | cc="${CROSS_COMPILE}gcc" | |
435 | fi |
|
435 | fi | |
436 |
|
436 | |||
437 | # Cross compile kernel and dtbs |
|
437 | # Cross compile kernel and dtbs | |
438 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs |
|
438 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs | |
439 |
|
439 | |||
440 | # Cross compile kernel modules |
|
440 | # Cross compile kernel modules | |
441 | if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then |
|
441 | if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then | |
442 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules |
|
442 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules | |
443 | fi |
|
443 | fi | |
444 | # end if "$KERNELSRC_PREBUILT" = false |
|
444 | # end if "$KERNELSRC_PREBUILT" = false | |
445 | fi |
|
445 | fi | |
446 |
|
446 | |||
447 | # Check if kernel compilation was successful |
|
447 | # Check if kernel compilation was successful | |
448 | if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then |
|
448 | if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then | |
449 | echo "error: kernel compilation failed! (kernel image not found)" |
|
449 | echo "error: kernel compilation failed! (kernel image not found)" | |
450 | cleanup |
|
450 | cleanup | |
451 | exit 1 |
|
451 | exit 1 | |
452 | fi |
|
452 | fi | |
453 |
|
453 | |||
454 | # Install kernel modules |
|
454 | # Install kernel modules | |
455 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
455 | if [ "$ENABLE_REDUCE" = true ] ; then | |
456 | if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then |
|
456 | if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then | |
457 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install |
|
457 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install | |
458 | fi |
|
458 | fi | |
459 | else |
|
459 | else | |
460 | if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then |
|
460 | if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then | |
461 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install |
|
461 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install | |
462 | fi |
|
462 | fi | |
463 |
|
463 | |||
464 | # Install kernel firmware |
|
464 | # Install kernel firmware | |
465 | if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then |
|
465 | if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then | |
466 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install |
|
466 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install | |
467 | fi |
|
467 | fi | |
468 | fi |
|
468 | fi | |
469 |
|
469 | |||
470 | # Install kernel headers |
|
470 | # Install kernel headers | |
471 | if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then |
|
471 | if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then | |
472 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install |
|
472 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install | |
473 | fi |
|
473 | fi | |
474 |
|
474 | |||
475 | # Prepare boot (firmware) directory |
|
475 | # Prepare boot (firmware) directory | |
476 | mkdir "${BOOT_DIR}" |
|
476 | mkdir "${BOOT_DIR}" | |
477 |
|
477 | |||
478 | # Get kernel release version |
|
478 | # Get kernel release version | |
479 | KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release") |
|
479 | KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release") | |
480 |
|
480 | |||
481 | # Copy kernel configuration file to the boot directory |
|
481 | # Copy kernel configuration file to the boot directory | |
482 | install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}" |
|
482 | install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}" | |
483 |
|
483 | |||
484 | # Prepare device tree directory |
|
484 | # Prepare device tree directory | |
485 | mkdir "${BOOT_DIR}/overlays" |
|
485 | mkdir "${BOOT_DIR}/overlays" | |
486 |
|
486 | |||
487 | # Ensure the proper .dtb is located |
|
487 | # Ensure the proper .dtb is located | |
488 | if [ "$KERNEL_ARCH" = "arm" ] ; then |
|
488 | if [ "$KERNEL_ARCH" = "arm" ] ; then | |
489 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do |
|
489 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do | |
490 | if [ -f "${dtb}" ] ; then |
|
490 | if [ -f "${dtb}" ] ; then | |
491 | install_readonly "${dtb}" "${BOOT_DIR}/" |
|
491 | install_readonly "${dtb}" "${BOOT_DIR}/" | |
492 | fi |
|
492 | fi | |
493 | done |
|
493 | done | |
494 | else |
|
494 | else | |
495 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do |
|
495 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do | |
496 | if [ -f "${dtb}" ] ; then |
|
496 | if [ -f "${dtb}" ] ; then | |
497 | install_readonly "${dtb}" "${BOOT_DIR}/" |
|
497 | install_readonly "${dtb}" "${BOOT_DIR}/" | |
498 | fi |
|
498 | fi | |
499 | done |
|
499 | done | |
500 | fi |
|
500 | fi | |
501 |
|
501 | |||
502 | # Copy compiled dtb device tree files |
|
502 | # Copy compiled dtb device tree files | |
503 | if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then |
|
503 | if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then | |
504 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtbo ; do |
|
504 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtbo ; do | |
505 | if [ -f "${dtb}" ] ; then |
|
505 | if [ -f "${dtb}" ] ; then | |
506 | install_readonly "${dtb}" "${BOOT_DIR}/overlays/" |
|
506 | install_readonly "${dtb}" "${BOOT_DIR}/overlays/" | |
507 | fi |
|
507 | fi | |
508 | done |
|
508 | done | |
509 |
|
509 | |||
510 | if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then |
|
510 | if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then | |
511 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README" |
|
511 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README" | |
512 | fi |
|
512 | fi | |
513 | fi |
|
513 | fi | |
514 |
|
514 | |||
515 | if [ "$ENABLE_UBOOT" = false ] ; then |
|
515 | if [ "$ENABLE_UBOOT" = false ] ; then | |
516 | # Convert and copy kernel image to the boot directory |
|
516 | # Convert and copy kernel image to the boot directory | |
517 | "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
517 | "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" | |
518 | else |
|
518 | else | |
519 | # Copy kernel image to the boot directory |
|
519 | # Copy kernel image to the boot directory | |
520 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
520 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" | |
521 | fi |
|
521 | fi | |
522 |
|
522 | |||
523 | # Remove kernel sources |
|
523 | # Remove kernel sources | |
524 | if [ "$KERNEL_REMOVESRC" = true ] ; then |
|
524 | if [ "$KERNEL_REMOVESRC" = true ] ; then | |
525 | rm -fr "${KERNEL_DIR}" |
|
525 | rm -fr "${KERNEL_DIR}" | |
526 | else |
|
526 | else | |
527 | # Prepare compiled kernel modules |
|
527 | # Prepare compiled kernel modules | |
528 | if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then |
|
528 | if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then | |
529 | if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then |
|
529 | if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then | |
530 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare |
|
530 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare | |
531 | fi |
|
531 | fi | |
532 |
|
532 | |||
533 | # Create symlinks for kernel modules |
|
533 | # Create symlinks for kernel modules | |
534 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build" |
|
534 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build" | |
535 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source" |
|
535 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source" | |
536 | fi |
|
536 | fi | |
537 | fi |
|
537 | fi | |
538 |
|
538 | |||
539 | else # BUILD_KERNEL=false |
|
539 | else # BUILD_KERNEL=false | |
540 | if [ "$SET_ARCH" = 64 ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then |
|
540 | if [ "$SET_ARCH" = 64 ] | |
541 |
|
541 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then | ||
542 | # Use Sakakis modified kernel if ZSWAP is active |
|
542 | # Use Sakakis modified kernel if ZSWAP is active | |
543 | if [ "$KERNEL_ZSWAP" = true ] || [ "$KERNEL_VIRT" = true ] || [ "$KERNEL_NF" = true ] || [ "$KERNEL_BPF" = true ] ; then |
|
543 | if [ "$KERNEL_ZSWAP" = true ] || [ "$KERNEL_VIRT" = true ] || [ "$KERNEL_NF" = true ] || [ "$KERNEL_BPF" = true ] ; then | |
544 | RPI3_64_KERNEL_URL="${RPI3_64_BIS_KERNEL_URL}" |
|
544 | RPI3_64_KERNEL_URL="${RPI3_64_BIS_KERNEL_URL}" | |
545 | fi |
|
545 | fi | |
546 |
|
546 | |||
547 | # Create temporary directory for dl |
|
547 | # Create temporary directory for dl | |
548 | temp_dir=$(as_nobody mktemp -d) |
|
548 | temp_dir=$(as_nobody mktemp -d) | |
549 |
|
549 | |||
550 | # Fetch kernel dl |
|
550 | # Fetch kernel dl | |
551 | as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL" |
|
551 | as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL" | |
|
552 | fi | |||
|
553 | if [ "$SET_ARCH" = 64 ] && [ "$RPI_MODEL" = 4 ] ; then | |||
|
554 | # Create temporary directory for dl | |||
|
555 | temp_dir=$(as_nobody mktemp -d) | |||
|
556 | ||||
|
557 | # Fetch kernel dl | |||
|
558 | as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI4_64_KERNEL_URL" | |||
|
559 | fi | |||
552 |
|
560 | |||
553 |
|
|
561 | #extract download | |
554 | tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}" |
|
562 | tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}" | |
555 |
|
563 | |||
556 | #move extracted kernel to /boot/firmware |
|
564 | #move extracted kernel to /boot/firmware | |
557 | mkdir "${R}/boot/firmware" |
|
565 | mkdir "${R}/boot/firmware" | |
558 | cp "${temp_dir}"/boot/* "${R}"/boot/firmware/ |
|
566 | cp "${temp_dir}"/boot/* "${R}"/boot/firmware/ | |
559 | cp -r "${temp_dir}"/lib/* "${R}"/lib/ |
|
567 | cp -r "${temp_dir}"/lib/* "${R}"/lib/ | |
560 |
|
568 | |||
561 | # Remove temporary directory for kernel sources |
|
569 | # Remove temporary directory for kernel sources | |
562 | rm -fr "${temp_dir}" |
|
570 | rm -fr "${temp_dir}" | |
563 |
|
571 | |||
564 | # Set permissions of the kernel sources |
|
572 | # Set permissions of the kernel sources | |
565 | chown -R root:root "${R}/boot/firmware" |
|
573 | chown -R root:root "${R}/boot/firmware" | |
566 | chown -R root:root "${R}/lib/modules" |
|
574 | chown -R root:root "${R}/lib/modules" | |
567 | fi |
|
575 | fi | |
568 |
|
576 | |||
569 | # Install Kernel from hypriot comptabile with all Raspberry PI |
|
577 | # Install Kernel from hypriot comptabile with all Raspberry PI (dunno if its compatible with RPI4 - better compile your own kernel) | |
570 | if [ "$SET_ARCH" = 32 ] ; then |
|
578 | if [ "$SET_ARCH" = 32 ] && [ "$RPI_MODEL" != 4 ] ; then | |
571 | # Create temporary directory for dl |
|
579 | # Create temporary directory for dl | |
572 | temp_dir=$(as_nobody mktemp -d) |
|
580 | temp_dir=$(as_nobody mktemp -d) | |
573 |
|
581 | |||
574 | # Fetch kernel |
|
582 | # Fetch kernel | |
575 | as_nobody wget -O "${temp_dir}"/kernel.deb -c "$RPI_32_KERNEL_URL" |
|
583 | as_nobody wget -O "${temp_dir}"/kernel.deb -c "$RPI_32_KERNEL_URL" | |
576 |
|
584 | |||
577 |
# Copy downloaded |
|
585 | # Copy downloaded kernel package | |
578 | mv "${temp_dir}"/kernel.deb "${R}"/tmp/kernel.deb |
|
586 | mv "${temp_dir}"/kernel.deb "${R}"/tmp/kernel.deb | |
579 |
|
587 | |||
580 | # Set permissions |
|
588 | # Set permissions | |
581 | chown -R root:root "${R}"/tmp/kernel.deb |
|
589 | chown -R root:root "${R}"/tmp/kernel.deb | |
582 |
|
590 | |||
583 | # Install kernel |
|
591 | # Install kernel | |
584 | chroot_exec dpkg -i /tmp/kernel.deb |
|
592 | chroot_exec dpkg -i /tmp/kernel.deb | |
585 |
|
593 | |||
586 | # move /boot to /boot/firmware to fit script env. |
|
594 | # move /boot to /boot/firmware to fit script env. | |
587 | #mkdir "${BOOT_DIR}" |
|
595 | #mkdir "${BOOT_DIR}" | |
588 | mkdir "${temp_dir}"/firmware |
|
596 | mkdir "${temp_dir}"/firmware | |
589 | mv "${R}"/boot/* "${temp_dir}"/firmware/ |
|
597 | mv "${R}"/boot/* "${temp_dir}"/firmware/ | |
590 | mv "${temp_dir}"/firmware "${R}"/boot/ |
|
598 | mv "${temp_dir}"/firmware "${R}"/boot/ | |
591 |
|
599 | |||
592 | #same for kernel headers |
|
600 | #same for kernel headers | |
593 | if [ "$KERNEL_HEADERS" = true ] ; then |
|
601 | if [ "$KERNEL_HEADERS" = true ] ; then | |
594 | # Fetch kernel header |
|
602 | # Fetch kernel header | |
595 | as_nobody wget -O "${temp_dir}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL" |
|
603 | as_nobody wget -O "${temp_dir}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL" | |
596 | mv "${temp_dir}"/kernel-header.deb "${R}"/tmp/kernel-header.deb |
|
604 | mv "${temp_dir}"/kernel-header.deb "${R}"/tmp/kernel-header.deb | |
597 | chown -R root:root "${R}"/tmp/kernel-header.deb |
|
605 | chown -R root:root "${R}"/tmp/kernel-header.deb | |
598 | # Install kernel header |
|
606 | # Install kernel header | |
599 | chroot_exec dpkg -i /tmp/kernel-header.deb |
|
607 | chroot_exec dpkg -i /tmp/kernel-header.deb | |
600 | rm -f "${R}"/tmp/kernel-header.deb |
|
608 | rm -f "${R}"/tmp/kernel-header.deb | |
601 | fi |
|
609 | fi | |
602 |
|
610 | |||
603 | # Remove temporary directory and files |
|
611 | # Remove temporary directory and files | |
604 | rm -fr "${temp_dir}" |
|
612 | rm -fr "${temp_dir}" | |
605 | rm -f "${R}"/tmp/kernel.deb |
|
613 | rm -f "${R}"/tmp/kernel.deb | |
606 | fi |
|
614 | fi | |
607 |
|
615 | |||
608 | # Check if kernel installation was successful |
|
616 | # Check if kernel installation was successful | |
609 | KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)" |
|
617 | KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)" | |
610 | if [ -z "$KERNEL" ] ; then |
|
618 | if [ -z "$KERNEL" ] ; then | |
611 | echo "error: kernel installation failed! (/boot/kernel* not found)" |
|
619 | echo "error: kernel installation failed! (/boot/kernel* not found)" | |
612 | cleanup |
|
620 | cleanup | |
613 | exit 1 |
|
621 | exit 1 | |
614 | fi |
|
622 | fi | |
615 | fi |
|
623 | fi |
@@ -1,300 +1,300 | |||||
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 [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then |
|
8 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then | |
9 | # Install boot binaries from local directory |
|
9 | # Install boot binaries from local directory | |
10 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin |
|
10 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin | |
11 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat |
|
11 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat | |
12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat |
|
12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat | |
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat |
|
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat | |
14 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf |
|
14 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf | |
15 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf |
|
15 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf | |
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf |
|
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf | |
17 | else |
|
17 | else | |
18 | # Create temporary directory for boot binaries |
|
18 | # Create temporary directory for boot binaries | |
19 | temp_dir=$(as_nobody mktemp -d) |
|
19 | temp_dir=$(as_nobody mktemp -d) | |
20 |
|
20 | |||
21 | # Install latest boot binaries from raspberry/firmware github |
|
21 | # Install latest boot binaries from raspberry/firmware github | |
22 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" |
|
22 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" | |
23 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" |
|
23 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" | |
24 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" |
|
24 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" | |
25 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" |
|
25 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" | |
26 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" |
|
26 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" | |
27 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" |
|
27 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" | |
28 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" |
|
28 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" | |
29 |
|
29 | |||
30 | # Move downloaded boot binaries |
|
30 | # Move downloaded boot binaries | |
31 | mv "${temp_dir}/"* "${BOOT_DIR}/" |
|
31 | mv "${temp_dir}/"* "${BOOT_DIR}/" | |
32 |
|
32 | |||
33 | # Remove temporary directory for boot binaries |
|
33 | # Remove temporary directory for boot binaries | |
34 | rm -fr "${temp_dir}" |
|
34 | rm -fr "${temp_dir}" | |
35 |
|
35 | |||
36 | # Set permissions of the boot binaries |
|
36 | # Set permissions of the boot binaries | |
37 | chown -R root:root "${BOOT_DIR}" |
|
37 | chown -R root:root "${BOOT_DIR}" | |
38 | chmod -R 600 "${BOOT_DIR}" |
|
38 | chmod -R 600 "${BOOT_DIR}" | |
39 | fi |
|
39 | fi | |
40 |
|
40 | |||
41 | # Setup firmware boot cmdline |
|
41 | # Setup firmware boot cmdline | |
42 | if [ "$ENABLE_USBBOOT" = true ] ; then |
|
42 | if [ "$ENABLE_USBBOOT" = true ] ; then | |
43 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" |
|
43 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" | |
44 | else |
|
44 | else | |
45 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
45 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
46 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" |
|
46 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" | |
47 | else |
|
47 | else | |
48 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" |
|
48 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" | |
49 | fi |
|
49 | fi | |
50 | fi |
|
50 | fi | |
51 |
|
51 | |||
52 | # Add encrypted root partition to cmdline.txt |
|
52 | # Add encrypted root partition to cmdline.txt | |
53 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
53 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
54 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
54 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
55 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") |
|
55 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") | |
56 | else |
|
56 | else | |
57 | if [ "$ENABLE_USBBOOT" = true ] ; then |
|
57 | if [ "$ENABLE_USBBOOT" = true ] ; then | |
58 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") |
|
58 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") | |
59 | else |
|
59 | else | |
60 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") |
|
60 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") | |
61 | fi |
|
61 | fi | |
62 | fi |
|
62 | fi | |
63 | fi |
|
63 | fi | |
64 |
|
64 | |||
65 | # Enable Kernel messages on standard output |
|
65 | # Enable Kernel messages on standard output | |
66 | if [ "$ENABLE_PRINTK" = true ] ; then |
|
66 | if [ "$ENABLE_PRINTK" = true ] ; then | |
67 | install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf" |
|
67 | install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf" | |
68 | fi |
|
68 | fi | |
69 |
|
69 | |||
70 | # Enable Kernel messages on standard output |
|
70 | # Enable Kernel messages on standard output | |
71 | if [ "$KERNEL_SECURITY" = true ] ; then |
|
71 | if [ "$KERNEL_SECURITY" = true ] ; then | |
72 | install_readonly files/sysctl.d/84-rpi-ASLR.conf "${ETC_DIR}/sysctl.d/84-rpi-ASLR.conf" |
|
72 | install_readonly files/sysctl.d/84-rpi-ASLR.conf "${ETC_DIR}/sysctl.d/84-rpi-ASLR.conf" | |
73 | fi |
|
73 | fi | |
74 |
|
74 | |||
75 | # Install udev rule for serial alias - serial0 = console serial1=bluetooth |
|
75 | # Install udev rule for serial alias - serial0 = console serial1=bluetooth | |
76 | install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules" |
|
76 | install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules" | |
77 |
|
77 | |||
78 | # Remove IPv6 networking support |
|
78 | # Remove IPv6 networking support | |
79 | if [ "$ENABLE_IPV6" = false ] ; then |
|
79 | if [ "$ENABLE_IPV6" = false ] ; then | |
80 | CMDLINE="${CMDLINE} ipv6.disable=1" |
|
80 | CMDLINE="${CMDLINE} ipv6.disable=1" | |
81 | fi |
|
81 | fi | |
82 |
|
82 | |||
83 | # Automatically assign predictable network interface names |
|
83 | # Automatically assign predictable network interface names | |
84 | if [ "$ENABLE_IFNAMES" = false ] ; then |
|
84 | if [ "$ENABLE_IFNAMES" = false ] ; then | |
85 | CMDLINE="${CMDLINE} net.ifnames=0" |
|
85 | CMDLINE="${CMDLINE} net.ifnames=0" | |
86 | else |
|
86 | else | |
87 | CMDLINE="${CMDLINE} net.ifnames=1" |
|
87 | CMDLINE="${CMDLINE} net.ifnames=1" | |
88 | fi |
|
88 | fi | |
89 |
|
89 | |||
90 | # Disable Raspberry Pi console logo |
|
90 | # Disable Raspberry Pi console logo | |
91 | if [ "$ENABLE_LOGO" = false ] ; then |
|
91 | if [ "$ENABLE_LOGO" = false ] ; then | |
92 | CMDLINE="${CMDLINE} logo.nologo" |
|
92 | CMDLINE="${CMDLINE} logo.nologo" | |
93 | fi |
|
93 | fi | |
94 |
|
94 | |||
95 | # Strictly limit verbosity of boot up console messages |
|
95 | # Strictly limit verbosity of boot up console messages | |
96 | if [ "$ENABLE_SILENT_BOOT" = true ] ; then |
|
96 | if [ "$ENABLE_SILENT_BOOT" = true ] ; then | |
97 | CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0" |
|
97 | CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0" | |
98 | fi |
|
98 | fi | |
99 |
|
99 | |||
100 | # Install firmware config |
|
100 | # Install firmware config | |
101 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" |
|
101 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" | |
102 |
|
102 | |||
103 | # Disable Raspberry Pi console logo |
|
103 | # Disable Raspberry Pi console logo | |
104 | if [ "$ENABLE_SLASH" = false ] ; then |
|
104 | if [ "$ENABLE_SLASH" = false ] ; then | |
105 | echo "disable_splash=1" >> "${BOOT_DIR}/config.txt" |
|
105 | echo "disable_splash=1" >> "${BOOT_DIR}/config.txt" | |
106 | fi |
|
106 | fi | |
107 |
|
107 | |||
108 | # Locks CPU frequency at maximum |
|
108 | # Locks CPU frequency at maximum | |
109 | if [ "$ENABLE_TURBO" = true ] ; then |
|
109 | if [ "$ENABLE_TURBO" = true ] ; then | |
110 | echo "force_turbo=1" >> "${BOOT_DIR}/config.txt" |
|
110 | echo "force_turbo=1" >> "${BOOT_DIR}/config.txt" | |
111 | # helps to avoid sdcard corruption when force_turbo is enabled. |
|
111 | # helps to avoid sdcard corruption when force_turbo is enabled. | |
112 | echo "boot_delay=1" >> "${BOOT_DIR}/config.txt" |
|
112 | echo "boot_delay=1" >> "${BOOT_DIR}/config.txt" | |
113 | fi |
|
113 | fi | |
114 |
|
114 | |||
115 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then |
|
115 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; then | |
116 |
|
116 | |||
117 | # Bluetooth enabled |
|
117 | # Bluetooth enabled | |
118 | if [ "$ENABLE_BLUETOOTH" = true ] ; then |
|
118 | if [ "$ENABLE_BLUETOOTH" = true ] ; then | |
119 | # Create temporary directory for Bluetooth sources |
|
119 | # Create temporary directory for Bluetooth sources | |
120 | temp_dir=$(as_nobody mktemp -d) |
|
120 | temp_dir=$(as_nobody mktemp -d) | |
121 |
|
121 | |||
122 | # Fetch Bluetooth sources |
|
122 | # Fetch Bluetooth sources | |
123 | as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" |
|
123 | as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" | |
124 |
|
124 | |||
125 | # Copy downloaded sources |
|
125 | # Copy downloaded sources | |
126 | mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" |
|
126 | mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" | |
127 |
|
127 | |||
128 | # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/ |
|
128 | # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/ | |
129 | as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth |
|
129 | as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth | |
130 | as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd |
|
130 | as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd | |
131 |
|
131 | |||
132 | # Set permissions |
|
132 | # Set permissions | |
133 | chown -R root:root "${R}/tmp/pi-bluetooth" |
|
133 | chown -R root:root "${R}/tmp/pi-bluetooth" | |
134 |
|
134 | |||
135 | # Install tools |
|
135 | # Install tools | |
136 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" |
|
136 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" | |
137 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" |
|
137 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" | |
138 |
|
138 | |||
139 | # make scripts executable |
|
139 | # make scripts executable | |
140 | chmod +x "${R}/usr/bin/bthelper" |
|
140 | chmod +x "${R}/usr/bin/bthelper" | |
141 | chmod +x "${R}/usr/bin/btuart" |
|
141 | chmod +x "${R}/usr/bin/btuart" | |
142 |
|
142 | |||
143 | # Install bluetooth udev rule |
|
143 | # Install bluetooth udev rule | |
144 | install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" |
|
144 | install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" | |
145 |
|
145 | |||
146 | # Install Firmware Flash file and apropiate licence |
|
146 | # Install Firmware Flash file and apropiate licence | |
147 | mkdir -p "$BLUETOOTH_FIRMWARE_DIR" |
|
147 | mkdir -p "$BLUETOOTH_FIRMWARE_DIR" | |
148 | install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx" |
|
148 | install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx" | |
149 | install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd" |
|
149 | install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd" | |
150 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" |
|
150 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" | |
151 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" |
|
151 | install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" | |
152 |
|
152 | |||
153 | # Remove temporary directories |
|
153 | # Remove temporary directories | |
154 | rm -fr "${temp_dir}" |
|
154 | rm -fr "${temp_dir}" | |
155 | rm -fr "${R}"/tmp/pi-bluetooth |
|
155 | rm -fr "${R}"/tmp/pi-bluetooth | |
156 |
|
156 | |||
157 | # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0 |
|
157 | # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0 | |
158 | if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then |
|
158 | if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then | |
159 | # set overlay to swap ttyAMA0 and ttyS0 |
|
159 | # set overlay to swap ttyAMA0 and ttyS0 | |
160 | echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt" |
|
160 | echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt" | |
161 |
|
161 | |||
162 | if [ "$ENABLE_TURBO" = false ] ; then |
|
162 | if [ "$ENABLE_TURBO" = false ] ; then | |
163 | echo "core_freq=250" >> "${BOOT_DIR}/config.txt" |
|
163 | echo "core_freq=250" >> "${BOOT_DIR}/config.txt" | |
164 | fi |
|
164 | fi | |
165 |
|
165 | |||
166 | fi |
|
166 | fi | |
167 |
|
167 | |||
168 | # Activate services |
|
168 | # Activate services | |
169 | chroot_exec systemctl enable pi-bluetooth.hciuart.service |
|
169 | chroot_exec systemctl enable pi-bluetooth.hciuart.service | |
170 |
|
170 | |||
171 | else # if ENABLE_BLUETOOTH = false |
|
171 | else # if ENABLE_BLUETOOTH = false | |
172 | # set overlay to disable bluetooth |
|
172 | # set overlay to disable bluetooth | |
173 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" |
|
173 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" | |
174 | fi # ENABLE_BLUETOOTH end |
|
174 | fi # ENABLE_BLUETOOTH end | |
175 | fi |
|
175 | fi | |
176 |
|
176 | |||
177 | # may need sudo systemctl disable hciuart |
|
177 | # may need sudo systemctl disable hciuart | |
178 | if [ "$ENABLE_CONSOLE" = true ] ; then |
|
178 | if [ "$ENABLE_CONSOLE" = true ] ; then | |
179 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" |
|
179 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" | |
180 | # add string to cmdline |
|
180 | # add string to cmdline | |
181 | CMDLINE="${CMDLINE} console=serial0,115200" |
|
181 | CMDLINE="${CMDLINE} console=serial0,115200" | |
182 |
|
182 | |||
183 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then |
|
183 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then | |
184 | # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken |
|
184 | # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken | |
185 | if [ "$ENABLE_TURBO" = false ] ; then |
|
185 | if [ "$ENABLE_TURBO" = false ] ; then | |
186 | echo "core_freq=250" >> "${BOOT_DIR}/config.txt" |
|
186 | echo "core_freq=250" >> "${BOOT_DIR}/config.txt" | |
187 | fi |
|
187 | fi | |
188 | fi |
|
188 | fi | |
189 |
|
189 | |||
190 | # Enable serial console systemd style |
|
190 | # Enable serial console systemd style | |
191 | chroot_exec systemctl enable serial-getty@serial0.service |
|
191 | chroot_exec systemctl enable serial-getty@serial0.service | |
192 | else |
|
192 | else | |
193 | echo "enable_uart=0" >> "${BOOT_DIR}/config.txt" |
|
193 | echo "enable_uart=0" >> "${BOOT_DIR}/config.txt" | |
194 | fi |
|
194 | fi | |
195 |
|
195 | |||
196 | # Disable dphys-swapfile service. Will get enabled on first boot |
|
196 | # Disable dphys-swapfile service. Will get enabled on first boot | |
197 | if [ "$ENABLE_DPHYSSWAP" = true ] ; then |
|
197 | if [ "$ENABLE_DPHYSSWAP" = true ] ; then | |
198 | chroot_exec systemctl disable dphys-swapfile |
|
198 | chroot_exec systemctl disable dphys-swapfile | |
199 | fi |
|
199 | fi | |
200 |
|
200 | |||
201 | if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then |
|
201 | if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then | |
202 | # Create temporary directory for systemd-swap sources |
|
202 | # Create temporary directory for systemd-swap sources | |
203 | temp_dir=$(as_nobody mktemp -d) |
|
203 | temp_dir=$(as_nobody mktemp -d) | |
204 |
|
204 | |||
205 | # Fetch systemd-swap sources |
|
205 | # Fetch systemd-swap sources | |
206 | as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}" |
|
206 | as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}" | |
207 |
|
207 | |||
208 | # Copy downloaded systemd-swap sources |
|
208 | # Copy downloaded systemd-swap sources | |
209 | mv "${temp_dir}/systemd-swap" "${R}/tmp/" |
|
209 | mv "${temp_dir}/systemd-swap" "${R}/tmp/" | |
210 |
|
210 | |||
211 | # Change into downloaded src dir |
|
211 | # Change into downloaded src dir | |
212 | cd "${R}/tmp/systemd-swap" || exit |
|
212 | cd "${R}/tmp/systemd-swap" || exit | |
213 |
|
213 | |||
214 | # Build package |
|
214 | # Build package | |
215 | bash ./package.sh debian |
|
215 | bash ./package.sh debian | |
216 |
|
216 | |||
217 | # Change back into script root dir |
|
217 | # Change back into script root dir | |
218 | cd "${WORKDIR}" || exit |
|
218 | cd "${WORKDIR}" || exit | |
219 |
|
219 | |||
220 | # Set permissions of the systemd-swap sources |
|
220 | # Set permissions of the systemd-swap sources | |
221 | chown -R root:root "${R}/tmp/systemd-swap" |
|
221 | chown -R root:root "${R}/tmp/systemd-swap" | |
222 |
|
222 | |||
223 | # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR. |
|
223 | # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR. | |
224 | chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_4.0.1_any.deb |
|
224 | chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_4.0.1_any.deb | |
225 |
|
225 | |||
226 | # Enable service |
|
226 | # Enable service | |
227 | chroot_exec systemctl enable systemd-swap |
|
227 | chroot_exec systemctl enable systemd-swap | |
228 |
|
228 | |||
229 | # Remove temporary directory for systemd-swap sources |
|
229 | # Remove temporary directory for systemd-swap sources | |
230 | rm -fr "${temp_dir}" |
|
230 | rm -fr "${temp_dir}" | |
231 | else |
|
231 | else | |
232 | # Enable ZSWAP in cmdline if systemd-swap is not used |
|
232 | # Enable ZSWAP in cmdline if systemd-swap is not used | |
233 | if [ "$KERNEL_ZSWAP" = true ] ; then |
|
233 | if [ "$KERNEL_ZSWAP" = true ] ; then | |
234 | CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4" |
|
234 | CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4" | |
235 | fi |
|
235 | fi | |
236 | fi |
|
236 | fi | |
237 | if [ "$KERNEL_SECURITY" = true ] ; then |
|
237 | if [ "$KERNEL_SECURITY" = true ] ; then | |
238 | CMDLINE="${CMDLINE} apparmor=1 security=apparmor" |
|
238 | CMDLINE="${CMDLINE} apparmor=1 security=apparmor" | |
239 | fi |
|
239 | fi | |
240 |
|
240 | |||
241 | # Install firmware boot cmdline |
|
241 | # Install firmware boot cmdline | |
242 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" |
|
242 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" | |
243 |
|
243 | |||
244 | # Setup minimal GPU memory allocation size: 16MB (no X) |
|
244 | # Setup minimal GPU memory allocation size: 16MB (no X) | |
245 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
245 | if [ "$ENABLE_MINGPU" = true ] ; then | |
246 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" |
|
246 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" | |
247 | fi |
|
247 | fi | |
248 |
|
248 | |||
249 | # Setup boot with initramfs |
|
249 | # Setup boot with initramfs | |
250 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
250 | if [ "$ENABLE_INITRAMFS" = true ] ; then | |
251 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" |
|
251 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" | |
252 | fi |
|
252 | fi | |
253 |
|
253 | |||
254 | # Create firmware configuration and cmdline symlinks |
|
254 | # Create firmware configuration and cmdline symlinks | |
255 | ln -sf firmware/config.txt "${R}/boot/config.txt" |
|
255 | ln -sf firmware/config.txt "${R}/boot/config.txt" | |
256 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" |
|
256 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" | |
257 |
|
257 | |||
258 | # Install and setup kernel modules to load at boot |
|
258 | # Install and setup kernel modules to load at boot | |
259 | mkdir -p "${LIB_DIR}/modules-load.d/" |
|
259 | mkdir -p "${LIB_DIR}/modules-load.d/" | |
260 | install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
260 | install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" | |
261 |
|
261 | |||
262 | # Load hardware random module at boot |
|
262 | # Load hardware random module at boot | |
263 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then |
|
263 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then | |
264 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
264 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
265 | fi |
|
265 | fi | |
266 |
|
266 | |||
267 | # Load sound module at boot |
|
267 | # Load sound module at boot | |
268 | if [ "$ENABLE_SOUND" = true ] ; then |
|
268 | if [ "$ENABLE_SOUND" = true ] ; then | |
269 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
269 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
270 | else |
|
270 | else | |
271 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" |
|
271 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" | |
272 | fi |
|
272 | fi | |
273 |
|
273 | |||
274 | # Enable I2C interface |
|
274 | # Enable I2C interface | |
275 | if [ "$ENABLE_I2C" = true ] ; then |
|
275 | if [ "$ENABLE_I2C" = true ] ; then | |
276 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" |
|
276 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" | |
277 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
277 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
278 | sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
278 | sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
279 | fi |
|
279 | fi | |
280 |
|
280 | |||
281 | # Enable SPI interface |
|
281 | # Enable SPI interface | |
282 | if [ "$ENABLE_SPI" = true ] ; then |
|
282 | if [ "$ENABLE_SPI" = true ] ; then | |
283 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" |
|
283 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" | |
284 | echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
284 | echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" | |
285 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then |
|
285 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then | |
286 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
286 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
287 | fi |
|
287 | fi | |
288 | fi |
|
288 | fi | |
289 |
|
289 | |||
290 | # Disable RPi2/3 under-voltage warnings |
|
290 | # Disable RPi2/3 under-voltage warnings | |
291 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
291 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
292 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" |
|
292 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" | |
293 | fi |
|
293 | fi | |
294 |
|
294 | |||
295 | # Install kernel modules blacklist |
|
295 | # Install kernel modules blacklist | |
296 | mkdir -p "${ETC_DIR}/modprobe.d/" |
|
296 | mkdir -p "${ETC_DIR}/modprobe.d/" | |
297 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" |
|
297 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" | |
298 |
|
298 | |||
299 | # Install sysctl.d configuration files |
|
299 | # Install sysctl.d configuration files | |
300 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
|
300 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
@@ -1,136 +1,136 | |||||
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/^RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hostname" |
|
10 | sed -i "s/^RaspberryPI/${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/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts" |
|
14 | sed -i "s/RaspberryPI/${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 [ "$RPI_MODEL" = 3P ] ; then |
|
33 | if [ "$RPI_MODEL" = 3P ] ; then | |
34 | printf "\n[Link]\nGenericReceiveOffload=off\nTCPSegmentationOffload=off\nGenericSegmentationOffload=off" >> "${ETC_DIR}/systemd/network/eth.network" |
|
34 | printf "\n[Link]\nGenericReceiveOffload=off\nTCPSegmentationOffload=off\nGenericSegmentationOffload=off" >> "${ETC_DIR}/systemd/network/eth.network" | |
35 | fi |
|
35 | fi | |
36 |
|
36 | |||
37 | # Install configuration for interface wl* |
|
37 | # Install configuration for interface wl* | |
38 | install_readonly files/network/wlan.network "${ETC_DIR}/systemd/network/wlan.network" |
|
38 | install_readonly files/network/wlan.network "${ETC_DIR}/systemd/network/wlan.network" | |
39 |
|
39 | |||
40 | #always with dhcp since wpa_supplicant integration is missing |
|
40 | #always with dhcp since wpa_supplicant integration is missing | |
41 | sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan.network" |
|
41 | sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan.network" | |
42 |
|
42 | |||
43 | if [ "$ENABLE_DHCP" = true ] ; then |
|
43 | if [ "$ENABLE_DHCP" = true ] ; then | |
44 | # Enable DHCP configuration for interface eth0 |
|
44 | # Enable DHCP configuration for interface eth0 | |
45 | sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network" |
|
45 | sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network" | |
46 |
|
46 | |||
47 | # Set DHCP configuration to IPv4 only |
|
47 | # Set DHCP configuration to IPv4 only | |
48 | if [ "$ENABLE_IPV6" = false ] ; then |
|
48 | if [ "$ENABLE_IPV6" = false ] ; then | |
49 | sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network" |
|
49 | sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network" | |
50 | fi |
|
50 | fi | |
51 |
|
51 | |||
52 | else # ENABLE_DHCP=false |
|
52 | else # ENABLE_DHCP=false | |
53 | # Set static network configuration for interface eth0 |
|
53 | # Set static network configuration for interface eth0 | |
54 | sed -i\ |
|
54 | sed -i\ | |
55 | -e "s|DHCP=.*|DHCP=no|"\ |
|
55 | -e "s|DHCP=.*|DHCP=no|"\ | |
56 | -e "s|Address=\$|Address=${NET_ADDRESS}|"\ |
|
56 | -e "s|Address=\$|Address=${NET_ADDRESS}|"\ | |
57 | -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\ |
|
57 | -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\ | |
58 | -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\ |
|
58 | -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\ | |
59 | -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\ |
|
59 | -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\ | |
60 | -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\ |
|
60 | -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\ | |
61 | -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\ |
|
61 | -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\ | |
62 | -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\ |
|
62 | -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\ | |
63 | "${ETC_DIR}/systemd/network/eth.network" |
|
63 | "${ETC_DIR}/systemd/network/eth.network" | |
64 | fi |
|
64 | fi | |
65 |
|
65 | |||
66 | # Remove empty settings from network configuration |
|
66 | # Remove empty settings from network configuration | |
67 | sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network" |
|
67 | sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network" | |
68 | # Remove empty settings from wlan configuration |
|
68 | # Remove empty settings from wlan configuration | |
69 | sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network" |
|
69 | sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network" | |
70 |
|
70 | |||
71 | # Move systemd network configuration if required by Debian release |
|
71 | # Move systemd network configuration if required by Debian release | |
72 | mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network" |
|
72 | mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network" | |
73 | # If WLAN is enabled copy wlan configuration too |
|
73 | # If WLAN is enabled copy wlan configuration too | |
74 | if [ "$ENABLE_WIRELESS" = true ] ; then |
|
74 | if [ "$ENABLE_WIRELESS" = true ] ; then | |
75 | mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network" |
|
75 | mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network" | |
76 | fi |
|
76 | fi | |
77 | rm -fr "${ETC_DIR}/systemd/network" |
|
77 | rm -fr "${ETC_DIR}/systemd/network" | |
78 |
|
78 | |||
79 | # Enable systemd-networkd service |
|
79 | # Enable systemd-networkd service | |
80 | chroot_exec systemctl enable systemd-networkd |
|
80 | chroot_exec systemctl enable systemd-networkd | |
81 |
|
81 | |||
82 | # Install host.conf resolver configuration |
|
82 | # Install host.conf resolver configuration | |
83 | install_readonly files/network/host.conf "${ETC_DIR}/host.conf" |
|
83 | install_readonly files/network/host.conf "${ETC_DIR}/host.conf" | |
84 |
|
84 | |||
85 | # Enable network stack hardening |
|
85 | # Enable network stack hardening | |
86 | if [ "$ENABLE_HARDNET" = true ] ; then |
|
86 | if [ "$ENABLE_HARDNET" = true ] ; then | |
87 | # Install sysctl.d configuration files |
|
87 | # Install sysctl.d configuration files | |
88 | install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf" |
|
88 | install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf" | |
89 |
|
89 | |||
90 | # Setup resolver warnings about spoofed addresses |
|
90 | # Setup resolver warnings about spoofed addresses | |
91 | sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf" |
|
91 | sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf" | |
92 | fi |
|
92 | fi | |
93 |
|
93 | |||
94 | # Enable time sync |
|
94 | # Enable time sync | |
95 | if [ "$NET_NTP_1" != "" ] ; then |
|
95 | if [ "$NET_NTP_1" != "" ] ; then | |
96 | chroot_exec systemctl enable systemd-timesyncd.service |
|
96 | chroot_exec systemctl enable systemd-timesyncd.service | |
97 | fi |
|
97 | fi | |
98 |
|
98 | |||
99 | # Download the firmware binary blob required to use the RPi3 wireless interface |
|
99 | # Download the firmware binary blob required to use the RPi3 wireless interface | |
100 | if [ "$ENABLE_WIRELESS" = true ] ; then |
|
100 | if [ "$ENABLE_WIRELESS" = true ] ; then | |
101 | if [ ! -d "${WLAN_FIRMWARE_DIR}" ] ; then |
|
101 | if [ ! -d "${WLAN_FIRMWARE_DIR}" ] ; then | |
102 | mkdir -p "${WLAN_FIRMWARE_DIR}" |
|
102 | mkdir -p "${WLAN_FIRMWARE_DIR}" | |
103 | fi |
|
103 | fi | |
104 |
|
104 | |||
105 | # Create temporary directory for firmware binary blob |
|
105 | # Create temporary directory for firmware binary blob | |
106 | temp_dir=$(as_nobody mktemp -d) |
|
106 | temp_dir=$(as_nobody mktemp -d) | |
107 |
|
107 | |||
108 | # Fetch firmware binary blob for RPI3B+ |
|
108 | # Fetch firmware binary blob for RPI3B+ | |
109 | if [ "$RPI_MODEL" = 3P ] ; then |
|
109 | if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then | |
110 | # Fetch firmware binary blob for RPi3P |
|
110 | # Fetch firmware binary blob for RPi3P | |
111 | as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin" |
|
111 | as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin" | |
112 | as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt" |
|
112 | as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt" | |
113 | as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob" |
|
113 | as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob" | |
114 |
|
114 | |||
115 | # Move downloaded firmware binary blob |
|
115 | # Move downloaded firmware binary blob | |
116 | mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/" |
|
116 | mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/" | |
117 |
|
117 | |||
118 | # Set permissions of the firmware binary blob |
|
118 | # Set permissions of the firmware binary blob | |
119 | chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* |
|
119 | chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* | |
120 | chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* |
|
120 | chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* | |
121 | elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then |
|
121 | elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then | |
122 | # Fetch firmware binary blob for RPi3 |
|
122 | # Fetch firmware binary blob for RPi3 | |
123 | as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin" |
|
123 | as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin" | |
124 | as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt" |
|
124 | as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt" | |
125 |
|
125 | |||
126 | # Move downloaded firmware binary blob |
|
126 | # Move downloaded firmware binary blob | |
127 | mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/" |
|
127 | mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/" | |
128 |
|
128 | |||
129 | # Set permissions of the firmware binary blob |
|
129 | # Set permissions of the firmware binary blob | |
130 | chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* |
|
130 | chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* | |
131 | chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* |
|
131 | chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* | |
132 | fi |
|
132 | fi | |
133 |
|
133 | |||
134 | # Remove temporary directory for firmware binary blob |
|
134 | # Remove temporary directory for firmware binary blob | |
135 | rm -fr "${temp_dir}" |
|
135 | rm -fr "${temp_dir}" | |
136 | fi |
|
136 | fi |
@@ -1,97 +1,97 | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 | # |
|
2 | # | |
3 | # Build and Setup nexmon with monitor mode patch |
|
3 | # Build and Setup nexmon with monitor mode patch | |
4 | # |
|
4 | # | |
5 |
|
5 | |||
6 | # Load utility functions |
|
6 | # Load utility functions | |
7 | . ./functions.sh |
|
7 | . ./functions.sh | |
8 |
|
8 | |||
9 | if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then |
|
9 | if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then | |
10 | # Copy existing nexmon sources into chroot directory |
|
10 | # Copy existing nexmon sources into chroot directory | |
11 | if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then |
|
11 | if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then | |
12 | # Copy local U-Boot sources |
|
12 | # Copy local U-Boot sources | |
13 | cp -r "${NEXMONSRC_DIR}" "${R}/tmp" |
|
13 | cp -r "${NEXMONSRC_DIR}" "${R}/tmp" | |
14 | else |
|
14 | else | |
15 | # Create temporary directory for nexmon sources |
|
15 | # Create temporary directory for nexmon sources | |
16 | temp_dir=$(as_nobody mktemp -d) |
|
16 | temp_dir=$(as_nobody mktemp -d) | |
17 |
|
17 | |||
18 | # Fetch nexmon sources |
|
18 | # Fetch nexmon sources | |
19 | as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}" |
|
19 | as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}" | |
20 |
|
20 | |||
21 | # Copy downloaded nexmon sources |
|
21 | # Copy downloaded nexmon sources | |
22 | mv "${temp_dir}/nexmon" "${R}"/tmp/ |
|
22 | mv "${temp_dir}/nexmon" "${R}"/tmp/ | |
23 |
|
23 | |||
24 | # Set permissions of the nexmon sources |
|
24 | # Set permissions of the nexmon sources | |
25 | chown -R root:root "${R}"/tmp/nexmon |
|
25 | chown -R root:root "${R}"/tmp/nexmon | |
26 |
|
26 | |||
27 | # Remove temporary directory for nexmon sources |
|
27 | # Remove temporary directory for nexmon sources | |
28 | rm -fr "${temp_dir}" |
|
28 | rm -fr "${temp_dir}" | |
29 | fi |
|
29 | fi | |
30 |
|
30 | |||
31 | # Set script Root |
|
31 | # Set script Root | |
32 | export NEXMON_ROOT="${R}"/tmp/nexmon |
|
32 | export NEXMON_ROOT="${R}"/tmp/nexmon | |
33 |
|
33 | |||
34 | # Build nexmon firmware outside the build system, if we can. |
|
34 | # Build nexmon firmware outside the build system, if we can. | |
35 | cd "${NEXMON_ROOT}" || exit |
|
35 | cd "${NEXMON_ROOT}" || exit | |
36 |
|
36 | |||
37 | # Make ancient isl build |
|
37 | # Make ancient isl build | |
38 | cd buildtools/isl-0.10 || exit |
|
38 | cd buildtools/isl-0.10 || exit | |
39 | ./configure |
|
39 | ./configure | |
40 | make |
|
40 | make | |
41 | cd ../.. || exit |
|
41 | cd ../.. || exit | |
42 |
|
42 | |||
43 | # Disable statistics |
|
43 | # Disable statistics | |
44 | touch DISABLE_STATISTICS |
|
44 | touch DISABLE_STATISTICS | |
45 |
|
45 | |||
46 | # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh |
|
46 | # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh | |
47 | export KERNEL="${KERNEL_IMAGE}" |
|
47 | export KERNEL="${KERNEL_IMAGE}" | |
48 | export ARCH=arm |
|
48 | export ARCH=arm | |
49 | export SUBARCH=arm |
|
49 | export SUBARCH=arm | |
50 | export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- |
|
50 | export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- | |
51 | export CC="${CC}"gcc |
|
51 | export CC="${CC}"gcc | |
52 | export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so |
|
52 | export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so | |
53 | export ZLIBFLATE="zlib-flate -compress" |
|
53 | export ZLIBFLATE="zlib-flate -compress" | |
54 | export Q=@ |
|
54 | export Q=@ | |
55 | export NEXMON_SETUP_ENV=1 |
|
55 | export NEXMON_SETUP_ENV=1 | |
56 | export HOSTUNAME=$(uname -s) |
|
56 | export HOSTUNAME=$(uname -s) | |
57 | export PLATFORMUNAME=$(uname -m) |
|
57 | export PLATFORMUNAME=$(uname -m) | |
58 |
|
58 | |||
59 | # Make nexmon |
|
59 | # Make nexmon | |
60 | make |
|
60 | make | |
61 |
|
61 | |||
62 | # build patches |
|
62 | # build patches | |
63 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then |
|
63 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then | |
64 | cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit |
|
64 | cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit | |
65 | sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile |
|
65 | sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile | |
66 | make clean |
|
66 | make clean | |
67 |
|
67 | |||
68 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. |
|
68 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. | |
69 | LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- |
|
69 | LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- | |
70 |
|
70 | |||
71 | # copy RPi0W & RPi3 firmware |
|
71 | # copy RPi0W & RPi3 firmware | |
72 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin |
|
72 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin | |
73 | cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin |
|
73 | cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin | |
74 | cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin |
|
74 | cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin | |
75 | fi |
|
75 | fi | |
76 |
|
76 | |||
77 | if [ "$RPI_MODEL" = 3P ] ; then |
|
77 | if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then | |
78 | cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit |
|
78 | cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit | |
79 | sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile |
|
79 | sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile | |
80 | make clean |
|
80 | make clean | |
81 |
|
81 | |||
82 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. |
|
82 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. | |
83 | LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- |
|
83 | LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- | |
84 |
|
84 | |||
85 | # RPi3B+ firmware |
|
85 | # RPi3B+ firmware | |
86 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin |
|
86 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin | |
87 | cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin |
|
87 | cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin | |
88 | cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin |
|
88 | cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin | |
89 | fi |
|
89 | fi | |
90 |
|
90 | |||
91 | #Revert to previous directory |
|
91 | #Revert to previous directory | |
92 | cd "${WORKDIR}" || exit |
|
92 | cd "${WORKDIR}" || exit | |
93 |
|
93 | |||
94 | # Remove nexmon sources |
|
94 | # Remove nexmon sources | |
95 | rm -fr "${NEXMON_ROOT}" |
|
95 | rm -fr "${NEXMON_ROOT}" | |
96 |
|
96 | |||
97 | fi |
|
97 | fi |
@@ -1,883 +1,886 | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 | ######################################################################## |
|
2 | ######################################################################## | |
3 | # rpi23-gen-image.sh 2015-2017 |
|
3 | # rpi23-gen-image.sh 2015-2017 | |
4 | # |
|
4 | # | |
5 | # Advanced Debian "stretch" and "buster" bootstrap script for Raspberry Pi |
|
5 | # Advanced Debian "stretch" and "buster" bootstrap script for Raspberry Pi | |
6 | # |
|
6 | # | |
7 | # This program is free software; you can redistribute it and/or |
|
7 | # This program is free software; you can redistribute it and/or | |
8 | # modify it under the terms of the GNU General Public License |
|
8 | # modify it under the terms of the GNU General Public License | |
9 | # as published by the Free Software Foundation; either version 2 |
|
9 | # as published by the Free Software Foundation; either version 2 | |
10 | # of the License, or (at your option) any later version. |
|
10 | # of the License, or (at your option) any later version. | |
11 | # |
|
11 | # | |
12 | # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu> |
|
12 | # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu> | |
13 | # |
|
13 | # | |
14 | # Big thanks for patches and enhancements by 20+ github contributors! |
|
14 | # Big thanks for patches and enhancements by 20+ github contributors! | |
15 | ######################################################################## |
|
15 | ######################################################################## | |
16 |
|
16 | |||
17 | # Are we running as root? |
|
17 | # Are we running as root? | |
18 | if [ "$(id -u)" -ne "0" ] ; then |
|
18 | if [ "$(id -u)" -ne "0" ] ; then | |
19 | echo "error: this script must be executed with root privileges!" |
|
19 | echo "error: this script must be executed with root privileges!" | |
20 | exit 1 |
|
20 | exit 1 | |
21 | fi |
|
21 | fi | |
22 |
|
22 | |||
23 | # Check if ./functions.sh script exists |
|
23 | # Check if ./functions.sh script exists | |
24 | if [ ! -r "./functions.sh" ] ; then |
|
24 | if [ ! -r "./functions.sh" ] ; then | |
25 | echo "error: './functions.sh' required script not found!" |
|
25 | echo "error: './functions.sh' required script not found!" | |
26 | exit 1 |
|
26 | exit 1 | |
27 | fi |
|
27 | fi | |
28 |
|
28 | |||
29 | # Load utility functions |
|
29 | # Load utility functions | |
30 | . ./functions.sh |
|
30 | . ./functions.sh | |
31 |
|
31 | |||
32 | # Load parameters from configuration template file |
|
32 | # Load parameters from configuration template file | |
33 | if [ -n "$CONFIG_TEMPLATE" ] ; then |
|
33 | if [ -n "$CONFIG_TEMPLATE" ] ; then | |
34 | use_template |
|
34 | use_template | |
35 | fi |
|
35 | fi | |
36 |
|
36 | |||
37 | # Introduce settings |
|
37 | # Introduce settings | |
38 | set -e |
|
38 | set -e | |
39 | echo -n -e "\n#\n# RPi 0/1/2/3 Bootstrap Settings\n#\n" |
|
39 | echo -n -e "\n#\n# RPi 0/1/2/3 Bootstrap Settings\n#\n" | |
40 | set -x |
|
40 | set -x | |
41 |
|
41 | |||
42 | # Raspberry Pi model configuration |
|
42 | # Raspberry Pi model configuration | |
43 | RPI_MODEL=${RPI_MODEL:=2} |
|
43 | RPI_MODEL=${RPI_MODEL:=2} | |
44 |
|
44 | |||
45 | # Debian release |
|
45 | # Debian release | |
46 | RELEASE=${RELEASE:=buster} |
|
46 | RELEASE=${RELEASE:=buster} | |
47 |
|
47 | |||
48 | # Kernel Branch |
|
48 | # Kernel Branch | |
49 | KERNEL_BRANCH=${KERNEL_BRANCH:=""} |
|
49 | KERNEL_BRANCH=${KERNEL_BRANCH:=""} | |
50 |
|
50 | |||
51 | # URLs |
|
51 | # URLs | |
52 | KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} |
|
52 | KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} | |
53 | FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} |
|
53 | FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} | |
54 | WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} |
|
54 | WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} | |
55 | COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian} |
|
55 | COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian} | |
56 | FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} |
|
56 | FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} | |
57 | UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} |
|
57 | UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} | |
58 | VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland} |
|
58 | VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland} | |
59 | BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} |
|
59 | BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} | |
60 | NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git} |
|
60 | NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git} | |
61 | SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git} |
|
61 | SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git} | |
62 |
|
62 | |||
63 | # Kernel deb packages for 32bit kernel |
|
63 | # Kernel deb packages for 32bit kernel | |
64 | RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb} |
|
64 | RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb} | |
65 | RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb} |
|
65 | RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb} | |
66 | # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used |
|
66 | # Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used | |
67 | RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz} |
|
67 | RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz} | |
68 | # Default precompiled 64bit kernel |
|
68 | # Default precompiled 64bit kernel | |
69 | RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz} |
|
69 | RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz} | |
|
70 | # Sakaki BIS Kernel RPI4 | |||
|
71 | RPI4_64_DEF_KERNEL_URL=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.59.20190724/bcm2711-kernel-bis-4.19.59.20190724.tar.xz | |||
70 | # Generic |
|
72 | # Generic | |
71 | RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL} |
|
73 | RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL} | |
|
74 | RPI4_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI4_64_DEF_KERNEL_URL} | |||
72 | # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul) |
|
75 | # Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul) | |
73 | KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git} |
|
76 | KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git} | |
74 |
|
77 | |||
75 | # Build directories |
|
78 | # Build directories | |
76 | WORKDIR=$(pwd) |
|
79 | WORKDIR=$(pwd) | |
77 | BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}} |
|
80 | BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}} | |
78 | BUILDDIR="${BASEDIR}/build" |
|
81 | BUILDDIR="${BASEDIR}/build" | |
79 |
|
82 | |||
80 | # Chroot directories |
|
83 | # Chroot directories | |
81 | R="${BUILDDIR}/chroot" |
|
84 | R="${BUILDDIR}/chroot" | |
82 | ETC_DIR="${R}/etc" |
|
85 | ETC_DIR="${R}/etc" | |
83 | LIB_DIR="${R}/lib" |
|
86 | LIB_DIR="${R}/lib" | |
84 | BOOT_DIR="${R}/boot/firmware" |
|
87 | BOOT_DIR="${R}/boot/firmware" | |
85 | KERNEL_DIR="${R}/usr/src/linux" |
|
88 | KERNEL_DIR="${R}/usr/src/linux" | |
86 | WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm" |
|
89 | WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm" | |
87 | BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt" |
|
90 | BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt" | |
88 |
|
91 | |||
89 | # Firmware directory: Blank if download from github |
|
92 | # Firmware directory: Blank if download from github | |
90 | RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} |
|
93 | RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} | |
91 |
|
94 | |||
92 | # General settings |
|
95 | # General settings | |
93 | SET_ARCH=${SET_ARCH:=32} |
|
96 | SET_ARCH=${SET_ARCH:=32} | |
94 | HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} |
|
97 | HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} | |
95 | PASSWORD=${PASSWORD:=raspberry} |
|
98 | PASSWORD=${PASSWORD:=raspberry} | |
96 | USER_PASSWORD=${USER_PASSWORD:=raspberry} |
|
99 | USER_PASSWORD=${USER_PASSWORD:=raspberry} | |
97 | DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} |
|
100 | DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} | |
98 | TIMEZONE=${TIMEZONE:="Europe/Berlin"} |
|
101 | TIMEZONE=${TIMEZONE:="Europe/Berlin"} | |
99 | EXPANDROOT=${EXPANDROOT:=true} |
|
102 | EXPANDROOT=${EXPANDROOT:=true} | |
100 | ENABLE_DPHYSSWAP=${ENABLE_DPHYSSWAP:=true} |
|
103 | ENABLE_DPHYSSWAP=${ENABLE_DPHYSSWAP:=true} | |
101 |
|
104 | |||
102 | # Keyboard settings |
|
105 | # Keyboard settings | |
103 | XKB_MODEL=${XKB_MODEL:=""} |
|
106 | XKB_MODEL=${XKB_MODEL:=""} | |
104 | XKB_LAYOUT=${XKB_LAYOUT:=""} |
|
107 | XKB_LAYOUT=${XKB_LAYOUT:=""} | |
105 | XKB_VARIANT=${XKB_VARIANT:=""} |
|
108 | XKB_VARIANT=${XKB_VARIANT:=""} | |
106 | XKB_OPTIONS=${XKB_OPTIONS:=""} |
|
109 | XKB_OPTIONS=${XKB_OPTIONS:=""} | |
107 |
|
110 | |||
108 | # Network settings (DHCP) |
|
111 | # Network settings (DHCP) | |
109 | ENABLE_DHCP=${ENABLE_DHCP:=true} |
|
112 | ENABLE_DHCP=${ENABLE_DHCP:=true} | |
110 |
|
113 | |||
111 | # Network settings (static) |
|
114 | # Network settings (static) | |
112 | NET_ADDRESS=${NET_ADDRESS:=""} |
|
115 | NET_ADDRESS=${NET_ADDRESS:=""} | |
113 | NET_GATEWAY=${NET_GATEWAY:=""} |
|
116 | NET_GATEWAY=${NET_GATEWAY:=""} | |
114 | NET_DNS_1=${NET_DNS_1:=""} |
|
117 | NET_DNS_1=${NET_DNS_1:=""} | |
115 | NET_DNS_2=${NET_DNS_2:=""} |
|
118 | NET_DNS_2=${NET_DNS_2:=""} | |
116 | NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} |
|
119 | NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} | |
117 | NET_NTP_1=${NET_NTP_1:=""} |
|
120 | NET_NTP_1=${NET_NTP_1:=""} | |
118 | NET_NTP_2=${NET_NTP_2:=""} |
|
121 | NET_NTP_2=${NET_NTP_2:=""} | |
119 |
|
122 | |||
120 | # APT settings |
|
123 | # APT settings | |
121 | APT_PROXY=${APT_PROXY:=""} |
|
124 | APT_PROXY=${APT_PROXY:=""} | |
122 | APT_SERVER=${APT_SERVER:="ftp.debian.org"} |
|
125 | APT_SERVER=${APT_SERVER:="ftp.debian.org"} | |
123 | KEEP_APT_PROXY=${KEEP_APT_PROXY:=false} |
|
126 | KEEP_APT_PROXY=${KEEP_APT_PROXY:=false} | |
124 |
|
127 | |||
125 | # Feature settings |
|
128 | # Feature settings | |
126 | ENABLE_PRINTK=${ENABLE_PRINTK:=false} |
|
129 | ENABLE_PRINTK=${ENABLE_PRINTK:=false} | |
127 | ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false} |
|
130 | ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false} | |
128 | ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false} |
|
131 | ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false} | |
129 | ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} |
|
132 | ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} | |
130 | ENABLE_I2C=${ENABLE_I2C:=false} |
|
133 | ENABLE_I2C=${ENABLE_I2C:=false} | |
131 | ENABLE_SPI=${ENABLE_SPI:=false} |
|
134 | ENABLE_SPI=${ENABLE_SPI:=false} | |
132 | ENABLE_IPV6=${ENABLE_IPV6:=true} |
|
135 | ENABLE_IPV6=${ENABLE_IPV6:=true} | |
133 | ENABLE_SSHD=${ENABLE_SSHD:=true} |
|
136 | ENABLE_SSHD=${ENABLE_SSHD:=true} | |
134 | ENABLE_NONFREE=${ENABLE_NONFREE:=false} |
|
137 | ENABLE_NONFREE=${ENABLE_NONFREE:=false} | |
135 | ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} |
|
138 | ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} | |
136 | ENABLE_SOUND=${ENABLE_SOUND:=true} |
|
139 | ENABLE_SOUND=${ENABLE_SOUND:=true} | |
137 | ENABLE_DBUS=${ENABLE_DBUS:=true} |
|
140 | ENABLE_DBUS=${ENABLE_DBUS:=true} | |
138 | ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} |
|
141 | ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} | |
139 | ENABLE_MINGPU=${ENABLE_MINGPU:=false} |
|
142 | ENABLE_MINGPU=${ENABLE_MINGPU:=false} | |
140 | ENABLE_XORG=${ENABLE_XORG:=false} |
|
143 | ENABLE_XORG=${ENABLE_XORG:=false} | |
141 | ENABLE_WM=${ENABLE_WM:=""} |
|
144 | ENABLE_WM=${ENABLE_WM:=""} | |
142 | ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} |
|
145 | ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} | |
143 | ENABLE_USER=${ENABLE_USER:=true} |
|
146 | ENABLE_USER=${ENABLE_USER:=true} | |
144 | USER_NAME=${USER_NAME:="pi"} |
|
147 | USER_NAME=${USER_NAME:="pi"} | |
145 | ENABLE_ROOT=${ENABLE_ROOT:=false} |
|
148 | ENABLE_ROOT=${ENABLE_ROOT:=false} | |
146 | ENABLE_QEMU=${ENABLE_QEMU:=false} |
|
149 | ENABLE_QEMU=${ENABLE_QEMU:=false} | |
147 | ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false} |
|
150 | ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false} | |
148 |
|
151 | |||
149 | # SSH settings |
|
152 | # SSH settings | |
150 | SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} |
|
153 | SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} | |
151 | SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} |
|
154 | SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} | |
152 | SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} |
|
155 | SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} | |
153 | SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} |
|
156 | SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} | |
154 | SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} |
|
157 | SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} | |
155 |
|
158 | |||
156 | # Advanced settings |
|
159 | # Advanced settings | |
157 | ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false} |
|
160 | ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false} | |
158 | ENABLE_MINBASE=${ENABLE_MINBASE:=false} |
|
161 | ENABLE_MINBASE=${ENABLE_MINBASE:=false} | |
159 | ENABLE_REDUCE=${ENABLE_REDUCE:=false} |
|
162 | ENABLE_REDUCE=${ENABLE_REDUCE:=false} | |
160 | ENABLE_UBOOT=${ENABLE_UBOOT:=false} |
|
163 | ENABLE_UBOOT=${ENABLE_UBOOT:=false} | |
161 | UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} |
|
164 | UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} | |
162 | ENABLE_USBBOOT=${ENABLE_USBBOOT=false} |
|
165 | ENABLE_USBBOOT=${ENABLE_USBBOOT=false} | |
163 | ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} |
|
166 | ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} | |
164 | ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false} |
|
167 | ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false} | |
165 | ENABLE_NEXMON=${ENABLE_NEXMON:=false} |
|
168 | ENABLE_NEXMON=${ENABLE_NEXMON:=false} | |
166 | VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} |
|
169 | VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} | |
167 | FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} |
|
170 | FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} | |
168 | NEXMONSRC_DIR=${NEXMONSRC_DIR:=""} |
|
171 | NEXMONSRC_DIR=${NEXMONSRC_DIR:=""} | |
169 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} |
|
172 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} | |
170 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} |
|
173 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} | |
171 | ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} |
|
174 | ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} | |
172 | ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} |
|
175 | ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} | |
173 | ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} |
|
176 | ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} | |
174 | ENABLE_SPLASH=${ENABLE_SPLASH:=true} |
|
177 | ENABLE_SPLASH=${ENABLE_SPLASH:=true} | |
175 | ENABLE_LOGO=${ENABLE_LOGO:=true} |
|
178 | ENABLE_LOGO=${ENABLE_LOGO:=true} | |
176 | ENABLE_SILENT_BOOT=${ENABLE_SILENT_BOOT=false} |
|
179 | ENABLE_SILENT_BOOT=${ENABLE_SILENT_BOOT=false} | |
177 | DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} |
|
180 | DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} | |
178 |
|
181 | |||
179 | # Kernel compilation settings |
|
182 | # Kernel compilation settings | |
180 | BUILD_KERNEL=${BUILD_KERNEL:=true} |
|
183 | BUILD_KERNEL=${BUILD_KERNEL:=true} | |
181 | KERNEL_REDUCE=${KERNEL_REDUCE:=false} |
|
184 | KERNEL_REDUCE=${KERNEL_REDUCE:=false} | |
182 | KERNEL_THREADS=${KERNEL_THREADS:=1} |
|
185 | KERNEL_THREADS=${KERNEL_THREADS:=1} | |
183 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} |
|
186 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} | |
184 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} |
|
187 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} | |
185 | KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} |
|
188 | KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} | |
186 | KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} |
|
189 | KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} | |
187 | KERNEL_CCACHE=${KERNEL_CCACHE:=false} |
|
190 | KERNEL_CCACHE=${KERNEL_CCACHE:=false} | |
188 | KERNEL_ZSWAP=${KERNEL_ZSWAP:=false} |
|
191 | KERNEL_ZSWAP=${KERNEL_ZSWAP:=false} | |
189 | KERNEL_VIRT=${KERNEL_VIRT:=false} |
|
192 | KERNEL_VIRT=${KERNEL_VIRT:=false} | |
190 | KERNEL_BPF=${KERNEL_BPF:=false} |
|
193 | KERNEL_BPF=${KERNEL_BPF:=false} | |
191 | KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=ondemand} |
|
194 | KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=ondemand} | |
192 | KERNEL_SECURITY=${KERNEL_SECURITY:=false} |
|
195 | KERNEL_SECURITY=${KERNEL_SECURITY:=false} | |
193 | KERNEL_NF=${KERNEL_NF:=false} |
|
196 | KERNEL_NF=${KERNEL_NF:=false} | |
194 |
|
197 | |||
195 | # Kernel compilation from source directory settings |
|
198 | # Kernel compilation from source directory settings | |
196 | KERNELSRC_DIR=${KERNELSRC_DIR:=""} |
|
199 | KERNELSRC_DIR=${KERNELSRC_DIR:=""} | |
197 | KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} |
|
200 | KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} | |
198 | KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} |
|
201 | KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} | |
199 | KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} |
|
202 | KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} | |
200 |
|
203 | |||
201 | # Reduce disk usage settings |
|
204 | # Reduce disk usage settings | |
202 | REDUCE_APT=${REDUCE_APT:=true} |
|
205 | REDUCE_APT=${REDUCE_APT:=true} | |
203 | REDUCE_DOC=${REDUCE_DOC:=true} |
|
206 | REDUCE_DOC=${REDUCE_DOC:=true} | |
204 | REDUCE_MAN=${REDUCE_MAN:=true} |
|
207 | REDUCE_MAN=${REDUCE_MAN:=true} | |
205 | REDUCE_VIM=${REDUCE_VIM:=false} |
|
208 | REDUCE_VIM=${REDUCE_VIM:=false} | |
206 | REDUCE_BASH=${REDUCE_BASH:=false} |
|
209 | REDUCE_BASH=${REDUCE_BASH:=false} | |
207 | REDUCE_HWDB=${REDUCE_HWDB:=true} |
|
210 | REDUCE_HWDB=${REDUCE_HWDB:=true} | |
208 | REDUCE_SSHD=${REDUCE_SSHD:=true} |
|
211 | REDUCE_SSHD=${REDUCE_SSHD:=true} | |
209 | REDUCE_LOCALE=${REDUCE_LOCALE:=true} |
|
212 | REDUCE_LOCALE=${REDUCE_LOCALE:=true} | |
210 |
|
213 | |||
211 | # Encrypted filesystem settings |
|
214 | # Encrypted filesystem settings | |
212 | ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false} |
|
215 | ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false} | |
213 | CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""} |
|
216 | CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""} | |
214 | CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"} |
|
217 | CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"} | |
215 | CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"} |
|
218 | CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"} | |
216 | CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512} |
|
219 | CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512} | |
217 | #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup |
|
220 | #Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup | |
218 | CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false} |
|
221 | CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false} | |
219 | #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated |
|
222 | #Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated | |
220 | CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""} |
|
223 | CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""} | |
221 |
|
224 | |||
222 | # Chroot scripts directory |
|
225 | # Chroot scripts directory | |
223 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} |
|
226 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} | |
224 |
|
227 | |||
225 | # Packages required in the chroot build environment |
|
228 | # Packages required in the chroot build environment | |
226 | APT_INCLUDES=${APT_INCLUDES:=""} |
|
229 | APT_INCLUDES=${APT_INCLUDES:=""} | |
227 | APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd" |
|
230 | APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup,libnss-systemd" | |
228 |
|
231 | |||
229 | # Packages to exclude from chroot build environment |
|
232 | # Packages to exclude from chroot build environment | |
230 | APT_EXCLUDES=${APT_EXCLUDES:=""} |
|
233 | APT_EXCLUDES=${APT_EXCLUDES:=""} | |
231 |
|
234 | |||
232 | # Packages required for bootstrapping |
|
235 | # Packages required for bootstrapping | |
233 | REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo" |
|
236 | REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo" | |
234 | MISSING_PACKAGES="" |
|
237 | MISSING_PACKAGES="" | |
235 |
|
238 | |||
236 | # Packages installed for c/c++ build environment in chroot (keep empty) |
|
239 | # Packages installed for c/c++ build environment in chroot (keep empty) | |
237 | COMPILER_PACKAGES="" |
|
240 | COMPILER_PACKAGES="" | |
238 |
|
241 | |||
239 | # Check if apt-cacher-ng has port 3142 open and set APT_PROXY |
|
242 | # Check if apt-cacher-ng has port 3142 open and set APT_PROXY | |
240 | APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d') |
|
243 | APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d') | |
241 | if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then |
|
244 | if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then | |
242 | APT_PROXY=http://127.0.0.1:3142/ |
|
245 | APT_PROXY=http://127.0.0.1:3142/ | |
243 | fi |
|
246 | fi | |
244 |
|
247 | |||
245 | # Setup architecture specific settings |
|
248 | # Setup architecture specific settings | |
246 | if [ -n "$SET_ARCH" ] ; then |
|
249 | if [ -n "$SET_ARCH" ] ; then | |
247 | # 64-bit configuration |
|
250 | # 64-bit configuration | |
248 | if [ "$SET_ARCH" = 64 ] ; then |
|
251 | if [ "$SET_ARCH" = 64 ] ; then | |
249 | # General 64-bit depended settings |
|
252 | # General 64-bit depended settings | |
250 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} |
|
253 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} | |
251 | KERNEL_ARCH=${KERNEL_ARCH:=arm64} |
|
254 | KERNEL_ARCH=${KERNEL_ARCH:=arm64} | |
252 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} |
|
255 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} | |
253 |
|
256 | |||
254 | # Raspberry Pi model specific settings |
|
257 | # Raspberry Pi model specific settings | |
255 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then |
|
258 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then | |
256 | if [ "$RPI_MODEL" != 4 ] ; then |
|
259 | if [ "$RPI_MODEL" != 4 ] ; then | |
257 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} |
|
260 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} | |
258 | else |
|
261 | else | |
259 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig} |
|
262 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig} | |
260 | fi |
|
263 | fi | |
261 |
|
264 | |||
262 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" |
|
265 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" | |
263 | RELEASE_ARCH=${RELEASE_ARCH:=arm64} |
|
266 | RELEASE_ARCH=${RELEASE_ARCH:=arm64} | |
264 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} |
|
267 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} | |
265 | CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-} |
|
268 | CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-} | |
266 | else |
|
269 | else | |
267 | echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit" |
|
270 | echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit" | |
268 | exit 1 |
|
271 | exit 1 | |
269 | fi |
|
272 | fi | |
270 | fi |
|
273 | fi | |
271 |
|
274 | |||
272 | # 32-bit configuration |
|
275 | # 32-bit configuration | |
273 | if [ "$SET_ARCH" = 32 ] ; then |
|
276 | if [ "$SET_ARCH" = 32 ] ; then | |
274 | # General 32-bit dependend settings |
|
277 | # General 32-bit dependend settings | |
275 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} |
|
278 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} | |
276 | KERNEL_ARCH=${KERNEL_ARCH:=arm} |
|
279 | KERNEL_ARCH=${KERNEL_ARCH:=arm} | |
277 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} |
|
280 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} | |
278 |
|
281 | |||
279 | # Raspberry Pi model specific settings |
|
282 | # Raspberry Pi model specific settings | |
280 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then |
|
283 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then | |
281 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" |
|
284 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" | |
282 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} |
|
285 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} | |
283 | RELEASE_ARCH=${RELEASE_ARCH:=armel} |
|
286 | RELEASE_ARCH=${RELEASE_ARCH:=armel} | |
284 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img} |
|
287 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img} | |
285 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-} |
|
288 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-} | |
286 | fi |
|
289 | fi | |
287 |
|
290 | |||
288 | # Raspberry Pi model specific settings |
|
291 | # Raspberry Pi model specific settings | |
289 | if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then |
|
292 | if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then | |
290 | if [ "$RPI_MODEL" != 4 ] ; then |
|
293 | if [ "$RPI_MODEL" != 4 ] ; then | |
291 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} |
|
294 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} | |
292 | else |
|
295 | else | |
293 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig} |
|
296 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig} | |
294 | fi |
|
297 | fi | |
295 |
|
298 | |||
296 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" |
|
299 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" | |
297 | RELEASE_ARCH=${RELEASE_ARCH:=armhf} |
|
300 | RELEASE_ARCH=${RELEASE_ARCH:=armhf} | |
298 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} |
|
301 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} | |
299 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} |
|
302 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} | |
300 | fi |
|
303 | fi | |
301 | fi |
|
304 | fi | |
302 | # SET_ARCH not set |
|
305 | # SET_ARCH not set | |
303 | else |
|
306 | else | |
304 | echo "error: Please set '32' or '64' as value for SET_ARCH" |
|
307 | echo "error: Please set '32' or '64' as value for SET_ARCH" | |
305 | exit 1 |
|
308 | exit 1 | |
306 | fi |
|
309 | fi | |
307 | # Device specific configuration and U-Boot configuration |
|
310 | # Device specific configuration and U-Boot configuration | |
308 | case "$RPI_MODEL" in |
|
311 | case "$RPI_MODEL" in | |
309 | 0) |
|
312 | 0) | |
310 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} |
|
313 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} | |
311 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} |
|
314 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} | |
312 | ;; |
|
315 | ;; | |
313 | 1) |
|
316 | 1) | |
314 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} |
|
317 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} | |
315 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} |
|
318 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} | |
316 | ;; |
|
319 | ;; | |
317 | 1P) |
|
320 | 1P) | |
318 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} |
|
321 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} | |
319 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} |
|
322 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} | |
320 | ;; |
|
323 | ;; | |
321 | 2) |
|
324 | 2) | |
322 | DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb} |
|
325 | DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb} | |
323 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig} |
|
326 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig} | |
324 | ;; |
|
327 | ;; | |
325 | 3) |
|
328 | 3) | |
326 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} |
|
329 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} | |
327 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} |
|
330 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} | |
328 | ;; |
|
331 | ;; | |
329 | 3P) |
|
332 | 3P) | |
330 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} |
|
333 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} | |
331 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} |
|
334 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} | |
332 | ;; |
|
335 | ;; | |
333 | 4) |
|
336 | 4) | |
334 | DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb} |
|
337 | DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb} | |
335 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig} |
|
338 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig} | |
336 | ;; |
|
339 | ;; | |
337 | *) |
|
340 | *) | |
338 | echo "error: Raspberry Pi model $RPI_MODEL is not supported!" |
|
341 | echo "error: Raspberry Pi model $RPI_MODEL is not supported!" | |
339 | exit 1 |
|
342 | exit 1 | |
340 | ;; |
|
343 | ;; | |
341 | esac |
|
344 | esac | |
342 |
|
345 | |||
343 | # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard |
|
346 | # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard | |
344 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then |
|
347 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then | |
345 | # Include bluetooth packages on supported boards |
|
348 | # Include bluetooth packages on supported boards | |
346 | if [ "$ENABLE_BLUETOOTH" = true ] ; then |
|
349 | if [ "$ENABLE_BLUETOOTH" = true ] ; then | |
347 | APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez" |
|
350 | APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez" | |
348 | fi |
|
351 | fi | |
349 | if [ "$ENABLE_WIRELESS" = true ] ; then |
|
352 | if [ "$ENABLE_WIRELESS" = true ] ; then | |
350 | APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb" |
|
353 | APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb" | |
351 | fi |
|
354 | fi | |
352 | else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard |
|
355 | else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard | |
353 | # Check if the internal wireless interface is not supported by the RPi model |
|
356 | # Check if the internal wireless interface is not supported by the RPi model | |
354 | if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then |
|
357 | if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then | |
355 | echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth" |
|
358 | echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth" | |
356 | exit 1 |
|
359 | exit 1 | |
357 | fi |
|
360 | fi | |
358 | fi |
|
361 | fi | |
359 |
|
362 | |||
360 | if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then |
|
363 | if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then | |
361 | echo "error: You have to compile kernel sources, if you want to enable nexmon" |
|
364 | echo "error: You have to compile kernel sources, if you want to enable nexmon" | |
362 | exit 1 |
|
365 | exit 1 | |
363 | fi |
|
366 | fi | |
364 |
|
367 | |||
365 | # Prepare date string for default image file name |
|
368 | # Prepare date string for default image file name | |
366 | DATE="$(date +%Y-%m-%d)" |
|
369 | DATE="$(date +%Y-%m-%d)" | |
367 | if [ -z "$KERNEL_BRANCH" ] ; then |
|
370 | if [ -z "$KERNEL_BRANCH" ] ; then | |
368 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
371 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} | |
369 | else |
|
372 | else | |
370 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
373 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} | |
371 | fi |
|
374 | fi | |
372 |
|
375 | |||
373 | # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported |
|
376 | # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported | |
374 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
377 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
375 | if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then |
|
378 | if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then | |
376 | echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported" |
|
379 | echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported" | |
377 | exit 1 |
|
380 | exit 1 | |
378 | fi |
|
381 | fi | |
379 | fi |
|
382 | fi | |
380 |
|
383 | |||
381 | # Add cmake to compile videocore sources |
|
384 | # Add cmake to compile videocore sources | |
382 | if [ "$ENABLE_VIDEOCORE" = true ] ; then |
|
385 | if [ "$ENABLE_VIDEOCORE" = true ] ; then | |
383 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" |
|
386 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" | |
384 | fi |
|
387 | fi | |
385 |
|
388 | |||
386 | # Add deps for nexmon |
|
389 | # Add deps for nexmon | |
387 | if [ "$ENABLE_NEXMON" = true ] ; then |
|
390 | if [ "$ENABLE_NEXMON" = true ] ; then | |
388 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool" |
|
391 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf bison flex make autoconf automake build-essential libtool" | |
389 | fi |
|
392 | fi | |
390 |
|
393 | |||
391 | # Add libncurses5 to enable kernel menuconfig |
|
394 | # Add libncurses5 to enable kernel menuconfig | |
392 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
395 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |
393 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev" |
|
396 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev" | |
394 | fi |
|
397 | fi | |
395 |
|
398 | |||
396 | # Add ccache compiler cache for (faster) kernel cross (re)compilation |
|
399 | # Add ccache compiler cache for (faster) kernel cross (re)compilation | |
397 | if [ "$KERNEL_CCACHE" = true ] ; then |
|
400 | if [ "$KERNEL_CCACHE" = true ] ; then | |
398 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache" |
|
401 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache" | |
399 | fi |
|
402 | fi | |
400 |
|
403 | |||
401 | # Add cryptsetup package to enable filesystem encryption |
|
404 | # Add cryptsetup package to enable filesystem encryption | |
402 | if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then |
|
405 | if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then | |
403 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" |
|
406 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" | |
404 | APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup" |
|
407 | APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup" | |
405 |
|
408 | |||
406 | # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package |
|
409 | # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package | |
407 | if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then |
|
410 | if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then | |
408 | APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs" |
|
411 | APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs" | |
409 | fi |
|
412 | fi | |
410 |
|
413 | |||
411 | if [ -z "$CRYPTFS_PASSWORD" ] ; then |
|
414 | if [ -z "$CRYPTFS_PASSWORD" ] ; then | |
412 | echo "error: no password defined (CRYPTFS_PASSWORD)!" |
|
415 | echo "error: no password defined (CRYPTFS_PASSWORD)!" | |
413 | exit 1 |
|
416 | exit 1 | |
414 | fi |
|
417 | fi | |
415 | ENABLE_INITRAMFS=true |
|
418 | ENABLE_INITRAMFS=true | |
416 | fi |
|
419 | fi | |
417 |
|
420 | |||
418 | # Add initramfs generation tools |
|
421 | # Add initramfs generation tools | |
419 | if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then |
|
422 | if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then | |
420 | APT_INCLUDES="${APT_INCLUDES},initramfs-tools" |
|
423 | APT_INCLUDES="${APT_INCLUDES},initramfs-tools" | |
421 | fi |
|
424 | fi | |
422 |
|
425 | |||
423 | # Add device-tree-compiler required for building the U-Boot bootloader |
|
426 | # Add device-tree-compiler required for building the U-Boot bootloader | |
424 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
427 | if [ "$ENABLE_UBOOT" = true ] ; then | |
425 | APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc" |
|
428 | APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc" | |
426 | fi |
|
429 | fi | |
427 |
|
430 | |||
428 | if [ "$ENABLE_USBBOOT" = true ] ; then |
|
431 | if [ "$ENABLE_USBBOOT" = true ] ; then | |
429 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then |
|
432 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then | |
430 | echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P" |
|
433 | echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P" | |
431 | exit 1 |
|
434 | exit 1 | |
432 | fi |
|
435 | fi | |
433 | fi |
|
436 | fi | |
434 |
|
437 | |||
435 | # Check if root SSH (v2) public key file exists |
|
438 | # Check if root SSH (v2) public key file exists | |
436 | if [ -n "$SSH_ROOT_PUB_KEY" ] ; then |
|
439 | if [ -n "$SSH_ROOT_PUB_KEY" ] ; then | |
437 | if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then |
|
440 | if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then | |
438 | echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!" |
|
441 | echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!" | |
439 | exit 1 |
|
442 | exit 1 | |
440 | fi |
|
443 | fi | |
441 | fi |
|
444 | fi | |
442 |
|
445 | |||
443 | # Check if $USER_NAME SSH (v2) public key file exists |
|
446 | # Check if $USER_NAME SSH (v2) public key file exists | |
444 | if [ -n "$SSH_USER_PUB_KEY" ] ; then |
|
447 | if [ -n "$SSH_USER_PUB_KEY" ] ; then | |
445 | if [ ! -f "$SSH_USER_PUB_KEY" ] ; then |
|
448 | if [ ! -f "$SSH_USER_PUB_KEY" ] ; then | |
446 | echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!" |
|
449 | echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!" | |
447 | exit 1 |
|
450 | exit 1 | |
448 | fi |
|
451 | fi | |
449 | fi |
|
452 | fi | |
450 |
|
453 | |||
451 | if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then |
|
454 | if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then | |
452 | echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON" |
|
455 | echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON" | |
453 | exit 1 |
|
456 | exit 1 | |
454 | fi |
|
457 | fi | |
455 |
|
458 | |||
456 | # Check if all required packages are installed on the build system |
|
459 | # Check if all required packages are installed on the build system | |
457 | for package in $REQUIRED_PACKAGES ; do |
|
460 | for package in $REQUIRED_PACKAGES ; do | |
458 | if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then |
|
461 | if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then | |
459 | MISSING_PACKAGES="${MISSING_PACKAGES} $package" |
|
462 | MISSING_PACKAGES="${MISSING_PACKAGES} $package" | |
460 | fi |
|
463 | fi | |
461 | done |
|
464 | done | |
462 |
|
465 | |||
463 | # If there are missing packages ask confirmation for install, or exit |
|
466 | # If there are missing packages ask confirmation for install, or exit | |
464 | if [ -n "$MISSING_PACKAGES" ] ; then |
|
467 | if [ -n "$MISSING_PACKAGES" ] ; then | |
465 | echo "the following packages needed by this script are not installed:" |
|
468 | echo "the following packages needed by this script are not installed:" | |
466 | echo "$MISSING_PACKAGES" |
|
469 | echo "$MISSING_PACKAGES" | |
467 |
|
470 | |||
468 | printf "\ndo you want to install the missing packages right now? [y/n] " |
|
471 | printf "\ndo you want to install the missing packages right now? [y/n] " | |
469 | read -r confirm |
|
472 | read -r confirm | |
470 | [ "$confirm" != "y" ] && exit 1 |
|
473 | [ "$confirm" != "y" ] && exit 1 | |
471 |
|
474 | |||
472 | # Make sure all missing required packages are installed |
|
475 | # Make sure all missing required packages are installed | |
473 | apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"` |
|
476 | apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"` | |
474 | fi |
|
477 | fi | |
475 |
|
478 | |||
476 | # Check if ./bootstrap.d directory exists |
|
479 | # Check if ./bootstrap.d directory exists | |
477 | if [ ! -d "./bootstrap.d/" ] ; then |
|
480 | if [ ! -d "./bootstrap.d/" ] ; then | |
478 | echo "error: './bootstrap.d' required directory not found!" |
|
481 | echo "error: './bootstrap.d' required directory not found!" | |
479 | exit 1 |
|
482 | exit 1 | |
480 | fi |
|
483 | fi | |
481 |
|
484 | |||
482 | # Check if ./files directory exists |
|
485 | # Check if ./files directory exists | |
483 | if [ ! -d "./files/" ] ; then |
|
486 | if [ ! -d "./files/" ] ; then | |
484 | echo "error: './files' required directory not found!" |
|
487 | echo "error: './files' required directory not found!" | |
485 | exit 1 |
|
488 | exit 1 | |
486 | fi |
|
489 | fi | |
487 |
|
490 | |||
488 | # Check if specified KERNELSRC_DIR directory exists |
|
491 | # Check if specified KERNELSRC_DIR directory exists | |
489 | if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then |
|
492 | if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then | |
490 | echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!" |
|
493 | echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!" | |
491 | exit 1 |
|
494 | exit 1 | |
492 | fi |
|
495 | fi | |
493 |
|
496 | |||
494 | # Check if specified UBOOTSRC_DIR directory exists |
|
497 | # Check if specified UBOOTSRC_DIR directory exists | |
495 | if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then |
|
498 | if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then | |
496 | echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!" |
|
499 | echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!" | |
497 | exit 1 |
|
500 | exit 1 | |
498 | fi |
|
501 | fi | |
499 |
|
502 | |||
500 | # Check if specified VIDEOCORESRC_DIR directory exists |
|
503 | # Check if specified VIDEOCORESRC_DIR directory exists | |
501 | if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then |
|
504 | if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then | |
502 | echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!" |
|
505 | echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!" | |
503 | exit 1 |
|
506 | exit 1 | |
504 | fi |
|
507 | fi | |
505 |
|
508 | |||
506 | # Check if specified FBTURBOSRC_DIR directory exists |
|
509 | # Check if specified FBTURBOSRC_DIR directory exists | |
507 | if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then |
|
510 | if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then | |
508 | echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!" |
|
511 | echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!" | |
509 | exit 1 |
|
512 | exit 1 | |
510 | fi |
|
513 | fi | |
511 |
|
514 | |||
512 | # Check if specified NEXMONSRC_DIR directory exists |
|
515 | # Check if specified NEXMONSRC_DIR directory exists | |
513 | if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then |
|
516 | if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then | |
514 | echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!" |
|
517 | echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!" | |
515 | exit 1 |
|
518 | exit 1 | |
516 | fi |
|
519 | fi | |
517 |
|
520 | |||
518 | # Check if specified CHROOT_SCRIPTS directory exists |
|
521 | # Check if specified CHROOT_SCRIPTS directory exists | |
519 | if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then |
|
522 | if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then | |
520 | echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" |
|
523 | echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" | |
521 | exit 1 |
|
524 | exit 1 | |
522 | fi |
|
525 | fi | |
523 |
|
526 | |||
524 | # Check if specified device mapping already exists (will be used by cryptsetup) |
|
527 | # Check if specified device mapping already exists (will be used by cryptsetup) | |
525 | if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then |
|
528 | if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then | |
526 | echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding" |
|
529 | echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding" | |
527 | exit 1 |
|
530 | exit 1 | |
528 | fi |
|
531 | fi | |
529 |
|
532 | |||
530 | # Don't clobber an old build |
|
533 | # Don't clobber an old build | |
531 | if [ -e "$BUILDDIR" ] ; then |
|
534 | if [ -e "$BUILDDIR" ] ; then | |
532 | echo "error: directory ${BUILDDIR} already exists, not proceeding" |
|
535 | echo "error: directory ${BUILDDIR} already exists, not proceeding" | |
533 | exit 1 |
|
536 | exit 1 | |
534 | fi |
|
537 | fi | |
535 |
|
538 | |||
536 | # Setup chroot directory |
|
539 | # Setup chroot directory | |
537 | mkdir -p "${R}" |
|
540 | mkdir -p "${R}" | |
538 |
|
541 | |||
539 | # Check if build directory has enough of free disk space >512MB |
|
542 | # Check if build directory has enough of free disk space >512MB | |
540 | if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then |
|
543 | if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then | |
541 | echo "error: ${BUILDDIR} not enough space left to generate the output image!" |
|
544 | echo "error: ${BUILDDIR} not enough space left to generate the output image!" | |
542 | exit 1 |
|
545 | exit 1 | |
543 | fi |
|
546 | fi | |
544 |
|
547 | |||
545 | set -x |
|
548 | set -x | |
546 |
|
549 | |||
547 | # Call "cleanup" function on various signals and errors |
|
550 | # Call "cleanup" function on various signals and errors | |
548 | trap cleanup 0 1 2 3 6 |
|
551 | trap cleanup 0 1 2 3 6 | |
549 |
|
552 | |||
550 | # Add required packages for the minbase installation |
|
553 | # Add required packages for the minbase installation | |
551 | if [ "$ENABLE_MINBASE" = true ] ; then |
|
554 | if [ "$ENABLE_MINBASE" = true ] ; then | |
552 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown" |
|
555 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown" | |
553 | fi |
|
556 | fi | |
554 |
|
557 | |||
555 | # Add parted package, required to get partprobe utility |
|
558 | # Add parted package, required to get partprobe utility | |
556 | if [ "$EXPANDROOT" = true ] ; then |
|
559 | if [ "$EXPANDROOT" = true ] ; then | |
557 | APT_INCLUDES="${APT_INCLUDES},parted" |
|
560 | APT_INCLUDES="${APT_INCLUDES},parted" | |
558 | fi |
|
561 | fi | |
559 |
|
562 | |||
560 | # Add dphys-swapfile package, required to enable swap |
|
563 | # Add dphys-swapfile package, required to enable swap | |
561 | if [ "$ENABLE_DPHYSSWAP" = true ] ; then |
|
564 | if [ "$ENABLE_DPHYSSWAP" = true ] ; then | |
562 | APT_INCLUDES="${APT_INCLUDES},dphys-swapfile" |
|
565 | APT_INCLUDES="${APT_INCLUDES},dphys-swapfile" | |
563 | fi |
|
566 | fi | |
564 |
|
567 | |||
565 | # Add dbus package, recommended if using systemd |
|
568 | # Add dbus package, recommended if using systemd | |
566 | if [ "$ENABLE_DBUS" = true ] ; then |
|
569 | if [ "$ENABLE_DBUS" = true ] ; then | |
567 | APT_INCLUDES="${APT_INCLUDES},dbus" |
|
570 | APT_INCLUDES="${APT_INCLUDES},dbus" | |
568 | fi |
|
571 | fi | |
569 |
|
572 | |||
570 | # Add iptables IPv4/IPv6 package |
|
573 | # Add iptables IPv4/IPv6 package | |
571 | if [ "$ENABLE_IPTABLES" = true ] ; then |
|
574 | if [ "$ENABLE_IPTABLES" = true ] ; then | |
572 | APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent" |
|
575 | APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent" | |
573 | fi |
|
576 | fi | |
574 | # Add apparmor for KERNEL_SECURITY |
|
577 | # Add apparmor for KERNEL_SECURITY | |
575 | if [ "$KERNEL_SECURITY" = true ] ; then |
|
578 | if [ "$KERNEL_SECURITY" = true ] ; then | |
576 | APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl" |
|
579 | APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl" | |
577 | fi |
|
580 | fi | |
578 |
|
581 | |||
579 | # Add openssh server package |
|
582 | # Add openssh server package | |
580 | if [ "$ENABLE_SSHD" = true ] ; then |
|
583 | if [ "$ENABLE_SSHD" = true ] ; then | |
581 | APT_INCLUDES="${APT_INCLUDES},openssh-server" |
|
584 | APT_INCLUDES="${APT_INCLUDES},openssh-server" | |
582 | fi |
|
585 | fi | |
583 |
|
586 | |||
584 | # Add alsa-utils package |
|
587 | # Add alsa-utils package | |
585 | if [ "$ENABLE_SOUND" = true ] ; then |
|
588 | if [ "$ENABLE_SOUND" = true ] ; then | |
586 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" |
|
589 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" | |
587 | fi |
|
590 | fi | |
588 |
|
591 | |||
589 | # Add rng-tools package |
|
592 | # Add rng-tools package | |
590 | if [ "$ENABLE_HWRANDOM" = true ] ; then |
|
593 | if [ "$ENABLE_HWRANDOM" = true ] ; then | |
591 | APT_INCLUDES="${APT_INCLUDES},rng-tools" |
|
594 | APT_INCLUDES="${APT_INCLUDES},rng-tools" | |
592 | fi |
|
595 | fi | |
593 |
|
596 | |||
594 | # Add fbturbo video driver |
|
597 | # Add fbturbo video driver | |
595 | if [ "$ENABLE_FBTURBO" = true ] ; then |
|
598 | if [ "$ENABLE_FBTURBO" = true ] ; then | |
596 | # Enable xorg package dependencies |
|
599 | # Enable xorg package dependencies | |
597 | ENABLE_XORG=true |
|
600 | ENABLE_XORG=true | |
598 | fi |
|
601 | fi | |
599 |
|
602 | |||
600 | # Add user defined window manager package |
|
603 | # Add user defined window manager package | |
601 | if [ -n "$ENABLE_WM" ] ; then |
|
604 | if [ -n "$ENABLE_WM" ] ; then | |
602 | APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" |
|
605 | APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" | |
603 |
|
606 | |||
604 | # Enable xorg package dependencies |
|
607 | # Enable xorg package dependencies | |
605 | ENABLE_XORG=true |
|
608 | ENABLE_XORG=true | |
606 | fi |
|
609 | fi | |
607 |
|
610 | |||
608 | # Add xorg package |
|
611 | # Add xorg package | |
609 | if [ "$ENABLE_XORG" = true ] ; then |
|
612 | if [ "$ENABLE_XORG" = true ] ; then | |
610 | APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11" |
|
613 | APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11" | |
611 | fi |
|
614 | fi | |
612 |
|
615 | |||
613 | # Replace selected packages with smaller clones |
|
616 | # Replace selected packages with smaller clones | |
614 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
617 | if [ "$ENABLE_REDUCE" = true ] ; then | |
615 | # Add levee package instead of vim-tiny |
|
618 | # Add levee package instead of vim-tiny | |
616 | if [ "$REDUCE_VIM" = true ] ; then |
|
619 | if [ "$REDUCE_VIM" = true ] ; then | |
617 | APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")" |
|
620 | APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")" | |
618 | fi |
|
621 | fi | |
619 |
|
622 | |||
620 | # Add dropbear package instead of openssh-server |
|
623 | # Add dropbear package instead of openssh-server | |
621 | if [ "$REDUCE_SSHD" = true ] ; then |
|
624 | if [ "$REDUCE_SSHD" = true ] ; then | |
622 | APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" |
|
625 | APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" | |
623 | fi |
|
626 | fi | |
624 | fi |
|
627 | fi | |
625 |
|
628 | |||
626 | # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available |
|
629 | # Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available | |
627 | if [ "$ENABLE_SYSVINIT" = false ] ; then |
|
630 | if [ "$ENABLE_SYSVINIT" = false ] ; then | |
628 | APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" |
|
631 | APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" | |
629 | fi |
|
632 | fi | |
630 |
|
633 | |||
631 | # Configure kernel sources if no KERNELSRC_DIR |
|
634 | # Configure kernel sources if no KERNELSRC_DIR | |
632 | if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then |
|
635 | if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then | |
633 | KERNELSRC_CONFIG=true |
|
636 | KERNELSRC_CONFIG=true | |
634 | fi |
|
637 | fi | |
635 |
|
638 | |||
636 | # Configure reduced kernel |
|
639 | # Configure reduced kernel | |
637 | if [ "$KERNEL_REDUCE" = true ] ; then |
|
640 | if [ "$KERNEL_REDUCE" = true ] ; then | |
638 | KERNELSRC_CONFIG=false |
|
641 | KERNELSRC_CONFIG=false | |
639 | fi |
|
642 | fi | |
640 |
|
643 | |||
641 | # Configure qemu compatible kernel |
|
644 | # Configure qemu compatible kernel | |
642 | if [ "$ENABLE_QEMU" = true ] ; then |
|
645 | if [ "$ENABLE_QEMU" = true ] ; then | |
643 | DTB_FILE=vexpress-v2p-ca15_a7.dtb |
|
646 | DTB_FILE=vexpress-v2p-ca15_a7.dtb | |
644 | UBOOT_CONFIG=vexpress_ca15_tc2_defconfig |
|
647 | UBOOT_CONFIG=vexpress_ca15_tc2_defconfig | |
645 | KERNEL_DEFCONFIG="vexpress_defconfig" |
|
648 | KERNEL_DEFCONFIG="vexpress_defconfig" | |
646 | if [ "$KERNEL_MENUCONFIG" = false ] ; then |
|
649 | if [ "$KERNEL_MENUCONFIG" = false ] ; then | |
647 | KERNEL_OLDDEFCONFIG=true |
|
650 | KERNEL_OLDDEFCONFIG=true | |
648 | fi |
|
651 | fi | |
649 | fi |
|
652 | fi | |
650 |
|
653 | |||
651 | # Execute bootstrap scripts |
|
654 | # Execute bootstrap scripts | |
652 | for SCRIPT in bootstrap.d/*.sh; do |
|
655 | for SCRIPT in bootstrap.d/*.sh; do | |
653 | head -n 3 "$SCRIPT" |
|
656 | head -n 3 "$SCRIPT" | |
654 | . "$SCRIPT" |
|
657 | . "$SCRIPT" | |
655 | done |
|
658 | done | |
656 |
|
659 | |||
657 | ## Execute custom bootstrap scripts |
|
660 | ## Execute custom bootstrap scripts | |
658 | if [ -d "custom.d" ] ; then |
|
661 | if [ -d "custom.d" ] ; then | |
659 | for SCRIPT in custom.d/*.sh; do |
|
662 | for SCRIPT in custom.d/*.sh; do | |
660 | . "$SCRIPT" |
|
663 | . "$SCRIPT" | |
661 | done |
|
664 | done | |
662 | fi |
|
665 | fi | |
663 |
|
666 | |||
664 | # Execute custom scripts inside the chroot |
|
667 | # Execute custom scripts inside the chroot | |
665 | if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then |
|
668 | if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then | |
666 | cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" |
|
669 | cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" | |
667 | chroot_exec /bin/bash -x <<'EOF' |
|
670 | chroot_exec /bin/bash -x <<'EOF' | |
668 | for SCRIPT in /chroot_scripts/* ; do |
|
671 | for SCRIPT in /chroot_scripts/* ; do | |
669 | if [ -f $SCRIPT -a -x $SCRIPT ] ; then |
|
672 | if [ -f $SCRIPT -a -x $SCRIPT ] ; then | |
670 | $SCRIPT |
|
673 | $SCRIPT | |
671 | fi |
|
674 | fi | |
672 | done |
|
675 | done | |
673 | EOF |
|
676 | EOF | |
674 | rm -rf "${R}/chroot_scripts" |
|
677 | rm -rf "${R}/chroot_scripts" | |
675 | fi |
|
678 | fi | |
676 |
|
679 | |||
677 | # Remove c/c++ build environment from the chroot |
|
680 | # Remove c/c++ build environment from the chroot | |
678 | chroot_remove_cc |
|
681 | chroot_remove_cc | |
679 |
|
682 | |||
680 | # Generate required machine-id |
|
683 | # Generate required machine-id | |
681 | MACHINE_ID=$(dbus-uuidgen) |
|
684 | MACHINE_ID=$(dbus-uuidgen) | |
682 | echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id" |
|
685 | echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id" | |
683 | echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id" |
|
686 | echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id" | |
684 |
|
687 | |||
685 | # APT Cleanup |
|
688 | # APT Cleanup | |
686 | chroot_exec apt-get -y clean |
|
689 | chroot_exec apt-get -y clean | |
687 | chroot_exec apt-get -y autoclean |
|
690 | chroot_exec apt-get -y autoclean | |
688 | chroot_exec apt-get -y autoremove |
|
691 | chroot_exec apt-get -y autoremove | |
689 |
|
692 | |||
690 | # Unmount mounted filesystems |
|
693 | # Unmount mounted filesystems | |
691 | umount -l "${R}/proc" |
|
694 | umount -l "${R}/proc" | |
692 | umount -l "${R}/sys" |
|
695 | umount -l "${R}/sys" | |
693 |
|
696 | |||
694 | # Clean up directories |
|
697 | # Clean up directories | |
695 | rm -rf "${R}/run/*" |
|
698 | rm -rf "${R}/run/*" | |
696 | rm -rf "${R}/tmp/*" |
|
699 | rm -rf "${R}/tmp/*" | |
697 |
|
700 | |||
698 | # Clean up APT proxy settings |
|
701 | # Clean up APT proxy settings | |
699 | if [ "$KEEP_APT_PROXY" = false ] ; then |
|
702 | if [ "$KEEP_APT_PROXY" = false ] ; then | |
700 | rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy" |
|
703 | rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy" | |
701 | fi |
|
704 | fi | |
702 |
|
705 | |||
703 | # Clean up files |
|
706 | # Clean up files | |
704 | rm -f "${ETC_DIR}/ssh/ssh_host_*" |
|
707 | rm -f "${ETC_DIR}/ssh/ssh_host_*" | |
705 | rm -f "${ETC_DIR}/dropbear/dropbear_*" |
|
708 | rm -f "${ETC_DIR}/dropbear/dropbear_*" | |
706 | rm -f "${ETC_DIR}/apt/sources.list.save" |
|
709 | rm -f "${ETC_DIR}/apt/sources.list.save" | |
707 | rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original" |
|
710 | rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original" | |
708 | rm -f "${ETC_DIR}/*-" |
|
711 | rm -f "${ETC_DIR}/*-" | |
709 | rm -f "${ETC_DIR}/resolv.conf" |
|
712 | rm -f "${ETC_DIR}/resolv.conf" | |
710 | rm -f "${R}/root/.bash_history" |
|
713 | rm -f "${R}/root/.bash_history" | |
711 | rm -f "${R}/var/lib/urandom/random-seed" |
|
714 | rm -f "${R}/var/lib/urandom/random-seed" | |
712 | rm -f "${R}/initrd.img" |
|
715 | rm -f "${R}/initrd.img" | |
713 | rm -f "${R}/vmlinuz" |
|
716 | rm -f "${R}/vmlinuz" | |
714 | rm -f "${R}${QEMU_BINARY}" |
|
717 | rm -f "${R}${QEMU_BINARY}" | |
715 |
|
718 | |||
716 | if [ "$ENABLE_QEMU" = true ] ; then |
|
719 | if [ "$ENABLE_QEMU" = true ] ; then | |
717 | # Setup QEMU directory |
|
720 | # Setup QEMU directory | |
718 | mkdir "${BASEDIR}/qemu" |
|
721 | mkdir "${BASEDIR}/qemu" | |
719 |
|
722 | |||
720 | # Copy kernel image to QEMU directory |
|
723 | # Copy kernel image to QEMU directory | |
721 | install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}" |
|
724 | install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}" | |
722 |
|
725 | |||
723 | # Copy kernel config to QEMU directory |
|
726 | # Copy kernel config to QEMU directory | |
724 | install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}" |
|
727 | install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}" | |
725 |
|
728 | |||
726 | # Copy kernel dtbs to QEMU directory |
|
729 | # Copy kernel dtbs to QEMU directory | |
727 | for dtb in "${BOOT_DIR}/"*.dtb ; do |
|
730 | for dtb in "${BOOT_DIR}/"*.dtb ; do | |
728 | if [ -f "${dtb}" ] ; then |
|
731 | if [ -f "${dtb}" ] ; then | |
729 | install_readonly "${dtb}" "${BASEDIR}/qemu/" |
|
732 | install_readonly "${dtb}" "${BASEDIR}/qemu/" | |
730 | fi |
|
733 | fi | |
731 | done |
|
734 | done | |
732 |
|
735 | |||
733 | # Copy kernel overlays to QEMU directory |
|
736 | # Copy kernel overlays to QEMU directory | |
734 | if [ -d "${BOOT_DIR}/overlays" ] ; then |
|
737 | if [ -d "${BOOT_DIR}/overlays" ] ; then | |
735 | # Setup overlays dtbs directory |
|
738 | # Setup overlays dtbs directory | |
736 | mkdir "${BASEDIR}/qemu/overlays" |
|
739 | mkdir "${BASEDIR}/qemu/overlays" | |
737 |
|
740 | |||
738 | for dtb in "${BOOT_DIR}/overlays/"*.dtbo ; do |
|
741 | for dtb in "${BOOT_DIR}/overlays/"*.dtbo ; do | |
739 | if [ -f "${dtb}" ] ; then |
|
742 | if [ -f "${dtb}" ] ; then | |
740 | install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/" |
|
743 | install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/" | |
741 | fi |
|
744 | fi | |
742 | done |
|
745 | done | |
743 | fi |
|
746 | fi | |
744 |
|
747 | |||
745 | # Copy u-boot files to QEMU directory |
|
748 | # Copy u-boot files to QEMU directory | |
746 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
749 | if [ "$ENABLE_UBOOT" = true ] ; then | |
747 | if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then |
|
750 | if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then | |
748 | install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin" |
|
751 | install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin" | |
749 | fi |
|
752 | fi | |
750 | if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then |
|
753 | if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then | |
751 | install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage" |
|
754 | install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage" | |
752 | fi |
|
755 | fi | |
753 | if [ -f "${BOOT_DIR}/boot.scr" ] ; then |
|
756 | if [ -f "${BOOT_DIR}/boot.scr" ] ; then | |
754 | install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr" |
|
757 | install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr" | |
755 | fi |
|
758 | fi | |
756 | fi |
|
759 | fi | |
757 |
|
760 | |||
758 | # Copy initramfs to QEMU directory |
|
761 | # Copy initramfs to QEMU directory | |
759 | if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then |
|
762 | if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then | |
760 | install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}" |
|
763 | install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}" | |
761 | fi |
|
764 | fi | |
762 | fi |
|
765 | fi | |
763 |
|
766 | |||
764 | # Calculate size of the chroot directory in KB |
|
767 | # Calculate size of the chroot directory in KB | |
765 | CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')") |
|
768 | CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')") | |
766 |
|
769 | |||
767 | # Calculate the amount of needed 512 Byte sectors |
|
770 | # Calculate the amount of needed 512 Byte sectors | |
768 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) |
|
771 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) | |
769 | FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512) |
|
772 | FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512) | |
770 | ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}") |
|
773 | ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}") | |
771 |
|
774 | |||
772 | # The root partition is EXT4 |
|
775 | # The root partition is EXT4 | |
773 | # This means more space than the actual used space of the chroot is used. |
|
776 | # This means more space than the actual used space of the chroot is used. | |
774 | # As overhead for journaling and reserved blocks 35% are added. |
|
777 | # As overhead for journaling and reserved blocks 35% are added. | |
775 | ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512) |
|
778 | ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512) | |
776 |
|
779 | |||
777 | # Calculate required image size in 512 Byte sectors |
|
780 | # Calculate required image size in 512 Byte sectors | |
778 | IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}") |
|
781 | IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}") | |
779 |
|
782 | |||
780 | # Prepare image file |
|
783 | # Prepare image file | |
781 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
784 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
782 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}" |
|
785 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}" | |
783 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}" |
|
786 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}" | |
784 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" |
|
787 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" | |
785 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}" |
|
788 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}" | |
786 |
|
789 | |||
787 | # Write firmware/boot partition tables |
|
790 | # Write firmware/boot partition tables | |
788 | sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM |
|
791 | sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM | |
789 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* |
|
792 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* | |
790 | EOM |
|
793 | EOM | |
791 |
|
794 | |||
792 | # Write root partition table |
|
795 | # Write root partition table | |
793 | sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM |
|
796 | sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM | |
794 | ${TABLE_SECTORS},${ROOT_SECTORS},83 |
|
797 | ${TABLE_SECTORS},${ROOT_SECTORS},83 | |
795 | EOM |
|
798 | EOM | |
796 |
|
799 | |||
797 | # Setup temporary loop devices |
|
800 | # Setup temporary loop devices | |
798 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)" |
|
801 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)" | |
799 | ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)" |
|
802 | ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)" | |
800 | else # ENABLE_SPLITFS=false |
|
803 | else # ENABLE_SPLITFS=false | |
801 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}" |
|
804 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}" | |
802 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}" |
|
805 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}" | |
803 |
|
806 | |||
804 | # Write partition table |
|
807 | # Write partition table | |
805 | sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM |
|
808 | sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM | |
806 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* |
|
809 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* | |
807 | ${ROOT_OFFSET},${ROOT_SECTORS},83 |
|
810 | ${ROOT_OFFSET},${ROOT_SECTORS},83 | |
808 | EOM |
|
811 | EOM | |
809 |
|
812 | |||
810 | # Setup temporary loop devices |
|
813 | # Setup temporary loop devices | |
811 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)" |
|
814 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)" | |
812 | ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)" |
|
815 | ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)" | |
813 | fi |
|
816 | fi | |
814 |
|
817 | |||
815 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
818 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
816 | # Create dummy ext4 fs |
|
819 | # Create dummy ext4 fs | |
817 | mkfs.ext4 "$ROOT_LOOP" |
|
820 | mkfs.ext4 "$ROOT_LOOP" | |
818 |
|
821 | |||
819 | # Setup password keyfile |
|
822 | # Setup password keyfile | |
820 | touch .password |
|
823 | touch .password | |
821 | chmod 600 .password |
|
824 | chmod 600 .password | |
822 | echo -n ${CRYPTFS_PASSWORD} > .password |
|
825 | echo -n ${CRYPTFS_PASSWORD} > .password | |
823 |
|
826 | |||
824 | # Initialize encrypted partition |
|
827 | # Initialize encrypted partition | |
825 | echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password |
|
828 | echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password | |
826 |
|
829 | |||
827 | # Open encrypted partition and setup mapping |
|
830 | # Open encrypted partition and setup mapping | |
828 | cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}" |
|
831 | cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}" | |
829 |
|
832 | |||
830 | # Secure delete password keyfile |
|
833 | # Secure delete password keyfile | |
831 | shred -zu .password |
|
834 | shred -zu .password | |
832 |
|
835 | |||
833 | # Update temporary loop device |
|
836 | # Update temporary loop device | |
834 | ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}" |
|
837 | ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}" | |
835 |
|
838 | |||
836 | # Wipe encrypted partition (encryption cipher is used for randomness) |
|
839 | # Wipe encrypted partition (encryption cipher is used for randomness) | |
837 | dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")" |
|
840 | dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")" | |
838 | fi |
|
841 | fi | |
839 |
|
842 | |||
840 | # Build filesystems |
|
843 | # Build filesystems | |
841 | mkfs.vfat "$FRMW_LOOP" |
|
844 | mkfs.vfat "$FRMW_LOOP" | |
842 | mkfs.ext4 "$ROOT_LOOP" |
|
845 | mkfs.ext4 "$ROOT_LOOP" | |
843 |
|
846 | |||
844 | # Mount the temporary loop devices |
|
847 | # Mount the temporary loop devices | |
845 | mkdir -p "$BUILDDIR/mount" |
|
848 | mkdir -p "$BUILDDIR/mount" | |
846 | mount "$ROOT_LOOP" "$BUILDDIR/mount" |
|
849 | mount "$ROOT_LOOP" "$BUILDDIR/mount" | |
847 |
|
850 | |||
848 | mkdir -p "$BUILDDIR/mount/boot/firmware" |
|
851 | mkdir -p "$BUILDDIR/mount/boot/firmware" | |
849 | mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" |
|
852 | mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" | |
850 |
|
853 | |||
851 | # Copy all files from the chroot to the loop device mount point directory |
|
854 | # Copy all files from the chroot to the loop device mount point directory | |
852 | rsync -a "${R}/" "$BUILDDIR/mount/" |
|
855 | rsync -a "${R}/" "$BUILDDIR/mount/" | |
853 |
|
856 | |||
854 | # Unmount all temporary loop devices and mount points |
|
857 | # Unmount all temporary loop devices and mount points | |
855 | cleanup |
|
858 | cleanup | |
856 |
|
859 | |||
857 | # Create block map file(s) of image(s) |
|
860 | # Create block map file(s) of image(s) | |
858 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
861 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
859 | # Create block map files for "bmaptool" |
|
862 | # Create block map files for "bmaptool" | |
860 | bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img" |
|
863 | bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img" | |
861 | bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img" |
|
864 | bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img" | |
862 |
|
865 | |||
863 | # Image was successfully created |
|
866 | # Image was successfully created | |
864 | echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
867 | echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
865 | echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
868 | echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
866 | else |
|
869 | else | |
867 | # Create block map file for "bmaptool" |
|
870 | # Create block map file for "bmaptool" | |
868 | bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img" |
|
871 | bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img" | |
869 |
|
872 | |||
870 | # Image was successfully created |
|
873 | # Image was successfully created | |
871 | echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
874 | echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
872 |
|
875 | |||
873 | # Create qemu qcow2 image |
|
876 | # Create qemu qcow2 image | |
874 | if [ "$ENABLE_QEMU" = true ] ; then |
|
877 | if [ "$ENABLE_QEMU" = true ] ; then | |
875 | QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
878 | QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} | |
876 | QEMU_SIZE=16G |
|
879 | QEMU_SIZE=16G | |
877 |
|
880 | |||
878 | qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2 |
|
881 | qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2 | |
879 | qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE |
|
882 | qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE | |
880 |
|
883 | |||
881 | echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created" |
|
884 | echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created" | |
882 | fi |
|
885 | fi | |
883 | fi |
|
886 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant