@@ -52,7 +52,10 @@ function post_family_config__000_ask_override_family() {
5252# Uses post_family_config because the kernel patch staging hook needs it before fetch_sources_tools runs
5353function post_family_config__ask_fetch_repo() {
5454 # Skip during config-dump-json: no $HOME is set, fetch_from_repo would fail in git_ensure_safe_directory
55- [[ " ${CONFIG_DEFS_ONLY} " == " yes" ]] && { declare -g ASK_CACHE_DIR=" ${SRC} /cache/sources/ask-repo" ; return 0; }
55+ [[ " ${CONFIG_DEFS_ONLY} " == " yes" || " ${ARMBIAN_COMMAND} " == " download-artifact" ]] && {
56+ declare -g ASK_CACHE_DIR=" ${SRC} /cache/sources/ask-repo"
57+ return 0
58+ }
5659 # For local file:// repos in Docker, safe.directory is needed (container runs as root)
5760 # Use env vars instead of git config --global to avoid persistent side effects
5861 if [[ " ${ASK_REPO} " == file://* ]]; then
@@ -62,7 +65,7 @@ function post_family_config__ask_fetch_repo() {
6265 export GIT_CONFIG_KEY_1=" safe.directory" GIT_CONFIG_VALUE_1=" ${local_path} /.git"
6366 fi
6467 fetch_from_repo " ${ASK_REPO} " " ask-repo" " ${ASK_BRANCH} "
65- unset GIT_CONFIG_COUNT GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0 GIT_CONFIG_KEY_1 GIT_CONFIG_VALUE_1 2> /dev/null
68+ unset GIT_CONFIG_COUNT GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0 GIT_CONFIG_KEY_1 GIT_CONFIG_VALUE_1 2> /dev/null
6669 declare -g ASK_CACHE_DIR=" ${SRC} /cache/sources/ask-repo"
6770}
6871
@@ -90,25 +93,31 @@ function custom_kernel_config__ask_modules() {
9093 local ask_drv=" ${kernel_work_dir} /drivers/net/ethernet/freescale/ask"
9194 local bsp_dir=" ${SRC} /packages/bsp/gateway-dk"
9295
96+ # Cleanup previous tree if it exists (otherwise copying again creates 1-deep duplicates)
97+ if [[ -d " ${ask_drv} " ]]; then
98+ display_alert " ASK extension" " removing previous ASK module tree in kernel" " info"
99+ run_host_command_logged rm -rf " ${ask_drv} "
100+ fi
101+
93102 # Copy module sources and Kbuild files from ASK cache
94103 # (Kbuild files coexist with old Makefiles — kbuild prefers Kbuild when both exist)
95- mkdir -p " ${ask_drv} "
96- cp -a " ${ASK_CACHE_DIR} /${ASK_CDX_DIR} " " ${ask_drv} /cdx"
97- cp -a " ${ASK_CACHE_DIR} /${ASK_FCI_DIR} " " ${ask_drv} /fci"
98- cp -a " ${ASK_CACHE_DIR} /${ASK_AUTOBRIDGE_DIR} " " ${ask_drv} /auto_bridge"
104+ run_host_command_logged mkdir -pv " ${ask_drv} "
105+ run_host_command_logged cp -av " ${ASK_CACHE_DIR} /${ASK_CDX_DIR} " " ${ask_drv} /cdx"
106+ run_host_command_logged cp -av " ${ASK_CACHE_DIR} /${ASK_FCI_DIR} " " ${ask_drv} /fci"
107+ run_host_command_logged cp -av " ${ASK_CACHE_DIR} /${ASK_AUTOBRIDGE_DIR} " " ${ask_drv} /auto_bridge"
99108
100109 # Parent Kconfig and Makefile from ASK repo
101- cp " ${ASK_CACHE_DIR} /Kconfig" " ${ask_drv} /Kconfig"
102- cp " ${ASK_CACHE_DIR} /Kbuild.mk" " ${ask_drv} /Makefile"
110+ run_host_command_logged cp -v " ${ASK_CACHE_DIR} /Kconfig" " ${ask_drv} /Kconfig"
111+ run_host_command_logged cp -v " ${ASK_CACHE_DIR} /Kbuild.mk" " ${ask_drv} /Makefile"
103112
104113 # Board-specific modules (not part of ASK repo — from Armbian BSP)
105114 if [[ " ${BOARD} " == " gateway-dk" ]]; then
106- mkdir -p " ${ask_drv} /sfp_led" " ${ask_drv} /leds_lp5812"
107- cp " ${bsp_dir} /sfp-led.c" " ${ask_drv} /sfp_led/"
108- cp " ${bsp_dir} /sfp-led.Kbuild" " ${ask_drv} /sfp_led/Kbuild"
109- cp " ${bsp_dir} /leds-lp5812.c" " ${ask_drv} /leds_lp5812/"
110- cp " ${bsp_dir} /leds-lp5812.h" " ${ask_drv} /leds_lp5812/"
111- cp " ${bsp_dir} /leds-lp5812.Kbuild" " ${ask_drv} /leds_lp5812/Kbuild"
115+ run_host_command_logged mkdir -pv " ${ask_drv} /sfp_led" " ${ask_drv} /leds_lp5812"
116+ run_host_command_logged cp -v " ${bsp_dir} /sfp-led.c" " ${ask_drv} /sfp_led/"
117+ run_host_command_logged cp -v " ${bsp_dir} /sfp-led.Kbuild" " ${ask_drv} /sfp_led/Kbuild"
118+ run_host_command_logged cp -v " ${bsp_dir} /leds-lp5812.c" " ${ask_drv} /leds_lp5812/"
119+ run_host_command_logged cp -v " ${bsp_dir} /leds-lp5812.h" " ${ask_drv} /leds_lp5812/"
120+ run_host_command_logged cp -v " ${bsp_dir} /leds-lp5812.Kbuild" " ${ask_drv} /leds_lp5812/Kbuild"
112121
113122 # Add board-specific entries to ASK Kconfig and Makefile
114123 patch -p1 -d " ${ask_drv} " < " ${bsp_dir} /ask-kconfig-board-modules.patch"
@@ -118,11 +127,18 @@ function custom_kernel_config__ask_modules() {
118127
119128 # Wire into parent freescale Kconfig and Makefile
120129 local fsl_dir=" ${kernel_work_dir} /drivers/net/ethernet/freescale"
121- if ! grep -q ' source.*ask/Kconfig' " ${fsl_dir} /Kconfig" 2> /dev/null; then
130+ if ! grep -q ' source.*ask/Kconfig' " ${fsl_dir} /Kconfig" ; then
131+ display_alert " ASK extension" " adding ASK Kconfig to freescale Kconfig" " info"
122132 sed -i ' /endif.*NET_VENDOR_FREESCALE/i source "drivers/net/ethernet/freescale/ask/Kconfig"' " ${fsl_dir} /Kconfig"
133+ else
134+ display_alert " ASK extension" " ASK Kconfig already present in freescale Kconfig" " info"
123135 fi
124- if ! grep -q ' ask/' " ${fsl_dir} /Makefile" 2> /dev/null; then
136+
137+ if ! grep -q ' ask/' " ${fsl_dir} /Makefile" ; then
138+ display_alert " ASK extension" " adding ASK modules to freescale Makefile" " info"
125139 echo ' obj-y += ask/' >> " ${fsl_dir} /Makefile"
140+ else
141+ display_alert " ASK extension" " ASK modules already present in freescale Makefile"
126142 fi
127143
128144 display_alert " ASK extension" " ASK module sources and Kbuild files placed in kernel tree" " info"
@@ -138,21 +154,35 @@ function custom_kernel_config__ask_modules() {
138154 fi
139155}
140156
141- # Copy ASK kernel patch to userpatches (gitignored) so it's applied during kernel build.
157+ # Copy ASK kernel patch to userpatches so it's applied during kernel build.
142158# userpatches/ is the Armbian-standard location for extension-provided patches — the build
143- # framework merges them with patches from patch/kernel/ at build time. The directory is
144- # gitignored and ephemeral; it does not persist across clean builds.
145- function post_family_config__ask_kernel_patch() {
146- [[ " ${CONFIG_DEFS_ONLY} " == " yes" ]] && return 0 # cache wasn't populated during config-dump-json
147- local patch_src=" ${ASK_CACHE_DIR} /patches/kernel/002-mono-gateway-ask-kernel_linux_6_12.patch"
159+ # framework merges them with patches from patch/kernel/ at build time.
160+ function kernel_extra_create_patches__ask_kernel_patch() {
161+ display_alert " ASK extension" " ASK kernel patch being staged in userpatches" " wrn"
162+ declare patch_src=" ${ASK_CACHE_DIR} /patches/kernel/002-mono-gateway-ask-kernel_linux_6_12.patch"
148163 [[ -f " ${patch_src} " ]] || exit_with_error " ASK kernel patch not found" " ${patch_src} "
149- local patch_dst=" ${SRC} /userpatches/kernel/${KERNELPATCHDIR} "
150- mkdir -p " ${patch_dst} "
164+ declare patch_dst=" ${SRC} /userpatches/kernel/${KERNELPATCHDIR} "
165+ declare patch_dst_file=" ${patch_dst} /003-mono-gateway-ask-kernel_linux_6_12.patch"
166+ run_host_command_logged mkdir -pv " ${patch_dst} "
151167 # Renamed to 003- to apply after 001-ina234 and 002-device-tree in the Armbian patch dir
152- cp " ${patch_src} " " ${patch_dst} /003-mono-gateway-ask-kernel_linux_6_12.patch"
168+ run_host_command_logged cp -v " ${patch_src} " " ${patch_dst_file} "
169+ run_host_command_logged touch " ${patch_dst_file} " # always recently-modified
153170 display_alert " ASK extension" " ASK kernel patch staged in userpatches" " info"
154171}
155172
173+ function post_family_config__cleanup_ask_kernel_patch() {
174+ declare patch_dst=" ${SRC} /userpatches/kernel/${KERNELPATCHDIR} "
175+ declare patch_dst_file=" ${patch_dst} /003-mono-gateway-ask-kernel_linux_6_12.patch"
176+ # if patch_dst_file exists, remove it -- it shouldn't be there in post_family_config stage (pre-hashing)
177+ # read: "the previous build left a staged ASK kernel patch in userpatches, remove it so patches hash doesn't change"
178+ if [[ -f " ${patch_dst_file} " ]]; then
179+ display_alert " ASK extension" " removing staged ASK kernel patch from userpatches" " info"
180+ run_host_command_logged rm -f " ${patch_dst_file} "
181+ else
182+ display_alert " ASK extension" " no staged ASK kernel patch found in userpatches, nothing to remove" " info"
183+ fi
184+ return 0
185+ }
156186
157187# Install module autoload config (modules are in the kernel .deb, just need the load list)
158188function post_install_kernel_debs__ask_module_autoload() {
@@ -211,8 +241,8 @@ function pre_customize_image__001_build_ask_userspace() {
211241 chroot_sdcard " cd /tmp/ask-userspace/fmlib && \
212242 patch -p1 < /tmp/ask-userspace/01-mono-ask-extensions.patch && \
213243 make KERNEL_SRC=${kdir} libfm-arm.a && \
214- make DESTDIR=/ PREFIX=/usr LIB_DEST_DIR=/usr/lib/${ASK_HOST_TRIPLET} install-libfm-arm" \
215- || exit_with_error " fmlib build failed"
244+ make DESTDIR=/ PREFIX=/usr LIB_DEST_DIR=/usr/lib/${ASK_HOST_TRIPLET} install-libfm-arm" ||
245+ exit_with_error " fmlib build failed"
216246
217247 # --- fmc ---
218248 display_alert " ASK extension" " building fmc" " info"
@@ -233,8 +263,8 @@ function pre_customize_image__001_build_ask_userspace() {
233263 install -m 644 source/fmc.h /usr/include/fmc/ && \
234264 install -m 644 source/libfmc.a /usr/lib/${ASK_HOST_TRIPLET} / && \
235265 install -d /etc/fmc/config && \
236- install -m 644 etc/fmc/config/* /etc/fmc/config/" \
237- || exit_with_error " fmc build failed"
266+ install -m 644 etc/fmc/config/* /etc/fmc/config/" ||
267+ exit_with_error " fmc build failed"
238268
239269 # --- libcli ---
240270 display_alert " ASK extension" " building libcli" " info"
@@ -243,8 +273,8 @@ function pre_customize_image__001_build_ask_userspace() {
243273
244274 chroot_sdcard " cd /tmp/ask-userspace/libcli && \
245275 make CFLAGS='-Wno-calloc-transposed-args' && \
246- make PREFIX=/usr DESTDIR=/ install" \
247- || exit_with_error " libcli build failed"
276+ make PREFIX=/usr DESTDIR=/ install" ||
277+ exit_with_error " libcli build failed"
248278
249279 # --- libfci ---
250280 display_alert " ASK extension" " building libfci" " info"
@@ -253,8 +283,8 @@ function pre_customize_image__001_build_ask_userspace() {
253283 chroot_sdcard " cd /tmp/ask-userspace/libfci && \
254284 make && \
255285 install -m 644 libfci.a /usr/lib/${ASK_HOST_TRIPLET} / && \
256- install -m 644 include/libfci.h /usr/include/" \
257- || exit_with_error " libfci build failed"
286+ install -m 644 include/libfci.h /usr/include/" ||
287+ exit_with_error " libfci build failed"
258288
259289 # --- dpa-app ---
260290 display_alert " ASK extension" " building dpa-app" " info"
@@ -269,8 +299,8 @@ function pre_customize_image__001_build_ask_userspace() {
269299 -I/usr/include/fmc -I/usr/include/fmd -I/usr/include/fmd/integrations \
270300 -I/usr/include/fmd/Peripherals -I/usr/include/fmd/Peripherals/common -I/usr/include/cdx' \
271301 LDFLAGS='-lfmc -lfm-arm -lstdc++ -lxml2 -lpthread -lcli' && \
272- install -m 755 dpa_app /usr/bin/" \
273- || exit_with_error " dpa-app build failed"
302+ install -m 755 dpa_app /usr/bin/" ||
303+ exit_with_error " dpa-app build failed"
274304
275305 # Install DPA-App config files (from ASK repo)
276306 cp " ${ASK_CACHE_DIR} /config/gateway-dk/cdx_cfg.xml" " ${SDCARD} /etc/"
@@ -295,8 +325,8 @@ function pre_customize_image__001_build_ask_userspace() {
295325 install -d /usr/lib/${ASK_HOST_TRIPLET} /xtables && \
296326 for name in ${ask_xtables_modules[*]} ; do \
297327 install -m 644 \"\$ {name}.so\" /usr/lib/${ASK_HOST_TRIPLET} /xtables/ || exit 1; \
298- done" \
299- || exit_with_error " xtables extensions build failed"
328+ done" ||
329+ exit_with_error " xtables extensions build failed"
300330
301331 # --- Patched system libraries (must be before CMM which depends on patched libnetfilter-conntrack) ---
302332 build_ask_patched_libraries
@@ -318,8 +348,8 @@ function pre_customize_image__001_build_ask_userspace() {
318348 LIBFCI_DIR=/tmp/ask-userspace/libfci \
319349 ABM_DIR=/usr \
320350 SYSROOT=/ && \
321- install -m 755 src/cmm /usr/bin/" \
322- || exit_with_error " cmm build failed"
351+ install -m 755 src/cmm /usr/bin/" ||
352+ exit_with_error " cmm build failed"
323353
324354 # Install and enable CMM service (from ASK repo)
325355 # Guarded by ConditionPathExists=/dev/cdx_ctrl — won't start without ASK FMAN ucode on NOR
@@ -379,7 +409,7 @@ function pre_customize_image__001_build_ask_userspace() {
379409 # Libraries — snapshot all ASK-installed libs from chroot
380410 mkdir -p " ${pkgdir} /usr/lib/${ASK_HOST_TRIPLET} "
381411 for lib in libfm-arm.a libfmc.a; do
382- [[ -f " ${SDCARD} /usr/lib/${ASK_HOST_TRIPLET} /${lib} " ]] && \
412+ [[ -f " ${SDCARD} /usr/lib/${ASK_HOST_TRIPLET} /${lib} " ]] &&
383413 cp -a " ${SDCARD} /usr/lib/${ASK_HOST_TRIPLET} /${lib} " " ${pkgdir} /usr/lib/${ASK_HOST_TRIPLET} /"
384414 done
385415 for pattern in libcli libfci; do
@@ -463,11 +493,11 @@ CONFFILES
463493 # Build .deb once, install in chroot and save to output
464494 local debfile=" ${pkgname} _${ask_version} _arm64.deb"
465495 mkdir -p " ${SRC} /output/debs"
466- run_host_command_logged dpkg-deb -b " ${pkgdir} " " ${SRC} /output/debs/${debfile} " \
467- || exit_with_error " dpkg-deb failed for ${debfile} "
496+ run_host_command_logged dpkg-deb -b " ${pkgdir} " " ${SRC} /output/debs/${debfile} " ||
497+ exit_with_error " dpkg-deb failed for ${debfile} "
468498 cp " ${SRC} /output/debs/${debfile} " " ${SDCARD} /root/"
469- chroot_sdcard " DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends /root/${debfile} " \
470- || exit_with_error " apt install failed for ${debfile} "
499+ chroot_sdcard " DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends /root/${debfile} " ||
500+ exit_with_error " apt install failed for ${debfile} "
471501 rm -f " ${SDCARD} /root/${debfile} "
472502
473503 rm -rf " ${pkgdir} "
@@ -494,10 +524,9 @@ function build_ask_patched_libraries() {
494524 " 01-nxp-ask-nonblocking-heap-buffer.patch" \
495525 " libnfnetlink0_*.deb libnfnetlink-dev_*.deb"
496526
497-
498527 # Copy patched .debs to output for distribution
499528 mkdir -p " ${SRC} /output/debs"
500- cp " ${SDCARD} " /tmp/ask-patched-debs/* .deb " ${SRC} /output/debs/" 2> /dev/null || true
529+ cp " ${SDCARD} " /tmp/ask-patched-debs/* .deb " ${SRC} /output/debs/" 2> /dev/null || true
501530 rm -rf " ${SDCARD} /tmp/ask-patched-debs"
502531}
503532
@@ -528,6 +557,5 @@ function rebuild_patched_deb() {
528557 DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -uc -us && \
529558 cd '${workdir} ' && dpkg -i ${debs} && \
530559 cp ${debs} /tmp/ask-patched-debs/ && \
531- rm -rf '${workdir} '" \
532- || exit_with_error " ${pkg} rebuild failed"
560+ rm -rf '${workdir} '" || exit_with_error " ${pkg} rebuild failed"
533561}
0 commit comments