From b0d300e788571f48e95d6e673c6f94e54d1dd355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 24 Mar 2022 12:38:32 +0100 Subject: install_symlink: Handle $DESTDIR case for links with absolute path In case a link is pointing_to an absolute path and we are using $DESTDIR we fail in case the target is missing. This is incorrect because we may need to use an absolute path to an already installed file that is in $DESTDIR. So if an absolute target is not existing, check if we have such file in $DESTDIR before failing for real. --- mesonbuild/minstall.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index f33ad0a..1531be4 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -431,10 +431,12 @@ class Installer: append_to_log(self.lf, to_file) return True - def do_symlink(self, target: str, link: str, full_dst_dir: str, allow_missing: bool) -> bool: + def do_symlink(self, target: str, link: str, destdir: str, full_dst_dir: str, allow_missing: bool) -> bool: abs_target = target if not os.path.isabs(target): abs_target = os.path.join(full_dst_dir, target) + elif not os.path.exists(abs_target) and not allow_missing: + abs_target = destdir_join(destdir, abs_target) if not os.path.exists(abs_target) and not allow_missing: raise MesonException(f'Tried to install symlink to missing file {abs_target}') if os.path.exists(link): @@ -604,7 +606,7 @@ class Installer: full_dst_dir = get_destdir_path(destdir, fullprefix, s.install_path) full_link_name = get_destdir_path(destdir, fullprefix, s.name) dm.makedirs(full_dst_dir, exist_ok=True) - if self.do_symlink(s.target, full_link_name, full_dst_dir, s.allow_missing): + if self.do_symlink(s.target, full_link_name, destdir, full_dst_dir, s.allow_missing): self.did_install_something = True def install_man(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix: str) -> None: -- cgit v1.1