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

Contents of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (hide annotations) (download)
Thu Mar 12 04:29:09 2009 UTC (5 years, 6 months ago) by vapier
Branch: MAIN
Changes since 1.15: +23 -1 lines
add a func to automatically process patches in rpm specs

1 vapier 1.15 # Copyright 1999-2006 Gentoo Foundation
2 liquidx 1.1 # Distributed under the terms of the GNU General Public License v2
3 vapier 1.16 # $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.15 2006/06/27 06:49:09 vapier Exp $
4 liquidx 1.1
5     # Author : Alastair Tse <liquidx@gentoo.org> (21 Jun 2003)
6     #
7     # Convienence class for extracting RPMs
8 swegener 1.14 #
9 liquidx 1.1 # Basically, rpm_src_unpack does:
10     #
11 liquidx 1.5 # 1. uses rpm_unpack to unpack a rpm file using rpmoffset and cpio
12     # 2. if it is a source rpm, it finds all .tar .tar.gz, .tgz, .tbz2, .tar.bz2,
13 liquidx 1.1 # .zip, .ZIP and unpacks them using unpack() (with a little hackery)
14 liquidx 1.5 # 3. deletes all the unpacked tarballs and zip files from ${WORKDIR}
15 liquidx 1.1 #
16 liquidx 1.5 # This ebuild now re-defines a utility function called rpm_unpack which
17     # basically does what rpm2targz does, except faster. It does not gzip the
18     # output tar again but directly extracts to ${WORKDIR}
19 liquidx 1.1 #
20 liquidx 1.5 # It will autodetect for rpm2cpio (included in app-arch/rpm) and if it exists
21     # it will use that instead of the less reliable rpmoffset. This means if a
22     # particular rpm cannot be read using rpmoffset, you just need to put :
23     #
24 swegener 1.14 # DEPEND="app-arch/rpm"
25 liquidx 1.5 #
26     # in your ebuild and it will install and use rpm2cpio instead. If you wish
27     # to force your ebuild to use rpmoffset in the presence of rpm2cpio, define:
28 swegener 1.14 #
29 liquidx 1.5 # USE_RPMOFFSET_ONLY="1"
30 liquidx 1.1
31 vapier 1.16 inherit eutils
32 liquidx 1.1
33 liquidx 1.5 USE_RPMOFFSET_ONLY=${USE_RPMOFFSET_ONLY-""}
34    
35 mr_bones_ 1.9 DEPEND=">=app-arch/rpm2targz-9.0-r1"
36 liquidx 1.1
37 liquidx 1.6 # extracts the contents of the RPM in ${WORKDIR}
38 liquidx 1.5 rpm_unpack() {
39 liquidx 1.7 local rpmfile rpmoff decompcmd
40 liquidx 1.5 rpmfile=$1
41     if [ -z "${rpmfile}" ]; then
42     return 1
43     fi
44     if [ -x /usr/bin/rpm2cpio -a -z "${USE_RPMOFFSET_ONLY}" ]; then
45     rpm2cpio ${rpmfile} | cpio -idmu --no-preserve-owner --quiet || return 1
46     else
47 liquidx 1.7 rpmoff=`rpmoffset < ${rpmfile}`
48     [ -z "${rpmoff}" ] && return 1
49 swegener 1.14
50 liquidx 1.7 decompcmd="gzip -dc"
51     if [ -n "`dd if=${rpmfile} skip=${rpmoff} bs=1 count=3 2>/dev/null | file - | grep bzip2`" ]; then
52     decompcmd="bzip2 -dc"
53     fi
54     dd ibs=${rpmoff} skip=1 if=${rpmfile} 2> /dev/null \
55     | ${decompcmd} \
56 liquidx 1.5 | cpio -idmu --no-preserve-owner --quiet || return 1
57 swegener 1.14 fi
58    
59 liquidx 1.5 return 0
60     }
61    
62 liquidx 1.1 rpm_src_unpack() {
63     local x prefix ext myfail OLD_DISTDIR
64 swegener 1.14
65 liquidx 1.1 for x in ${A}; do
66     myfail="failure unpacking ${x}"
67     ext=${x##*.}
68     case "$ext" in
69     rpm)
70 vapier 1.15 echo ">>> Unpacking ${x} to ${WORKDIR}"
71 liquidx 1.1 prefix=${x%.rpm}
72     cd ${WORKDIR}
73 liquidx 1.5 rpm_unpack ${DISTDIR}/${x} || die "${myfail}"
74 swegener 1.14
75 liquidx 1.1 # find all tar.gz files and extract for srpms
76     if [ "${prefix##*.}" = "src" ]; then
77     OLD_DISTDIR=${DISTDIR}
78     DISTDIR=${WORKDIR}
79 liquidx 1.4 findopts="* -maxdepth 0 -name *.tar"
80 liquidx 1.1 for t in *.tar.gz *.tgz *.tbz2 *.tar.bz2 *.zip *.ZIP; do
81     findopts="${findopts} -o -name ${t}"
82     done
83 liquidx 1.4 for t in $(find ${findopts} | xargs); do
84 liquidx 1.1 unpack ${t}
85     rm -f ${t}
86     done
87     DISTDIR=${OLD_DISTDIR}
88 swegener 1.14 fi
89 liquidx 1.1 ;;
90     *)
91     unpack ${x}
92     ;;
93     esac
94     done
95     }
96    
97 vapier 1.16 # @FUNCTION: rpm_spec_epatch
98     # @USAGE: [spec]
99     # @DESCRIPTION:
100     # Read the specified spec (defaults to ${PN}.spec) and attempt to apply
101     # all the patches listed in it. If the spec does funky things like moving
102     # files around, well this won't handle that.
103     rpm_spec_epatch() {
104     local p spec=${1:-${PN}.spec}
105     local dir=${spec%/*}
106     grep '^%patch' "${spec}" | \
107     while read line ; do
108     set -- ${line}
109     p=$1
110     shift
111     EPATCH_OPTS="$*"
112     set -- $(grep "^P${p#%p}: " "${spec}")
113     shift
114     epatch "${dir:+${dir}/}$*"
115     done
116     }
117    
118 liquidx 1.1 EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20