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

Contents of /eclass/rpm.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sat Jun 21 13:24:12 2003 UTC (12 years, 1 month ago) by liquidx
Branch: MAIN
new rpm extraction convienence eclass

1 liquidx 1.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/stardict.eclass,v 1.1 2003/06/04 13:13:59 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     # Also, rpm2targz-8.0 behaves differently from rpm2targz-9.0. The newer
26     # versions will autodetect rpm2cpio whereas 8.0 doesn't. Also, 9.0 will
27     # detect if it is a source rpm and place files in ${prefix%.src} whereas
28     # 8.0 will just place them in the current directory. This eclass DEPENDS
29     # on rpm2targz 9.0.
30    
31     ECLASS="rpm"
32     INHERITED="$INHERITED $ECLASS"
33    
34     newdepend ">=app-arch/rpm2targz-0.9"
35    
36     rpm_src_unpack() {
37     local x prefix ext myfail OLD_DISTDIR
38    
39     for x in ${A}; do
40     myfail="failure unpacking ${x}"
41     ext=${x##*.}
42     case "$ext" in
43     rpm)
44     echo ">>> Unpacking ${x}"
45     prefix=${x%.rpm}
46     cd ${WORKDIR}
47     # convert rpm to tar.gz and then extract
48     rpm2targz ${DISTDIR}/${x} || die "${myfail}"
49     if [ "$(tar tzvf ${WORKDIR}/${prefix}.tar.gz | wc -l)" -lt 2 ]; then
50     die "rpm2targz failed, produced an empty tar.gz"
51     fi
52     tar xz --no-same-owner -f ${WORKDIR}/${prefix}.tar.gz || die "${myfail}"
53     rm -f ${WORKDIR}/${prefix}.tar.gz
54    
55     # find all tar.gz files and extract for srpms
56     if [ "${prefix##*.}" = "src" ]; then
57     OLD_DISTDIR=${DISTDIR}
58     DISTDIR=${WORKDIR}
59     findopts="-name *.tar"
60     for t in *.tar.gz *.tgz *.tbz2 *.tar.bz2 *.zip *.ZIP; do
61     findopts="${findopts} -o -name ${t}"
62     done
63     for t in $(find ${prefix%.src} ${findopts} | xargs); do
64     unpack ${t}
65     rm -f ${t}
66     done
67     DISTDIR=${OLD_DISTDIR}
68     fi
69     ;;
70     *)
71     unpack ${x}
72     ;;
73     esac
74     done
75    
76     }
77    
78     EXPORT_FUNCTIONS src_unpack

  ViewVC Help
Powered by ViewVC 1.1.20