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

Diff of /eclass/rpm.eclass

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

Revision 1.2 Revision 1.6
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.2 2003/06/21 13:42:42 liquidx Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.6 2003/06/22 16:31:23 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 wil# detect if it is a source rpm and place files in 26# in your ebuild and it will install and use rpm2cpio instead. If you wish
29# ${prefix%.src} 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-0.9" 36newdepend "app-arch/rpm2targz"
37
38# extracts the contents of the RPM in ${WORKDIR}
39rpm_unpack() {
40 local rpmfile
41 rpmfile=$1
42 if [ -z "${rpmfile}" ]; then
43 return 1
44 fi
45
46 cd ${WORKDIR}
47 if [ -x /usr/bin/rpm2cpio -a -z "${USE_RPMOFFSET_ONLY}" ]; then
48 rpm2cpio ${rpmfile} | cpio -idmu --no-preserve-owner --quiet || return 1
49 else
50 dd ibs=`rpmoffset < ${rpmfile}` skip=1 if=${rpmfile} 2> /dev/null \
51 | gzip -dc \
52 | cpio -idmu --no-preserve-owner --quiet || return 1
53 fi
54
55 return 0
56}
37 57
38rpm_src_unpack() { 58rpm_src_unpack() {
39 local x prefix ext myfail OLD_DISTDIR 59 local x prefix ext myfail OLD_DISTDIR
40 60
41 for x in ${A}; do 61 for x in ${A}; do
44 case "$ext" in 64 case "$ext" in
45 rpm) 65 rpm)
46 echo ">>> Unpacking ${x}" 66 echo ">>> Unpacking ${x}"
47 prefix=${x%.rpm} 67 prefix=${x%.rpm}
48 cd ${WORKDIR} 68 cd ${WORKDIR}
49 # 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}
61 findopts="-name *.tar" 75 findopts="* -maxdepth 0 -name *.tar"
62 for t in *.tar.gz *.tgz *.tbz2 *.tar.bz2 *.zip *.ZIP; do 76 for t in *.tar.gz *.tgz *.tbz2 *.tar.bz2 *.zip *.ZIP; do
63 findopts="${findopts} -o -name ${t}" 77 findopts="${findopts} -o -name ${t}"
64 done 78 done
65 for t in $(find * ${findopts} | xargs); do 79 for t in $(find ${findopts} | xargs); do
66 unpack ${t} 80 unpack ${t}
67 rm -f ${t} 81 rm -f ${t}
68 done 82 done
69 DISTDIR=${OLD_DISTDIR} 83 DISTDIR=${OLD_DISTDIR}
70 fi 84 fi

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.20