##// END OF EJS Templates
a
Unknown -
r461:94a4fd90add9
parent child
Show More
@@ -1,472 +1,469
1 #
1 #
2 # Build and Setup RPi2/3 Kernel
2 # Build and Setup RPi2/3 Kernel
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Fetch and build latest raspberry kernel
8 # Fetch and build latest raspberry kernel
9 if [ "$BUILD_KERNEL" = true ] ; then
9 if [ "$BUILD_KERNEL" = true ] ; then
10 # Setup source directory
10 # Setup source directory
11 mkdir -p "${KERNEL_DIR}"
11 mkdir -p "${KERNEL_DIR}"
12
12
13 # Copy existing kernel sources into chroot directory
13 # Copy existing kernel sources into chroot directory
14 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
14 if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then
15 # Copy kernel sources and include hidden files
15 # Copy kernel sources and include hidden files
16 cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}"
16 cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}"
17
17
18 # Clean the kernel sources
18 # Clean the kernel sources
19 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
19 if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then
20 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
20 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper
21 fi
21 fi
22 else # KERNELSRC_DIR=""
22 else # KERNELSRC_DIR=""
23 # Create temporary directory for kernel sources
23 # Create temporary directory for kernel sources
24 temp_dir=$(as_nobody mktemp -d)
24 temp_dir=$(as_nobody mktemp -d)
25
25
26 # Fetch current RPi2/3 kernel sources
26 # Fetch current RPi2/3 kernel sources
27 if [ -z "${KERNEL_BRANCH}" ] ; then
27 if [ -z "${KERNEL_BRANCH}" ] ; then
28 as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
28 as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux
29 else
29 else
30 as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
30 as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux
31 fi
31 fi
32
32
33 # Copy downloaded kernel sources
33 # Copy downloaded kernel sources
34 cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}"
34 cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}"
35
35
36 # Remove temporary directory for kernel sources
36 # Remove temporary directory for kernel sources
37 rm -fr "${temp_dir}"
37 rm -fr "${temp_dir}"
38
38
39 # Set permissions of the kernel sources
39 # Set permissions of the kernel sources
40 chown -R root:root "${R}/usr/src"
40 chown -R root:root "${R}/usr/src"
41 fi
41 fi
42
42
43 # Calculate optimal number of kernel building threads
43 # Calculate optimal number of kernel building threads
44 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
44 if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then
45 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
45 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
46 fi
46 fi
47
47
48 # Configure and build kernel
48 # Configure and build kernel
49 if [ "$KERNELSRC_PREBUILT" = false ] ; then
49 if [ "$KERNELSRC_PREBUILT" = false ] ; then
50 # Remove device, network and filesystem drivers from kernel configuration
50 # Remove device, network and filesystem drivers from kernel configuration
51 if [ "$KERNEL_REDUCE" = true ] ; then
51 if [ "$KERNEL_REDUCE" = true ] ; then
52 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
52 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
53 sed -i\
53 sed -i\
54 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
54 -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\
55 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
55 -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\
56 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
56 -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\
57 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
57 -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\
58 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
58 -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\
59 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
59 -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\
60 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
60 -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\
61 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
61 -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\
62 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
62 -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\
63 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
63 -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\
64 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
64 -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\
65 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
65 -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\
66 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
66 -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\
67 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
67 -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\
68 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
68 -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\
69 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
69 -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\
70 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
70 -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\
71 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
71 -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\
72 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
72 -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\
73 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
73 -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\
74 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
74 -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\
75 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
75 -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\
76 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
76 -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\
77 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
77 -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\
78 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
78 -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\
79 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
79 -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\
80 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
80 -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\
81 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
81 -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\
82 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
82 -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\
83 "${KERNEL_DIR}/.config"
83 "${KERNEL_DIR}/.config"
84 fi
84 fi
85
85
86 if [ "$KERNELSRC_CONFIG" = true ] ; then
86 if [ "$KERNELSRC_CONFIG" = true ] ; then
87 # Load default raspberry kernel configuration
87 # Load default raspberry kernel configuration
88 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
88 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
89
89
90 #Switch to KERNELSRC_DIR so we can use set_kernel_config
90 #Switch to KERNELSRC_DIR so we can use set_kernel_config
91 cd "${KERNEL_DIR}" || exit
91 cd "${KERNEL_DIR}" || exit
92
92
93 # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap
93 # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap
94 if [ "$KERNEL_ZSWAP" = true ] ; then
94 if [ "$KERNEL_ZSWAP" = true ] ; then
95 set_kernel_config CONFIG_ZPOOL y
95 set_kernel_config CONFIG_ZPOOL y
96 set_kernel_config CONFIG_ZSWAP y
96 set_kernel_config CONFIG_ZSWAP y
97 set_kernel_config CONFIG_ZBUD y
97 set_kernel_config CONFIG_ZBUD y
98 set_kernel_config CONFIG_Z3FOLD y
98 set_kernel_config CONFIG_Z3FOLD y
99 set_kernel_config CONFIG_ZSMALLOC y
99 set_kernel_config CONFIG_ZSMALLOC y
100 set_kernel_config CONFIG_PGTABLE_MAPPING y
100 set_kernel_config CONFIG_PGTABLE_MAPPING y
101 fi
101 fi
102
102
103 # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
103 # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
104 if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
104 if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
105 set_kernel_config CONFIG_VIRTUALIZATION y
105 set_kernel_config CONFIG_VIRTUALIZATION y
106 set_kernel_config CONFIG_KVM y
106 set_kernel_config CONFIG_KVM y
107 set_kernel_config CONFIG_VHOST_NET m
107 set_kernel_config CONFIG_VHOST_NET m
108 set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y
108 set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y
109 fi
109 fi
110
110
111 # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
111 # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
112 if [ "$KERNEL_NF" = true ] ; then
112 if [ "$KERNEL_NF" = true ] ; then
113 set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m
113 set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m
114 set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m
114 set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m
115 set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m
115 set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m
116 set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m
116 set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m
117 set_kernel_config CONFIG_NFT_FIB_INET m
117 set_kernel_config CONFIG_NFT_FIB_INET m
118 set_kernel_config CONFIG_NFT_FIB_IPV4 m
118 set_kernel_config CONFIG_NFT_FIB_IPV4 m
119 set_kernel_config CONFIG_NFT_FIB_IPV6 m
119 set_kernel_config CONFIG_NFT_FIB_IPV6 m
120 set_kernel_config CONFIG_NFT_FIB_NETDEV m
120 set_kernel_config CONFIG_NFT_FIB_NETDEV m
121 set_kernel_config CONFIG_NFT_OBJREF m
121 set_kernel_config CONFIG_NFT_OBJREF m
122 set_kernel_config CONFIG_NFT_RT m
122 set_kernel_config CONFIG_NFT_RT m
123 set_kernel_config CONFIG_NFT_SET_BITMAP m
123 set_kernel_config CONFIG_NFT_SET_BITMAP m
124 set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y
124 set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y
125 set_kernel_config CONFIG_NF_LOG_ARP m
125 set_kernel_config CONFIG_NF_LOG_ARP m
126 set_kernel_config CONFIG_NF_SOCKET_IPV4 m
126 set_kernel_config CONFIG_NF_SOCKET_IPV4 m
127 set_kernel_config CONFIG_NF_SOCKET_IPV6 m
127 set_kernel_config CONFIG_NF_SOCKET_IPV6 m
128 set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m
128 set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m
129 set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m
129 set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m
130 set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m
130 set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m
131 set_kernel_config CONFIG_IP6_NF_IPTABLES m
131 set_kernel_config CONFIG_IP6_NF_IPTABLES m
132 set_kernel_config CONFIG_IP6_NF_MATCH_AH m
132 set_kernel_config CONFIG_IP6_NF_MATCH_AH m
133 set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m
133 set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m
134 set_kernel_config CONFIG_IP6_NF_NAT m
134 set_kernel_config CONFIG_IP6_NF_NAT m
135 set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m
135 set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m
136 set_kernel_config CONFIG_IP6_NF_TARGET_NPT m
136 set_kernel_config CONFIG_IP6_NF_TARGET_NPT m
137 set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m
137 set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m
138 set_kernel_config CONFIG_IP_SET_BITMAP_PORT m
138 set_kernel_config CONFIG_IP_SET_BITMAP_PORT m
139 set_kernel_config CONFIG_IP_SET_HASH_IP m
139 set_kernel_config CONFIG_IP_SET_HASH_IP m
140 set_kernel_config CONFIG_IP_SET_HASH_IPMARK m
140 set_kernel_config CONFIG_IP_SET_HASH_IPMARK m
141 set_kernel_config CONFIG_IP_SET_HASH_IPPORT m
141 set_kernel_config CONFIG_IP_SET_HASH_IPPORT m
142 set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m
142 set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m
143 set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m
143 set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m
144 set_kernel_config CONFIG_IP_SET_HASH_MAC m
144 set_kernel_config CONFIG_IP_SET_HASH_MAC m
145 set_kernel_config CONFIG_IP_SET_HASH_NET m
145 set_kernel_config CONFIG_IP_SET_HASH_NET m
146 set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m
146 set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m
147 set_kernel_config CONFIG_IP_SET_HASH_NETNET m
147 set_kernel_config CONFIG_IP_SET_HASH_NETNET m
148 set_kernel_config CONFIG_IP_SET_HASH_NETPORT m
148 set_kernel_config CONFIG_IP_SET_HASH_NETPORT m
149 set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m
149 set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m
150 set_kernel_config CONFIG_IP_SET_LIST_SET m
150 set_kernel_config CONFIG_IP_SET_LIST_SET m
151 set_kernel_config CONFIG_NETFILTER_XTABLES m
151 set_kernel_config CONFIG_NETFILTER_XTABLES m
152 set_kernel_config CONFIG_NETFILTER_XTABLES m
152 set_kernel_config CONFIG_NETFILTER_XTABLES m
153 set_kernel_config CONFIG_NFT_BRIDGE_META m
153 set_kernel_config CONFIG_NFT_BRIDGE_META m
154 set_kernel_config CONFIG_NFT_BRIDGE_REJECT m
154 set_kernel_config CONFIG_NFT_BRIDGE_REJECT m
155 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m
155 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m
156 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m
156 set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m
157 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m
157 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m
158 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m
158 set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m
159 set_kernel_config CONFIG_NFT_COMPAT m
159 set_kernel_config CONFIG_NFT_COMPAT m
160 set_kernel_config CONFIG_NFT_COUNTER m
160 set_kernel_config CONFIG_NFT_COUNTER m
161 set_kernel_config CONFIG_NFT_CT m
161 set_kernel_config CONFIG_NFT_CT m
162 set_kernel_config CONFIG_NFT_DUP_IPV4 m
162 set_kernel_config CONFIG_NFT_DUP_IPV4 m
163 set_kernel_config CONFIG_NFT_DUP_IPV6 m
163 set_kernel_config CONFIG_NFT_DUP_IPV6 m
164 set_kernel_config CONFIG_NFT_DUP_NETDEV m
164 set_kernel_config CONFIG_NFT_DUP_NETDEV m
165 set_kernel_config CONFIG_NFT_EXTHDR m
165 set_kernel_config CONFIG_NFT_EXTHDR m
166 set_kernel_config CONFIG_NFT_FWD_NETDEV m
166 set_kernel_config CONFIG_NFT_FWD_NETDEV m
167 set_kernel_config CONFIG_NFT_HASH m
167 set_kernel_config CONFIG_NFT_HASH m
168 set_kernel_config CONFIG_NFT_LIMIT m
168 set_kernel_config CONFIG_NFT_LIMIT m
169 set_kernel_config CONFIG_NFT_LOG m
169 set_kernel_config CONFIG_NFT_LOG m
170 set_kernel_config CONFIG_NFT_MASQ m
170 set_kernel_config CONFIG_NFT_MASQ m
171 set_kernel_config CONFIG_NFT_MASQ_IPV4 m
171 set_kernel_config CONFIG_NFT_MASQ_IPV4 m
172 set_kernel_config CONFIG_NFT_MASQ_IPV6 m
172 set_kernel_config CONFIG_NFT_MASQ_IPV6 m
173 set_kernel_config CONFIG_NFT_META m
173 set_kernel_config CONFIG_NFT_META m
174 set_kernel_config CONFIG_NFT_NAT m
174 set_kernel_config CONFIG_NFT_NAT m
175 set_kernel_config CONFIG_NFT_NUMGEN m
175 set_kernel_config CONFIG_NFT_NUMGEN m
176 set_kernel_config CONFIG_NFT_QUEUE m
176 set_kernel_config CONFIG_NFT_QUEUE m
177 set_kernel_config CONFIG_NFT_QUOTA m
177 set_kernel_config CONFIG_NFT_QUOTA m
178 set_kernel_config CONFIG_NFT_REDIR m
178 set_kernel_config CONFIG_NFT_REDIR m
179 set_kernel_config CONFIG_NFT_REDIR_IPV4 m
179 set_kernel_config CONFIG_NFT_REDIR_IPV4 m
180 set_kernel_config CONFIG_NFT_REDIR_IPV6 m
180 set_kernel_config CONFIG_NFT_REDIR_IPV6 m
181 set_kernel_config CONFIG_NFT_REJECT m
181 set_kernel_config CONFIG_NFT_REJECT m
182 set_kernel_config CONFIG_NFT_REJECT_INET m
182 set_kernel_config CONFIG_NFT_REJECT_INET m
183 set_kernel_config CONFIG_NFT_REJECT_IPV4 m
183 set_kernel_config CONFIG_NFT_REJECT_IPV4 m
184 set_kernel_config CONFIG_NFT_REJECT_IPV6 m
184 set_kernel_config CONFIG_NFT_REJECT_IPV6 m
185 set_kernel_config CONFIG_NFT_SET_HASH m
185 set_kernel_config CONFIG_NFT_SET_HASH m
186 set_kernel_config CONFIG_NFT_SET_RBTREE m
186 set_kernel_config CONFIG_NFT_SET_RBTREE m
187 set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m
187 set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m
188 set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m
188 set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m
189 set_kernel_config CONFIG_NF_DEFRAG_IPV4 m
189 set_kernel_config CONFIG_NF_DEFRAG_IPV4 m
190 set_kernel_config CONFIG_NF_DEFRAG_IPV6 m
190 set_kernel_config CONFIG_NF_DEFRAG_IPV6 m
191 set_kernel_config CONFIG_NF_DUP_IPV4 m
191 set_kernel_config CONFIG_NF_DUP_IPV4 m
192 set_kernel_config CONFIG_NF_DUP_IPV6 m
192 set_kernel_config CONFIG_NF_DUP_IPV6 m
193 set_kernel_config CONFIG_NF_DUP_NETDEV m
193 set_kernel_config CONFIG_NF_DUP_NETDEV m
194 set_kernel_config CONFIG_NF_LOG_BRIDGE m
194 set_kernel_config CONFIG_NF_LOG_BRIDGE m
195 set_kernel_config CONFIG_NF_LOG_IPV4 m
195 set_kernel_config CONFIG_NF_LOG_IPV4 m
196 set_kernel_config CONFIG_NF_LOG_IPV6 m
196 set_kernel_config CONFIG_NF_LOG_IPV6 m
197 set_kernel_config CONFIG_NF_NAT_IPV4 m
197 set_kernel_config CONFIG_NF_NAT_IPV4 m
198 set_kernel_config CONFIG_NF_NAT_IPV6 m
198 set_kernel_config CONFIG_NF_NAT_IPV6 m
199 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 m
199 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 m
200 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 m
200 set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 m
201 set_kernel_config CONFIG_NF_NAT_PPTP m
201 set_kernel_config CONFIG_NF_NAT_PPTP m
202 set_kernel_config CONFIG_NF_NAT_PROTO_GRE m
202 set_kernel_config CONFIG_NF_NAT_PROTO_GRE m
203 set_kernel_config CONFIG_NF_NAT_REDIRECT m
203 set_kernel_config CONFIG_NF_NAT_REDIRECT m
204 set_kernel_config CONFIG_NF_NAT_SIP m
204 set_kernel_config CONFIG_NF_NAT_SIP m
205 set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m
205 set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m
206 set_kernel_config CONFIG_NF_NAT_TFTP m
206 set_kernel_config CONFIG_NF_NAT_TFTP m
207 set_kernel_config CONFIG_NF_REJECT_IPV4 m
207 set_kernel_config CONFIG_NF_REJECT_IPV4 m
208 set_kernel_config CONFIG_NF_REJECT_IPV6 m
208 set_kernel_config CONFIG_NF_REJECT_IPV6 m
209 set_kernel_config CONFIG_NF_TABLES m
209 set_kernel_config CONFIG_NF_TABLES m
210 set_kernel_config CONFIG_NF_TABLES_ARP m
210 set_kernel_config CONFIG_NF_TABLES_ARP m
211 set_kernel_config CONFIG_NF_TABLES_BRIDGE m
211 set_kernel_config CONFIG_NF_TABLES_BRIDGE m
212 set_kernel_config CONFIG_NF_TABLES_INET m
212 set_kernel_config CONFIG_NF_TABLES_INET m
213 set_kernel_config CONFIG_NF_TABLES_IPV4 m
213 set_kernel_config CONFIG_NF_TABLES_IPV4 m
214 set_kernel_config CONFIG_NF_TABLES_IPV6 m
214 set_kernel_config CONFIG_NF_TABLES_IPV6 m
215 set_kernel_config CONFIG_NF_TABLES_NETDEV m
215 set_kernel_config CONFIG_NF_TABLES_NETDEV m
216 fi
216 fi
217
217
218 # 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
218 # 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
219 if [ "$KERNEL_BPF" = true ] ; then
219 if [ "$KERNEL_BPF" = true ] ; then
220 set_kernel_config CONFIG_BPF_SYSCALL y
220 set_kernel_config CONFIG_BPF_SYSCALL y
221 set_kernel_config CONFIG_BPF_EVENTS y
221 set_kernel_config CONFIG_BPF_EVENTS y
222 set_kernel_config CONFIG_BPF_STREAM_PARSER y
222 set_kernel_config CONFIG_BPF_STREAM_PARSER y
223 set_kernel_config CONFIG_CGROUP_BPF y
223 set_kernel_config CONFIG_CGROUP_BPF y
224 fi
224 fi
225
225
226 # KERNEL_DEFAULT_GOV was set by user
226 # KERNEL_DEFAULT_GOV was set by user
227 if ! [ "$KERNEL_DEFAULT_GOV" = POWERSAVE ] && [ -n "$KERNEL_DEFAULT_GOV" ]; then
227 if ! [ "$KERNEL_DEFAULT_GOV" = POWERSAVE ] && [ -n "$KERNEL_DEFAULT_GOV" ]; then
228 # unset default governor
228 # unset default governor
229 unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE
229 unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE
230
230
231 case "$KERNEL_DEFAULT_GOV" in
231 case "$KERNEL_DEFAULT_GOV" in
232 "PERFORMANCE")
232 "PERFORMANCE")
233 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y
233 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y
234 ;;
234 ;;
235 "USERSPACE")
235 "USERSPACE")
236 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE y
236 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE y
237 ;;
237 ;;
238 "ONDEMAND")
238 "ONDEMAND")
239 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND y
239 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND y
240 ;;
240 ;;
241 "CONSERVATIVE")
241 "CONSERVATIVE")
242 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE y
242 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE y
243 ;;
243 ;;
244 "CONSERVATIVE")
244 "CONSERVATIVE")
245 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL y
245 set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL y
246 ;;
246 ;;
247 *)
247 *)
248 echo "error: unsupported default cpu governor"
248 echo "error: unsupported default cpu governor"
249 exit 1
249 exit 1
250 ;;
250 ;;
251 esac
251 esac
252 fi
252 fi
253
253
254
254
255
255
256 #Revert to previous directory
256 #Revert to previous directory
257 cd "${WORKDIR}" || exit
257 cd "${WORKDIR}" || exit
258
258
259 # Set kernel configuration parameters to enable qemu emulation
259 # Set kernel configuration parameters to enable qemu emulation
260 if [ "$ENABLE_QEMU" = true ] ; then
260 if [ "$ENABLE_QEMU" = true ] ; then
261 echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config
261 echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config
262 echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config
262 echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config
263
263
264 if [ "$ENABLE_CRYPTFS" = true ] ; then
264 if [ "$ENABLE_CRYPTFS" = true ] ; then
265 {
265 {
266 echo "CONFIG_EMBEDDED=y"
266 echo "CONFIG_EMBEDDED=y"
267 echo "CONFIG_EXPERT=y"
267 echo "CONFIG_EXPERT=y"
268 echo "CONFIG_DAX=y"
268 echo "CONFIG_DAX=y"
269 echo "CONFIG_MD=y"
269 echo "CONFIG_MD=y"
270 echo "CONFIG_BLK_DEV_MD=y"
270 echo "CONFIG_BLK_DEV_MD=y"
271 echo "CONFIG_MD_AUTODETECT=y"
271 echo "CONFIG_MD_AUTODETECT=y"
272 echo "CONFIG_BLK_DEV_DM=y"
272 echo "CONFIG_BLK_DEV_DM=y"
273 echo "CONFIG_BLK_DEV_DM_BUILTIN=y"
273 echo "CONFIG_BLK_DEV_DM_BUILTIN=y"
274 echo "CONFIG_DM_CRYPT=y"
274 echo "CONFIG_DM_CRYPT=y"
275 echo "CONFIG_CRYPTO_BLKCIPHER=y"
275 echo "CONFIG_CRYPTO_BLKCIPHER=y"
276 echo "CONFIG_CRYPTO_CBC=y"
276 echo "CONFIG_CRYPTO_CBC=y"
277 echo "CONFIG_CRYPTO_XTS=y"
277 echo "CONFIG_CRYPTO_XTS=y"
278 echo "CONFIG_CRYPTO_SHA512=y"
278 echo "CONFIG_CRYPTO_SHA512=y"
279 echo "CONFIG_CRYPTO_MANAGER=y"
279 echo "CONFIG_CRYPTO_MANAGER=y"
280 } >> "${KERNEL_DIR}"/.config
280 } >> "${KERNEL_DIR}"/.config
281 fi
281 fi
282 fi
282 fi
283
283
284 # Copy custom kernel configuration file
284 # Copy custom kernel configuration file
285 if [ -n "$KERNELSRC_USRCONFIG" ] ; then
285 if [ -n "$KERNELSRC_USRCONFIG" ] ; then
286 cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config
286 cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config
287 fi
287 fi
288
288
289 # Set kernel configuration parameters to their default values
289 # Set kernel configuration parameters to their default values
290 if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
290 if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
291 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
291 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
292 fi
292 fi
293
293
294 # Start menu-driven kernel configuration (interactive)
294 # Start menu-driven kernel configuration (interactive)
295 if [ "$KERNEL_MENUCONFIG" = true ] ; then
295 if [ "$KERNEL_MENUCONFIG" = true ] ; then
296 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
296 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
297 fi
297 fi
298 # end if "$KERNELSRC_CONFIG" = true
298 # end if "$KERNELSRC_CONFIG" = true
299 fi
299 fi
300
300
301 # Use ccache to cross compile the kernel
301 # Use ccache to cross compile the kernel
302 if [ "$KERNEL_CCACHE" = true ] ; then
302 if [ "$KERNEL_CCACHE" = true ] ; then
303 cc="ccache ${CROSS_COMPILE}gcc"
303 cc="ccache ${CROSS_COMPILE}gcc"
304 else
304 else
305 cc="${CROSS_COMPILE}gcc"
305 cc="${CROSS_COMPILE}gcc"
306 fi
306 fi
307
307
308 # Cross compile kernel and dtbs
308 # Cross compile kernel and dtbs
309 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
309 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
310
310
311 # Cross compile kernel modules
311 # Cross compile kernel modules
312 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
312 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
313 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
313 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
314 fi
314 fi
315 # end if "$KERNELSRC_PREBUILT" = false
315 # end if "$KERNELSRC_PREBUILT" = false
316 fi
316 fi
317
317
318 # Check if kernel compilation was successful
318 # Check if kernel compilation was successful
319 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then
319 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then
320 echo "error: kernel compilation failed! (kernel image not found)"
320 echo "error: kernel compilation failed! (kernel image not found)"
321 cleanup
321 cleanup
322 exit 1
322 exit 1
323 fi
323 fi
324
324
325 # Install kernel modules
325 # Install kernel modules
326 if [ "$ENABLE_REDUCE" = true ] ; then
326 if [ "$ENABLE_REDUCE" = true ] ; then
327 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
327 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
328 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
328 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
329 fi
329 fi
330 else
330 else
331 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
331 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
332 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
332 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
333 fi
333 fi
334
334
335 # Install kernel firmware
335 # Install kernel firmware
336 if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then
336 if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then
337 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
337 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
338 fi
338 fi
339 fi
339 fi
340
340
341 # Install kernel headers
341 # Install kernel headers
342 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
342 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
343 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
343 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
344 fi
344 fi
345 # make tar.gz kernel package - missing os bzw. modules
345 # make tar.gz kernel package - missing os bzw. modules
346 #** ** ** WARNING ** ** **
346 #** ** ** WARNING ** ** **
347 #Your architecture did not define any architecture-dependent files
347 #Your architecture did not define any architecture-dependent files
348 #to be placed into the tarball. Please add those to ./scripts/package/buildtar .
348 #to be placed into the tarball. Please add those to ./scripts/package/buildtar .
349 # make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" targz-pkg
349 # make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" targz-pkg
350
350
351 # Prepare boot (firmware) directory
351 # Prepare boot (firmware) directory
352 mkdir "${BOOT_DIR}"
352 mkdir "${BOOT_DIR}"
353
353
354 # Get kernel release version
354 # Get kernel release version
355 KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release")
355 KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release")
356
356
357 # Copy kernel configuration file to the boot directory
357 # Copy kernel configuration file to the boot directory
358 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
358 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
359
359
360 # Prepare device tree directory
360 # Prepare device tree directory
361 mkdir "${BOOT_DIR}/overlays"
361 mkdir "${BOOT_DIR}/overlays"
362
362
363 # Ensure the proper .dtb is located
363 # Ensure the proper .dtb is located
364 if [ "$KERNEL_ARCH" = "arm" ] ; then
364 if [ "$KERNEL_ARCH" = "arm" ] ; then
365 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
365 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
366 if [ -f "${dtb}" ] ; then
366 if [ -f "${dtb}" ] ; then
367 install_readonly "${dtb}" "${BOOT_DIR}/"
367 install_readonly "${dtb}" "${BOOT_DIR}/"
368 fi
368 fi
369 done
369 done
370 else
370 else
371 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
371 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
372 if [ -f "${dtb}" ] ; then
372 if [ -f "${dtb}" ] ; then
373 install_readonly "${dtb}" "${BOOT_DIR}/"
373 install_readonly "${dtb}" "${BOOT_DIR}/"
374 fi
374 fi
375 done
375 done
376 fi
376 fi
377
377
378 # Copy compiled dtb device tree files
378 # Copy compiled dtb device tree files
379 if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
379 if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
380 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do
380 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do
381 if [ -f "${dtb}" ] ; then
381 if [ -f "${dtb}" ] ; then
382 install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
382 install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
383 fi
383 fi
384 done
384 done
385
385
386 if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
386 if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
387 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
387 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
388 fi
388 fi
389 fi
389 fi
390
390
391 if [ "$ENABLE_UBOOT" = false ] ; then
391 if [ "$ENABLE_UBOOT" = false ] ; then
392 # Convert and copy kernel image to the boot directory
392 # Convert and copy kernel image to the boot directory
393 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
393 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
394 else
394 else
395 # Copy kernel image to the boot directory
395 # Copy kernel image to the boot directory
396 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
396 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
397 fi
397 fi
398
398
399 # Remove kernel sources
399 # Remove kernel sources
400 if [ "$KERNEL_REMOVESRC" = true ] ; then
400 if [ "$KERNEL_REMOVESRC" = true ] ; then
401 rm -fr "${KERNEL_DIR}"
401 rm -fr "${KERNEL_DIR}"
402 else
402 else
403 # Prepare compiled kernel modules
403 # Prepare compiled kernel modules
404 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
404 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
405 if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then
405 if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then
406 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
406 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
407 fi
407 fi
408
408
409 # Create symlinks for kernel modules
409 # Create symlinks for kernel modules
410 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
410 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
411 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
411 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
412 fi
412 fi
413 fi
413 fi
414
414
415 else # BUILD_KERNEL=false
415 else # BUILD_KERNEL=false
416 # echo Install precompiled kernel...
416 # echo Install precompiled kernel...
417 # echo error: not implemented
417 # echo error: not implemented
418 if [ "$SET_ARCH" = 64 ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
418 if [ "$SET_ARCH" = 64 ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
419 if [ "$KERNEL_ZSWAP" = true ] ; then
419 if [ "$KERNEL_ZSWAP" = true ] ; then
420 RPI3_64_KERNEL_URL=RPI3_64_BIS_KERNEL_URL
420 RPI3_64_KERNEL_URL=RPI3_64_BIS_KERNEL_URL
421 fi
421 fi
422 # Create temporary directory for dl
422 # Create temporary directory for dl
423 temp_dir=$(as_nobody mktemp -d)
423 temp_dir=$(as_nobody mktemp -d)
424
424
425 # Fetch kernel dl
425 # Fetch kernel dl
426 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL"
426 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL"
427 #extract download
427 #extract download
428 tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}"
428 tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}"
429
429
430 #move extracted kernel to /boot/firmware
430 #move extracted kernel to /boot/firmware
431 mkdir "${R}/boot/firmware"
431 mkdir "${R}/boot/firmware"
432 cp "${temp_dir}"/boot/* "${R}"/boot/firmware/
432 cp "${temp_dir}"/boot/* "${R}"/boot/firmware/
433 cp -r "${temp_dir}"/lib/* "${R}"/lib/
433 cp -r "${temp_dir}"/lib/* "${R}"/lib/
434
434
435 # Remove temporary directory for kernel sources
435 # Remove temporary directory for kernel sources
436 rm -fr "${temp_dir}"
436 rm -fr "${temp_dir}"
437 # Set permissions of the kernel sources
437 # Set permissions of the kernel sources
438 chown -R root:root "${R}/boot/firmware"
438 chown -R root:root "${R}/boot/firmware"
439 chown -R root:root "${R}/lib/modules"
439 chown -R root:root "${R}/lib/modules"
440 #Create cmdline.txt for 15-rpi-config.sh
440 #Create cmdline.txt for 15-rpi-config.sh
441 touch "${BOOT_DIR}/cmdline.txt"
441 touch "${BOOT_DIR}/cmdline.txt"
442 fi
442 fi
443
443
444 # INstall Kernel from hypriot comptabile with all Raspberry PI
444 # Install Kernel from hypriot comptabile with all Raspberry PI
445 if [ "$SET_ARCH" = 32 ] ; then
445 if [ "$SET_ARCH" = 32 ] ; then
446 # Create temporary directory for dl
447 temp_dir=$(as_nobody mktemp -d)
448
449 # Fetch kernel
446 # Fetch kernel
450 as_nobody wget -O "${temp_dir}"/kernel.deb -c "$RPI_32_KERNEL_URL"
447 as_nobody wget -O "${R}"/kernel.deb -c "$RPI_32_KERNEL_URL"
451
448
452 # Fetch kernel header
449 # Fetch kernel header
453 as_nobody wget -O "${temp_dir}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL"
450 as_nobody wget -O "${R}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL"
454
451
455 # Install kernel
452 # Install kernel
456 chroot_exec dpkg -i "${temp_dir}"/kernel.deb
453 chroot_exec dpkg -i "${R}"/kernel.deb
457
454
458 # Install kernel header
455 # Install kernel header
459 chroot_exec dpkg -i "${temp_dir}"/kernel-header.deb
456 chroot_exec dpkg -i "${R}"/kernel-header.deb
460
457
461 # Remove temporary directory for U-Boot sources
458 # Remove temporary directory for U-Boot sources
462 rm -fr "${temp_dir}"
459 rm -fr "${temp_dir}"
463 fi
460 fi
464
461
465 # Check if kernel installation was successful
462 # Check if kernel installation was successful
466 KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)"
463 KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)"
467 if [ -z "$KERNEL" ] ; then
464 if [ -z "$KERNEL" ] ; then
468 echo "error: kernel installation failed! (/boot/kernel* not found)"
465 echo "error: kernel installation failed! (/boot/kernel* not found)"
469 cleanup
466 cleanup
470 exit 1
467 exit 1
471 fi
468 fi
472 fi
469 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant