From 8ced384540612d8fc4aebaf6fb6c8b570793ec4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 7 Jun 2024 15:18:45 +0200 Subject: [PATCH] unified-isos: Resolve symlinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the compose is configured to use symlinks for packages, the unified ISO would include the symlinks which is useless. Instead, let's check and replace any symlinks pointing outside of the compose with the actual file. JIRA: RHELCMP-13802 Signed-off-by: Lubomír Sedlář --- pungi_utils/unified_isos.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pungi_utils/unified_isos.py b/pungi_utils/unified_isos.py index c9630059..a3ae6dff 100644 --- a/pungi_utils/unified_isos.py +++ b/pungi_utils/unified_isos.py @@ -148,6 +148,13 @@ class UnifiedISO(object): new_path = os.path.join(self.temp_dir, "trees", arch, old_relpath) makedirs(os.path.dirname(new_path)) + # Resolve symlinks to external files. Symlinks within the + # provided `dir` are kept. + if os.path.islink(old_path): + real_path = os.readlink(old_path) + abspath = os.path.normpath(os.path.join(os.path.dirname(old_path), real_path)) + if not abspath.startswith(dir): + old_path = real_path try: self.linker.link(old_path, new_path) except OSError as exc: