/[gentoo-x86]/eclass/unpacker.eclass
Gentoo

Diff of /eclass/unpacker.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.8 Revision 1.10
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.8 2012/04/29 00:15:10 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/unpacker.eclass,v 1.10 2012/08/22 01:41:12 ottxor 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
274 fi 274 fi
275 275
276 unpacker ./data.tar* 276 unpacker ./data.tar*
277} 277}
278 278
279# @FUNCTION: unpack_cpio
280# @USAGE: <one cpio to unpack>
281# @DESCRIPTION:
282# Unpack a cpio archive, file "-" means stdin.
283unpack_cpio() {
284 [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} <file>"
285
286 # needed as cpio always reads from stdin
287 local cpio_cmd=( cpio --make-directories --extract --preserve-modification-time )
288 if [[ $1 == "-" ]] ; then
289 unpack_banner "stdin"
290 "${cpio_cmd[@]}"
291 else
292 local cpio=$(find_unpackable_file "$1")
293 unpack_banner "${cpio}"
294 "${cpio_cmd[@]}" <"${cpio}"
295 fi
296}
297
279# @FUNCTION: _unpacker 298# @FUNCTION: _unpacker
280# @USAGE: <one archive to unpack> 299# @USAGE: <one archive to unpack>
281# @INTERNAL 300# @INTERNAL
282# @DESCRIPTION: 301# @DESCRIPTION:
283# Unpack the specified archive. We only operate on one archive here 302# Unpack the specified archive. We only operate on one archive here
307 # then figure out if there are any archiving aspects 326 # then figure out if there are any archiving aspects
308 arch="" 327 arch=""
309 case ${m} in 328 case ${m} in
310 *.tgz|*.tbz|*.tbz2|*.txz|*.tar.*|*.tar) 329 *.tgz|*.tbz|*.tbz2|*.txz|*.tar.*|*.tar)
311 arch="tar --no-same-owner -xof" ;; 330 arch="tar --no-same-owner -xof" ;;
331 *.cpio.*|*.cpio)
332 arch="unpack_cpio" ;;
312 *.deb) 333 *.deb)
313 arch="unpack_deb" ;; 334 arch="unpack_deb" ;;
314 *.run) 335 *.run)
315 arch="unpack_makeself" ;; 336 arch="unpack_makeself" ;;
337 *.sh)
338 # Not all shell scripts are makeself
339 if head -n 30 "${a}" | grep -qs '#.*Makeself' ; then
340 arch="unpack_makeself"
341 fi
342 ;;
316 *.bin) 343 *.bin)
317 # Makeself archives can be annoyingly named 344 # Makeself archives can be annoyingly named
318 if head -c 100 "${a}" | grep -qs '#.*Makeself' ; then 345 if head -c 100 "${a}" | grep -qs '#.*Makeself' ; then
319 arch="unpack_makeself" 346 arch="unpack_makeself"
320 fi 347 fi
373 400
374 [[ $# -eq 0 ]] && set -- ${SRC_URI} 401 [[ $# -eq 0 ]] && set -- ${SRC_URI}
375 402
376 for uri in "$@" ; do 403 for uri in "$@" ; do
377 case ${uri} in 404 case ${uri} in
405 *.cpio.*|*.cpio)
406 d="app-arch/cpio" ;;
378 *.rar|*.RAR) 407 *.rar|*.RAR)
379 d="app-arch/unrar" ;; 408 d="app-arch/unrar" ;;
380 *.7z) 409 *.7z)
381 d="app-arch/p7zip" ;; 410 d="app-arch/p7zip" ;;
382 *.xz) 411 *.xz)

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.20