@@ -55,6 +55,35 @@ replace_with_custom_package_wrapper() {
5555 echo " [BOOT] Replaced $label with custom OpenWrt package wrapper"
5656}
5757
58+ configure_package_use_source_dir () {
59+ local pkg_dir=$1
60+ local source_dir_rel=$2
61+ local label=$3
62+ local makefile=" $pkg_dir /Makefile"
63+ local temp_file
64+
65+ if [ ! -d " $source_dir_rel " ] || [ ! -f " $makefile " ]; then
66+ return 1
67+ fi
68+
69+ temp_file=" $( mktemp) "
70+ awk -v source_dir=" $source_dir_rel " '
71+ /^USE_SOURCE_DIR:=/ { next }
72+ /^include \$\(INCLUDE_DIR\)\/package\.mk/ && !inserted {
73+ print "USE_SOURCE_DIR:=$(TOPDIR)/" source_dir
74+ inserted=1
75+ }
76+ { print }
77+ END {
78+ if (!inserted) {
79+ print "USE_SOURCE_DIR:=$(TOPDIR)/" source_dir
80+ }
81+ }
82+ ' " $makefile " > " $temp_file "
83+ mv " $temp_file " " $makefile "
84+ echo " [BOOT] Configured $label wrapper to use local source dir $source_dir_rel "
85+ }
86+
5887# ## feeds 优化 ###
5988# 先尝试 GitHub 镜像,失败后回退到 git.openwrt.org
6089rewrite_feeds () {
@@ -83,7 +112,7 @@ disable_mtk_feed() {
83112}
84113
85114mtk_feed_source_dir=" ./.mtk-feed-source"
86- mtk_feed_mode=" ${MTK_FEED_MODE:- disabled } "
115+ mtk_feed_mode=" ${MTK_FEED_MODE:- auto } "
87116mtk_feed_branch=" ${MTK_FEED_BRANCH:- master} "
88117mtk_feed_version_dir=" ${MTK_FEED_VERSION_DIR:- 24.10} "
89118mtk_feed_official_url=" ${MTK_FEED_OFFICIAL_URL:- https:// git01.mediatek.com/ openwrt/ feeds/ mtk-openwrt-feeds.git} "
@@ -246,10 +275,6 @@ if ! ./scripts/feeds update -a; then
246275 ./scripts/feeds update -a
247276fi
248277
249- if ! ./scripts/feeds install -a; then
250- echo " Feeds 安装部分失败,请检查上游仓库状态。" >&2
251- fi
252-
253278# ## 基础部分 ###
254279prepare_mtk_feed_source
255280
@@ -258,35 +283,47 @@ if [ "$mtk_feed_mode" != "disabled" ]; then
258283 apply_mtk_feed_overlay
259284fi
260285
286+ if ! ./scripts/feeds install -a; then
287+ echo " Feeds 安装部分失败,请检查上游仓库状态。" >&2
288+ fi
289+
261290# ## Custom Bootloader (Yuzhii0718) & GPT for A/B Partition ###
262291restore_openwrt_boot_package arm-trusted-firmware-mediatek || true
263292restore_openwrt_boot_package uboot-mediatek || true
264293
265294if [ -d " ../bl-mt798x-dhcpd" ]; then
266295 echo " [BOOT] Found custom bootloader repo: bl-mt798x-dhcpd"
267- atf_wrapper_replaced =0
296+ atf_custom_applied =0
268297
269298 # 1. Replace Arm Trusted Firmware (ATF)
270299 if replace_with_custom_package_wrapper \
271300 " ../bl-mt798x-dhcpd/atf-20260123" \
272301 " ./package/boot/arm-trusted-firmware-mediatek" \
273302 " ATF" ; then
274- atf_wrapper_replaced=1
303+ atf_custom_applied=1
304+ elif configure_package_use_source_dir \
305+ " ./package/boot/arm-trusted-firmware-mediatek" \
306+ " ../bl-mt798x-dhcpd/atf-20260123" \
307+ " ATF" ; then
308+ atf_custom_applied=1
275309 fi
276310
277311 # 2. Replace U-Boot
278312 replace_with_custom_package_wrapper \
279313 " ../bl-mt798x-dhcpd/uboot-mtk-20250711" \
280314 " ./package/boot/uboot-mediatek" \
315+ " U-Boot" || configure_package_use_source_dir \
316+ " ./package/boot/uboot-mediatek" \
317+ " ../bl-mt798x-dhcpd/uboot-mtk-20250711" \
281318 " U-Boot" || true
282319
283320 # 3. Inject media-specific GPT definitions for block-device targets when requested
284- if [ " $atf_wrapper_replaced " -eq 1 ] && [ -n " $BPI_R4_GPT_LAYOUT " ] && [ -f " ../PATCH/gpt/$BPI_R4_GPT_LAYOUT " ]; then
285- mkdir -p ./package/boot/arm-trusted-firmware-mediatek /src/gpt
286- cp " ../PATCH/gpt/$BPI_R4_GPT_LAYOUT " ./package/boot/arm-trusted-firmware-mediatek /src/gpt/
321+ if [ " $atf_custom_applied " -eq 1 ] && [ -n " $BPI_R4_GPT_LAYOUT " ] && [ -f " ../PATCH/gpt/$BPI_R4_GPT_LAYOUT " ]; then
322+ mkdir -p ../bl-mt798x-dhcpd/atf-20260123 /src/gpt
323+ cp " ../PATCH/gpt/$BPI_R4_GPT_LAYOUT " ../bl-mt798x-dhcpd/atf-20260123 /src/gpt/
287324 echo " [GPT] Injected GPT layout: $BPI_R4_GPT_LAYOUT "
288- elif [ -n " $BPI_R4_GPT_LAYOUT " ] && [ " $atf_wrapper_replaced " -ne 1 ]; then
289- echo " [GPT] Skipping GPT layout injection because no custom ATF package wrapper was applied"
325+ elif [ -n " $BPI_R4_GPT_LAYOUT " ] && [ " $atf_custom_applied " -ne 1 ]; then
326+ echo " [GPT] Skipping GPT layout injection because no custom ATF source was applied"
290327 elif [ -n " $BPI_R4_GPT_LAYOUT " ]; then
291328 echo " [GPT] Requested GPT layout '$BPI_R4_GPT_LAYOUT ' not found, skipping"
292329 else
0 commit comments