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

Contents of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (hide annotations) (download)
Sat Oct 3 08:56:17 2009 UTC (5 years, 2 months ago) by vapier
Branch: MAIN
Changes since 1.16: +52 -80 lines
simplify rpm code greatly by forcing rpm2targz and recent portage, and document things

1 vapier 1.17 # Copyright 1999-2009 Gentoo Foundation
2 liquidx 1.1 # Distributed under the terms of the GNU General Public License v2
3 vapier 1.17 # $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.16 2009/03/12 04:29:09 vapier Exp $
4 liquidx 1.1
5 vapier 1.17 # @ECLASS: rpm.eclass
6     # @MAINTAINER:
7     # base-system@gentoo.org
8     # @BLURB: convenience class for extracting RPMs
9 liquidx 1.1
10 vapier 1.16 inherit eutils
11 liquidx 1.1
12 vapier 1.17 DEPEND=">=app-arch/rpm2targz-9.0.0.3g"
13 liquidx 1.5
14 vapier 1.17 # @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 liquidx 1.1
50 vapier 1.17 eval "${old_shopts}"
51 swegener 1.14
52 liquidx 1.5 return 0
53     }
54    
55 vapier 1.17 # @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 liquidx 1.1 rpm_src_unpack() {
60 vapier 1.17 local a
61     for a in ${A} ; do
62     case ${a} in
63     *.rpm) srcrpm_unpack "${a}" ;;
64     *) unpack "${a}" ;;
65 liquidx 1.1 esac
66     done
67     }
68    
69 vapier 1.16 # @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 liquidx 1.1 EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20