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

Contents of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (show annotations) (download)
Mon Oct 5 06:05:04 2009 UTC (5 years, 1 month ago) by vapier
Branch: MAIN
Changes since 1.17: +10 -2 lines
since the API for rpm_unpack has changed, detect poor behavior and warn about it rather than outright failing #287536

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.17 2009/10/03 08:56:17 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 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'
28 else
29 a="${DISTDIR}/${a}"
30 fi
31 rpm2tar -O "${a}" | tar xf - || die "failure unpacking ${a}"
32 done
33 }
34
35 # @FUNCTION: srcrpm_unpack
36 # @USAGE: <rpms>
37 # @DESCRIPTION:
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).
42 srcrpm_unpack() {
43 rpm_unpack "$@"
44
45 # no .src.rpm files, then nothing to do
46 [[ "$* " != *".src.rpm " ]] && return 0
47
48 local old_shopts=$(shopt -p nullglob)
49 shopt -s nullglob
50
51 # unpack everything
52 local a
53 for a in *.tar.{gz,bz2} *.t{gz,bz2} *.zip *.ZIP ; do
54 unpack "./${a}"
55 rm -f "${a}"
56 done
57
58 eval "${old_shopts}"
59
60 return 0
61 }
62
63 # @FUNCTION: rpm_src_unpack
64 # @DESCRIPTION:
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.
67 rpm_src_unpack() {
68 local a
69 for a in ${A} ; do
70 case ${a} in
71 *.rpm) srcrpm_unpack "${a}" ;;
72 *) unpack "${a}" ;;
73 esac
74 done
75 }
76
77 # @FUNCTION: rpm_spec_epatch
78 # @USAGE: [spec]
79 # @DESCRIPTION:
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.
83 rpm_spec_epatch() {
84 local p spec=${1:-${PN}.spec}
85 local dir=${spec%/*}
86 grep '^%patch' "${spec}" | \
87 while read line ; do
88 set -- ${line}
89 p=$1
90 shift
91 EPATCH_OPTS="$*"
92 set -- $(grep "^P${p#%p}: " "${spec}")
93 shift
94 epatch "${dir:+${dir}/}$*"
95 done
96 }
97
98 EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20