summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2012-06-11 14:22:19 +0000
committerMichał Górny <mgorny@gentoo.org>2012-06-11 14:22:19 +0000
commite65dbed4a2894716a68af0e76d77e2e9534a301b (patch)
tree3607420e44f038c424b75b2fb13a7f7138349b77 /eclass
parentUse matching name for download & S to make the ebuilds forward-proof to vcs-s... (diff)
downloadgentoo-2-e65dbed4a2894716a68af0e76d77e2e9534a301b.tar.gz
gentoo-2-e65dbed4a2894716a68af0e76d77e2e9534a301b.tar.bz2
gentoo-2-e65dbed4a2894716a68af0e76d77e2e9534a301b.zip
Unpack tarballs in directory matching their name rather than ${P}. This allows the eclass to handle multiple tarballs in one ebuild, and non-snapshot tarballs should work fine too.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog7
-rw-r--r--eclass/vcs-snapshot.eclass56
2 files changed, 44 insertions, 19 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index e248a41a8523..1ee5a8613de5 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,11 @@
# ChangeLog for eclass directory
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.308 2012/06/11 13:02:21 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.309 2012/06/11 14:22:19 mgorny Exp $
+
+ 11 Jun 2012; Michał Górny <mgorny@gentoo.org> vcs-snapshot.eclass:
+ Unpack tarballs in directory matching their name rather than ${P}. This
+ allows the eclass to handle multiple tarballs in one ebuild, and non-snapshot
+ tarballs should work fine too.
11 Jun 2012; Michał Górny <mgorny@gentoo.org> xorg-2.eclass:
Replace remove_libtool_files with prune_libtool_files.
diff --git a/eclass/vcs-snapshot.eclass b/eclass/vcs-snapshot.eclass
index 87293ad709fe..1c8e31d1ba7c 100644
--- a/eclass/vcs-snapshot.eclass
+++ b/eclass/vcs-snapshot.eclass
@@ -1,24 +1,27 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/vcs-snapshot.eclass,v 1.3 2012/06/07 21:51:48 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/vcs-snapshot.eclass,v 1.4 2012/06/11 14:22:19 mgorny Exp $
# @ECLASS: vcs-snapshot.eclass
# @MAINTAINER:
# mgorny@gentoo.org
-# @BLURB: support eclass for VCS (github, bitbucket, gitweb) snapshots
+# @BLURB: support eclass for unpacking VCS snapshot tarballs
# @DESCRIPTION:
-# This eclass provides a convenience src_unpack() which does support
-# working with snapshots generated by various VCS-es. It unpacks those
-# to ${WORKDIR}/${P} rather than the original directory containing
-# the commit id.
+# This eclass provides a convenience src_unpack() which does unpack all
+# the tarballs in SRC_URI to locations matching their (local) names,
+# discarding the original parent directory.
#
-# Note that this eclass handles only unpacking. You need to specify
-# SRC_URI yourself, and call any autoreconfiguration as necessary.
-# The example does that using autotools-utils eclass.
+# The typical use case are VCS snapshots, coming from github, bitbucket
+# and similar services. They have hash appended to the directory name
+# which makes extracting them a painful experience. But if you just use
+# a SRC_URI arrow to rename it (which you're likely have to do anyway),
+# vcs-snapshot will just extract it into a matching directory.
+#
+# Please note that this eclass handles only tarballs (.tar, .tar.gz,
+# .tar.bz2 & .tar.xz). For any other file format (or suffix) it will
+# fall back to regular unpack. Support for additional formats may be
+# added at some point so please keep your SRC_URIs clean.
#
-# Right now, the eclass was tested with github, bitbucket and gitweb
-# snapshots. Feel free to report snapshotting services which aren't
-# working.
# @EXAMPLE:
#
# @CODE
@@ -28,19 +31,36 @@
#
# SRC_URI="http://github.com/example/${PN}/tarball/v${PV} -> ${P}.tar.gz"
# @CODE
+#
+# and however the tarball was originally named, all files will appear
+# in ${WORKDIR}/${P}.
case ${EAPI:-0} in
- 0|1) die "EAPI ${EAPI} unsupported.";; # default(), SRC_URI arrows
- 2|3|4) ;;
+ 0|1|2|3|4) ;;
*) die "vcs-snapshot.eclass API in EAPI ${EAPI} not yet established."
esac
EXPORT_FUNCTIONS src_unpack
vcs-snapshot_src_unpack() {
- default
+ local f
+
+ for f in ${A}
+ do
+ case "${f}" in
+ *.tar|*.tar.gz|*.tar.bz2|*.tar.xz)
+ local destdir=${WORKDIR}/${f%.tar*}
- # github, bitbucket: username-projectname-hash
- # gitweb: projectname-tagname-hash
- mv *-*-[0-9a-f]*[0-9a-f]/ "${WORKDIR}"/${P} || die
+ # XXX: check whether the directory structure inside is
+ # fine? i.e. if the tarball has actually a parent dir.
+ mkdir "${destdir}" || die
+ tar -C "${destdir}" -x --strip-components 1 \
+ -f "${DISTDIR}/${f}" || die
+ ;;
+ *)
+ # fall back to the default method
+ unpack "${f}"
+ ;;
+ esac
+ done
}