unpack: always unpack to cwd (bug #376741)
authorZac Medico <zmedico@gentoo.org>
Mon, 1 Aug 2011 23:48:07 +0000 (16:48 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 1 Aug 2011 23:48:07 +0000 (16:48 -0700)
This brings portage into agreement with PMS. Also, for existing EAPIs,
if the source file is in a writable directory then this will create a
symlink for backward-compatible emulation of tools like gunzip and
bunzip2.

bin/ebuild.sh

index 4aef4134de7bc8123e820547462c2101420e4baf..3d4d5576ad7f1a8cab713014a16b16fc9a7853c8 100755 (executable)
@@ -370,7 +370,21 @@ unpack() {
                                $1 -c -- "$srcdir$x" | tar xof -
                                assert_sigpipe_ok "$myfail"
                        else
-                               $1 -c -- "${srcdir}${x}" > ${x%.*} || die "$myfail"
+                               local cwd_dest=${x##*/}
+                               cwd_dest=${cwd_dest%.*}
+                               $1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "$myfail"
+                               case "$EAPI" in
+                                       0|1|2|3|4|4-python)
+                                               # If the source file is in a writable directory then
+                                               # create a symlink for backward-compatible emulation
+                                               # of tools like gunzip and bunzip2 (see bug #376741).
+                                               if [[ ! -e ${x%.*} && -w ${x%/*} ]] && \
+                                                       [[ ${x} == "${PORTAGE_BUILDDIR}/"* ||
+                                                       ${x} == ./* || ${x} != /* ]] ; then
+                                                       ln -snf "${PWD}/${cwd_dest}" "${x%.*}"
+                                               fi
+                                               ;;
+                               esac
                        fi
                }