bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnulib-tool: fix --symlink option


From: Bruno Haible
Subject: gnulib-tool: fix --symlink option
Date: Mon, 13 Nov 2006 14:35:17 +0100
User-agent: KMail/1.9.1

The --symlink option did not put the right links in place when --local-dir
was specified as a relative directory.


2006-11-12  Bruno Haible  <address@hidden>

        * gnulib-tool (func_ln): New function.
        (func_ln_if_changed, func_create_testdir): Use it instead of "ln -s".

*** gnulib-20061108-modified/gnulib-tool        2006-11-12 21:46:42.000000000 
+0100
--- gnulib-20061108/gnulib-tool 2006-11-13 02:33:17.000000000 +0100
***************
*** 271,291 ****
    }
  fi
  
- # func_ln_if_changed SRC DEST
- # Like ln -s, but avoids munging timestamps if the link is correct.
- func_ln_if_changed ()
- {
-   if test $# -ne 2; then
-     echo "usage: func_ln_if_changed SRC DEST" >&2
-   fi
-   if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
-     :
-   else
-     rm -f "$2"
-     ln -s "$1" "$2"
-   fi
- }
- 
  # func_relativize DIR1 DIR2
  # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
  # Input:
--- 273,278 ----
***************
*** 379,384 ****
--- 366,410 ----
    done
  }
  
+ # func_ln 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.
+ func_ln ()
+ {
+   case "$1" in
+     /*)
+       ln -s "$1" "$2" ;;
+     *) # SRC is relative.
+       case "$2" in
+         /*)
+           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"
+           ;;
+       esac
+       ;;
+   esac
+ }
+ 
+ # func_ln_if_changed SRC DEST
+ # Like func_ln, but avoids munging timestamps if the link is correct.
+ func_ln_if_changed ()
+ {
+   if test $# -ne 2; then
+     echo "usage: func_ln_if_changed SRC DEST" >&2
+   fi
+   ln_target=`func_readlink "$2"`
+   if test -L "$2" && test "$1" = "$ln_target"; then
+     :
+   else
+     rm -f "$2"
+     func_ln "$1" "$2"
+   fi
+ }
+ 
  # Command-line option processing.
  # Removes the OPTIONS from the arguments. Sets the variables:
  # - mode            list or import or create-testdir or create-megatestdir
***************
*** 2246,2252 ****
          if test -z "$symbolic"; then
            cp -p "$lookedup_file" "$testdir/$g"
          else
!           ln -s "$lookedup_file" "$testdir/$g"
          fi
        fi
      done
--- 2246,2252 ----
          if test -z "$symbolic"; then
            cp -p "$lookedup_file" "$testdir/$g"
          else
!           func_ln "$lookedup_file" "$testdir/$g"
          fi
        fi
      done




reply via email to

[Prev in Thread] Current Thread [Next in Thread]