| 1 |
# Copyright 1999-2009 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.16 2009/03/12 04:29:09 vapier Exp $
|
| 4 |
|
| 5 |
# @ECLASS: rpm.eclass
|
| 6 |
# @MAINTAINER:
|
| 7 |
# base-system@gentoo.org
|
| 8 |
# @BLURB: convenience class for extracting RPMs
|
| 9 |
|
| 10 |
inherit eutils
|
| 11 |
|
| 12 |
DEPEND=">=app-arch/rpm2targz-9.0.0.3g"
|
| 13 |
|
| 14 |
# @FUNCTION: rpm_unpack
|
| 15 |
# @USAGE: <rpms>
|
| 16 |
# @DESCRIPTION:
|
| 17 |
# Unpack the contents of the specified rpms like the unpack() function.
|
| 18 |
rpm_unpack() {
|
| 19 |
local a
|
| 20 |
for a in "$@" ; do
|
| 21 |
echo ">>> Unpacking ${a} to ${PWD}"
|
| 22 |
[[ ${a} != ./* ]] && a="${DISTDIR}/${a}"
|
| 23 |
rpm2tar -O "${a}" | tar xf - || die "failure unpacking ${a}"
|
| 24 |
done
|
| 25 |
}
|
| 26 |
|
| 27 |
# @FUNCTION: srcrpm_unpack
|
| 28 |
# @USAGE: <rpms>
|
| 29 |
# @DESCRIPTION:
|
| 30 |
# Unpack the contents of the specified rpms like the unpack() function as well
|
| 31 |
# as any archives that it might contain. Note that the secondary archive
|
| 32 |
# unpack isn't perfect in that it simply unpacks all archives in the working
|
| 33 |
# directory (with the assumption that there weren't any to start with).
|
| 34 |
srcrpm_unpack() {
|
| 35 |
rpm_unpack "$@"
|
| 36 |
|
| 37 |
# no .src.rpm files, then nothing to do
|
| 38 |
[[ "$* " != *".src.rpm " ]] && return 0
|
| 39 |
|
| 40 |
local old_shopts=$(shopt -p nullglob)
|
| 41 |
shopt -s nullglob
|
| 42 |
|
| 43 |
# unpack everything
|
| 44 |
local a
|
| 45 |
for a in *.tar.{gz,bz2} *.t{gz,bz2} *.zip *.ZIP ; do
|
| 46 |
unpack "./${a}"
|
| 47 |
rm -f "${a}"
|
| 48 |
done
|
| 49 |
|
| 50 |
eval "${old_shopts}"
|
| 51 |
|
| 52 |
return 0
|
| 53 |
}
|
| 54 |
|
| 55 |
# @FUNCTION: rpm_src_unpack
|
| 56 |
# @DESCRIPTION:
|
| 57 |
# Automatically unpack all archives in ${A} including rpms. If one of the
|
| 58 |
# archives in a source rpm, then the sub archives will be unpacked as well.
|
| 59 |
rpm_src_unpack() {
|
| 60 |
local a
|
| 61 |
for a in ${A} ; do
|
| 62 |
case ${a} in
|
| 63 |
*.rpm) srcrpm_unpack "${a}" ;;
|
| 64 |
*) unpack "${a}" ;;
|
| 65 |
esac
|
| 66 |
done
|
| 67 |
}
|
| 68 |
|
| 69 |
# @FUNCTION: rpm_spec_epatch
|
| 70 |
# @USAGE: [spec]
|
| 71 |
# @DESCRIPTION:
|
| 72 |
# Read the specified spec (defaults to ${PN}.spec) and attempt to apply
|
| 73 |
# all the patches listed in it. If the spec does funky things like moving
|
| 74 |
# files around, well this won't handle that.
|
| 75 |
rpm_spec_epatch() {
|
| 76 |
local p spec=${1:-${PN}.spec}
|
| 77 |
local dir=${spec%/*}
|
| 78 |
grep '^%patch' "${spec}" | \
|
| 79 |
while read line ; do
|
| 80 |
set -- ${line}
|
| 81 |
p=$1
|
| 82 |
shift
|
| 83 |
EPATCH_OPTS="$*"
|
| 84 |
set -- $(grep "^P${p#%p}: " "${spec}")
|
| 85 |
shift
|
| 86 |
epatch "${dir:+${dir}/}$*"
|
| 87 |
done
|
| 88 |
}
|
| 89 |
|
| 90 |
EXPORT_FUNCTIONS src_unpack
|