Bug #273636 - Add doins and newins support for symlink preservation in
authorZac Medico <zmedico@gentoo.org>
Sun, 18 Oct 2009 03:58:14 +0000 (03:58 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 18 Oct 2009 03:58:14 +0000 (03:58 -0000)
EAPI 3. Thanks to Jonathan Callen <abcd@g.o> for the initial patch (I
added EAPI conditionals in order to share code between all EAPIs).
(trunk r14625)

svn path=/main/branches/2.1.7/; revision=14653

bin/ebuild-helpers/doins
bin/ebuild-helpers/newins

index 82f0bf3b60fdd21d0e5b589b1b7a2518cf477d09..b5f00e8d8280169f03fcc131019604f53d769231 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2007 Gentoo Foundation
+# Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
@@ -25,6 +25,15 @@ if [[ ${INSDESTTREE#${D}} != "${INSDESTTREE}" ]]; then
        exit 1
 fi
 
+case "$EAPI" in
+       0|1|2)
+               PRESERVE_SYMLINKS=n
+               ;;
+       *)
+               PRESERVE_SYMLINKS=y
+               ;;
+esac
+
 export TMP=$T/.doins_tmp
 # Use separate directories to avoid potential name collisions.
 mkdir -p "$TMP"/{1,2}
@@ -35,9 +44,15 @@ _doins() {
        local mysrc="$1" mydir="$2" cleanup="" rval
 
        if [ -L "$mysrc" ] ; then
-               cp "$mysrc" "$TMP/2"
-               mysrc="$TMP/2/${mysrc##*/}"
-               cleanup=${mysrc}
+               if [ $PRESERVE_SYMLINKS = y ] ; then
+                       rm -rf "$D$INSDESTTREE/$mydir/${mysrc##*/}" || return $?
+                       cp -P "$mysrc" "$D$INSDESTTREE/$mydir/${mysrc##*/}"
+                       return $?
+               else
+                       cp "$mysrc" "$TMP/2/${mysrc##*/}" || return $?
+                       mysrc="$TMP/2/${mysrc##*/}"
+                       cleanup=$mysrc
+               fi
        fi
 
        install ${INSOPTIONS} "${mysrc}" "${D}${INSDESTTREE}/${mydir}"
@@ -56,7 +71,8 @@ _xdoins() {
 success=0
 
 for x in "$@" ; do
-       if [ -d "$x" ] ; then
+       if [[ $PRESERVE_SYMLINKS = n && -d $x ]] || \
+               [[ $PRESERVE_SYMLINKS = y && -d $x && ! -L $x ]] ; then
                if [ "${DOINSRECUR}" == "n" ] ; then
                        continue
                fi
index f235835a275c3ab16166f7088473bd267a80a2fd..d15006d024f5026735ed2b92b1da89395f3e04f4 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
@@ -14,7 +14,14 @@ if [ ! -e "$1" ] ; then
 fi
 
 rm -rf "${T}/${2}" || exit $?
-cp -f "${1}" "${T}/${2}" || exit $?
+case "$EAPI" in
+       0|1|2)
+               cp "$1" "$T/$2" || exit $?
+               ;;
+       *)
+               cp -P "$1" "$T/$2" || exit $?
+               ;;
+esac
 doins "${T}/${2}"
 ret=$?
 rm -rf "${T}/${2}"