]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Implement options --symlink and --local-symlink.
authorBruno Haible <bruno@clisp.org>
Sun, 31 Jul 2022 19:08:55 +0000 (21:08 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 31 Jul 2022 21:52:50 +0000 (23:52 +0200)
* gnulib-tool.py (main): Handle options --symlink and --local-symlink.
* pygnulib/constants.py (link_if_changed): Ignore FileNotFoundError from
os.remove call.

ChangeLog
gnulib-tool.py
pygnulib/constants.py

index 43033c1efb72c241830ecf95e23473ce2f4add0f..dd285f54f7845e2dcf393f7a628ff01d035a70ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2022-07-31  Bruno Haible  <bruno@clisp.org>
 
+       gnulib-tool.py: Implement options --symlink and --local-symlink.
+       * gnulib-tool.py (main): Handle options --symlink and --local-symlink.
+       * pygnulib/constants.py (link_if_changed): Ignore FileNotFoundError from
+       os.remove call.
+
        gnulib-tool.py: Make --copy-file work.
        * gnulib-tool.py (main) [copy-file]: Fix reference to uninitialized
        variable. Fix error handling of os.makedirs. Pass the destdir to the
index f20d1157a37d349b7490891d320d82c338ea1212..f936a92031e600600b45a673f3866adb9f896849 100755 (executable)
@@ -337,6 +337,16 @@ def main():
                         dest="makefile",
                         default=None,
                         type=str)
+    # symlink
+    parser.add_argument('-s', '--symbolic', '--symlink',
+                        dest='symlink',
+                        default=None,
+                        action='store_true')
+    # local-symlink
+    parser.add_argument('--local-symlink',
+                        dest='lsymlink',
+                        default=None,
+                        action='store_true')
     # All other arguments are collected.
     parser.add_argument("non_option_arguments",
                         nargs='*')
@@ -543,6 +553,8 @@ def main():
         avoids = [ module
                    for list1 in avoids
                    for module in list1 ]
+    symlink = cmdargs.symlink == True
+    lsymlink = cmdargs.lsymlink == True
 
     # Create pygnulib configuration.
     config = classes.GLConfig(
@@ -566,6 +578,8 @@ def main():
         podomain=podomain,
         witness_c_macro=witness_c_macro,
         vc_files=vc_files,
+        symbolic=symlink,
+        lsymbolic=lsymlink,
         modcache=modcache,
         verbose=verbose,
         dryrun=dryrun,
index 9ef2e01089c1b44bd5c82366eccdf49134042609..10bd363f5bf11041354cf045d31ebb9d4c7e2353 100644 (file)
@@ -330,7 +330,10 @@ def link_if_changed(src, dest):
     '''Create a symlink, but avoids munging timestamps if the link is correct.'''
     ln_target = os.path.realpath(src)
     if not (os.path.islink(dest) and src == ln_target):
-        os.remove(dest)
+        try:
+            os.remove(dest)
+        except FileNotFoundError:
+            pass
         link_relative(src, dest)