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

Diff of /eclass/rpm.eclass

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

Revision 1.4 Revision 1.5
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2003 Gentoo Technologies, Inc.
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.4 2003/06/21 14:22:18 liquidx Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.5 2003/06/22 16:29:32 liquidx Exp $
4 4
5# Author : Alastair Tse <liquidx@gentoo.org> (21 Jun 2003) 5# Author : Alastair Tse <liquidx@gentoo.org> (21 Jun 2003)
6# 6#
7# Convienence class for extracting RPMs 7# Convienence class for extracting RPMs
8# 8#
9# Basically, rpm_src_unpack does: 9# Basically, rpm_src_unpack does:
10# 10#
11# 1. convert all *.rpm in ${A} to tar.gz, non rpm files are passed through 11# 1. uses rpm_unpack to unpack a rpm file using rpmoffset and cpio
12# unpack()
13# 2. unpacks the tar.gz into ${WORKDIR}
14# 3. if it is a source rpm, it finds all .tar .tar.gz, .tgz, .tbz2, .tar.bz2, 12# 2. if it is a source rpm, it finds all .tar .tar.gz, .tgz, .tbz2, .tar.bz2,
15# .zip, .ZIP and unpacks them using unpack() (with a little hackery) 13# .zip, .ZIP and unpacks them using unpack() (with a little hackery)
16# 4. deletes all the unpacked tarballs and zip files from ${WORKDIR} 14# 3. deletes all the unpacked tarballs and zip files from ${WORKDIR}
17# 15#
18# Warning !! 16# 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# 19#
20# Sometimes, pure rpm2targz will fail on certain RPMs (eg: scim-chinese) 20# It will autodetect for rpm2cpio (included in app-arch/rpm) and if it exists
21# because their code for detecting RPM header offset is not good enough. 21# it will use that instead of the less reliable rpmoffset. This means if a
22# In that case, you need to add app-arch/rpm to your DEPEND. rpm2targz 22# particular rpm cannot be read using rpmoffset, you just need to put :
23# will automatically find rpm2cpio and use it instead of its own rpmoffset.
24# 23#
25# In addition, rpm2targz-8.0 behaves differently from rpm2targz-9.0. The newer 24# DEPEND="app-arch/rpm"
26# versions will autodetect rpm2cpio whereas 8.0 doesn't.
27# 25#
28# Also, 9.0 will place files in ${prefix%.src} if extracting a source rpm 26# in your ebuild and it will install and use rpm2cpio instead. If you wish
29# whereas 8.0 will just place them in the current directory. 27# to force your ebuild to use rpmoffset in the presence of rpm2cpio, define:
30# As of writing, the current rpm2targz-9.0 in portage has been patched to 28#
31# remove this behaviour for backwards compatibility. 29# USE_RPMOFFSET_ONLY="1"
32 30
33ECLASS="rpm" 31ECLASS="rpm"
34INHERITED="$INHERITED $ECLASS" 32INHERITED="$INHERITED $ECLASS"
35 33
34USE_RPMOFFSET_ONLY=${USE_RPMOFFSET_ONLY-""}
35
36newdepend "app-arch/rpm2targz" 36newdepend "app-arch/rpm2targz"
37
38rpm_unpack() {
39 local rpmfile
40 rpmfile=$1
41 if [ -z "${rpmfile}" ]; then
42 return 1
43 fi
44
45 cd ${WORKDIR}
46 if [ -x /usr/bin/rpm2cpio -a -z "${USE_RPMOFFSET_ONLY}" ]; then
47 rpm2cpio ${rpmfile} | cpio -idmu --no-preserve-owner --quiet || return 1
48 else
49 dd ibs=`rpmoffset < ${rpmfile}` skip=1 if=${rpmfile} 2> /dev/null \
50 | gzip -dc \
51 | cpio -idmu --no-preserve-owner --quiet || return 1
52 fi
53
54 return 0
55}
37 56
38rpm_src_unpack() { 57rpm_src_unpack() {
39 local x prefix ext myfail OLD_DISTDIR 58 local x prefix ext myfail OLD_DISTDIR
40 59
41 for x in ${A}; do 60 for x in ${A}; do
45 rpm) 64 rpm)
46 echo ">>> Unpacking ${x}" 65 echo ">>> Unpacking ${x}"
47 prefix=${x%.rpm} 66 prefix=${x%.rpm}
48 cd ${WORKDIR} 67 cd ${WORKDIR}
49 # convert rpm to tar.gz and then extract 68 # convert rpm to tar.gz and then extract
50 rpm2targz ${DISTDIR}/${x} || die "${myfail}" 69 rpm_unpack ${DISTDIR}/${x} || die "${myfail}"
51 if [ "$(tar tzvf ${WORKDIR}/${prefix}.tar.gz | wc -l)" -lt 2 ]; then
52 die "rpm2targz failed, produced an empty tar.gz"
53 fi
54 tar xz --no-same-owner -f ${WORKDIR}/${prefix}.tar.gz || die "${myfail}"
55 rm -f ${WORKDIR}/${prefix}.tar.gz
56 70
57 # find all tar.gz files and extract for srpms 71 # find all tar.gz files and extract for srpms
58 if [ "${prefix##*.}" = "src" ]; then 72 if [ "${prefix##*.}" = "src" ]; then
59 OLD_DISTDIR=${DISTDIR} 73 OLD_DISTDIR=${DISTDIR}
60 DISTDIR=${WORKDIR} 74 DISTDIR=${WORKDIR}

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.20