Skip to content

Commit dce9c55

Browse files
Hi-Angeljpakkane
authored andcommitted
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: #12253
1 parent 7d44982 commit dce9c55

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

mesonbuild/backend/backends.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ class InstallSymlinkData:
177177
install_path: str
178178
subproject: str
179179
tag: T.Optional[str] = None
180-
allow_missing: bool = False
181180

182181
# cannot use dataclass here because "exclude" is out of order
183182
class SubdirInstallData(InstallDataBase):
@@ -1710,7 +1709,7 @@ def generate_target_install(self, d: InstallData) -> None:
17101709

17111710
for alias, to, tag in t.get_aliases():
17121711
alias = os.path.join(first_outdir, alias)
1713-
s = InstallSymlinkData(to, alias, first_outdir, t.subproject, tag, allow_missing=True)
1712+
s = InstallSymlinkData(to, alias, first_outdir, t.subproject, tag)
17141713
d.symlinks.append(s)
17151714

17161715
if isinstance(t, (build.SharedLibrary, build.SharedModule, build.Executable)):

mesonbuild/minstall.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,13 @@ def do_copyfile(self, from_file: str, to_file: str,
441441
append_to_log(self.lf, to_file)
442442
return True
443443

444-
def do_symlink(self, target: str, link: str, destdir: str, full_dst_dir: str, allow_missing: bool) -> bool:
444+
def do_symlink(self, target: str, link: str, destdir: str, full_dst_dir: str) -> bool:
445445
abs_target = target
446446
if not os.path.isabs(target):
447447
abs_target = os.path.join(full_dst_dir, target)
448-
elif not os.path.exists(abs_target) and not allow_missing:
448+
elif not os.path.exists(abs_target):
449449
abs_target = destdir_join(destdir, abs_target)
450-
if not os.path.exists(abs_target) and not allow_missing:
451-
raise MesonException(f'Tried to install symlink to missing file {abs_target}')
452-
if os.path.exists(link):
450+
if os.path.lexists(link):
453451
if not os.path.islink(link):
454452
raise MesonException(f'Destination {link!r} already exists and is not a symlink')
455453
self.remove(link)
@@ -656,7 +654,7 @@ def install_symlinks(self, d: InstallData, dm: DirMaker, destdir: str, fullprefi
656654
full_dst_dir = get_destdir_path(destdir, fullprefix, s.install_path)
657655
full_link_name = get_destdir_path(destdir, fullprefix, s.name)
658656
dm.makedirs(full_dst_dir, exist_ok=True)
659-
if self.do_symlink(s.target, full_link_name, destdir, full_dst_dir, s.allow_missing):
657+
if self.do_symlink(s.target, full_link_name, destdir, full_dst_dir):
660658
self.did_install_something = True
661659

662660
def install_man(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix: str) -> None:

0 commit comments

Comments
 (0)