[gimp] tools: improve the install-* meson targets.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] tools: improve the install-* meson targets.
- Date: Sat, 14 Sep 2019 22:01:52 +0000 (UTC)
commit 8e74a22ce7da0acd906a2e22aec27b5ed7a7b03b
Author: Jehan <jehan girinstud io>
Date: Sat Sep 14 23:51:12 2019 +0200
tools: improve the install-* meson targets.
Continue installing the list of files to install even if a failure
occured. In particular, I encountered a problem where script-fu was
failing to install because the installed binary was being executed (and
its memory probably mmap-ed). Hence the copy failed with:
> [Errno 26] Text file busy: '/my/prefix/lib64/gimp/2.99/plug-ins/script-fu/script-fu'
Yet trying to reinstall plug-ins while GIMP is being run, hence
script-fu is being executed, is a very common development trick (for me
at least). So instead, when such an error occurs, I simply save it and
output all the exceptions in the end (where these warnings are properly
visible), instead of failing everything.
Of course, ideally the subtarget should not even try to install
script-fu as it is unchanged. This is why I changed shutil.copy() by
shutil.copy2() to install metadata, which include last access timestamp.
Maybe this could be used to decide whether the installed file is already
the last one, thus not retry, though I am actually unsure if this is
enough (on the other hand, the ultimate check of bit-to-bit comparison
may obviously be too much/slow which is counter-productive), which is
why I am not doing this change right now.
tools/meson_install_subdir.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/tools/meson_install_subdir.py b/tools/meson_install_subdir.py
index da220db1b2..7011e92b7a 100755
--- a/tools/meson_install_subdir.py
+++ b/tools/meson_install_subdir.py
@@ -67,6 +67,7 @@ def get_files_of_part(part_name):
return files_of_part
def install_files(files, verbose):
+ warnings = []
for file in sorted(files.keys()):
target = files[file]
if verbose: print(file + ' → ' + target, end='\n')
@@ -74,7 +75,14 @@ def install_files(files, verbose):
if os.path.isdir(file):
copytree(file, target)
if os.path.isfile(file):
- shutil.copy(file, target)
+ try:
+ shutil.copy2(file, target)
+ except Exception as e:
+ warnings += [(file, e)]
+ if len(warnings) > 0:
+ sys.stderr.write("\n*** WARNING: *** Some file installation failed:\n")
+ for (file, e) in warnings:
+ sys.stderr.write("- {}: {}\n".format(file, e))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]