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
11 DEPEND=">=app-arch/rpm2targz-9.0.0.3g"
13 # @FUNCTION: rpm_unpack
16 # Unpack the contents of the specified rpms like the unpack() function.
18 [[ $# -eq 0 ]] && set -- ${A}
21 echo ">>> Unpacking ${a} to ${PWD}"
22 if [[ ${a} == ./* ]] ; then
23 : nothing to do -- path is local
24 elif [[ ${a} == ${DISTDIR}/* ]] ; then
25 ewarn 'QA: do not use ${DISTDIR} with rpm_unpack -- it is added for you'
26 elif [[ ${a} == /* ]] ; then
27 ewarn 'QA: do not use full paths with rpm_unpack -- use ./ paths instead'
31 rpm2tar -O "${a}" | tar xf - || die "failure unpacking ${a}"
35 # @FUNCTION: srcrpm_unpack
38 # Unpack the contents of the specified rpms like the unpack() function as well
39 # as any archives that it might contain. Note that the secondary archive
40 # unpack isn't perfect in that it simply unpacks all archives in the working
41 # directory (with the assumption that there weren't any to start with).
43 [[ $# -eq 0 ]] && set -- ${A}
46 # no .src.rpm files, then nothing to do
47 [[ "$* " != *".src.rpm " ]] && return 0
49 eshopts_push -s nullglob
53 for a in *.tar.{gz,bz2,xz} *.t{gz,bz2,xz,pxz} *.zip *.ZIP ; do
63 # @FUNCTION: rpm_src_unpack
65 # Automatically unpack all archives in ${A} including rpms. If one of the
66 # archives in a source rpm, then the sub archives will be unpacked as well.
71 *.rpm) srcrpm_unpack "${a}" ;;
77 # @FUNCTION: rpm_spec_epatch
80 # Read the specified spec (defaults to ${PN}.spec) and attempt to apply
81 # all the patches listed in it. If the spec does funky things like moving
82 # files around, well this won't handle that.
87 if [[ -z ${spec} ]] ; then
88 # search likely places for the spec file
89 for spec in "${PWD}" "${S}" "${WORKDIR}" ; do
91 [[ -e ${spec} ]] && break
94 [[ ${spec} == */* ]] \
98 ebegin "Applying patches from ${spec}"
100 grep '^%patch' "${spec}" | \
102 # expand the %patch line
107 # process the %patch arguments
112 -b) EPATCH_OPTS+=" --suffix" ;;
113 *) EPATCH_OPTS+=" ${arg}" ;;
117 # extract the patch name from the Patch# line
118 set -- $(grep "^P${p#%p}: " "${spec}")
120 epatch "${dir:+${dir}/}$*"
126 EXPORT_FUNCTIONS src_unpack