aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2020-08-20 10:13:43 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2020-08-20 23:47:54 +0300
commit86b47250c61bd373a3d28dd05a4a231564b1bfef (patch)
tree634a8a9ace6752a0e5190229a9f309c1361c8d45
parent1c403e20e70ac523216a31f977901fb815166b7a (diff)
downloadmeson-86b47250c61bd373a3d28dd05a4a231564b1bfef.zip
meson-86b47250c61bd373a3d28dd05a4a231564b1bfef.tar.gz
meson-86b47250c61bd373a3d28dd05a4a231564b1bfef.tar.bz2
simplify shutil usage by invoking copy2 where appropriate
It's equivalent to copyfile + copystat with the same arguments.
-rw-r--r--mesonbuild/interpreter.py3
-rw-r--r--mesonbuild/minstall.py6
-rw-r--r--mesonbuild/scripts/gettext.py3
-rw-r--r--mesonbuild/scripts/yelphelper.py3
4 files changed, 5 insertions, 10 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index dc231cc..3a61c66 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -4368,8 +4368,7 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
if len(inputs_abs) != 1:
raise InterpreterException('Exactly one input file must be given in copy mode')
os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True)
- shutil.copyfile(inputs_abs[0], ofile_abs)
- shutil.copystat(inputs_abs[0], ofile_abs)
+ shutil.copy2(inputs_abs[0], ofile_abs)
else:
# Not reachable
raise AssertionError
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 0be01fe..e6e973a 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -270,11 +270,9 @@ class Installer:
# Remove this entire branch when changing the behaviour to duplicate
# symlinks rather than copying what they point to.
print(symlink_warning)
- shutil.copyfile(from_file, to_file)
- shutil.copystat(from_file, to_file)
+ shutil.copy2(from_file, to_file)
else:
- shutil.copyfile(from_file, to_file)
- shutil.copystat(from_file, to_file)
+ shutil.copy2(from_file, to_file)
selinux_updates.append(to_file)
append_to_log(self.lf, to_file)
return True
diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py
index f5c0421..7042863 100644
--- a/mesonbuild/scripts/gettext.py
+++ b/mesonbuild/scripts/gettext.py
@@ -83,8 +83,7 @@ def do_install(src_sub, bld_sub, dest, pkgname, langs):
pkgname + '.mo')
tempfile = outfile + '.tmp'
os.makedirs(os.path.dirname(outfile), exist_ok=True)
- shutil.copyfile(srcfile, tempfile)
- shutil.copystat(srcfile, tempfile)
+ shutil.copy2(srcfile, tempfile)
os.replace(tempfile, outfile)
print('Installing %s to %s' % (srcfile, outfile))
return 0
diff --git a/mesonbuild/scripts/yelphelper.py b/mesonbuild/scripts/yelphelper.py
index 95c8c9c..6bf0673 100644
--- a/mesonbuild/scripts/yelphelper.py
+++ b/mesonbuild/scripts/yelphelper.py
@@ -68,8 +68,7 @@ def install_help(srcdir, blddir, sources, media, langs, install_dir, destdir, pr
infile = os.path.join(srcdir if lang == 'C' else blddir, lang, source)
outfile = os.path.join(indir, source)
mlog.log('Installing %s to %s' % (infile, outfile))
- shutil.copyfile(infile, outfile)
- shutil.copystat(infile, outfile)
+ shutil.copy2(infile, outfile)
for m in media:
infile = os.path.join(srcdir, lang, m)
outfile = os.path.join(indir, m)