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

Contents of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Sat Jun 21 13:47:34 2003 UTC (11 years, 6 months ago) by liquidx
Branch: MAIN
Changes since 1.2: +4 -4 lines
typos in comments, also make it depend on any rpm2targz eclass for now
because we want to use this for all stable packages too.

1 # Copyright 1999-2003 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /home/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.2 2003/06/21 13:42:42 liquidx Exp $
4
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 # 1. convert all *.rpm in ${A} to tar.gz, non rpm files are passed through
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,
15 # .zip, .ZIP and unpacks them using unpack() (with a little hackery)
16 # 4. deletes all the unpacked tarballs and zip files from ${WORKDIR}
17 #
18 # Warning !!
19 #
20 # Sometimes, pure rpm2targz will fail on certain RPMs (eg: scim-chinese)
21 # because their code for detecting RPM header offset is not good enough.
22 # In that case, you need to add app-arch/rpm to your DEPEND. rpm2targz
23 # will automatically find rpm2cpio and use it instead of its own rpmoffset.
24 #
25 # In addition, rpm2targz-8.0 behaves differently from rpm2targz-9.0. The newer
26 # versions will autodetect rpm2cpio whereas 8.0 doesn't.
27 #
28 # Also, 9.0 will place files in ${prefix%.src} if extracting a source rpm
29 # whereas 8.0 will just place them in the current directory.
30 # As of writing, the current rpm2targz-9.0 in portage has been patched to
31 # remove this behaviour for backwards compatibility.
32
33 ECLASS="rpm"
34 INHERITED="$INHERITED $ECLASS"
35
36 newdepend "app-arch/rpm2targz"
37
38 rpm_src_unpack() {
39 local x prefix ext myfail OLD_DISTDIR
40
41 for x in ${A}; do
42 myfail="failure unpacking ${x}"
43 ext=${x##*.}
44 case "$ext" in
45 rpm)
46 echo ">>> Unpacking ${x}"
47 prefix=${x%.rpm}
48 cd ${WORKDIR}
49 # convert rpm to tar.gz and then extract
50 rpm2targz ${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
57 # find all tar.gz files and extract for srpms
58 if [ "${prefix##*.}" = "src" ]; then
59 OLD_DISTDIR=${DISTDIR}
60 DISTDIR=${WORKDIR}
61 findopts="-name *.tar"
62 for t in *.tar.gz *.tgz *.tbz2 *.tar.bz2 *.zip *.ZIP; do
63 findopts="${findopts} -o -name ${t}"
64 done
65 for t in $(find * ${findopts} | xargs); do
66 unpack ${t}
67 rm -f ${t}
68 done
69 DISTDIR=${OLD_DISTDIR}
70 fi
71 ;;
72 *)
73 unpack ${x}
74 ;;
75 esac
76 done
77
78 }
79
80 EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20