scripts: gen-secure-initramfs: convert absolute symlinks into relative ones

prpl CI enables CONFIG_IB which runs imagebuilder. Imagebuilder was
failing when trying to copy targets from symlink whose path was
absolute. The solution is to convert absolute symlinks into relative
ones when creating the secure initramfs.

Fixes: PCF-1893
Tracked-by: FEAT-29
Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
This commit is contained in:
Paul HENRYS 2025-12-10 10:51:27 +01:00 committed by Petr Štetiar
parent 6ecd84b713
commit 5aa0a8800d
No known key found for this signature in database
GPG Key ID: 58EE120F30CC02D3

View File

@ -104,9 +104,16 @@ function find_binary {
function import_file_symlink {
import_file_other "$1"
mkdir -p `dirname $TMP_FOLDER$1`
target=`readlink "$ROOTFS_FOLDER$1"`
[[ "$target" == /* ]] || target=`dirname "$1"`/$target
if [[ "$target" == /* ]] ; then
# Create a relative symlink
reltarget=$(realpath --relative-to="$(dirname "$ROOTFS_FOLDER$1")" "$ROOTFS_FOLDER$target")
ln -sf "$reltarget" "$TMP_FOLDER$1"
else
cp -pPTr "$ROOTFS_FOLDER$1" "$TMP_FOLDER$1"
target=`dirname "$1"`/$target
fi
import_file "$target"
}