1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 # base-system@gentoo.org
8 # @BLURB: convenience class for extracting RPMs
12 DEPEND=">=app-arch/rpm2targz-9.0.0.3g"
14 # @FUNCTION: rpm_unpack
17 # Unpack the contents of the specified rpms like the unpack() function.
19 [[ $# -eq 0 ]] && set -- ${A}
22 echo ">>> Unpacking ${a} to ${PWD}"
23 if [[ ${a} == ./* ]] ; then
24 : nothing to do -- path is local
25 elif [[ ${a} == ${DISTDIR}/* ]] ; then
26 ewarn 'QA: do not use ${DISTDIR} with rpm_unpack -- it is added for you'
27 elif [[ ${a} == /* ]] ; then
28 ewarn 'QA: do not use full paths with rpm_unpack -- use ./ paths instead'
32 rpm2tar -O "${a}" | tar xf - || die "failure unpacking ${a}"
36 # @FUNCTION: srcrpm_unpack
39 # Unpack the contents of the specified rpms like the unpack() function as well
40 # as any archives that it might contain. Note that the secondary archive
41 # unpack isn't perfect in that it simply unpacks all archives in the working
42 # directory (with the assumption that there weren't any to start with).
44 [[ $# -eq 0 ]] && set -- ${A}
47 # no .src.rpm files, then nothing to do
48 [[ "$* " != *".src.rpm " ]] && return 0
50 eshopts_push -s nullglob
54 for a in *.tar.{gz,bz2,xz} *.t{gz,bz2,xz,pxz} *.zip *.ZIP ; do
64 # @FUNCTION: rpm_src_unpack
66 # Automatically unpack all archives in ${A} including rpms. If one of the
67 # archives in a source rpm, then the sub archives will be unpacked as well.
72 *.rpm) srcrpm_unpack "${a}" ;;
78 # @FUNCTION: rpm_spec_epatch
81 # Read the specified spec (defaults to ${PN}.spec) and attempt to apply
82 # all the patches listed in it. If the spec does funky things like moving
83 # files around, well this won't handle that.
88 if [[ -z ${spec} ]] ; then
89 # search likely places for the spec file
90 for spec in "${PWD}" "${S}" "${WORKDIR}" ; do
92 [[ -e ${spec} ]] && break
95 [[ ${spec} == */* ]] \
99 ebegin "Applying patches from ${spec}"
101 grep '^%patch' "${spec}" | \
103 # expand the %patch line
108 # process the %patch arguments
113 -b) EPATCH_OPTS+=" --suffix" ;;
114 *) EPATCH_OPTS+=" ${arg}" ;;
118 # extract the patch name from the Patch# line
119 set -- $(grep "^P${p#%p}: " "${spec}")
121 epatch "${dir:+${dir}/}$*"
127 EXPORT_FUNCTIONS src_unpack