]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool: don't assume ln -s works
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 1 May 2013 04:39:22 +0000 (13:39 +0900)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 15 Jan 2016 18:09:00 +0000 (10:09 -0800)
* gnulib-tool (func_ln_s): New function.
(func_ln): Use it.

ChangeLog
gnulib-tool

index 5bedafaf0be30792e5d18a5231a39ddc48bb4d0f..80d496e38c2b91ab161c8e0c1b096bb24357fde6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-01-15  Paul Eggert  <eggert@cs.ucla.edu>
+            KO Myung-Hun  <komh@chollian.net>
+
+       gnulib-tool: don't assume ln -s works
+       * gnulib-tool (func_ln_s): New function.
+       (func_ln): Use it.
+
 2016-01-15  KO Myung-Hun  <komh@chollian.net>
 
        utimes: detect utimes() correctly on OS/2 kLIBC
index 34676f92c6630948649c5e549e7256083ca66771..af1dcc4891278b8583fa859a70b84816428152c9 100755 (executable)
@@ -767,23 +767,45 @@ func_relconcat ()
   done
 }
 
+# func_ln_s SRC DEST
+# Like ln -s, except use cp -p if ln -s fails.
+func_ln_s ()
+{
+  ln -s "$1" "$2" || {
+    echo "$progname: ln -s failed; falling back on cp -p" >>/tmp/log
+    echo "$progname: ln -s failed; falling back on cp -p" >&2
+    symbolic=
+    lsymbolic=
+    do_copyrights=true
+
+    case "$1" in
+      /* | ?:*) # SRC is absolute.
+        cp_src=$1 ;;
+      *) # SRC is relative to the directory of DEST.
+        cp_src=${2%/*}/$1 ;;
+    esac
+
+    cp -p "$cp_src" "$2"
+  }
+}
+
 # func_ln SRC DEST
-# Like ln -s, except that SRC is given relative to the current directory (or
+# Like func_ln_s, except that SRC is given relative to the current directory (or
 # absolute), not given relative to the directory of DEST.
 func_ln ()
 {
   case "$1" in
     /* | ?:*)
-      ln -s "$1" "$2" ;;
+      func_ln_s "$1" "$2" ;;
     *) # SRC is relative.
       case "$2" in
         /* | ?:*)
-          ln -s "`pwd`/$1" "$2" ;;
+          func_ln_s "`pwd`/$1" "$2" ;;
         *) # DEST is relative too.
           ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
           test -n "$ln_destdir" || ln_destdir="."
           func_relativize "$ln_destdir" "$1"
-          ln -s "$reldir" "$2"
+          func_ln_s "$reldir" "$2"
           ;;
       esac
       ;;