diff options
author | Konstantin Kharlamov <Hi-Angel@yandex.ru> | 2023-09-15 17:01:15 +0300 |
---|---|---|
committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-08-10 20:37:38 +0300 |
commit | dce9c554536928bb55667d6ca53b24ad91c4c475 (patch) | |
tree | 92caa40fc10c402db5badd3e27ffdff8e31ad33f | |
parent | 7d44982b32974059f5c3e0b6a7dfc7838e295390 (diff) | |
download | meson-dce9c554536928bb55667d6ca53b24ad91c4c475.zip meson-dce9c554536928bb55667d6ca53b24ad91c4c475.tar.gz meson-dce9c554536928bb55667d6ca53b24ad91c4c475.tar.bz2 |
minstall: allow missing symlink destination in `install_symlink`
Currently there's an undocumented behavior where using
`install_symlink()` to point to a file that does not exist results in
failure `ERROR: Tried to install symlink to missing file`.
Such behavior makes little sense because there's no reason the
destination file should exist. The "destination file" may belong to
another package, in particular to a package inside the same repo the
Meson is controlling, in both cases there's no reason the other
package should be present in the system, because installation does not
typically happen into the system but rather to DESTDIR. And the file
may not be present in DESTDIR either because it may belong to a
different installation target (and different DESTDIR) even if it's in
the same repo.
Best backward-compatible decision here would be to just remove the
check, which is done by this commit.
Fixes: https://github.com/mesonbuild/meson/issues/12253
-rw-r--r-- | mesonbuild/backend/backends.py | 3 | ||||
-rw-r--r-- | mesonbuild/minstall.py | 10 |
2 files changed, 5 insertions, 8 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index e3d6c60..d4de240 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -177,7 +177,6 @@ class InstallSymlinkData: install_path: str subproject: str tag: T.Optional[str] = None - allow_missing: bool = False # cannot use dataclass here because "exclude" is out of order class SubdirInstallData(InstallDataBase): @@ -1710,7 +1709,7 @@ class Backend: for alias, to, tag in t.get_aliases(): alias = os.path.join(first_outdir, alias) - s = InstallSymlinkData(to, alias, first_outdir, t.subproject, tag, allow_missing=True) + s = InstallSymlinkData(to, alias, first_outdir, t.subproject, tag) d.symlinks.append(s) if isinstance(t, (build.SharedLibrary, build.SharedModule, build.Executable)): diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index f65087c..eec22be 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -441,15 +441,13 @@ class Installer: append_to_log(self.lf, to_file) return True - def do_symlink(self, target: str, link: str, destdir: str, full_dst_dir: str, allow_missing: bool) -> bool: + def do_symlink(self, target: str, link: str, destdir: str, full_dst_dir: str) -> 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: + elif not os.path.exists(abs_target): 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): + if os.path.lexists(link): if not os.path.islink(link): raise MesonException(f'Destination {link!r} already exists and is not a symlink') self.remove(link) @@ -656,7 +654,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, destdir, full_dst_dir, s.allow_missing): + if self.do_symlink(s.target, full_link_name, destdir, full_dst_dir): self.did_install_something = True def install_man(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix: str) -> None: |