doins: dereference abs symlinks to files
authorZac Medico <zmedico@gentoo.org>
Mon, 11 Apr 2011 23:23:54 +0000 (16:23 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 11 Apr 2011 23:23:54 +0000 (16:23 -0700)
Our fake $DISTDIR contains symlinks that should not be reproduced
inside $D. In order to ensure that things like dodoc
"$DISTDIR"/foo.pdf work as expected, we dereference symlinked files
that are referenced by absolute paths. Thanks to James Cloos
<cloos@jhcloos.com> for reporting this issue which he observed with
the sci-mathematics/minisat ebuild.

bin/ebuild-helpers/doins

index 0aedcb9e56ef5444365c3f71609b8b60e76bb810..3daa9a01a26a5fb1f34d0893f0959aaf1113aab8 100755 (executable)
@@ -55,7 +55,13 @@ _doins() {
        local mysrc="$1" mydir="$2" cleanup="" rval
 
        if [ -L "$mysrc" ] ; then
-               if [ $PRESERVE_SYMLINKS = y ] ; then
+               # Our fake $DISTDIR contains symlinks that should
+               # not be reproduced inside $D. In order to ensure
+               # that things like dodoc "$DISTDIR"/foo.pdf work
+               # as expected, we dereference symlinked files that
+               # are referenced by absolute paths.
+               if [ $PRESERVE_SYMLINKS = y ] && \
+                       ! [[ -f "$mysrc" && $(readlink "$mysrc") == /* ]] ; then
                        rm -rf "$D$INSDESTTREE/$mydir/${mysrc##*/}" || return $?
                        cp -P "$mysrc" "$D$INSDESTTREE/$mydir/${mysrc##*/}"
                        return $?