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

Contents of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Wed Nov 30 09:59:18 2005 UTC (8 years, 9 months ago) by chriswhite
Changes since 1.1: +52 -34 lines
*** empty log message ***

1 chriswhite 1.1.1.1 # Copyright 1999-2004 Gentoo Foundation
2 liquidx 1.1 # Distributed under the terms of the GNU General Public License v2
3 chriswhite 1.1.1.1 # $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.14 2005/07/11 15:08:06 swegener Exp $
4 liquidx 1.1
5     # Author : Alastair Tse <liquidx@gentoo.org> (21 Jun 2003)
6     #
7     # Convienence class for extracting RPMs
8 chriswhite 1.1.1.1 #
9 liquidx 1.1 # Basically, rpm_src_unpack does:
10     #
11 chriswhite 1.1.1.1 # 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 chriswhite 1.1.1.1 # 3. deletes all the unpacked tarballs and zip files from ${WORKDIR}
15     #
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     #
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
22     # particular rpm cannot be read using rpmoffset, you just need to put :
23 liquidx 1.1 #
24 chriswhite 1.1.1.1 # DEPEND="app-arch/rpm"
25 liquidx 1.1 #
26 chriswhite 1.1.1.1 # 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 liquidx 1.1 #
29 chriswhite 1.1.1.1 # USE_RPMOFFSET_ONLY="1"
30    
31    
32     USE_RPMOFFSET_ONLY=${USE_RPMOFFSET_ONLY-""}
33    
34     DEPEND=">=app-arch/rpm2targz-9.0-r1"
35 liquidx 1.1
36 chriswhite 1.1.1.1 # extracts the contents of the RPM in ${WORKDIR}
37     rpm_unpack() {
38     local rpmfile rpmoff decompcmd
39     rpmfile=$1
40     if [ -z "${rpmfile}" ]; then
41     return 1
42     fi
43     if [ -x /usr/bin/rpm2cpio -a -z "${USE_RPMOFFSET_ONLY}" ]; then
44     rpm2cpio ${rpmfile} | cpio -idmu --no-preserve-owner --quiet || return 1
45     else
46     rpmoff=`rpmoffset < ${rpmfile}`
47     [ -z "${rpmoff}" ] && return 1
48 liquidx 1.1
49 chriswhite 1.1.1.1 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 \
54     | ${decompcmd} \
55     | cpio -idmu --no-preserve-owner --quiet || return 1
56     fi
57    
58     return 0
59     }
60 liquidx 1.1
61     rpm_src_unpack() {
62     local x prefix ext myfail OLD_DISTDIR
63 chriswhite 1.1.1.1
64 liquidx 1.1 for x in ${A}; do
65     myfail="failure unpacking ${x}"
66     ext=${x##*.}
67     case "$ext" in
68     rpm)
69     echo ">>> Unpacking ${x}"
70     prefix=${x%.rpm}
71     cd ${WORKDIR}
72 chriswhite 1.1.1.1 rpm_unpack ${DISTDIR}/${x} || die "${myfail}"
73    
74 liquidx 1.1 # find all tar.gz files and extract for srpms
75     if [ "${prefix##*.}" = "src" ]; then
76     OLD_DISTDIR=${DISTDIR}
77     DISTDIR=${WORKDIR}
78 chriswhite 1.1.1.1 findopts="* -maxdepth 0 -name *.tar"
79 liquidx 1.1 for t in *.tar.gz *.tgz *.tbz2 *.tar.bz2 *.zip *.ZIP; do
80     findopts="${findopts} -o -name ${t}"
81     done
82 chriswhite 1.1.1.1 for t in $(find ${findopts} | xargs); do
83 liquidx 1.1 unpack ${t}
84     rm -f ${t}
85     done
86     DISTDIR=${OLD_DISTDIR}
87 chriswhite 1.1.1.1 fi
88 liquidx 1.1 ;;
89     *)
90     unpack ${x}
91     ;;
92     esac
93     done
94     }
95    
96     EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20