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

Contents of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (hide annotations) (download)
Sat Dec 10 08:50:47 2011 UTC (2 years, 7 months ago) by vapier
Branch: MAIN
Changes since 1.20: +32 -4 lines
extend rpm_spec_epatch to handle -b %patch options (which is really patch --suffix)

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.21 # $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.20 2010/07/18 21:57:20 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 vapier 1.19 [[ $# -eq 0 ]] && set -- ${A}
20 vapier 1.17 local a
21     for a in "$@" ; do
22     echo ">>> Unpacking ${a} to ${PWD}"
23 vapier 1.18 if [[ ${a} == ./* ]] ; then
24     : nothing to do -- path is local
25     elif [[ ${a} == ${DISTDIR}/* ]] ; then
26     ewarn 'QA: do not use ${DISTDIR} with rpm_unpack -- it is added for you'
27     elif [[ ${a} == /* ]] ; then
28     ewarn 'QA: do not use full paths with rpm_unpack -- use ./ paths instead'
29     else
30     a="${DISTDIR}/${a}"
31     fi
32 vapier 1.17 rpm2tar -O "${a}" | tar xf - || die "failure unpacking ${a}"
33     done
34     }
35    
36     # @FUNCTION: srcrpm_unpack
37     # @USAGE: <rpms>
38     # @DESCRIPTION:
39     # Unpack the contents of the specified rpms like the unpack() function as well
40     # as any archives that it might contain. Note that the secondary archive
41     # unpack isn't perfect in that it simply unpacks all archives in the working
42     # directory (with the assumption that there weren't any to start with).
43     srcrpm_unpack() {
44 vapier 1.19 [[ $# -eq 0 ]] && set -- ${A}
45 vapier 1.17 rpm_unpack "$@"
46    
47     # no .src.rpm files, then nothing to do
48     [[ "$* " != *".src.rpm " ]] && return 0
49    
50 vapier 1.20 eshopts_push -s nullglob
51 vapier 1.17
52     # unpack everything
53     local a
54     for a in *.tar.{gz,bz2} *.t{gz,bz2} *.zip *.ZIP ; do
55     unpack "./${a}"
56     rm -f "${a}"
57     done
58 liquidx 1.1
59 vapier 1.20 eshopts_pop
60 swegener 1.14
61 liquidx 1.5 return 0
62     }
63    
64 vapier 1.17 # @FUNCTION: rpm_src_unpack
65     # @DESCRIPTION:
66     # Automatically unpack all archives in ${A} including rpms. If one of the
67     # archives in a source rpm, then the sub archives will be unpacked as well.
68 liquidx 1.1 rpm_src_unpack() {
69 vapier 1.17 local a
70     for a in ${A} ; do
71     case ${a} in
72     *.rpm) srcrpm_unpack "${a}" ;;
73     *) unpack "${a}" ;;
74 liquidx 1.1 esac
75     done
76     }
77    
78 vapier 1.16 # @FUNCTION: rpm_spec_epatch
79     # @USAGE: [spec]
80     # @DESCRIPTION:
81     # Read the specified spec (defaults to ${PN}.spec) and attempt to apply
82     # all the patches listed in it. If the spec does funky things like moving
83     # files around, well this won't handle that.
84     rpm_spec_epatch() {
85 vapier 1.21 local p spec=$1
86     local dir
87    
88     if [[ -z ${spec} ]] ; then
89     # search likely places for the spec file
90     for spec in "${PWD}" "${S}" "${WORKDIR}" ; do
91     spec+="/${PN}.spec"
92     [[ -e ${spec} ]] && break
93     done
94     fi
95     [[ ${spec} == */* ]] \
96     && dir=${spec%/*} \
97     || dir=
98    
99     ebegin "Applying patches from ${spec}"
100    
101 vapier 1.16 grep '^%patch' "${spec}" | \
102     while read line ; do
103 vapier 1.21 # expand the %patch line
104 vapier 1.16 set -- ${line}
105     p=$1
106     shift
107 vapier 1.21
108     # process the %patch arguments
109     local arg
110     EPATCH_OPTS=
111     for arg in "$@" ; do
112     case ${arg} in
113     -b) EPATCH_OPTS+=" --suffix" ;;
114     *) EPATCH_OPTS+=" ${arg}" ;;
115     esac
116     done
117    
118     # extract the patch name from the Patch# line
119 vapier 1.16 set -- $(grep "^P${p#%p}: " "${spec}")
120     shift
121     epatch "${dir:+${dir}/}$*"
122     done
123 vapier 1.21
124     eend
125 vapier 1.16 }
126    
127 liquidx 1.1 EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20