blob: 872f14ac1ac538d6755ae20d5e109760c00bc449 [file] [log] [blame]
developer20d67712022-03-02 14:09:32 +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
12if [ -z ${BUILD_DIR} ]; then
13 LOCAL=1
14 BUILD_DIR=`pwd`
15fi
16
17MTK_FEED_DIR=${BUILD_DIR}/feeds/mtk_openwrt_feed
developer7273f5f2022-12-12 17:18:16 +080018MTK_MANIFEST_FEED=${BUILD_DIR}/../mtk-openwrt-feeds
developer20d67712022-03-02 14:09:32 +080019
20if [ -z ${INSTALL_DIR} ]; then
21 INSTALL_DIR=autobuild_release
22 mkdir -p ${INSTALL_DIR}
23 if [ ! -d target/linux ]; then
24 echo "You should call this scripts from openwrt's root directory."
25 fi
26fi
27
28OPENWRT_VER=`cat ${BUILD_DIR}/feeds.conf.default | grep "src-git packages" | awk -F ";openwrt" '{print $2}'`
developer068e1a42022-08-29 17:24:20 +080029if [ -z ${OPENWRT_VER} ]; then
30 OPENWRT_VER=`cat ${BUILD_DIR}/feeds.conf.default | grep "src-git-full packages" | awk -F ";openwrt" '{print $2}'`
31fi
32
developer20d67712022-03-02 14:09:32 +080033cp ${BUILD_DIR}/feeds.conf.default ${BUILD_DIR}/feeds.conf.default_ori
34
35clean() {
36 echo "clean start!"
37 echo "It will take some time ......"
38 make distclean
39 rm -rf ${INSTALL_DIR}
40 echo "clean done!"
41}
42
43do_patch(){
44 files=`find $1 -name "*.patch" | sort`
45 for file in $files
46 do
47 patch -f -p1 -i ${file} || exit 1
48 done
49}
50
developer699cda22022-12-17 15:21:57 +080051change_config_before_defconfig() {
52 return 0
53}
54
55change_config_after_defconfig() {
56 return 0
57}
58
developer20d67712022-03-02 14:09:32 +080059prepare() {
60 echo "Preparing...."
61 #FIXME : workaround HOST PC build issue
62 #cd package/mtk/applications/luci-app-mtk/;git checkout Makefile;cd -
63 #mv package/mtk package/mtk_soc/ ./
64 #rm -rf tmp/ feeds/ target/ package/ scripts/ tools/ include/ toolchain/ rules.mk
65 #git checkout target/ package/ scripts/ tools/ include/ toolchain/ rules.mk
66 #mv ./mtk ./mtk_soc/ package/
67 cp ${BUILD_DIR}/autobuild/feeds.conf.default${OPENWRT_VER} ${BUILD_DIR}/feeds.conf.default
68
69 #update feed
70 ${BUILD_DIR}/scripts/feeds update -a
71
72 #check if manifest mtk_feed exist,if yes,overwrite and update it in feeds/
73 if [ -d ${MTK_MANIFEST_FEED} ]; then
74 rm -rf ${MTK_FEED_DIR}
75 ln -s ${MTK_MANIFEST_FEED} ${MTK_FEED_DIR}
76 ${BUILD_DIR}/scripts/feeds update -a
77 fi
78
79 #do mtk_feed prepare_sdk.sh
80 cp ${MTK_FEED_DIR}/prepare_sdk.sh ${BUILD_DIR}
81
82 #if $1 exist(mt76), keep origin openwrt patches and remove mtk local eth driver
83 if [ -z ${1} ]; then
84 ${BUILD_DIR}/prepare_sdk.sh ${MTK_FEED_DIR} || exit 1
85 else
86 ${BUILD_DIR}/prepare_sdk.sh ${MTK_FEED_DIR} ${1} || exit 1
87 rm -rf ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/
88 fi
89 #install feed
90 ${BUILD_DIR}/scripts/feeds install -a
91 ${BUILD_DIR}/scripts/feeds install -a luci
92
93 #do mtk_soc openwrt patch
94 do_patch ${BUILD_DIR}/autobuild/openwrt_patches${OPENWRT_VER}/mtk_soc || exit 1
95}
96
97add_proprietary_kernel_files() {
98 #cp mtk proprietary ko_module source to mtk target
99 #and also need to be done in release mtk target
developer20d67712022-03-02 14:09:32 +0800100
developer9b3248d2022-07-06 00:44:05 +0800101 # mean it is old process for possible build issue and should delete it gradually in the furture.
102 if [ ! -d ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/wireless/wifi_utility ]; then
103 mkdir -p ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/wireless
104 cp -rf ${BUILD_DIR}/../ko_module/gateway/proprietary_driver/drivers/wifi_utility/ ${BUILD_DIR}/target/linux/mediatek/files-5.4/drivers/net/wireless
105 fi
developer20d67712022-03-02 14:09:32 +0800106
107 cp -fpR ${BUILD_DIR}/autobuild/target/ ${BUILD_DIR}
108}
109
110prepare_mtwifi() {
111 #remove officail OpenWRT wifi script
112 #wifi-profile pkg will install wifi_jedi instead
113 rm -rf ${BUILD_DIR}/package/base-files/files/sbin/wifi
114
115 add_proprietary_kernel_files
116
developerdbcd2cb2023-06-06 13:28:00 +0800117 #add common patch
118 cp -rfa ${BUILD_DIR}/autobuild/package ${BUILD_DIR}
119
developer20d67712022-03-02 14:09:32 +0800120 #do mtk_wifi openwrt patch
121 do_patch ${BUILD_DIR}/autobuild/openwrt_patches${OPENWRT_VER}/mtk_wifi || exit 1
122}
123
developer9b3248d2022-07-06 00:44:05 +0800124prepare_flowoffload() {
developer699cda22022-12-17 15:21:57 +0800125 #cp bridger and related utilities from master
126 cp -fpR ${BUILD_DIR}/./../mac80211_package/include/bpf.mk ${BUILD_DIR}/include
127
128 cp -fpR ${BUILD_DIR}/./../mac80211_package/include/kernel-5.15 ${BUILD_DIR}/include
129
130 cp -fpR ${BUILD_DIR}/./../mac80211_package/target/llvm-bpf ${BUILD_DIR}/target
131
132 cp -fpR ${BUILD_DIR}/./../mac80211_package/tools/llvm-bpf ${BUILD_DIR}/tools
133
134 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/kernel/bpf-headers ${BUILD_DIR}/package/kernel
135
developerdbcd2cb2023-06-06 13:28:00 +0800136 rm -rf ${BUILD_DIR}/package/network/utils/bpftool*
137 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/bpftool ${BUILD_DIR}/package/network/utils
138
139 rm -rf ${BUILD_DIR}/package/libs/libbpf
140 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/libbpf ${BUILD_DIR}/package/libs
developer699cda22022-12-17 15:21:57 +0800141
developer0d889982023-03-06 20:09:24 +0800142 rm -rf ${BUILD_DIR}/package/network/utils/iproute2
143 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/iproute2 ${BUILD_DIR}/package/network/utils
144
developer699cda22022-12-17 15:21:57 +0800145 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/services/bridger ${BUILD_DIR}/package/network/services
146
developerdbcd2cb2023-06-06 13:28:00 +0800147 patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0010-add-llvm_bpf-toolchain.patch || exit 1
developer699cda22022-12-17 15:21:57 +0800148
developerdbcd2cb2023-06-06 13:28:00 +0800149 patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0004-2102-netfilter-remove-nf_flow_table_hw.patch || exit 1
150 patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0005-add-netfilter-netlink-ftnl-package.patch || exit 1
developerb8095712023-03-25 08:27:43 +0800151
developer9b3248d2022-07-06 00:44:05 +0800152 #rm patches for flowblock
153 rm -rf ./target/linux/generic/pending-5.4/64*.patch
154 rm -rf ./target/linux/generic/hack-5.4/647-netfilter-flow-acct.patch
155 rm -rf ./target/linux/generic/hack-5.4/650-netfilter-add-xt_OFFLOAD-target.patch
developerddea6d92023-06-05 10:57:49 +0800156 rm -rf ./target/linux/mediatek/patches-5.4/999-2708-mtkhnat-add-support-for-virtual-interface-acceleration.patch
developer14e96da2023-06-09 15:59:19 +0800157 rm -rf ./target/linux/mediatek/patches-5.4/999-2726-mtkhnat-tnl-interface-offload-check.patch
developer9b3248d2022-07-06 00:44:05 +0800158
developer699cda22022-12-17 15:21:57 +0800159 #hack mt7988 config5.4
160 echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7988/config-5.4
161 echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7988/config-5.4
162 echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7988/config-5.4
developerdbcd2cb2023-06-06 13:28:00 +0800163 echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7988/config-5.4
164 echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7988/config-5.4
developer699cda22022-12-17 15:21:57 +0800165
developer9b3248d2022-07-06 00:44:05 +0800166 #hack mt7986 config5.4
167 echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7986/config-5.4
168 echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7986/config-5.4
169 echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7986/config-5.4
developerdbcd2cb2023-06-06 13:28:00 +0800170 echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7986/config-5.4
171 echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7986/config-5.4
developer9b3248d2022-07-06 00:44:05 +0800172
173 #hack mt7622 config5.4
174 echo "CONFIG_BRIDGE_NETFILTER=y" >> ./target/linux/mediatek/mt7622/config-5.4
175 echo "CONFIG_NETFILTER_FAMILY_BRIDGE=y" >> ./target/linux/mediatek/mt7622/config-5.4
176 echo "CONFIG_SKB_EXTENSIONS=y" >> ./target/linux/mediatek/mt7622/config-5.4
developerdbcd2cb2023-06-06 13:28:00 +0800177 echo "CONFIG_NETFILTER=y" >> ./target/linux/mediatek/mt7622/config-5.4
178 echo "CONFIG_NETFILTER_ADVANCED=y" >> ./target/linux/mediatek/mt7622/config-5.4
developer9b3248d2022-07-06 00:44:05 +0800179}
180
developere2cc0fa2022-03-29 17:31:03 +0800181prepare_mac80211() {
developer7b9aeab2022-06-13 11:31:33 +0800182 rm -rf ${BUILD_DIR}/package/network/services/hostapd
developer683be522023-05-11 14:24:50 +0800183 if [ $2 = "1" ]; then
developerdbcd2cb2023-06-06 13:28:00 +0800184 echo "========================Hostapd NEW==================="
developer683be522023-05-11 14:24:50 +0800185 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/services/hostapd ${BUILD_DIR}/package/network/services
186 rm -rf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/services/hostapd
187 mv ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/services/hostapd_new ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/services/hostapd
188 else
developerdbcd2cb2023-06-06 13:28:00 +0800189 echo "========================Hostapd OLD==================="
developer683be522023-05-11 14:24:50 +0800190 tar xvf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/services/hostapd/hostapd_v2.10_07730ff3.tar.gz -C ${BUILD_DIR}/package/network/services/
191 rm -rf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/network/services/hostapd/hostapd_v2.10_07730ff3.tar.gz
192 fi
developer7b9aeab2022-06-13 11:31:33 +0800193
194 rm -rf ${BUILD_DIR}/package/libs/libnl-tiny
195 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/libnl-tiny ${BUILD_DIR}/package/libs
196
197 rm -rf ${BUILD_DIR}/package/network/utils/iw
developerbd32d6d2022-06-14 13:19:41 +0800198 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/iw ${BUILD_DIR}/package/network/utils
developer7b9aeab2022-06-13 11:31:33 +0800199
200 rm -rf ${BUILD_DIR}/package/network/utils/iwinfo
201 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/utils/iwinfo ${BUILD_DIR}/package/network/utils
202
developer3e0400f2023-02-10 08:32:03 +0800203 rm -rf ${BUILD_DIR}/package/network/config/netifd
204 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/network/config/netifd ${BUILD_DIR}/package/network/config
205
developer7b9aeab2022-06-13 11:31:33 +0800206 rm -rf ${BUILD_DIR}/package/kernel/mac80211
developer7273f5f2022-12-12 17:18:16 +0800207 if [ $1 = "1" ]; then
208 echo "=========================MAC80211 v6.1==================="
209 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/kernel/mac80211 ${BUILD_DIR}/package/kernel
210 rm -rf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/kernel/mac80211
developer699cda22022-12-17 15:21:57 +0800211 mv ${MTK_FEED_DIR}/autobuild_mac80211_release/package/kernel/mac80211_dev ${MTK_FEED_DIR}/autobuild_mac80211_release/package/kernel/mac80211
developer7273f5f2022-12-12 17:18:16 +0800212 else
213 echo "=========================MAC80211 v5.15=================="
214 tar xvf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/kernel/mac80211/mac80211_v5.15.81_077622a1.tar.gz -C ${BUILD_DIR}/package/kernel/
developerdbcd2cb2023-06-06 13:28:00 +0800215 rm -rf ${MTK_FEED_DIR}/autobuild_mac80211_release/package/kernel/mac80211/mac80211_v5.15.81_077622a1.tar.gz
developer7273f5f2022-12-12 17:18:16 +0800216 fi
developer7b9aeab2022-06-13 11:31:33 +0800217
218 rm -rf ${BUILD_DIR}/package/firmware/wireless-regdb
developerbd32d6d2022-06-14 13:19:41 +0800219 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/firmware/wireless-regdb ${BUILD_DIR}/package/firmware
developer7b9aeab2022-06-13 11:31:33 +0800220
developer7e169772023-08-03 19:11:11 +0800221 rm -rf ${BUILD_DIR}/package/utils/ucode
222 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/utils/ucode ${BUILD_DIR}/package/utils
223 rm -rf ${BUILD_DIR}/package/libs/libubox
224 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/libs/libubox ${BUILD_DIR}/package/libs
225 rm -rf ${BUILD_DIR}/package/system/rpcd
226 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/system/rpcd ${BUILD_DIR}/package/system
227 rm -rf ${BUILD_DIR}/package/system/procd
228 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/system/procd ${BUILD_DIR}/package/system
229
developera18966d2022-12-22 14:26:02 +0800230 # do not directly remove mt76 folder, since the firmware folder will also be removed and enter an unsync state
developer3e0400f2023-02-10 08:32:03 +0800231 rm -rf ${BUILD_DIR}/package/kernel/mt76/Makefile
232 rm -rf ${BUILD_DIR}/package/kernel/mt76/patches
233 rm -rf ${BUILD_DIR}/package/kernel/mt76/src
234 cp -fpR ${BUILD_DIR}/./../mac80211_package/package/kernel/mt76 ${BUILD_DIR}/package/kernel
developerf0de14b2022-12-14 23:07:34 +0800235
developerdbcd2cb2023-06-06 13:28:00 +0800236 # hack hostapd config
developer9b3248d2022-07-06 00:44:05 +0800237 echo "CONFIG_MBO=y" >> ./package/network/services/hostapd/files/hostapd-full.config
developerdbcd2cb2023-06-06 13:28:00 +0800238 echo "CONFIG_SAE_PK=y" >> ./package/network/services/hostapd/files/hostapd-full.config
239 echo "CONFIG_TESTING_OPTIONS=y" >> ./package/network/services/hostapd/files/hostapd-full.config
240 echo "CONFIG_HS20=y" >> ./package/network/services/hostapd/files/hostapd-full.config
241 echo "CONFIG_P2P_MANAGER=y" >> ./package/network/services/hostapd/files/hostapd-full.config
developer9b3248d2022-07-06 00:44:05 +0800242 echo "CONFIG_WPS_UPNP=y" >> ./package/network/services/hostapd/files/hostapd-full.config
243 echo "CONFIG_DPP=y" >> ./package/network/services/hostapd/files/hostapd-full.config
244 echo "CONFIG_DPP2=y" >> ./package/network/services/hostapd/files/hostapd-full.config
245 echo "CONFIG_DPP3=y" >> ./package/network/services/hostapd/files/hostapd-full.config
246 echo "CONFIG_DPP=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
247 echo "CONFIG_DPP2=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
248 echo "CONFIG_DPP3=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
developerdbcd2cb2023-06-06 13:28:00 +0800249 # add configuration for STA wireless mode setting
developer8eb72a32023-03-30 08:32:07 +0800250 echo "CONFIG_HE_OVERRIDES=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
251 echo "CONFIG_EHT_OVERRIDES=y" >> ./package/network/services/hostapd/files/wpa_supplicant-full.config
developer9b3248d2022-07-06 00:44:05 +0800252
developerdbcd2cb2023-06-06 13:28:00 +0800253 # hack mt7988 config5.4
254 echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7988/config-5.4
255 echo "CONFIG_BLK_MQ_VIRTIO=y" >> ./target/linux/mediatek/mt7988/config-5.4
256 echo "CONFIG_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7988/config-5.4
257 echo "CONFIG_REMOTEPROC=y" >> ./target/linux/mediatek/mt7988/config-5.4
258 echo "CONFIG_VIRTIO=y" >> ./target/linux/mediatek/mt7988/config-5.4
259 echo "CONFIG_WANT_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7988/config-5.4
260 echo "CONFIG_VIRTIO_CONSOLE=n" >> ./target/linux/mediatek/mt7988/config-5.4
261 echo "CONFIG_VIRTIO_NET=n" >> ./target/linux/mediatek/mt7988/config-5.4
262 echo "CONFIG_VIRTIO_BLK=n" >> ./target/linux/mediatek/mt7988/config-5.4
263
264 # hack mt7986 config5.4
265 echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7986/config-5.4
266 echo "CONFIG_BLK_MQ_VIRTIO=y" >> ./target/linux/mediatek/mt7986/config-5.4
267 echo "CONFIG_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7986/config-5.4
268 echo "CONFIG_REMOTEPROC=y" >> ./target/linux/mediatek/mt7986/config-5.4
269 echo "CONFIG_VIRTIO=y" >> ./target/linux/mediatek/mt7986/config-5.4
270 echo "CONFIG_WANT_DEV_COREDUMP=y" >> ./target/linux/mediatek/mt7986/config-5.4
271 echo "CONFIG_VIRTIO_CONSOLE=n" >> ./target/linux/mediatek/mt7986/config-5.4
272 echo "CONFIG_VIRTIO_NET=n" >> ./target/linux/mediatek/mt7986/config-5.4
273 echo "CONFIG_VIRTIO_BLK=n" >> ./target/linux/mediatek/mt7986/config-5.4
274
275 # hack mt7622 config5.4
276 echo "CONFIG_RELAY=y" >> ./target/linux/mediatek/mt7622/config-5.4
277
developer24684862023-08-02 08:10:38 +0800278 # MAC80211/Hostapd Script
279 if [ $1 = "1" ]; then
280 patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch || exit 1
281 else
282 patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0001-wifi6-mac80211-generate-hostapd-setting-from-ap-cap.patch || exit 1
283 fi
284
285 # Hostapd Makefile
286 if [ $2 = "1" ]; then
287 patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0002-wifi7-hostapd-makefile-for-utils.patch || exit 1
288 else
289 patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0002-wifi6-hostapd-makefile-for-utils.patch || exit 1
290 fi
291
292 # MT76 Makefile
developerdbcd2cb2023-06-06 13:28:00 +0800293 patch -f -p1 -i ${MTK_FEED_DIR}/autobuild_mac80211_release/0003-master-mt76-makefile-for-new-chip.patch || exit 1
developere2cc0fa2022-03-29 17:31:03 +0800294 cp -rfa ${MTK_FEED_DIR}/autobuild_mac80211_release/package/ ${BUILD_DIR}
developer73b93122022-04-19 23:16:58 +0800295 cp -rfa ${MTK_FEED_DIR}/autobuild_mac80211_release/target/ ${BUILD_DIR}
developere2cc0fa2022-03-29 17:31:03 +0800296}
297
developer20d67712022-03-02 14:09:32 +0800298copy_main_Config() {
299 echo cp -rfa autobuild/$1/.config ./.config
300 cp -rfa autobuild/$1/.config ./.config
301}
302
303install_output_Image() {
304 mkdir -p ${INSTALL_DIR}/$1
305
306 files=`find bin/targets/$3/*${2}* -name "*.bin" -o -name "*.img"`
307 file_count=0
308
309 for file in $files
310 do
311 tmp=${file%.*}
312 cp -rf $file ${INSTALL_DIR}/$1/${tmp##*/}-${BUILD_TIME}.${file##*.}
313 ((file_count++))
314 done
315
316 if [ ${file_count} = 0 ]; then
317 if [ ${build_flag} -eq 0 ]; then
318 let build_flag+=1
319 echo " Restart to debug-build with "make V=s -j1", starting......"
320 build $1 -j1 || [ "$LOCAL" != "1" ]
321 else
322 echo " **********Failed to build $1, bin missing.**********"
323 fi
324 else
325 echo "Install image OK!!!"
326 echo "Build $1 successfully!"
327 fi
328}
329
330install_output_Config() {
331 echo cp -rfa autobuild/$1/.config ${INSTALL_DIR}/$1/openwrt.config
332 cp -rfa autobuild/$1/.config ${INSTALL_DIR}/$1/openwrt.config
333 [ -f tmp/kernel.config ] && cp tmp/kernel.config ${INSTALL_DIR}/$1/kernel.config
334}
335
336install_output_KernelDebugFile() {
337 KernelDebugFile=bin/targets/$3/mt${2}*/kernel-debug.tar.bz2
338 if [ -f ${KernelDebugFile} ]; then
339 echo cp -rfa ${KernelDebugFile} ${INSTALL_DIR}/$1/kernel-debug.tar.bz2
340 cp -rfa ${KernelDebugFile} ${INSTALL_DIR}/$1/kernel-debug.tar.bz2
341 fi
342}
343
344install_output_RootfsDebugFile() {
345 STAGING_DIR_ROOT=$(make -f "autobuild/get_stagingdir_root.mk" get-staging-dir-root)
346 if [ -d ${STAGING_DIR_ROOT} ]; then
347 STAGING_DIR_ROOT_PREFIX=$(dirname ${STAGING_DIR_ROOT})
348 STAGING_DIR_ROOT_NAME=$(basename ${STAGING_DIR_ROOT})
349 echo "tar -jcf ${INSTALL_DIR}/$1/rootfs-debug.tar.bz2 -C \"$STAGING_DIR_ROOT_PREFIX\" \"$STAGING_DIR_ROOT_NAME\""
350 tar -jcf ${INSTALL_DIR}/$1/rootfs-debug.tar.bz2 -C "$STAGING_DIR_ROOT_PREFIX" "$STAGING_DIR_ROOT_NAME"
351 fi
352}
353
354install_output_feeds_buildinfo() {
355 feeds_buildinfo=$(find bin/targets/$3/*${2}*/ -name "feeds.buildinfo")
356 echo "feeds_buildinfo=$feeds_buildinfo"
357 if [ -f ${feeds_buildinfo} ]; then
358 cp -rf $feeds_buildinfo ${INSTALL_DIR}/$1/feeds.buildinfo
359 else
360 echo "feeds.buildinfo is not found!!!"
361 fi
362}
363
developer699cda22022-12-17 15:21:57 +0800364install_output_at() {
developer3e0400f2023-02-10 08:32:03 +0800365 tar -zcvf to_at.tgz -C ${INSTALL_DIR}/$1 .
developer699cda22022-12-17 15:21:57 +0800366 mv to_at.tgz ${INSTALL_DIR}/
367}
368
developer20d67712022-03-02 14:09:32 +0800369install_release() {
370 temp=${1#*mt}
developerdbcd2cb2023-06-06 13:28:00 +0800371 if [ -z ${chip_name} ]; then
372 chip_name=${temp:0:4}
373 fi
developer20d67712022-03-02 14:09:32 +0800374 temp1=`grep "CONFIG_TARGET_ramips=y" autobuild/$1/.config`
375
376 if [ "${temp1}" == "CONFIG_TARGET_ramips=y" ]; then
377 arch_name="ramips"
378 else
379 arch_name="mediatek"
380 fi
381
382 #install output image
383 install_output_Image $1 ${chip_name} ${arch_name}
384
385 #install output config
386 install_output_Config $1
387
388 #install output Kernel-Debug-File
389 install_output_KernelDebugFile $1 ${chip_name} ${arch_name}
390
391 #tar unstripped rootfs for debug symbols
392 install_output_RootfsDebugFile $1
393
developer699cda22022-12-17 15:21:57 +0800394 #install output feeds buildinfo
395 install_output_feeds_buildinfo $1 ${chip_name} ${arch_name}
developer20d67712022-03-02 14:09:32 +0800396}
397
398prepare_final() {
399 #cp customized autobuild SDK patches
400 cp -fpR ${BUILD_DIR}/autobuild/$1/target/ ${BUILD_DIR}
401 cp -fpR ${BUILD_DIR}/autobuild/$1/package/ ${BUILD_DIR}
developer7273f5f2022-12-12 17:18:16 +0800402 cp -fpR ${BUILD_DIR}/autobuild/$1/tools/ ${BUILD_DIR}
developer20d67712022-03-02 14:09:32 +0800403
404
405 #cp special subtarget patches
406 case $1 in
407 mt7986*)
408 cp -rf ${BUILD_DIR}/autobuild/mt7986-AX6000/target/linux/mediatek/patches-5.4/*.* ${BUILD_DIR}/target/linux/mediatek/patches-5.4
409 ;;
410 *)
411 ;;
412 esac
413
414 #rm old legacy patch, ex old nfi nand driver
415 case $1 in
416 mt7986*|\
developer699cda22022-12-17 15:21:57 +0800417 mt7981*|\
418 mt7988*)
developer20d67712022-03-02 14:09:32 +0800419 rm -rf ${BUILD_DIR}/target/linux/mediatek/patches-5.4/0303-mtd-spinand-disable-on-die-ECC.patch
420 ;;
421 *)
422 ;;
423 esac
424
425 cd ${BUILD_DIR}
426 [ -f autobuild/$1/.config ] || {
427 echo "unable to locate autobuild/$1/.config !"
428 return
429 }
430
431 rm -rf ./tmp
432 #copy main test config(.config)
433 copy_main_Config $1
434
developer699cda22022-12-17 15:21:57 +0800435 change_config_before_defconfig
436
developer20d67712022-03-02 14:09:32 +0800437 echo make defconfig
438 make defconfig
developer699cda22022-12-17 15:21:57 +0800439
440 change_config_after_defconfig
developer20d67712022-03-02 14:09:32 +0800441}
442
443build() {
444 echo "###############################################################################"
445 echo "# $1"
446 echo "###############################################################################"
447 echo "build $1"
448
449 cd ${BUILD_DIR}
450
developer9b3248d2022-07-06 00:44:05 +0800451 #make
452
453 echo "make V=s -j $(($(nproc) + 1)) download world"
454 make V=s -j $(($(nproc) + 1)) download world || exit 1
455
456 #tar unstripped rootfs for debug symbols
457 install_release $1
458}
459
460build_log() {
461 echo "###############################################################################"
462 echo "# $1"
463 echo "###############################################################################"
464 echo "build $1"
465
466 cd ${BUILD_DIR}
467
468 #make
469
470 echo "make V=s -j $(($(nproc) + 1)) download world"
471 make V=s -j $(($(nproc) + 1)) download world || make V=s -j1 || exit 1
developer20d67712022-03-02 14:09:32 +0800472
473 #tar unstripped rootfs for debug symbols
474 install_release $1
475}