blob: 5fd05ebd57c7ef9252372e2e9e6a427158ef302e [file] [log] [blame]
developer73734032024-07-16 02:16:44 +08001#!/bin/bash
2#
3# There are 2 env-variables set for you, you can use it in your script.
4# ${BUILD_DIR} , working dir of this script, eg: openwrt/lede/
5# ${INSTALL_DIR}, where to install your build result, including: image, build log.
6#
7
8#Global variable
9BUILD_TIME=`date +%Y%m%d%H%M%S`
10build_flag=0
11
12# Bypass the hash check to prevent the related packages obtained from the
13# master branch from being affected by the changes made below, causing build fail.
14# https://github.com/openwrt/openwrt/commit/e8725a932e16eaf6ec51add8c084d959cbe32ff2
15SKIP_PKG_HASH_CHECK=1
16
17if [ -z ${BUILD_DIR} ]; then
18 LOCAL=1
19 BUILD_DIR=`pwd`
20fi
21
22MTK_FEED_DIR=${BUILD_DIR}/feeds/mtk_openwrt_feed
23MTK_MANIFEST_FEED=${BUILD_DIR}/../mtk-openwrt-feeds
24MAC80211_AUTOBUILD_RELEASE=${MTK_FEED_DIR}/autobuild/autobuild_5.4_mac80211_release
25
26if [ -z ${INSTALL_DIR} ]; then
27 INSTALL_DIR=autobuild_release
28 mkdir -p ${INSTALL_DIR}
29 if [ ! -d target/linux ]; then
30 echo "You should call this scripts from openwrt's root directory."
31 fi
32fi
33
34OPENWRT_VER=`cat ${BUILD_DIR}/feeds.conf.default | grep "src-git packages" | awk -F ";openwrt" '{print $2}'`
35if [ -z ${OPENWRT_VER} ]; then
36 OPENWRT_VER=`cat ${BUILD_DIR}/feeds.conf.default | grep "src-git-full packages" | awk -F ";openwrt" '{print $2}'`
37fi
38
39cp ${BUILD_DIR}/feeds.conf.default ${BUILD_DIR}/feeds.conf.default_ori
40
41clean() {
42 echo "clean start!"
43 echo "It will take some time ......"
44 make distclean
45 rm -rf ${INSTALL_DIR}
46 echo "clean done!"
47}
48
49do_patch(){
50 files=`find $1 -name "*.patch" | sort`
51 for file in $files
52 do
53 patch -f -p1 -i ${file} || exit 1
54 done
55}
56
57change_config_before_defconfig() {
58 return 0
59}
60
61change_config_after_defconfig() {
62 return 0
63}
64
65prepare() {
66 echo "Preparing...."
67 #FIXME : workaround HOST PC build issue
68 #cd package/mtk/applications/luci-app-mtk/;git checkout Makefile;cd -
69 #mv package/mtk package/mtk_soc/ ./
70 #rm -rf tmp/ feeds/ target/ package/ scripts/ tools/ include/ toolchain/ rules.mk
71 #git checkout target/ package/ scripts/ tools/ include/ toolchain/ rules.mk
72 #mv ./mtk ./mtk_soc/ package/
73 cp ${BUILD_DIR}/autobuild/feeds.conf.default${OPENWRT_VER} ${BUILD_DIR}/feeds.conf.default
74
75 #update feed
76 ${BUILD_DIR}/scripts/feeds update -a
77
78 #check if manifest mtk_feed exist,if yes,overwrite and update it in feeds/
79 if [ -d ${MTK_MANIFEST_FEED} ]; then
80 rm -rf ${MTK_FEED_DIR}
81 ln -s ${MTK_MANIFEST_FEED} ${MTK_FEED_DIR}
82 ${BUILD_DIR}/scripts/feeds update -a
83 fi
84
85 #do mtk_feed prepare_sdk.sh
86 cp ${MTK_FEED_DIR}/prepare_sdk.sh ${BUILD_DIR}
87
88 #if $1 exist(mt76), keep origin openwrt patches and remove mtk local eth driver
89 if [ -z ${1} ]; then
90 ${BUILD_DIR}/prepare_sdk.sh ${MTK_FEED_DIR} || exit 1
91 else
92 ${BUILD_DIR}/prepare_sdk.sh ${MTK_FEED_DIR} ${1} || exit 1
93 rm -rf ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/
94 fi
95 #install feed
96 ${BUILD_DIR}/scripts/feeds install -a
97 ${BUILD_DIR}/scripts/feeds install -a luci
98
99 #do mtk_soc openwrt patch
100 do_patch ${BUILD_DIR}/autobuild/openwrt_patches${OPENWRT_VER}/mtk_soc || exit 1
101}
102
103add_proprietary_kernel_files() {
104 #cp mtk proprietary ko_module source to mtk target
105 #and also need to be done in release mtk target
106
107 # mean it is old process for possible build issue and should delete it gradually in the furture.
108 if [ ! -d ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/wireless/wifi_utility ]; then
109 mkdir -p ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/wireless
110 cp -rf ${BUILD_DIR}/../ko_module/gateway/proprietary_driver/drivers/wifi_utility/ ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/wireless
111 fi
112
113 cp -fpR ${BUILD_DIR}/autobuild/target/ ${BUILD_DIR}
114}
115
116prepare_mtwifi() {
117 #remove officail OpenWRT wifi script
118 #wifi-profile pkg will install wifi_jedi instead
119 rm -rf ${BUILD_DIR}/package/base-files/files/sbin/wifi
120
121 add_proprietary_kernel_files
122
123 #do mtk_wifi openwrt patch
124 do_patch ${BUILD_DIR}/autobuild/openwrt_patches${OPENWRT_VER}/mtk_wifi || exit 1
125}
126
127prepare_flowoffload() {
128 #cp bridger and related utilities from master
129 cp -fpR ${BUILD_DIR}/./../mac80211_package/include/bpf.mk ${BUILD_DIR}/include
130
131 cp -fpR ${BUILD_DIR}/./../mac80211_package/include/kernel-5.15 ${BUILD_DIR}/include
132
133 cp -fpR ${BUILD_DIR}/./../mac80211_package/target/llvm-bpf ${BUILD_DIR}/target
134
135 cp -fpR ${BUILD_DIR}/./../mac80211_package/tools/llvm-bpf ${BUILD_DIR}/tools
136
137 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/kernel/bpf-headers ${BUILD_DIR}/package/kernel
138
139 rm -rf ${BUILD_DIR}/package/network/utils/bpftool*
140 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/bpftool ${BUILD_DIR}/package/network/utils
141
142 rm -rf ${BUILD_DIR}/package/libs/libbpf
143 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/libbpf ${BUILD_DIR}/package/libs
144
145 rm -rf ${BUILD_DIR}/package/network/utils/iproute2
146 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/iproute2 ${BUILD_DIR}/package/network/utils
147
148 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/services/bridger ${BUILD_DIR}/package/network/services
149
150 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0010-add-llvm_bpf-toolchain.patch || exit 1
151 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0004-2102-netfilter-remove-nf_flow_table_hw.patch || exit 1
152 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0005-add-netfilter-netlink-ftnl-package.patch || exit 1
153
154 #rm patches for flowblock
155 rm -rf ./target/linux/generic/pending-5.4/64*.patch
156 rm -rf ./target/linux/generic/hack-5.4/647-netfilter-flow-acct.patch
157 rm -rf ./target/linux/generic/hack-5.4/650-netfilter-add-xt_OFFLOAD-target.patch
158 rm -rf ./target/linux/mediatek/patches-5.4/999-2708-mtkhnat-add-support-for-virtual-interface-acceleration.patch
159 rm -rf ./target/linux/mediatek/patches-5.4/999-2726-mtkhnat-tnl-interface-offload-check.patch
160
161 # remove patches and packages of tops and ipsec
162 rm -rf ./target/linux/mediatek/patches-5.4/*mtk-tops*.patch
163 rm -rf ./target/linux/mediatek/patches-5.4/999-*xfrm*.patch
164 rm -rf ./target/linux/mediatek/patches-5.4/999-41*.patch
165 rm -rf ./target/linux/mediatek/patches-5.4/999-45*.patch
166 rm -rf ${BUILD_DIR}/package/feeds/mtk_openwrt_feed/tops
167 rm -rf ${BUILD_DIR}/package/feeds/mtk_openwrt_feed/crypto-eip
168 rm -rf ${BUILD_DIR}/package/feeds/mtk_openwrt_feed/pce
169 rm -rf ${BUILD_DIR}/package/feeds/mtk_openwrt_feed/tops-tool
170
171 #hack mt7988 config5.4
172 echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7988/config-5.4
173 echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7988/config-5.4
174 echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7988/config-5.4
175 echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7988/config-5.4
176 echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7988/config-5.4
177
178 #hack mt7986 config5.4
179 echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7986/config-5.4
180 echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7986/config-5.4
181 echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7986/config-5.4
182 echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7986/config-5.4
183 echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7986/config-5.4
184
185 #hack mt7981 config5.4
186 echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7981/config-5.4
187 echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7981/config-5.4
188 echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7981/config-5.4
189 echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7981/config-5.4
190 echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7981/config-5.4
191
192 #hack mt7622 config5.4
193 echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7622/config-5.4
194 echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7622/config-5.4
195 echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7622/config-5.4
196 echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7622/config-5.4
197 echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7622/config-5.4
198}
199
200prepare_mac80211() {
201 rm -rf ${BUILD_DIR}/package/network/services/hostapd
202 if [ "$2" = "1" ]; then
203 echo "========================Hostapd NEW==================="
204 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/services/hostapd ${BUILD_DIR}/package/network/services
205 rm -rf ${MAC80211_AUTOBUILD_RELEASE}/package/network/services/hostapd
developer73734032024-07-16 02:16:44 +0800206 do_patch ${MAC80211_AUTOBUILD_RELEASE}/openwrt_patches${OPENWRT_VER}/hostapd || exit 1
207 else
208 echo "========================Hostapd OLD==================="
209 tar xvf ${MAC80211_AUTOBUILD_RELEASE}/package/network/services/hostapd/hostapd_v2.10_07730ff3.tar.gz -C ${BUILD_DIR}/package/network/services/
210 fi
211
212 rm -rf ${BUILD_DIR}/package/libs/libnl-tiny
213 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/libnl-tiny ${BUILD_DIR}/package/libs
214
215 rm -rf ${BUILD_DIR}/package/network/utils/iw
216 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/iw ${BUILD_DIR}/package/network/utils
217
218 rm -rf ${BUILD_DIR}/package/network/utils/iwinfo
219 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/iwinfo ${BUILD_DIR}/package/network/utils
220
221 rm -rf ${BUILD_DIR}/package/network/config/netifd
222 if [ "$2" = "1" ]; then
223 echo "=========================Netifd NEW====================="
224 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/config/netifd ${BUILD_DIR}/package/network/config
225 rm -rf ${MAC80211_AUTOBUILD_RELEASE}/package/network/config/netifd
226 cp -fpR ${MAC80211_AUTOBUILD_RELEASE}/package/network/config/netifd_new ${MAC80211_AUTOBUILD_RELEASE}/package/network/config/netifd
227 #wifi-scripts
228 rm -rf ${BUILD_DIR}/package/base-files/files/sbin/wifi
229 rm -rf ${BUILD_DIR}/package/network/config/wifi-scripts
230 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/config/wifi-scripts ${BUILD_DIR}/package/network/config
231 #ucode
232 rm -rf ${BUILD_DIR}/package/utils/ucode
233 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/utils/ucode ${BUILD_DIR}/package/utils
234 #ubus
235 rm -rf ${BUILD_DIR}/package/system/ubus
236 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/system/ubus ${BUILD_DIR}/package/system
237 #ubox & libubox
238 rm -rf ${BUILD_DIR}/package/system/ubox
239 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/system/ubox ${BUILD_DIR}/package/system
240 rm -rf ${BUILD_DIR}/package/libs/libubox
241 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/libubox ${BUILD_DIR}/package/libs
242 #udebug
243 rm -rf ${BUILD_DIR}/package/libs/udebug
244 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/udebug ${BUILD_DIR}/package/libs
245 #umdns
246 rm -rf ${BUILD_DIR}/package/network/services/umdns
247 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/services/umdns ${BUILD_DIR}/package/network/services
248 #rpcd
249 rm -rf ${BUILD_DIR}/package/system/rpcd
250 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/system/rpcd ${BUILD_DIR}/package/system
251 rm -rf ${MAC80211_AUTOBUILD_RELEASE}/package/system/rpcd
252 #procd
253 rm -rf ${BUILD_DIR}/package/system/procd
254 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/system/procd ${BUILD_DIR}/package/system
255 else
256 echo "=========================Netifd OLD====================="
257 fi
258
259 rm -rf ${BUILD_DIR}/package/kernel/mac80211
260 if [ "$1" = "1" ]; then
261 echo "=========================MAC80211 v6.1==================="
262 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/kernel/mac80211 ${BUILD_DIR}/package/kernel
263 rm -rf ${MAC80211_AUTOBUILD_RELEASE}/package/kernel/mac80211
developer73734032024-07-16 02:16:44 +0800264 else
265 echo "=========================MAC80211 v5.15=================="
266 tar xvf ${MAC80211_AUTOBUILD_RELEASE}/package/kernel/mac80211/mac80211_v5.15.81_077622a1.tar.gz -C ${BUILD_DIR}/package/kernel/
267 fi
268
269 rm -rf ${BUILD_DIR}/package/firmware/wireless-regdb
270 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/firmware/wireless-regdb ${BUILD_DIR}/package/firmware
271
272 # do not directly remove mt76 folder, since the firmware folder will also be removed and enter an unsync state
273 rm -rf ${BUILD_DIR}/package/kernel/mt76/Makefile
274 rm -rf ${BUILD_DIR}/package/kernel/mt76/patches
275 rm -rf ${BUILD_DIR}/package/kernel/mt76/src
276 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/kernel/mt76 ${BUILD_DIR}/package/kernel
277 rm -rf ${BUILD_DIR}/package/kernel/mt76/patches/*build-on-linux-kernel-6.6.patch
278
279 # hack hostapd config
280 echo "CONFIG_MBO=y" >> ./package/network/services/hostapd/files/hostapd-full.config
281 echo "CONFIG_SAE_PK=y" >> ./package/network/services/hostapd/files/hostapd-full.config
282 echo "CONFIG_TESTING_OPTIONS=y" >> ./package/network/services/hostapd/files/hostapd-full.config
283 echo "CONFIG_HS20=y" >> ./package/network/services/hostapd/files/hostapd-full.config
284 echo "CONFIG_P2P_MANAGER=y" >> ./package/network/services/hostapd/files/hostapd-full.config
285 echo "CONFIG_WPS_UPNP=y" >> ./package/network/services/hostapd/files/hostapd-full.config
286 echo "CONFIG_DPP=y" >> ./package/network/services/hostapd/files/hostapd-full.config
287 echo "CONFIG_DPP2=y" >> ./package/network/services/hostapd/files/hostapd-full.config
288 echo "CONFIG_DPP3=y" >> ./package/network/services/hostapd/files/hostapd-full.config
289 echo "CONFIG_DPP=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
290 echo "CONFIG_DPP2=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
291 echo "CONFIG_DPP3=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
292 # add configuration for STA wireless mode setting
293 echo "CONFIG_HE_OVERRIDES=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
294 echo "CONFIG_EHT_OVERRIDES=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
295
296 # hack mt7988 config5.4
297 echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7988/config-5.4
298 echo "CONFIG_BLK_MQ_VIRTIO=y" >> ./target/linux/mediatek/mt7988/config-5.4
299 echo "CONFIG_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7988/config-5.4
300 echo "CONFIG_REMOTEPROC=y" >> ./target/linux/mediatek/mt7988/config-5.4
301 echo "CONFIG_VIRTIO=y" >> ./target/linux/mediatek/mt7988/config-5.4
302 echo "CONFIG_WANT_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7988/config-5.4
303 echo "CONFIG_VIRTIO_CONSOLE=n" >> ./target/linux/mediatek/mt7988/config-5.4
304 echo "CONFIG_VIRTIO_NET=n" >> ./target/linux/mediatek/mt7988/config-5.4
305 echo "CONFIG_VIRTIO_BLK=n" >> ./target/linux/mediatek/mt7988/config-5.4
306
307 # hack mt7986 config5.4
308 echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7986/config-5.4
309 echo "CONFIG_BLK_MQ_VIRTIO=y" >> ./target/linux/mediatek/mt7986/config-5.4
310 echo "CONFIG_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7986/config-5.4
311 echo "CONFIG_REMOTEPROC=y" >> ./target/linux/mediatek/mt7986/config-5.4
312 echo "CONFIG_VIRTIO=y" >> ./target/linux/mediatek/mt7986/config-5.4
313 echo "CONFIG_WANT_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7986/config-5.4
314 echo "CONFIG_VIRTIO_CONSOLE=n" >> ./target/linux/mediatek/mt7986/config-5.4
315 echo "CONFIG_VIRTIO_NET=n" >> ./target/linux/mediatek/mt7986/config-5.4
316 echo "CONFIG_VIRTIO_BLK=n" >> ./target/linux/mediatek/mt7986/config-5.4
317
318 # hack mt7981 config5.4
319 echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7981/config-5.4
320 echo "CONFIG_BLK_MQ_VIRTIO=y" >> ./target/linux/mediatek/mt7981/config-5.4
321 echo "CONFIG_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7981/config-5.4
322 echo "CONFIG_REMOTEPROC=y" >> ./target/linux/mediatek/mt7981/config-5.4
323 echo "CONFIG_VIRTIO=y" >> ./target/linux/mediatek/mt7981/config-5.4
324 echo "CONFIG_WANT_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7981/config-5.4
325 echo "CONFIG_VIRTIO_CONSOLE=n" >> ./target/linux/mediatek/mt7981/config-5.4
326 echo "CONFIG_VIRTIO_NET=n" >> ./target/linux/mediatek/mt7981/config-5.4
327 echo "CONFIG_VIRTIO_BLK=n" >> ./target/linux/mediatek/mt7981/config-5.4
328
329 # hack mt7622 config5.4
330 echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7622/config-5.4
331
developer73734032024-07-16 02:16:44 +0800332 if [ "$1" = "1" ]; then
developerf0ded142024-08-26 11:10:03 +0800333 # MAC80211/Hostapd Script
developer73734032024-07-16 02:16:44 +0800334 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch || exit 1
developerf0ded142024-08-26 11:10:03 +0800335 # Hostapd Makefile
developer73734032024-07-16 02:16:44 +0800336 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0002-wifi7-hostapd-makefile-for-utils.patch || exit 1
developerf0ded142024-08-26 11:10:03 +0800337 # MT76 Makefile
338 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0003-wifi7-mt76-makefile-for-new-chip.patch || exit 1
developerc4224812024-10-16 04:58:33 +0800339 rm ${MAC80211_AUTOBUILD_RELEASE}/package/kernel/mt76/Makefile
developer73734032024-07-16 02:16:44 +0800340 else
developerf0ded142024-08-26 11:10:03 +0800341 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0001-wifi6-mac80211-generate-hostapd-setting-from-ap-cap.patch || exit 1
developer73734032024-07-16 02:16:44 +0800342 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0002-wifi6-hostapd-makefile-for-utils.patch || exit 1
343 fi
344
developer73734032024-07-16 02:16:44 +0800345 cp -rfa ${MAC80211_AUTOBUILD_RELEASE}/package/ ${BUILD_DIR}
346 cp -rfa ${MAC80211_AUTOBUILD_RELEASE}/target/ ${BUILD_DIR}
347
348 # Bridge Default Setting
349 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0006-network-enable-bridge-igmp_snooping-by-default.patch || exit 1
350
351 # Relayd change trigger reload to trigger restart
352 patch -f -p1 -i ${MAC80211_AUTOBUILD_RELEASE}/0007-relayd-change-trigger-reload-to-trigger-restart.patch || exit 1
353}
354
developer73734032024-07-16 02:16:44 +0800355copy_main_Config() {
356 echo cp -rfa autobuild/$1/.config ./.config
357 cp -rfa autobuild/$1/.config ./.config
358}
359
360install_output_Image() {
361 mkdir -p ${INSTALL_DIR}/$1
362
363 files=`find bin/targets/$3/*${2}* -name "*.bin" -o -name "*.img"`
364 file_count=0
365
366 for file in $files
367 do
368 tmp=${file%.*}
369 cp -rf $file ${INSTALL_DIR}/$1/${tmp##*/}-${BUILD_TIME}.${file##*.}
370 ((file_count++))
371 done
372
373 if [ ${file_count} = 0 ]; then
374 if [ ${build_flag} -eq 0 ]; then
375 let build_flag+=1
376 echo " Restart to debug-build with "make V=s -j1", starting......"
377 build $1 -j1 || [ "$LOCAL" != "1" ]
378 else
379 echo " **********Failed to build $1, bin missing.**********"
380 fi
381 else
382 echo "Install image OK!!!"
383 echo "Build $1 successfully!"
384 fi
385}
386
387install_output_Config() {
388 echo cp -rfa autobuild/$1/.config ${INSTALL_DIR}/$1/openwrt.config
389 cp -rfa autobuild/$1/.config ${INSTALL_DIR}/$1/openwrt.config
390 [ -f tmp/kernel.config ] && cp tmp/kernel.config ${INSTALL_DIR}/$1/kernel.config
391}
392
393install_output_KernelDebugFile() {
394 KernelDebugFile=bin/targets/$3/mt${2}*/kernel-debug.tar.zst
395 if [ -f ${KernelDebugFile} ]; then
396 echo cp -rfa ${KernelDebugFile} ${INSTALL_DIR}/$1/kernel-debug.tar.zst
397 cp -rfa ${KernelDebugFile} ${INSTALL_DIR}/$1/kernel-debug.tar.zst
398 fi
399}
400
401install_output_RootfsDebugFile() {
402 STAGING_DIR_ROOT=$(make -f "autobuild/get_stagingdir_root.mk" get-staging-dir-root)
403 if [ -d ${STAGING_DIR_ROOT} ]; then
404 STAGING_DIR_ROOT_PREFIX=$(dirname ${STAGING_DIR_ROOT})
405 STAGING_DIR_ROOT_NAME=$(basename ${STAGING_DIR_ROOT})
406 echo "tar -jcf ${INSTALL_DIR}/$1/rootfs-debug.tar.bz2 -C \"$STAGING_DIR_ROOT_PREFIX\" \"$STAGING_DIR_ROOT_NAME\""
407 tar -jcf ${INSTALL_DIR}/$1/rootfs-debug.tar.bz2 -C "$STAGING_DIR_ROOT_PREFIX" "$STAGING_DIR_ROOT_NAME"
408 fi
409}
410
411install_output_feeds_buildinfo() {
412 feeds_buildinfo=$(find bin/targets/$3/*${2}*/ -name "feeds.buildinfo")
413 echo "feeds_buildinfo=$feeds_buildinfo"
414 if [ -f ${feeds_buildinfo} ]; then
415 cp -rf $feeds_buildinfo ${INSTALL_DIR}/$1/feeds.buildinfo
416 else
417 echo "feeds.buildinfo is not found!!!"
418 fi
419}
420
421install_output_at() {
422 tar -zcvf to_at.tgz -C ${INSTALL_DIR}/$1 .
423 mv to_at.tgz ${INSTALL_DIR}/
424}
425
426install_release() {
427 temp=${1#*mt}
428 if [ -z ${chip_name} ]; then
429 chip_name=${temp:0:4}
430 fi
431 temp1=`grep "CONFIG_TARGET_ramips=y" autobuild/$1/.config`
432
433 if [ "${temp1}" == "CONFIG_TARGET_ramips=y" ]; then
434 arch_name="ramips"
435 else
436 arch_name="mediatek"
437 fi
438
439 #install output image
440 install_output_Image $1 ${chip_name} ${arch_name}
441
442 #install output config
443 install_output_Config $1
444
445 #install output Kernel-Debug-File
446 install_output_KernelDebugFile $1 ${chip_name} ${arch_name}
447
448 #tar unstripped rootfs for debug symbols
449 install_output_RootfsDebugFile $1
450
451 #install output feeds buildinfo
452 install_output_feeds_buildinfo $1 ${chip_name} ${arch_name}
453
454 #tarball for AT
455 install_output_at $1
456}
457
458prepare_final() {
459 #cp customized autobuild SDK patches
460 cp -fpR ${BUILD_DIR}/autobuild/$1/target/ ${BUILD_DIR}
461 cp -fpR ${BUILD_DIR}/autobuild/$1/package/ ${BUILD_DIR}
462 cp -fpR ${BUILD_DIR}/autobuild/$1/tools/ ${BUILD_DIR}
463
464
465 #cp special subtarget patches
466 case $1 in
467 mt7986*)
468 cp -rf ${BUILD_DIR}/autobuild/mt7986-AX6000/target/linux/mediatek/patches-5.4/*.* ${BUILD_DIR}/target/linux/mediatek/patches-5.4
469 ;;
470 *)
471 ;;
472 esac
473
474 #rm old legacy patch, ex old nfi nand driver
475 case $1 in
476 mt7986*|\
477 mt7981*|\
478 mt7988*)
479 rm -rf ${BUILD_DIR}/target/linux/mediatek/patches-5.4/0303-mtd-spinand-disable-on-die-ECC.patch
480 ;;
481 *)
482 ;;
483 esac
484
485 cd ${BUILD_DIR}
486 [ -f autobuild/$1/.config ] || {
487 echo "unable to locate autobuild/$1/.config !"
488 return
489 }
490
491 rm -rf ./tmp
492 #copy main test config(.config)
493 copy_main_Config $1
494
495 change_config_before_defconfig
496
497 echo make defconfig
498 make defconfig
499
500 change_config_after_defconfig
501}
502
503build() {
504 echo "###############################################################################"
505 echo "# $1"
506 echo "###############################################################################"
507 echo "build $1"
508
509 cd ${BUILD_DIR}
510
511 #make
512
513 if [ ${SKIP_PKG_HASH_CHECK} -eq 1 ]; then
514 echo "make V=1 -j $(($(nproc) + 1)) download world PKG_HASH=skip PKG_MIRROR_HASH=skip"
515 make V=1 -j $(($(nproc) + 1)) download world PKG_HASH=skip PKG_MIRROR_HASH=skip || \
516 make V=s -j $(($(nproc) + 1)) PKG_HASH=skip PKG_MIRROR_HASH=skip || exit 1
517 else
518 echo "make V=1 -j $(($(nproc) + 1)) download world"
519 make V=1 -j $(($(nproc) + 1)) download world || make V=s -j $(($(nproc) + 1)) || exit 1
520 fi
521
522 #tar unstripped rootfs for debug symbols
523 install_release $1
524}
525
526build_log() {
527 echo "###############################################################################"
528 echo "# $1"
529 echo "###############################################################################"
530 echo "build $1"
531
532 cd ${BUILD_DIR}
533
developer73734032024-07-16 02:16:44 +0800534 #make
535
536 if [ ${SKIP_PKG_HASH_CHECK} -eq 1 ]; then
537 echo "make V=1 -j $(($(nproc) + 1)) download world PKG_HASH=skip PKG_MIRROR_HASH=skip"
538 make V=1 -j $(($(nproc) + 1)) download world PKG_HASH=skip PKG_MIRROR_HASH=skip || \
539 make V=s -j1 PKG_HASH=skip PKG_MIRROR_HASH=skip || exit 1
540 else
541 echo "make V=1 -j $(($(nproc) + 1)) download world"
542 make V=1 -j $(($(nproc) + 1)) download world || make V=s -j1 || exit 1
543 fi
544
545 #tar unstripped rootfs for debug symbols
546 install_release $1
547}