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

Diff of /eclass/unpacker.eclass

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

Revision 1.10 Revision 1.14
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2013 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.10 2012/08/22 01:41:12 ottxor Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/unpacker.eclass,v 1.14 2013/12/22 14:44:07 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
20 20
21# @ECLASS-VARIABLE: UNPACKER_BZ2 21# @ECLASS-VARIABLE: UNPACKER_BZ2
22# @DEFAULT_UNSET 22# @DEFAULT_UNSET
23# @DESCRIPTION: 23# @DESCRIPTION:
24# Utility to use to decompress bzip2 files. Will dynamically pick between 24# Utility to use to decompress bzip2 files. Will dynamically pick between
25# `pbzip2` and `bzip2`. Make sure your choice accepts the "-c" option. 25# `pbzip2` and `bzip2`. Make sure your choice accepts the "-dc" options.
26# Note: this is meant for users to set, not ebuilds. 26# Note: this is meant for users to set, not ebuilds.
27 27
28# for internal use only (unpack_pdv and unpack_makeself) 28# for internal use only (unpack_pdv and unpack_makeself)
29find_unpackable_file() { 29find_unpackable_file() {
30 local src=$1 30 local src=$1
72# Basically look for the first lseek command (we do the strings/grep because 72# Basically look for the first lseek command (we do the strings/grep because
73# sometimes the function call is _llseek or something) and steal the 2nd 73# sometimes the function call is _llseek or something) and steal the 2nd
74# parameter. Here is an example: 74# parameter. Here is an example:
75# 75#
76# @CODE 76# @CODE
77# vapier@vapier 0 pdv_unpack # strings hldsupdatetool.bin | grep lseek 77# $ strings hldsupdatetool.bin | grep lseek
78# lseek 78# lseek
79# vapier@vapier 0 pdv_unpack # strace -elseek ./hldsupdatetool.bin 79# $ strace -elseek ./hldsupdatetool.bin
80# lseek(3, -4, SEEK_END) = 2981250 80# lseek(3, -4, SEEK_END) = 2981250
81# @CODE 81# @CODE
82# 82#
83# Thus we would pass in the value of '4' as the second parameter. 83# Thus we would pass in the value of '4' as the second parameter.
84unpack_pdv() { 84unpack_pdv() {
176 if [[ -z ${skip} ]] ; then 176 if [[ -z ${skip} ]] ; then
177 local ver=$(grep -m1 -a '#.*Makeself' "${src}" | awk '{print $NF}') 177 local ver=$(grep -m1 -a '#.*Makeself' "${src}" | awk '{print $NF}')
178 local skip=0 178 local skip=0
179 exe=tail 179 exe=tail
180 case ${ver} in 180 case ${ver} in
181 1.5.*|1.6.0-nv) # tested 1.5.{3,4,5} ... guessing 1.5.x series is same 181 1.5.*|1.6.0-nv*) # tested 1.5.{3,4,5} ... guessing 1.5.x series is same
182 skip=$(grep -a ^skip= "${src}" | cut -d= -f2) 182 skip=$(grep -a ^skip= "${src}" | cut -d= -f2)
183 ;; 183 ;;
184 2.0|2.0.1) 184 2.0|2.0.1)
185 skip=$(grep -a ^$'\t'tail "${src}" | awk '{print $2}' | cut -b2-) 185 skip=$(grep -a ^$'\t'tail "${src}" | awk '{print $2}' | cut -b2-)
186 ;; 186 ;;
231 gzip*) 231 gzip*)
232 eval ${exe} | tar --no-same-owner -xzf - 232 eval ${exe} | tar --no-same-owner -xzf -
233 ;; 233 ;;
234 compress*) 234 compress*)
235 eval ${exe} | gunzip | tar --no-same-owner -xf - 235 eval ${exe} | gunzip | tar --no-same-owner -xf -
236 ;;
237 XZ*)
238 eval ${exe} | unxz | tar --no-same-owner -xf -
236 ;; 239 ;;
237 *) 240 *)
238 eerror "Unknown filetype \"${filetype}\" ?" 241 eerror "Unknown filetype \"${filetype}\" ?"
239 false 242 false
240 ;; 243 ;;
272 else 275 else
273 ar x "${deb}" 276 ar x "${deb}"
274 fi 277 fi
275 278
276 unpacker ./data.tar* 279 unpacker ./data.tar*
280
281 # Clean things up #458658. No one seems to actually care about
282 # these, so wait until someone requests to do something else ...
283 rm -f debian-binary {control,data}.tar*
277} 284}
278 285
279# @FUNCTION: unpack_cpio 286# @FUNCTION: unpack_cpio
280# @USAGE: <one cpio to unpack> 287# @USAGE: <one cpio to unpack>
281# @DESCRIPTION: 288# @DESCRIPTION:
291 else 298 else
292 local cpio=$(find_unpackable_file "$1") 299 local cpio=$(find_unpackable_file "$1")
293 unpack_banner "${cpio}" 300 unpack_banner "${cpio}"
294 "${cpio_cmd[@]}" <"${cpio}" 301 "${cpio_cmd[@]}" <"${cpio}"
295 fi 302 fi
303}
304
305# @FUNCTION: unpack_zip
306# @USAGE: <zip file>
307# @DESCRIPTION:
308# Unpack zip archives.
309# This function ignores all non-fatal errors (i.e. warnings).
310# That is useful for zip archives with extra crap attached
311# (e.g. self-extracting archives).
312unpack_zip() {
313 [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME} <file>"
314
315 local zip=$(find_unpackable_file "$1")
316 unpack_banner "${zip}"
317 unzip -qo "${zip}"
318
319 [[ $? -le 1 ]] || die "unpacking ${zip} failed (arch=unpack_zip)"
296} 320}
297 321
298# @FUNCTION: _unpacker 322# @FUNCTION: _unpacker
299# @USAGE: <one archive to unpack> 323# @USAGE: <one archive to unpack>
300# @INTERNAL 324# @INTERNAL
344 # Makeself archives can be annoyingly named 368 # Makeself archives can be annoyingly named
345 if head -c 100 "${a}" | grep -qs '#.*Makeself' ; then 369 if head -c 100 "${a}" | grep -qs '#.*Makeself' ; then
346 arch="unpack_makeself" 370 arch="unpack_makeself"
347 fi 371 fi
348 ;; 372 ;;
373 *.zip)
374 arch="unpack_zip" ;;
349 esac 375 esac
350 376
351 # finally do the unpack 377 # finally do the unpack
352 if [[ -z ${arch}${comp} ]] ; then 378 if [[ -z ${arch}${comp} ]] ; then
353 unpack "$1" 379 unpack "$1"
408 d="app-arch/unrar" ;; 434 d="app-arch/unrar" ;;
409 *.7z) 435 *.7z)
410 d="app-arch/p7zip" ;; 436 d="app-arch/p7zip" ;;
411 *.xz) 437 *.xz)
412 d="app-arch/xz-utils" ;; 438 d="app-arch/xz-utils" ;;
439 *.zip)
440 d="app-arch/unzip" ;;
413 esac 441 esac
414 deps+=" ${d}" 442 deps+=" ${d}"
415 done 443 done
416 444
417 echo "${deps}" 445 echo "${deps}"

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

  ViewVC Help
Powered by ViewVC 1.1.20