blob: 45477bb493612a97a0dd8e205e6584c4ac8e850c [file] [log] [blame]
developer782bc7f2024-08-23 15:39:22 +08001#!/bin/sh
2
3# Copyright (C) 2024 MediaTek Inc. All rights reserved.
4# Author: Weijie Gao <weijie.gao@mediatek.com>
5# Top rules
6
7# Declare substages of every stage
developer9ab216e2024-09-04 09:26:31 +08008sub_stage_prepare="update_ab_info mk_ab_tmp pre_prepare apply_feed_script_patch modify_feeds_conf update_feeds \
developer782bc7f2024-08-23 15:39:22 +08009 mtk_feed_prepare install_feeds autobuild_prepare post_prepare"
developer9ab216e2024-09-04 09:26:31 +080010sub_stage_build="update_ab_info pre_build do_build post_build"
developer782bc7f2024-08-23 15:39:22 +080011sub_stage_release="pre_release do_release post_release"
12sub_stage_sdk_release="pre_sdk_release do_sdk_release post_sdk_release"
13sub_stage_menuconfig="do_menuconfig_update"
14
15# Declare hooks of every substage
16hooks_pre_prepare=
17hooks_mtk_feed_prepare="remove_files_by_mtk_feed_list copy_mtk_feed_files apply_mtk_feed_base_patches \
18 apply_mtk_feed_feed_patches"
19hooks_autobuild_prepare="remove_files_by_global_list copy_global_files apply_global_patches \
20 remove_files_by_platform_list copy_platform_files apply_platform_patches \
21 remove_files_by_wifi_list copy_wifi_files apply_wifi_patches \
22 remove_files_by_sku_list copy_sku_files apply_sku_patches \
23 remove_files_by_variant_list copy_variant_files apply_variant_patches \
24 prepare_wifi_driver prepare_openwrt_config platform_change_openwrt_config \
25 wifi_change_openwrt_config sku_change_openwrt_config variant_change_openwrt_config \
26 enable_openwrt_collect_debug_symbols make_defconfig update_target_info \
27 platform_change_kernel_config wifi_change_kernel_config sku_change_kernel_config \
28 variant_change_kernel_config enable_kernel_proc_config_gz"
29hooks_post_prepare="prepare_stamp"
30
31hooks_pre_build=
32hooks_do_build="download_openwrt_packages build_openwrt"
33hooks_post_build=
34
35hooks_pre_release="update_target_info mk_ab_bin_release"
36hooks_do_release="collect_openwrt_images collect_openwrt_configs collect_kernel_debug_symbols \
37 collect_userspace_debug_symbols collect_feeds_buildinfo"
38hooks_post_release=
39
40hooks_pre_sdk_release=
41hooks_do_sdk_release="release_openwrt_sdk"
42hooks_post_sdk_release=
43
44# Global information
45build_time=
46internal_build=
47mtk_feed_path=
48kernel_ver=
49target_name=
50subtarget_name=
51
52openwrt_bin_dir=
53openwrt_config_file=
54kernel_config_file=
55
56# Generic function for modifying openwrt config, to be compliant with menuconfig
57# $1: Config name
58openwrt_config_disable() {
59 if test -z "${do_menuconfig}"; then
60 if kconfig_enabled "${openwrt_config_file}" "${1}"; then
61 kconfig_disable "${openwrt_config_file}" "${1}"
62 fi
63 fi
64}
65
66# $1: Config name
67# $2: Value to be set for config (y if not specified)
68openwrt_config_enable() {
69 if test -z "${do_menuconfig}"; then
70 if ! kconfig_enabled "${openwrt_config_file}" "${1}"; then
71 kconfig_enable "${openwrt_config_file}" "${1}" "${2}"
72 fi
73 fi
74}
75
76# $1: Config name
77openwrt_config_enabled() {
78 kconfig_enabled "${openwrt_config_file}" "${1}"
79}
80
81# Generic function for modifying target's kernel config
82# $1: Config name
83kernel_config_disable() {
84 if kconfig_enabled "${kernel_config_file}" "${1}"; then
85 kconfig_disable "${kernel_config_file}" "${1}"
86 fi
87}
88
89# $1: Config name
90# $2: Value to be set for config (y if not specified)
91kernel_config_enable() {
92 if ! kconfig_enabled "${kernel_config_file}" "${1}"; then
93 kconfig_enable "${kernel_config_file}" "${1}" "${2}"
94 fi
95}
96
97# $1: Config name
98kernel_config_enabled() {
99 kconfig_enabled "${kernel_config_file}" "${1}"
100}
101
developer9ab216e2024-09-04 09:26:31 +0800102# Whether this is for internal build
103update_ab_info() {
104 if test -z "${internal_build}"; then
105 if test -d "${openwrt_root}/../mtk-openwrt-feeds"; then
106 log_dbg "Internal repo build mode"
107 internal_build=1
108 fi
109 fi
110}
111
developer782bc7f2024-08-23 15:39:22 +0800112# Create the ${ab_tmp} directory
113mk_ab_tmp() {
114 exec_log "mkdir -p \"${ab_tmp}\""
115}
116
117# Modify scripts/feed to allow specify subdirectory for scanning
118apply_feed_script_patch() {
119 apply_patch "${ab_root}/scripts/${openwrt_branch}/scripts-feeds-support-subdir.patch"
120}
121
122modify_feeds_conf() {
123 local rev_file_list=
124 local feed_rev=
125 local feed_url="https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds"
126
127 # Backup original feeds
128 exec_log "cp -f \"${openwrt_root}/feeds.conf.default\" \"${ab_tmp}/\""
129
130 # Modify feeds
131 openwrt_feeds_replace_url packages https://gerrit.mediatek.inc/openwrt/feeds/packages
132 openwrt_feeds_replace_url luci https://gerrit.mediatek.inc/openwrt/feeds/luci
133 openwrt_feeds_replace_url routing https://gerrit.mediatek.inc/openwrt/feeds/routing
134 openwrt_feeds_disable telephony
135 openwrt_feeds_change_src_git_type packages 0
136 openwrt_feeds_change_src_git_type luci 0
137 openwrt_feeds_change_src_git_type routing 0
138
139 # Add mtk-openwrt-feeds
140 [ -n "${ab_variant_dir}" ] && list_append rev_file_list "${ab_variant_dir}/feed_revision"
141 [ -n "${ab_sku_dir}" ] && list_append rev_file_list "${ab_sku_dir}/feed_revision"
142 [ -n "${ab_wifi_dir}" ] && list_append rev_file_list "${ab_wifi_dir}/feed_revision"
143 [ -n "${ab_platform_dir}" ] && list_append rev_file_list "${ab_platform_dir}/feed_revision"
144 list_append rev_file_list "${ab_root}/feed_revision"
145
146 for rev_file in ${rev_file_list}; do
147 if test -f "${rev_file}"; then
148 feed_rev=$(cat "${rev_file}")
149 break;
150 fi
151 done
152
153 [ -n "${feed_rev}" ] && feed_rev="^${feed_rev}"
154
developer9ab216e2024-09-04 09:26:31 +0800155 if test -n "${internal_build}"; then
developer782bc7f2024-08-23 15:39:22 +0800156 feed_url="${openwrt_root}/../mtk-openwrt-feeds"
developer782bc7f2024-08-23 15:39:22 +0800157 fi
158
159 if test -n "${internal_build}" -a -z "${feed_rev}"; then
160 openwrt_feeds_add mtk_openwrt_feed src-link "${feed_url}" --subdir=feed
161 else
162 openwrt_feeds_add mtk_openwrt_feed src-git "${feed_url}${feed_rev}" --subdir=feed
163 fi
164}
165
166update_feeds() {
developerfe20bee2024-09-11 10:05:11 +0800167 exec_log "${openwrt_root}/scripts/feeds update -a -r -s"
developer782bc7f2024-08-23 15:39:22 +0800168
169 mtk_feed_path=${openwrt_root}/feeds/mtk_openwrt_feed
170}
171
172remove_files_by_mtk_feed_list() {
173 remove_files_from_list "${mtk_feed_path}/common/remove_list.txt"
174 remove_files_from_list "${mtk_feed_path}/${openwrt_branch}/remove_list.txt"
175}
176
177copy_mtk_feed_files() {
178 copy_files "${mtk_feed_path}/common/files"
179 copy_files "${mtk_feed_path}/tools" tools
180 copy_files "${mtk_feed_path}/${openwrt_branch}/files"
181}
182
183apply_mtk_feed_base_patches() {
184 apply_patches "${mtk_feed_path}/${openwrt_branch}/patches-base"
185}
186
187apply_mtk_feed_feed_patches() {
188 apply_patches "${mtk_feed_path}/${openwrt_branch}/patches-feeds"
189}
190
191install_feeds() {
192 exec_log "${openwrt_root}/scripts/feeds install -a"
193}
194
195remove_files_by_global_list() {
196 remove_files_from_list "${ab_global}/common/remove_list.txt"
197 remove_files_from_list "${ab_global}/${openwrt_branch}/remove_list.txt"
198}
199
200copy_global_files() {
201 copy_files "${ab_global}/common/files"
202 copy_files "${ab_global}/${openwrt_branch}/files"
203}
204
205apply_global_patches() {
206 apply_patches "${ab_global}/${openwrt_branch}/patches-base" || return 1
207 apply_patches "${ab_global}/${openwrt_branch}/patches-feeds" || return 1
208 apply_patches "${ab_global}/${openwrt_branch}/patches" || return 1
209}
210
211remove_files_by_platform_list() {
212 remove_files_from_list "${ab_platform_dir}/remove_list.txt"
213 remove_files_from_list "${ab_platform_dir}/${openwrt_branch}/remove_list.txt"
214}
215
216copy_platform_files() {
217 copy_files "${ab_platform_dir}/files"
218 copy_files "${ab_platform_dir}/${openwrt_branch}/files"
219}
220
221apply_platform_patches() {
222 apply_patches "${ab_platform_dir}/${openwrt_branch}/patches-base" || return 1
223 apply_patches "${ab_platform_dir}/${openwrt_branch}/patches-feeds" || return 1
224 apply_patches "${ab_platform_dir}/${openwrt_branch}/patches" || return 1
225}
226
227remove_files_by_wifi_list() {
228 if test -n "${ab_wifi_dir}"; then
229 remove_files_from_list "${ab_wifi_dir}/remove_list.txt"
230 remove_files_from_list "${ab_wifi_dir}/${openwrt_branch}/remove_list.txt"
231 fi
232}
233
234copy_wifi_files() {
235 if test -n "${ab_wifi_dir}"; then
236 copy_files "${ab_wifi_dir}/files"
237 copy_files "${ab_wifi_dir}/${openwrt_branch}/files"
238 fi
239}
240
241apply_wifi_patches() {
242 if test -n "${ab_wifi_dir}"; then
243 apply_patches "${ab_wifi_dir}/${openwrt_branch}/patches-base" || return 1
244 apply_patches "${ab_wifi_dir}/${openwrt_branch}/patches-feeds" || return 1
245 apply_patches "${ab_wifi_dir}/${openwrt_branch}/patches" || return 1
246 fi
247}
248
249remove_files_by_sku_list() {
250 if test -n "${ab_sku_dir}"; then
251 remove_files_from_list "${ab_sku_dir}/remove_list.txt"
252 remove_files_from_list "${ab_sku_dir}/${openwrt_branch}/remove_list.txt"
253 fi
254}
255
256copy_sku_files() {
257 if test -n "${ab_sku_dir}"; then
258 copy_files "${ab_sku_dir}/files"
259 copy_files "${ab_sku_dir}/${openwrt_branch}/files"
260 fi
261}
262
263apply_sku_patches() {
264 if test -n "${ab_sku_dir}"; then
265 apply_patches "${ab_sku_dir}/${openwrt_branch}/patches-base" || return 1
266 apply_patches "${ab_sku_dir}/${openwrt_branch}/patches-feeds" || return 1
267 apply_patches "${ab_sku_dir}/${openwrt_branch}/patches" || return 1
268 fi
269}
270
271remove_files_by_variant_list() {
272 if test -n "${ab_variant_dir}"; then
273 remove_files_from_list "${ab_sku_dir}/remove_list.txt"
274 remove_files_from_list "${ab_sku_dir}/${openwrt_branch}/remove_list.txt"
275 fi
276}
277
278copy_variant_files() {
279 if test -n "${ab_variant_dir}"; then
280 copy_files "${ab_variant_dir}/files"
281 copy_files "${ab_variant_dir}/${openwrt_branch}/files"
282 fi
283}
284
285apply_variant_patches() {
286 if test -n "${ab_variant_dir}"; then
287 apply_patches "${ab_variant_dir}/${openwrt_branch}/patches-base" || return 1
288 apply_patches "${ab_variant_dir}/${openwrt_branch}/patches-feeds" || return 1
289 apply_patches "${ab_variant_dir}/${openwrt_branch}/patches" || return 1
290 fi
291}
292
293# prepare_wifi_driver() { } Implemented by wifi inclusion
294
295prepare_openwrt_config() {
296 local kconfig_expr=
297 local kconfig_files="\"${ab_platform_dir}/${openwrt_branch}/defconfig\""
298
299 openwrt_config_file="${openwrt_root}/.config"
300
301 if test ${ab_branch_level} -ge 2; then
302 kconfig_expr="${kconfig_expr} +"
303 kconfig_files="${kconfig_files} \"${ab_wifi_dir}/${openwrt_branch}/defconfig\""
304
305 if test -f "${ab_wifi_dir}/${openwrt_branch}/defconfig_forced"; then
306 kconfig_expr="${kconfig_expr} +"
307 kconfig_files="${kconfig_files} \"${ab_wifi_dir}/${openwrt_branch}/defconfig_forced\""
308 fi
309 fi
310
311 if test ${ab_branch_level} -ge 3; then
312 kconfig_expr="${kconfig_expr} +"
313 kconfig_files="${kconfig_files} \"${ab_sku_dir}/${openwrt_branch}/defconfig\""
314
315 if test -f "${ab_sku_dir}/${openwrt_branch}/defconfig_forced"; then
316 kconfig_expr="${kconfig_expr} +"
317 kconfig_files="${kconfig_files} \"${ab_sku_dir}/${openwrt_branch}/defconfig_forced\""
318 fi
319 fi
320
321 if test ${ab_branch_level} -ge 4; then
322 kconfig_expr="${kconfig_expr} +"
323 kconfig_files="${kconfig_files} \"${ab_variant_dir}/${openwrt_branch}/defconfig\""
324
325 if test -f "${ab_variant_dir}/${openwrt_branch}/defconfig_forced"; then
326 kconfig_expr="${kconfig_expr} +"
327 kconfig_files="${kconfig_files} \"${ab_variant_dir}/${openwrt_branch}/defconfig_forced\""
328 fi
329 fi
330
331 if test -n "${kconfig_expr}" -a -n "${kconfig_files}"; then
332 exec_log "\"${openwrt_root}/scripts/kconfig.pl\" ${kconfig_expr} ${kconfig_files} > \"${ab_tmp}/.config\"" 1
333 else
334 exec_log "cp ${kconfig_files} \"${ab_tmp}/.config\""
335 fi
336
337 exec_log "rm -f \"${openwrt_root}/.config.old\""
338 exec_log "make -C \"${openwrt_root}\" -f \"${ab_root}/scripts/openwrt_kconfig.mk\" loaddefconfig CONFIG_FILE=\"${ab_tmp}/.config\""
339 exec_log "cp -f \"${openwrt_root}/.config\" \"${ab_tmp}/.config.prev\""
340}
341
342# {platform,wifi,sku,variant}_change_openwrt_config() { } Implemented by platform sub levels
343
344enable_openwrt_collect_debug_symbols() {
345 openwrt_config_enable CONFIG_COLLECT_KERNEL_DEBUG
346 openwrt_config_enable CONFIG_DEBUG
347 openwrt_config_disable CONFIG_KERNEL_DEBUG_INFO_REDUCED
348}
349
350make_defconfig() {
351 if test -f "${ab_tmp}/.config.prev" -a -f "${openwrt_root}/.config"; then
352 if ! cmp -s "${ab_tmp}/.config.prev" "${openwrt_root}/.config"; then
353 exec_log "make -C \"${openwrt_root}\" defconfig"
354 fi
355 fi
356}
357
358__target_info_updated=
359
360update_target_info() {
361 [ -n "${__target_info_updated}" ] && return 0
362
363 target_name=$(openwrt_get_target_name)
364 subtarget_name=$(openwrt_get_subtarget_name)
365
366 if test -z "${target_name}"; then
367 log_err "Failed to get OpenWrt's target name"
368 return 1
369 fi
370
371 log_info "Target name: ${target_name}"
372 [ -n "${subtarget_name}" ] && log_info "Subtarget name: ${subtarget_name}"
373
374 openwrt_bin_dir=$(openwrt_get_bin_dir)
375
376 if test -z "${openwrt_bin_dir}"; then
377 log_err "Failed to get OpenWrt's bin directory"
378 return 1
379 fi
380
381 log_dbg "Target bin dir: ${openwrt_bin_dir}"
382
383 kernel_ver=$(openwrt_get_target_kernel_version ${target_name})
384
385 if test -z "${kernel_ver}"; then
386 log_err "Failed to get OpenWrt's target kernel version"
387 return 1
388 else
389 log_info "Target kernel version: ${kernel_ver}"
390 fi
391
392 if test -n ${subtarget_name}; then
393 if test -f "${openwrt_root}/target/linux/${target_name}/${subtarget_name}/config-${kernel_ver}"; then
394 kernel_config_file="${openwrt_root}/target/linux/${target_name}/${subtarget_name}/config-${kernel_ver}"
395 fi
396 fi
397
398 if test -z ${kernel_config_file}; then
399 if test -f "${openwrt_root}/target/linux/${target_name}/config-${kernel_ver}"; then
400 kernel_config_file="${openwrt_root}/target/linux/${target_name}/config-${kernel_ver}"
401 fi
402 fi
403
404 if test -z ${kernel_config_file}; then
405 log_err "Unable to find target's kernel config file"
406 return 1
407 fi
408
409 log_dbg "Target kernel config file: ${kernel_config_file}"
410
411 __target_info_updated=1
412}
413
414# {platform,wifi,sku,variant}_change_kernel_config() { } Implemented by platform sub levels
415
416enable_kernel_proc_config_gz() {
417 kernel_config_enable CONFIG_IKCONFIG
418 kernel_config_enable CONFIG_IKCONFIG_PROC
419}
420
421prepare_stamp() {
422 if test -n "${do_menuconfig}"; then
423 touch "${ab_tmp}/.stamp.menuconfig"
424 else
425 rm -f "${ab_tmp}/.stamp.menuconfig"
426 fi
427
428 echo -n "${ab_branch}" > "${ab_tmp}/branch_name"
429 echo -n "${ab_cmdline}" > "${ab_tmp}/cmdline"
430}
431
432download_openwrt_packages() {
433 if test x"${internal_build}" = x"1"; then
developer9ab216e2024-09-04 09:26:31 +0800434 if test -d "${openwrt_root}/../dl"; then
435 if ! test -d "${openwrt_root}/dl" -o -L "${openwrt_root}/dl"; then
436 exec_log "ln -sf ../dl \"${openwrt_root}/dl\""
437 fi
developer782bc7f2024-08-23 15:39:22 +0800438 fi
439 fi
440
441 exec_log "make -C \"${openwrt_root}\" V=1 -j\$((\$(nproc) + 1)) download"
442}
443
444build_openwrt() {
445 local ret=
446 local verbose=1
447
448 if test x"${debug_set}" = x"yes"; then
449 verbose=s
450 fi
451
452 build_time=$(date +%Y%m%d%H%M%S)
453
454 exec_log "make -C \"${openwrt_root}\" V=${verbose} -j\$((\$(nproc) + 1))"
455
456 ret=$?
457
458 if test ${ret} != 0; then
459 log_warn "Build failed with error code ${ret}."
460 log_warn "Restart single-threaded building for debugging purpose."
461
462 exec_log "make -C \"${openwrt_root}\" V=s -j1"
463
464 ret=$?
465
466 if test ${ret} != 0; then
467 log_err "Debug build failed with error code ${ret}."
468 return 1
469 fi
470 fi
471
472 log_info "OpenWrt built successfully"
473}
474
475# Create the ${ab_bin_release} directory
476mk_ab_bin_release() {
477 exec_log "mkdir -p \"${ab_bin_release}\""
478}
479
480collect_openwrt_images() {
481 local file_count=0
482 local files=
483
484 if [ -z "${build_time}" ]; then
485 build_time=$(date +%Y%m%d%H%M%S)
486 fi
487
488 files=$(find "${openwrt_bin_dir}" -maxdepth 1 -name '*.bin' -o -name "*.img" -o -name '*.itb' -o -name '*.gz')
489
490 for file in ${files}; do
491 local file_no_ext=${file%.*}
492 local file_name=${file_no_ext##*/}
493 local file_ext=${file##*.}
494
495 exec_log "cp -rf \"${file}\" \"${ab_bin_release}/${file_name}-${build_time}.${file_ext}\""
496 ((file_count++))
497 done
498
499 log_info "Total ${file_count} image files copied."
500}
501
502collect_openwrt_configs() {
503 local linux_dir=$(openwrt_get_target_kernel_linux_build_dir ${target_name})
504
505 exec_log "cp -f \"${openwrt_root}/.config\" \"${ab_bin_release}/openwrt.config\""
506
507 if test -z "${linux_dir}"; then
508 log_warn "Failed to get OpenWrt's linux kernel build directory"
509 else
510 local kernel_config_data="${linux_dir}/kernel/config_data"
511
512 if [ -f "${kernel_config_data}" ]; then
513 exec_log "cp -f \"${kernel_config_data}\" \"${ab_bin_release}/kernel.config\""
514 fi
515 fi
516}
517
518collect_kernel_debug_symbols() {
519 if [ -f "${openwrt_bin_dir}/kernel-debug.tar.zst" ]; then
520 exec_log "cp -f \"${openwrt_bin_dir}/kernel-debug.tar.zst\" \"${ab_bin_release}/\""
521 fi
522}
523
524collect_userspace_debug_symbols() {
525 local staging_dir_root=$(openwrt_get_staging_dir_root)
526
527 log_dbg "Staging dir root: ${staging_dir_root}"
528
529 if test -d "${staging_dir_root}"; then
530 staging_dir_root_prefix=$(dirname "${staging_dir_root}")
531 staging_dir_root_name=$(basename "${staging_dir_root}")
532
developere10d8622024-09-05 09:17:25 +0800533 if test -x "${openwrt_root}/staging_dir/host/bin/zstd"; then
534 exec_log "tar -c -C \"${staging_dir_root_prefix}\" \"${staging_dir_root_name}\" | \"${openwrt_root}/staging_dir/host/bin/zstd\" -T0 -f -o \"${ab_bin_release}/rootfs-debug.tar.zst\""
535 else
536 exec_log "tar -jcf \"${ab_bin_release}/rootfs-debug.tar.bz2\" -C \"${staging_dir_root_prefix}\" \"${staging_dir_root_name}\""
537 fi
developer782bc7f2024-08-23 15:39:22 +0800538 fi
539}
540
541collect_feeds_buildinfo() {
542 if [ -f "${openwrt_bin_dir}/feeds.buildinfo" ]; then
543 exec_log "cp -f \"${openwrt_bin_dir}/feeds.buildinfo\" \"${ab_bin_release}/\""
544 fi
545}
546
547do_menuconfig_update() {
548 local kconfig_expr=
549 local kconfig_files=
550 local final_file=
551
552 exec_log "make -C \"${openwrt_root}\" menuconfig"
553
554 if test ${ab_branch_level} -eq 1; then
555 exec_log "make -C ${openwrt_root} -f \"${ab_root}/scripts/openwrt_kconfig.mk\" savedefconfig CONFIG_FILE=\"${ab_tmp}/defconfig\""
556 exec_log "\"${openwrt_root}/scripts/kconfig.pl\" + \"${ab_tmp}/defconfig\" /dev/null > \"${ab_platform_dir}/${openwrt_branch}/defconfig\"" 1
557 return
558 fi
559
560 exec_log "make -C ${openwrt_root} -f \"${ab_root}/scripts/openwrt_kconfig.mk\" savedefconfig CONFIG_FILE=\"${ab_tmp}/defconfig\""
561
562 if test ${ab_branch_level} -ge 2; then
563 kconfig_files="\"${ab_platform_dir}/${openwrt_branch}/defconfig\""
564 final_file="${ab_wifi_dir}/${openwrt_branch}/defconfig"
565
566 if test -f "${ab_wifi_dir}/${openwrt_branch}/defconfig_forced"; then
567 kconfig_expr="${kconfig_expr} +"
568 kconfig_files="${kconfig_files} \"${ab_wifi_dir}/${openwrt_branch}/defconfig_forced\""
569 fi
570 fi
571
572 if test ${ab_branch_level} -ge 3; then
573 kconfig_expr="${kconfig_expr} +"
574 kconfig_files="${kconfig_files} \"${final_file}\""
575 final_file="${ab_sku_dir}/${openwrt_branch}/defconfig"
576
577 if test -f "${ab_sku_dir}/${openwrt_branch}/defconfig_forced"; then
578 kconfig_expr="${kconfig_expr} +"
579 kconfig_files="${kconfig_files} \"${ab_sku_dir}/${openwrt_branch}/defconfig_forced\""
580 fi
581 fi
582
583 if test ${ab_branch_level} -ge 4; then
584 kconfig_expr="${kconfig_expr} +"
585 kconfig_files="${kconfig_files} \"${final_file}\""
586 final_file="${ab_variant_dir}/${openwrt_branch}/defconfig"
587
588 if test -f "${ab_variant_dir}/${openwrt_branch}/defconfig_forced"; then
589 kconfig_expr="${kconfig_expr} +"
590 kconfig_files="${kconfig_files} \"${ab_variant_dir}/${openwrt_branch}/defconfig_forced\""
591 fi
592 fi
593
594 if test -n "${kconfig_expr}" -a -n "${kconfig_files}"; then
595 exec_log "\"${openwrt_root}/scripts/kconfig.pl\" ${kconfig_expr} ${kconfig_files} > \"${ab_tmp}/.config.base\"" 1
596 else
597 exec_log "cp ${kconfig_files} \"${ab_tmp}/.config.base\""
598 fi
599
600 exec_log "\"${openwrt_root}/scripts/kconfig.pl\" - \"${ab_tmp}/defconfig\" \"${ab_tmp}/.config.base\" > \"${final_file}\"" 1
601}