aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/minstall.py
diff options
context:
space:
mode:
authorArsen Arsenović <arsen@aarsen.me>2022-07-12 15:26:22 +0200
committerEli Schwartz <eschwartz93@gmail.com>2023-09-13 21:44:40 -0400
commit0af126fec798d6dbb0d1ad52168cc1f3f1758acd (patch)
tree41e4a51789de1e92881b29e7a7d9f13e5f369f8f /mesonbuild/minstall.py
parent56ef698426bb58b7ffd32b0711e064b54166e10f (diff)
downloadmeson-0af126fec798d6dbb0d1ad52168cc1f3f1758acd.zip
meson-0af126fec798d6dbb0d1ad52168cc1f3f1758acd.tar.gz
meson-0af126fec798d6dbb0d1ad52168cc1f3f1758acd.tar.bz2
install_{data,headers,subdir}: implement follow_symlinks
This permits users who rely on following symlinks to stay on the old default of following them.
Diffstat (limited to 'mesonbuild/minstall.py')
-rw-r--r--mesonbuild/minstall.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 0d397b2..5f8629b 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -64,9 +64,11 @@ if T.TYPE_CHECKING:
strip: bool
-symlink_warning = '''Warning: trying to copy a symlink that points to a file. This will copy the file,
-but this will be changed in a future version of Meson to copy the symlink as is. Please update your
-build definitions so that it will not break when the change happens.'''
+symlink_warning = '''\
+Warning: trying to copy a symlink that points to a file. This currently copies
+the file by default, but will be changed in a future version of Meson to copy
+the link instead. Set follow_symlinks to true to preserve current behavior, or
+false to copy the link.'''
selinux_updates: T.List[str] = []
@@ -389,7 +391,8 @@ class Installer:
return from_time <= to_time
def do_copyfile(self, from_file: str, to_file: str,
- makedirs: T.Optional[T.Tuple[T.Any, str]] = None) -> bool:
+ makedirs: T.Optional[T.Tuple[T.Any, str]] = None,
+ follow_symlinks: T.Optional[bool] = None) -> bool:
outdir = os.path.split(to_file)[0]
if not os.path.isfile(from_file) and not os.path.islink(from_file):
raise MesonException(f'Tried to install something that isn\'t a file: {from_file!r}')
@@ -417,10 +420,10 @@ class Installer:
# Dangling symlink. Replicate as is.
self.copy(from_file, outdir, follow_symlinks=False)
else:
- # Remove this entire branch when changing the behaviour to duplicate
- # symlinks rather than copying what they point to.
- print(symlink_warning)
- self.copy2(from_file, to_file)
+ if follow_symlinks is None:
+ follow_symlinks = True # TODO: change to False when removing the warning
+ print(symlink_warning)
+ self.copy2(from_file, to_file, follow_symlinks=follow_symlinks)
else:
self.copy2(from_file, to_file)
selinux_updates.append(to_file)
@@ -454,7 +457,7 @@ class Installer:
def do_copydir(self, data: InstallData, src_dir: str, dst_dir: str,
exclude: T.Optional[T.Tuple[T.Set[str], T.Set[str]]],
- install_mode: 'FileMode', dm: DirMaker) -> None:
+ install_mode: 'FileMode', dm: DirMaker, follow_symlinks: T.Optional[bool] = None) -> None:
'''
Copies the contents of directory @src_dir into @dst_dir.
@@ -519,7 +522,7 @@ class Installer:
dm.makedirs(parent_dir)
self.copystat(os.path.dirname(abs_src), parent_dir)
# FIXME: what about symlinks?
- self.do_copyfile(abs_src, abs_dst)
+ self.do_copyfile(abs_src, abs_dst, follow_symlinks=follow_symlinks)
self.set_mode(abs_dst, install_mode, data.install_umask)
def do_install(self, datafilename: str) -> None:
@@ -613,7 +616,8 @@ class Installer:
full_dst_dir = get_destdir_path(destdir, fullprefix, i.install_path)
self.log(f'Installing subdir {i.path} to {full_dst_dir}')
dm.makedirs(full_dst_dir, exist_ok=True)
- self.do_copydir(d, i.path, full_dst_dir, i.exclude, i.install_mode, dm)
+ self.do_copydir(d, i.path, full_dst_dir, i.exclude, i.install_mode, dm,
+ follow_symlinks=i.follow_symlinks)
def install_data(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix: str) -> None:
for i in d.data:
@@ -622,7 +626,7 @@ class Installer:
fullfilename = i.path
outfilename = get_destdir_path(destdir, fullprefix, i.install_path)
outdir = os.path.dirname(outfilename)
- if self.do_copyfile(fullfilename, outfilename, makedirs=(dm, outdir)):
+ if self.do_copyfile(fullfilename, outfilename, makedirs=(dm, outdir), follow_symlinks=i.follow_symlinks):
self.did_install_something = True
self.set_mode(outfilename, i.install_mode, d.install_umask)
@@ -668,7 +672,8 @@ class Installer:
fname = os.path.basename(fullfilename)
outdir = get_destdir_path(destdir, fullprefix, t.install_path)
outfilename = os.path.join(outdir, fname)
- if self.do_copyfile(fullfilename, outfilename, makedirs=(dm, outdir)):
+ if self.do_copyfile(fullfilename, outfilename, makedirs=(dm, outdir),
+ follow_symlinks=t.follow_symlinks):
self.did_install_something = True
self.set_mode(outfilename, t.install_mode, d.install_umask)