]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 20.
authorBruno Haible <bruno@clisp.org>
Wed, 3 Aug 2022 12:37:12 +0000 (14:37 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 3 Aug 2022 12:37:12 +0000 (14:37 +0200)
Follow gnulib-tool changes
2016-01-15  Paul Eggert  <eggert@cs.ucla.edu>
gnulib-tool: don't assume ln -s works
2016-01-24  Paul Eggert  <eggert@cs.ucla.edu>
gnulib-tool: don't give up on ln -s so easily
2017-06-08  Bruno Haible  <bruno@clisp.org>
gnulib-tool: Fix bug in func_ln_s, from 2016-01-15.

* pygnulib/constants.py (symlink_relative): New function.
(link_relative): Use it instead of os.symlink.

ChangeLog
gnulib-tool.py.TODO
pygnulib/constants.py

index aeec6717fc77ab382de1768f633808541483452b..2b47dc08af12d9e643a2b4ee9bf12dd467724f40 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2022-08-03  Bruno Haible  <bruno@clisp.org>
 
+       gnulib-tool.py: Follow gnulib-tool changes, part 20.
+       Follow gnulib-tool changes
+       2016-01-15  Paul Eggert  <eggert@cs.ucla.edu>
+       gnulib-tool: don't assume ln -s works
+       2016-01-24  Paul Eggert  <eggert@cs.ucla.edu>
+       gnulib-tool: don't give up on ln -s so easily
+       2017-06-08  Bruno Haible  <bruno@clisp.org>
+       gnulib-tool: Fix bug in func_ln_s, from 2016-01-15.
+       * pygnulib/constants.py (symlink_relative): New function.
+       (link_relative): Use it instead of os.symlink.
+
        gnulib-tool.py: Avoid errors when writing to a VFAT file system, part 2.
        * pygnulib/constants.py (movefile): New function.
        * pygnulib/*.py: Use it instead of shutil.
index eeecd5ed8aa14108cedf49946d8bcde82cfc09cb..bfb613fb704b01c2812ada14b4ee61d9890449d5 100644 (file)
@@ -15,6 +15,10 @@ The following commits to gnulib-tool have not yet been reflected in
 
 --------------------------------------------------------------------------------
 
+Inline all 'sed' invocations.
+
+--------------------------------------------------------------------------------
+
 Implement the options:
   --find
   --extract-recursive-dependencies
@@ -37,8 +41,6 @@ Implement the options:
   --witness-c-macro
   --vc-files
   --no-vc-files
-  -s | --symbolic
-  --local-symlink
   -h | --hardlink
   --local-hardlink
   -S | --more-symlinks
@@ -1076,42 +1078,6 @@ Date:   Sun Oct 16 14:11:18 2016 +0200
 
 --------------------------------------------------------------------------------
 
-commit c09c24932066ecee81756adf2fca840b7c146e9d
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Thu Jun 8 14:45:39 2017 +0200
-
-    gnulib-tool: Fix bug in func_ln_s, from 2016-01-15.
-
-    * gnulib-tool (func_ln_s): Determine cp_src correctly.
-
-commit d9958eb1eb951f950f9b321419965001b1368a38
-Author: Paul Eggert <eggert@cs.ucla.edu>
-Date:   Sun Jan 24 14:24:35 2016 -0800
-
-    gnulib-tool: don't give up on ln -s so easily
-
-    * gnulib-tool (func_ln_s): Don't give up on a later ln -s merely
-    because an earlier one failed.  The targets could be on different
-    file systems.  Problem reported by KO Myung-Hun in:
-    http://lists.gnu.org/archive/html/bug-gnulib/2016-01/msg00081.html
-
-commit 350f2c6fb569f42f0a8ff47fd5b7442f24f0e658
-Author: Paul Eggert <eggert@cs.ucla.edu>
-Date:   Fri Jan 15 10:12:41 2016 -0800
-
-    * gnulib-tool: fix stray debug line in previous patch
-
-commit 0e50dd0071be89825810dbf4c2310663dcb77767
-Author: Paul Eggert <eggert@cs.ucla.edu>
-Date:   Wed May 1 13:39:22 2013 +0900
-
-    gnulib-tool: don't assume ln -s works
-
-    * gnulib-tool (func_ln_s): New function.
-    (func_ln): Use it.
-
---------------------------------------------------------------------------------
-
 commit 9bdf6c8a0cdeb13c12e4b65dee9538c5468dbe1d
 Author: Bruno Haible <bruno@clisp.org>
 Date:   Sun Aug 19 14:06:50 2012 +0200
index 34c17aec4631eada5e1a183624bc85de69f54834..ca5e3f79aaf7e33009e302e03e33c623fd61dc38 100644 (file)
@@ -338,6 +338,26 @@ def movefile(src, dest):
         os.remove(src)
 
 
+def symlink_relative(src, dest):
+    '''Like ln -s, except use cp -p if ln -s fails.
+    src is either absolute or relative to the directory of dest.'''
+    try:
+        os.symlink(src, dest)
+    except PermissionError:
+        sys.stderr.write('%s: ln -s failed; falling back on cp -p\n' % APP['name'])
+        if src.startswith('/') or (len(src) >= 2 and src[1] == ':'):
+            # src is absolute.
+            cp_src = src
+        else:
+            # src is relative to the directory of dest.
+            last_slash = dest.rfind('/')
+            if last_slash >= 0:
+                cp_src = joinpath(dest[0:last_slash-1], src)
+            else:
+                cp_src = src
+        copyfile2(cp_src, dest)
+
+
 def link_relative(src, dest):
     '''Like ln -s, except that src is given relative to the current directory
     (or absolute), not given relative to the directory of dest.'''
@@ -348,17 +368,17 @@ def link_relative(src, dest):
         raise TypeError(
             'dest must be a string, not %s' % (type(dest).__name__))
     if src.startswith('/') or (len(src) >= 2 and src[1] == ':'):
-        os.symlink(src, dest)
+        symlink_relative(src, dest)
     else:  # if src is not absolute
         if dest.startswith('/') or (len(dest) >= 2 and dest[1] == ':'):
             cwd = os.getcwd()
-            os.symlink(joinpath(cwd, src), dest)
+            symlink_relative(joinpath(cwd, src), dest)
         else:  # if dest is not absolute
             destdir = os.path.dirname(dest)
             if not destdir:
                 destdir = '.'
             src = relativize(destdir, src)
-            os.symlink(src, dest)
+            symlink_relative(src, dest)
 
 
 def link_if_changed(src, dest):