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

Contents of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (hide annotations) (download)
Mon Oct 5 06:14:36 2009 UTC (5 years ago) by vapier
Branch: MAIN
Changes since 1.18: +3 -1 lines
make rpm_unpack functions w/no args work off of $A like the unpack function

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.19 # $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.18 2009/10/05 06:05:04 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     local old_shopts=$(shopt -p nullglob)
51     shopt -s nullglob
52    
53     # unpack everything
54     local a
55     for a in *.tar.{gz,bz2} *.t{gz,bz2} *.zip *.ZIP ; do
56     unpack "./${a}"
57     rm -f "${a}"
58     done
59 liquidx 1.1
60 vapier 1.17 eval "${old_shopts}"
61 swegener 1.14
62 liquidx 1.5 return 0
63     }
64    
65 vapier 1.17 # @FUNCTION: rpm_src_unpack
66     # @DESCRIPTION:
67     # Automatically unpack all archives in ${A} including rpms. If one of the
68     # archives in a source rpm, then the sub archives will be unpacked as well.
69 liquidx 1.1 rpm_src_unpack() {
70 vapier 1.17 local a
71     for a in ${A} ; do
72     case ${a} in
73     *.rpm) srcrpm_unpack "${a}" ;;
74     *) unpack "${a}" ;;
75 liquidx 1.1 esac
76     done
77     }
78    
79 vapier 1.16 # @FUNCTION: rpm_spec_epatch
80     # @USAGE: [spec]
81     # @DESCRIPTION:
82     # Read the specified spec (defaults to ${PN}.spec) and attempt to apply
83     # all the patches listed in it. If the spec does funky things like moving
84     # files around, well this won't handle that.
85     rpm_spec_epatch() {
86     local p spec=${1:-${PN}.spec}
87     local dir=${spec%/*}
88     grep '^%patch' "${spec}" | \
89     while read line ; do
90     set -- ${line}
91     p=$1
92     shift
93     EPATCH_OPTS="$*"
94     set -- $(grep "^P${p#%p}: " "${spec}")
95     shift
96     epatch "${dir:+${dir}/}$*"
97     done
98     }
99    
100 liquidx 1.1 EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20