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

Diff of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.17 Revision 1.21
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 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 $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.21 2011/12/10 08:50:47 vapier Exp $
4 4
5# @ECLASS: rpm.eclass 5# @ECLASS: rpm.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @BLURB: convenience class for extracting RPMs 8# @BLURB: convenience class for extracting RPMs
14# @FUNCTION: rpm_unpack 14# @FUNCTION: rpm_unpack
15# @USAGE: <rpms> 15# @USAGE: <rpms>
16# @DESCRIPTION: 16# @DESCRIPTION:
17# Unpack the contents of the specified rpms like the unpack() function. 17# Unpack the contents of the specified rpms like the unpack() function.
18rpm_unpack() { 18rpm_unpack() {
19 [[ $# -eq 0 ]] && set -- ${A}
19 local a 20 local a
20 for a in "$@" ; do 21 for a in "$@" ; do
21 echo ">>> Unpacking ${a} to ${PWD}" 22 echo ">>> Unpacking ${a} to ${PWD}"
22 [[ ${a} != ./* ]] && a="${DISTDIR}/${a}" 23 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
23 rpm2tar -O "${a}" | tar xf - || die "failure unpacking ${a}" 32 rpm2tar -O "${a}" | tar xf - || die "failure unpacking ${a}"
24 done 33 done
25} 34}
26 35
27# @FUNCTION: srcrpm_unpack 36# @FUNCTION: srcrpm_unpack
30# Unpack the contents of the specified rpms like the unpack() function as well 39# 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 40# 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 41# 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). 42# directory (with the assumption that there weren't any to start with).
34srcrpm_unpack() { 43srcrpm_unpack() {
44 [[ $# -eq 0 ]] && set -- ${A}
35 rpm_unpack "$@" 45 rpm_unpack "$@"
36 46
37 # no .src.rpm files, then nothing to do 47 # no .src.rpm files, then nothing to do
38 [[ "$* " != *".src.rpm " ]] && return 0 48 [[ "$* " != *".src.rpm " ]] && return 0
39 49
40 local old_shopts=$(shopt -p nullglob)
41 shopt -s nullglob 50 eshopts_push -s nullglob
42 51
43 # unpack everything 52 # unpack everything
44 local a 53 local a
45 for a in *.tar.{gz,bz2} *.t{gz,bz2} *.zip *.ZIP ; do 54 for a in *.tar.{gz,bz2} *.t{gz,bz2} *.zip *.ZIP ; do
46 unpack "./${a}" 55 unpack "./${a}"
47 rm -f "${a}" 56 rm -f "${a}"
48 done 57 done
49 58
50 eval "${old_shopts}" 59 eshopts_pop
51 60
52 return 0 61 return 0
53} 62}
54 63
55# @FUNCTION: rpm_src_unpack 64# @FUNCTION: rpm_src_unpack
71# @DESCRIPTION: 80# @DESCRIPTION:
72# Read the specified spec (defaults to ${PN}.spec) and attempt to apply 81# 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 82# all the patches listed in it. If the spec does funky things like moving
74# files around, well this won't handle that. 83# files around, well this won't handle that.
75rpm_spec_epatch() { 84rpm_spec_epatch() {
76 local p spec=${1:-${PN}.spec} 85 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} == */* ]] \
77 local dir=${spec%/*} 96 && dir=${spec%/*} \
97 || dir=
98
99 ebegin "Applying patches from ${spec}"
100
78 grep '^%patch' "${spec}" | \ 101 grep '^%patch' "${spec}" | \
79 while read line ; do 102 while read line ; do
103 # expand the %patch line
80 set -- ${line} 104 set -- ${line}
81 p=$1 105 p=$1
82 shift 106 shift
107
108 # process the %patch arguments
109 local arg
83 EPATCH_OPTS="$*" 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
84 set -- $(grep "^P${p#%p}: " "${spec}") 119 set -- $(grep "^P${p#%p}: " "${spec}")
85 shift 120 shift
86 epatch "${dir:+${dir}/}$*" 121 epatch "${dir:+${dir}/}$*"
87 done 122 done
123
124 eend
88} 125}
89 126
90EXPORT_FUNCTIONS src_unpack 127EXPORT_FUNCTIONS src_unpack

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.20