gather: Resolve symlinks before linking packages

If we happen to have a symlink to an RPM that should be linked into the
compose, we should first resolve it to the actual path. This avoids a
problem if the symlink is relative, as otherwise Pungi would copy/link
the actual relative symlink, which would break it in the new location.

If the path is not a symlink, resolving the real path should make no
difference.

JIRA: RHELCMP-14504
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
(cherry picked from commit 859b968483b75f630bb9c7e15a90767eb0b68d95)
This commit is contained in:
Lubomír Sedlář 2025-04-09 13:32:14 +02:00 committed by Stepan Oksanichenko
parent 027eb45b1d
commit 8c897dda71

View File

@ -87,7 +87,7 @@ def link_files(compose, arch, variant, pkg_map, pkg_sets, manifest, srpm_map={})
dst_relpath = os.path.join(packages_dir_relpath, package_path) dst_relpath = os.path.join(packages_dir_relpath, package_path)
# link file # link file
pool.queue_put((pkg["path"], dst)) pool.queue_put((os.path.realpath(pkg["path"]), dst))
# update rpm manifest # update rpm manifest
pkg_obj = pkg_by_path[pkg["path"]] pkg_obj = pkg_by_path[pkg["path"]]
@ -116,7 +116,7 @@ def link_files(compose, arch, variant, pkg_map, pkg_sets, manifest, srpm_map={})
dst_relpath = os.path.join(packages_dir_relpath, package_path) dst_relpath = os.path.join(packages_dir_relpath, package_path)
# link file # link file
pool.queue_put((pkg["path"], dst)) pool.queue_put((os.path.realpath(pkg["path"]), dst))
# update rpm manifest # update rpm manifest
pkg_obj = pkg_by_path[pkg["path"]] pkg_obj = pkg_by_path[pkg["path"]]
@ -146,7 +146,7 @@ def link_files(compose, arch, variant, pkg_map, pkg_sets, manifest, srpm_map={})
dst_relpath = os.path.join(packages_dir_relpath, package_path) dst_relpath = os.path.join(packages_dir_relpath, package_path)
# link file # link file
pool.queue_put((pkg["path"], dst)) pool.queue_put((os.path.realpath(pkg["path"]), dst))
# update rpm manifest # update rpm manifest
pkg_obj = pkg_by_path[pkg["path"]] pkg_obj = pkg_by_path[pkg["path"]]