--- /usr/lib/portage/bin/ebuild.sh 2006-06-10 19:56:17.000000000 +0200 +++ /files/ebuild.sh 2006-06-14 17:30:12.000000000 +0200 @@ -360,7 +360,7 @@ y=${y##*.} myfail="${x} does not exist" - if [ "${x:0:2}" = "./" ] ; then + if [ "${x:0:2}" = "./" -o "${x:0:1}" = "/" ] ; then srcdir="" else srcdir="${DISTDIR}/" @@ -401,20 +401,91 @@ ;; 7Z|7z) local my_output - my_output="$(7z x -y "${srcdir}/${x}")" + my_output="$(7z x -y "${srcdir}${x}")" if [ $? -ne 0 ]; then echo "${my_output}" >&2 die "$myfail" fi ;; RAR|rar) - unrar x -idq "${srcdir}/${x}" || die "$myfail" + unrar x -idq "${srcdir}${x}" || die "$myfail" ;; LHa|LHA|lha|lzh) - lha xqf "${srcdir}/${x}" || die "$myfail" + lha xqf "${srcdir}${x}" || die "$myfail" ;; a|deb) - ar x "${srcdir}/${x}" || die "$myfail" + ar x "${srcdir}${x}" || die "$myfail" + ;; + sh|bin|run) + local src=${srcdir}${x} + if ! grep -aq '#.*Makeself' "${src}"; then + vecho "unpack ${x}: no Makeself packed file. Ignoring." + else + local ver=$(grep -a '#.*Makeself' "${src}" | awk '{print $NF}') + local skip=0 exe=tail + case ${ver} in + 1.5.*|1.6.0-nv) # tested 1.5.{3,4,5} ... guessing 1.5.x series is same + skip=$(grep -a ^skip= "${src}" | cut -d= -f2) + ;; + 2.0|2.0.1) + skip=$(grep -a ^$'\t'tail "${src}" | awk '{print $2}' | cut -b2-) + ;; + 2.1.1) + skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-) + let skip="skip + 1" + ;; + 2.1.2) + skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1) + let skip="skip + 1" + ;; + 2.1.3) + skip=`grep -a ^offset= "${src}" | awk '{print $3}'` + let skip="skip + 1" + ;; + 2.1.4|2.1.5) + skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1) + skip=$(head -n ${skip} "${src}" | wc -c) + exe="dd" + ;; + *) + eerror "I'm sorry, but I was unable to support the Makeself file." + eerror "The version I detected was '${ver}'." + eerror "Please file a bug about the file ${x} at" + eerror "http://bugs.gentoo.org/ so that support can be added." + die "makeself version '${ver}' not supported" + ;; + esac + debug-print "Detected Makeself version ${ver} ... using ${skip} as offset" + case ${exe} in + tail) exe="tail -n +${skip} '${src}'";; + dd) exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'";; + *) die "makeself cant handle exe '${exe}'";; + esac + + # lets grab the first few bytes of the file to figure out what kind of archive it is + local tmpfile="${T}/tmp.${RANDOM}.${RANDOM}.${RANDOM}" + eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}" + local filetype="$(file -b "${tmpfile}")" + case ${filetype} in + *tar\ archive) + eval ${exe} | tar --no-same-owner -xf - + ;; + bzip2*) + eval ${exe} | bzip2 -dc | tar --no-same-owner -xf - + ;; + gzip*) + eval ${exe} | tar --no-same-owner -xzf - + ;; + compress*) + eval ${exe} | gunzip | tar --no-same-owner -xf - + ;; + *) + eerror "makeself: Unknown filetype \"${filetype}\" ?" + false + ;; + esac + assert "failure unpacking (${filetype}) makeself ${x} ('${ver}' +${skip})" + fi ;; *) vecho "unpack ${x}: file format not recognized. Ignoring."