Bug #201771 - Make unpack() detect common errors such as absolute
authorZac Medico <zmedico@gentoo.org>
Thu, 13 Dec 2007 06:33:16 +0000 (06:33 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 13 Dec 2007 06:33:16 +0000 (06:33 -0000)
paths that start with ${DISTDIR} and die an appropriate error
message. Thanks to grobian for this patch. (trunk r8896)

svn path=/main/branches/2.1.2/; revision=8903

bin/ebuild.sh

index 50222eb6e5d8a9f95d7c9400f52166e775d42427..ff0dd78c40c3e435fb867549ce9a757d21ff0415 100755 (executable)
@@ -313,15 +313,16 @@ unpack() {
                y=${x%.*}
                y=${y##*.}
 
-               myfail="${x} does not exist"
-               if [ "${x:0:2}" = "./" ] ; then
+               if [[ ${x} == "./"* ]] ; then
                        srcdir=""
+               elif [[ ${x} == ${DISTDIR%/}/* ]] ; then
+                       die "Arguments to unpack() cannot begin with \${DISTDIR}."
+               elif [[ ${x} == "/"* ]] ; then
+                       die "Arguments to unpack() cannot be absolute"
                else
                        srcdir="${DISTDIR}/"
                fi
-               [[ ${x} == ${DISTDIR}* ]] && \
-                       die "Arguments to unpack() should not begin with \${DISTDIR}."
-               [ ! -s "${srcdir}${x}" ] && die "$myfail"
+               [[ ! -s ${srcdir}${x} ]] && die "${x} does not exist"
 
                myfail="failure unpacking ${x}"
                case "${x##*.}" in