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

Contents of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Sun Jun 22 16:29:32 2003 UTC (11 years, 2 months ago) by liquidx
Branch: MAIN
Changes since 1.4: +39 -25 lines
used agriffis' way of extracting rpms without gzipping at the end
also added test for rpm2cpio and use that instead if available

1 liquidx 1.1 # Copyright 1999-2003 Gentoo Technologies, Inc.
2     # Distributed under the terms of the GNU General Public License v2
3 liquidx 1.5 # $Header: /home/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.4 2003/06/21 14:22:18 liquidx Exp $
4 liquidx 1.1
5     # Author : Alastair Tse <liquidx@gentoo.org> (21 Jun 2003)
6     #
7     # Convienence class for extracting RPMs
8     #
9     # 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     # DEPEND="app-arch/rpm"
25     #
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     #
29     # USE_RPMOFFSET_ONLY="1"
30 liquidx 1.1
31     ECLASS="rpm"
32     INHERITED="$INHERITED $ECLASS"
33    
34 liquidx 1.5 USE_RPMOFFSET_ONLY=${USE_RPMOFFSET_ONLY-""}
35    
36 liquidx 1.3 newdepend "app-arch/rpm2targz"
37 liquidx 1.1
38 liquidx 1.5 rpm_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     }
56    
57 liquidx 1.1 rpm_src_unpack() {
58     local x prefix ext myfail OLD_DISTDIR
59    
60     for x in ${A}; do
61     myfail="failure unpacking ${x}"
62     ext=${x##*.}
63     case "$ext" in
64     rpm)
65     echo ">>> Unpacking ${x}"
66     prefix=${x%.rpm}
67     cd ${WORKDIR}
68     # convert rpm to tar.gz and then extract
69 liquidx 1.5 rpm_unpack ${DISTDIR}/${x} || die "${myfail}"
70 liquidx 1.1
71     # find all tar.gz files and extract for srpms
72     if [ "${prefix##*.}" = "src" ]; then
73     OLD_DISTDIR=${DISTDIR}
74     DISTDIR=${WORKDIR}
75 liquidx 1.4 findopts="* -maxdepth 0 -name *.tar"
76 liquidx 1.1 for t in *.tar.gz *.tgz *.tbz2 *.tar.bz2 *.zip *.ZIP; do
77     findopts="${findopts} -o -name ${t}"
78     done
79 liquidx 1.4 for t in $(find ${findopts} | xargs); do
80 liquidx 1.1 unpack ${t}
81     rm -f ${t}
82     done
83     DISTDIR=${OLD_DISTDIR}
84     fi
85     ;;
86     *)
87     unpack ${x}
88     ;;
89     esac
90     done
91    
92     }
93    
94     EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20