gitlab:build: Add option to export staging rootfs for debugging

Add support for exporting debug symbols from the staging directory
by creating a compressed archive (rootfs-debug.tar.xz) when the
CI_BUILD_EXPORT_STAGING_ROOTFS environment variable is set.

This helps with debugging build issues by preserving the staging
root directory contents for later analysis. The feature is:
- Disabled by default to avoid unnecessary overhead
- Activated only when explicitly requested via CI_BUILD_EXPORT_STAGING_ROOTFS
- Archives the staging_dir/root-* directories into rootfs-debug.tar.xz

To use this feature, simply set CI_BUILD_EXPORT_STAGING_ROOTFS when
running the CI build job.

References: PCF-1769
Signed-off-by: Mouna ALOUI <mouna.aloui@softathome.com>
This commit is contained in:
Mouna ALOUI 2025-04-15 11:12:59 +02:00 committed by Petr Štetiar
parent 67c7a70257
commit 99dcb0e625
No known key found for this signature in database
GPG Key ID: 58EE120F30CC02D3

View File

@ -99,6 +99,14 @@
exit 1
" ERR
- make -j $(nproc) 2>&1 | tee --append logs/build.log
- >
if [ -n "$CI_BUILD_EXPORT_STAGING_ROOTFS" ]; then
root_dir=$(find $(pwd)/staging_dir -maxdepth 2 -type d -name root-*)
tar cfJ "rootfs-debug.tar.xz" -C "$root_dir" .
echo "Export of staging_dir/root-* completed in rootfs-debug.tar.xz"
else
echo "Skipping export of staging/root-* as `CI_BUILD_EXPORT_STAGING_ROOTFS` is not set."
fi
- rm .build_failed
after_script:
@ -118,3 +126,4 @@
- bin
- logs
- ./*packages-hash-issues.patch
- rootfs-debug.tar.xz