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

Diff of /eclass/rpm.eclass

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

Revision 1.1.1.1 Revision 1.6
1# Copyright 1999-2004 Gentoo Foundation 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.1.1.1 2005/11/30 09:59:18 chriswhite 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. uses rpm_unpack to unpack a rpm file using rpmoffset and cpio 11# 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, 12# 2. if it is a source rpm, it finds all .tar .tar.gz, .tgz, .tbz2, .tar.bz2,
13# .zip, .ZIP and unpacks them using unpack() (with a little hackery) 13# .zip, .ZIP and unpacks them using unpack() (with a little hackery)
19# 19#
20# It will autodetect for rpm2cpio (included in app-arch/rpm) and if it exists 20# 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 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 : 22# particular rpm cannot be read using rpmoffset, you just need to put :
23# 23#
24# DEPEND="app-arch/rpm" 24# DEPEND="app-arch/rpm"
25# 25#
26# in your ebuild and it will install and use rpm2cpio instead. If you wish 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: 27# to force your ebuild to use rpmoffset in the presence of rpm2cpio, define:
28# 28#
29# USE_RPMOFFSET_ONLY="1" 29# USE_RPMOFFSET_ONLY="1"
30 30
31ECLASS="rpm"
32INHERITED="$INHERITED $ECLASS"
31 33
32USE_RPMOFFSET_ONLY=${USE_RPMOFFSET_ONLY-""} 34USE_RPMOFFSET_ONLY=${USE_RPMOFFSET_ONLY-""}
33 35
34DEPEND=">=app-arch/rpm2targz-9.0-r1" 36newdepend "app-arch/rpm2targz"
35 37
36# extracts the contents of the RPM in ${WORKDIR} 38# extracts the contents of the RPM in ${WORKDIR}
37rpm_unpack() { 39rpm_unpack() {
38 local rpmfile rpmoff decompcmd 40 local rpmfile
39 rpmfile=$1 41 rpmfile=$1
40 if [ -z "${rpmfile}" ]; then 42 if [ -z "${rpmfile}" ]; then
41 return 1 43 return 1
42 fi 44 fi
45
46 cd ${WORKDIR}
43 if [ -x /usr/bin/rpm2cpio -a -z "${USE_RPMOFFSET_ONLY}" ]; then 47 if [ -x /usr/bin/rpm2cpio -a -z "${USE_RPMOFFSET_ONLY}" ]; then
44 rpm2cpio ${rpmfile} | cpio -idmu --no-preserve-owner --quiet || return 1 48 rpm2cpio ${rpmfile} | cpio -idmu --no-preserve-owner --quiet || return 1
45 else 49 else
46 rpmoff=`rpmoffset < ${rpmfile}`
47 [ -z "${rpmoff}" ] && return 1
48
49 decompcmd="gzip -dc"
50 if [ -n "`dd if=${rpmfile} skip=${rpmoff} bs=1 count=3 2>/dev/null | file - | grep bzip2`" ]; then
51 decompcmd="bzip2 -dc"
52 fi
53 dd ibs=${rpmoff} skip=1 if=${rpmfile} 2> /dev/null \ 50 dd ibs=`rpmoffset < ${rpmfile}` skip=1 if=${rpmfile} 2> /dev/null \
54 | ${decompcmd} \ 51 | gzip -dc \
55 | cpio -idmu --no-preserve-owner --quiet || return 1 52 | cpio -idmu --no-preserve-owner --quiet || return 1
56 fi 53 fi
57 54
58 return 0 55 return 0
59} 56}
60 57
61rpm_src_unpack() { 58rpm_src_unpack() {
62 local x prefix ext myfail OLD_DISTDIR 59 local x prefix ext myfail OLD_DISTDIR
63 60
64 for x in ${A}; do 61 for x in ${A}; do
65 myfail="failure unpacking ${x}" 62 myfail="failure unpacking ${x}"
66 ext=${x##*.} 63 ext=${x##*.}
67 case "$ext" in 64 case "$ext" in
68 rpm) 65 rpm)
69 echo ">>> Unpacking ${x}" 66 echo ">>> Unpacking ${x}"
70 prefix=${x%.rpm} 67 prefix=${x%.rpm}
71 cd ${WORKDIR} 68 cd ${WORKDIR}
72 rpm_unpack ${DISTDIR}/${x} || die "${myfail}" 69 rpm_unpack ${DISTDIR}/${x} || die "${myfail}"
73 70
74 # find all tar.gz files and extract for srpms 71 # find all tar.gz files and extract for srpms
75 if [ "${prefix##*.}" = "src" ]; then 72 if [ "${prefix##*.}" = "src" ]; then
76 OLD_DISTDIR=${DISTDIR} 73 OLD_DISTDIR=${DISTDIR}
77 DISTDIR=${WORKDIR} 74 DISTDIR=${WORKDIR}
78 findopts="* -maxdepth 0 -name *.tar" 75 findopts="* -maxdepth 0 -name *.tar"
82 for t in $(find ${findopts} | xargs); do 79 for t in $(find ${findopts} | xargs); do
83 unpack ${t} 80 unpack ${t}
84 rm -f ${t} 81 rm -f ${t}
85 done 82 done
86 DISTDIR=${OLD_DISTDIR} 83 DISTDIR=${OLD_DISTDIR}
87 fi 84 fi
88 ;; 85 ;;
89 *) 86 *)
90 unpack ${x} 87 unpack ${x}
91 ;; 88 ;;
92 esac 89 esac
93 done 90 done
91
94} 92}
95 93
96EXPORT_FUNCTIONS src_unpack 94EXPORT_FUNCTIONS src_unpack

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

  ViewVC Help
Powered by ViewVC 1.1.20