| 1 | # Copyright 1999-2012 Gentoo Foundation |
1 | # Copyright 1999-2012 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/unpacker.eclass,v 1.3 2012/02/05 05:57:19 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/unpacker.eclass,v 1.6 2012/04/05 03:20:42 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: unpacker.eclass |
5 | # @ECLASS: unpacker.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # base-system@gentoo.org |
7 | # base-system@gentoo.org |
| 8 | # @BLURB: helpers for extraneous file formats and consistent behavior across EAPIs |
8 | # @BLURB: helpers for extraneous file formats and consistent behavior across EAPIs |
| … | |
… | |
| 194 | ;; |
194 | ;; |
| 195 | 2.1.3) |
195 | 2.1.3) |
| 196 | skip=`grep -a ^offset= "${src}" | awk '{print $3}'` |
196 | skip=`grep -a ^offset= "${src}" | awk '{print $3}'` |
| 197 | (( skip++ )) |
197 | (( skip++ )) |
| 198 | ;; |
198 | ;; |
| 199 | 2.1.4|2.1.5) |
199 | 2.1.4|2.1.5|2.1.6) |
| 200 | skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1) |
200 | skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1) |
| 201 | skip=$(head -n ${skip} "${src}" | wc -c) |
201 | skip=$(head -n ${skip} "${src}" | wc -c) |
| 202 | exe="dd" |
202 | exe="dd" |
| 203 | ;; |
203 | ;; |
| 204 | *) |
204 | *) |
| … | |
… | |
| 284 | comp="xz -dc" ;; |
284 | comp="xz -dc" ;; |
| 285 | *) comp="" ;; |
285 | *) comp="" ;; |
| 286 | esac |
286 | esac |
| 287 | |
287 | |
| 288 | # then figure out if there are any archiving aspects |
288 | # then figure out if there are any archiving aspects |
|
|
289 | arch="" |
| 289 | case ${m} in |
290 | case ${m} in |
| 290 | *.tgz|*.tbz|*.tbz2|*.txz|*.tar.*|*.tar) |
291 | *.tgz|*.tbz|*.tbz2|*.txz|*.tar.*|*.tar) |
| 291 | arch="tar --no-same-owner -xof" ;; |
292 | arch="tar --no-same-owner -xof" ;; |
| 292 | *.deb) |
293 | *.deb) |
| 293 | arch="unpack_deb" ;; |
294 | arch="unpack_deb" ;; |
| 294 | *.run) |
295 | *.run) |
| 295 | arch="unpack_makeself" ;; |
296 | arch="unpack_makeself" ;; |
| 296 | *) arch="" ;; |
297 | *.bin) |
|
|
298 | # Makeself archives can be annoyingly named |
|
|
299 | if head -c 100 "${a}" | grep -qs '#.*Makeself' ; then |
|
|
300 | arch="unpack_makeself" |
|
|
301 | fi |
|
|
302 | ;; |
| 297 | esac |
303 | esac |
| 298 | |
304 | |
| 299 | # finally do the unpack |
305 | # finally do the unpack |
| 300 | if [[ -z ${arch}${comp} ]] ; then |
306 | if [[ -z ${arch}${comp} ]] ; then |
| 301 | unpack "$1" |
307 | unpack "$1" |
| … | |
… | |
| 303 | fi |
309 | fi |
| 304 | |
310 | |
| 305 | [[ ${arch} != unpack_* ]] && unpack_banner "${a}" |
311 | [[ ${arch} != unpack_* ]] && unpack_banner "${a}" |
| 306 | |
312 | |
| 307 | if [[ -z ${arch} ]] ; then |
313 | if [[ -z ${arch} ]] ; then |
|
|
314 | # Need to decompress the file into $PWD #408801 |
|
|
315 | local _a=${a%.*} |
| 308 | ${comp} "${a}" > "${a%.*}" |
316 | ${comp} "${a}" > "${_a##*/}" |
| 309 | elif [[ -z ${comp} ]] ; then |
317 | elif [[ -z ${comp} ]] ; then |
| 310 | ${arch} "${a}" |
318 | ${arch} "${a}" |
| 311 | else |
319 | else |
| 312 | ${comp} "${a}" | ${arch} - |
320 | ${comp} "${a}" | ${arch} - |
| 313 | fi |
321 | fi |