| 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.2 |
# $Header: /home/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.1 2003/06/21 13:24:12 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 |
|
|
# 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 |
liquidx |
1.2 |
# 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 wil# detect if it is a source rpm and place files in
|
| 29 |
|
|
# ${prefix%.src} 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 |
liquidx |
1.1 |
|
| 33 |
|
|
ECLASS="rpm"
|
| 34 |
|
|
INHERITED="$INHERITED $ECLASS"
|
| 35 |
|
|
|
| 36 |
|
|
newdepend ">=app-arch/rpm2targz-0.9"
|
| 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 |
liquidx |
1.2 |
for t in $(find * ${findopts} | xargs); do
|
| 66 |
liquidx |
1.1 |
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
|