1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 # base-system@gentoo.org
7 # @BLURB: convenience class for extracting RPMs
12 [0-6]) DEPEND=">=app-arch/rpm2targz-9.0.0.3g" ;;
13 *) BDEPEND=">=app-arch/rpm2targz-9.0.0.3g" ;;
16 # @FUNCTION: rpm_unpack
19 # Unpack the contents of the specified rpms like the unpack() function.
21 [[ $# -eq 0 ]] && set -- ${A}
24 echo ">>> Unpacking ${a} to ${PWD}"
25 if [[ ${a} == ./* ]] ; then
26 : nothing to do -- path is local
27 elif [[ ${a} == ${DISTDIR}/* ]] ; then
28 ewarn 'QA: do not use ${DISTDIR} with rpm_unpack -- it is added for you'
29 elif [[ ${a} == /* ]] ; then
30 ewarn 'QA: do not use full paths with rpm_unpack -- use ./ paths instead'
34 rpm2tar -O "${a}" | tar xf - || die "failure unpacking ${a}"
38 # @FUNCTION: srcrpm_unpack
41 # Unpack the contents of the specified rpms like the unpack() function as well
42 # as any archives that it might contain. Note that the secondary archive
43 # unpack isn't perfect in that it simply unpacks all archives in the working
44 # directory (with the assumption that there weren't any to start with).
46 [[ $# -eq 0 ]] && set -- ${A}
49 # no .src.rpm files, then nothing to do
50 [[ "$* " != *".src.rpm " ]] && return 0
52 eshopts_push -s nullglob
56 for a in *.tar.{gz,bz2,xz} *.t{gz,bz2,xz,pxz} *.zip *.ZIP ; do
66 # @FUNCTION: rpm_src_unpack
68 # Automatically unpack all archives in ${A} including rpms. If one of the
69 # archives in a source rpm, then the sub archives will be unpacked as well.
74 *.rpm) srcrpm_unpack "${a}" ;;
80 # @FUNCTION: rpm_spec_epatch
83 # Read the specified spec (defaults to ${PN}.spec) and attempt to apply
84 # all the patches listed in it. If the spec does funky things like moving
85 # files around, well this won't handle that.
90 if [[ -z ${spec} ]] ; then
91 # search likely places for the spec file
92 for spec in "${PWD}" "${S}" "${WORKDIR}" ; do
94 [[ -e ${spec} ]] && break
97 [[ ${spec} == */* ]] \
101 ebegin "Applying patches from ${spec}"
103 grep '^%patch' "${spec}" | \
105 # expand the %patch line
110 # process the %patch arguments
115 -b) EPATCH_OPTS+=" --suffix" ;;
116 *) EPATCH_OPTS+=" ${arg}" ;;
120 # extract the patch name from the Patch# line
121 set -- $(grep "^P${p#%p}: " "${spec}")
123 epatch "${dir:+${dir}/}$*"
129 EXPORT_FUNCTIONS src_unpack