re-adding the unpack function to stable someone yanked... :)
authorBrian Harring <ferringb@gentoo.org>
Tue, 30 Aug 2005 04:07:00 +0000 (04:07 -0000)
committerBrian Harring <ferringb@gentoo.org>
Tue, 30 Aug 2005 04:07:00 +0000 (04:07 -0000)
svn path=/main/branches/2.0/; revision=1947

bin/ebuild.sh

index 3271859eaa5f22bcc0222d465cd8798e94cd2d4f..1783b83c7bc6b9973cb22302c8fae59747ec14df 100755 (executable)
@@ -335,6 +335,65 @@ keepdir()
        fi
 }
 
+unpack() {
+       local x
+       local y
+       local myfail
+       local tarvars
+
+       if [ "$USERLAND" == "BSD" ]; then
+               tarvars=""
+       else
+               tarvars="--no-same-owner"       
+       fi      
+
+       [ -z "$*" ] && die "Nothing passed to the 'unpack' command"
+
+       for x in "$@"; do
+               myfail="failure unpacking ${x}"
+               echo ">>> Unpacking ${x} to $(pwd)"
+               y="${x%.*}"
+               y="${y##*.}"
+
+               case "${x##*.}" in
+                       tar)
+                               tar xf "${DISTDIR}/${x}" ${tarvars} || die "$myfail"
+                               ;;
+                       tgz)
+                               tar xzf "${DISTDIR}/${x}" ${tarvars} || die "$myfail"
+                               ;;
+                       tbz2)
+                               bzip2 -dc "${DISTDIR}/${x}" | tar xf - ${tarvars}
+                               assert "$myfail"
+                               ;;
+                       ZIP|zip)
+                               unzip -qo "${DISTDIR}/${x}" || die "$myfail"
+                               ;;
+                       gz|Z|z)
+                               if [ "${y}" == "tar" ]; then
+                                       tar xzf "${DISTDIR}/${x}" ${tarvars} || die "$myfail"
+                               else
+                                       gzip -dc "${DISTDIR}/${x}" > ${x%.*} || die "$myfail"
+                               fi
+                               ;;
+                       bz2)
+                               if [ "${y}" == "tar" ]; then
+                                       bzip2 -dc "${DISTDIR}/${x}" | tar xf - ${tarvars} 
+                                       assert "$myfail"
+                               else
+                                       bzip2 -dc "${DISTDIR}/${x}" > ${x%.*} || die "$myfail"
+                               fi
+                               ;;
+                       RAR|rar)
+                               unrar x -idq "${DISTDIR}/${x}" || die "$myfail"
+                               ;;
+                       *)
+                               echo "unpack ${x}: file format not recognized. Ignoring."
+                               ;;
+               esac
+       done
+}
+
 strip_duplicate_slashes () { 
        if [ -n "${1}" ]; then
                local removed="${1/\/\///}"