/[gentoo-x86]/eclass/vcs-snapshot.eclass
Gentoo

Diff of /eclass/vcs-snapshot.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 Revision 1.4
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/vcs-snapshot.eclass,v 1.3 2012/06/07 21:51:48 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/vcs-snapshot.eclass,v 1.4 2012/06/11 14:22:19 mgorny Exp $
4 4
5# @ECLASS: vcs-snapshot.eclass 5# @ECLASS: vcs-snapshot.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# mgorny@gentoo.org 7# mgorny@gentoo.org
8# @BLURB: support eclass for VCS (github, bitbucket, gitweb) snapshots 8# @BLURB: support eclass for unpacking VCS snapshot tarballs
9# @DESCRIPTION: 9# @DESCRIPTION:
10# This eclass provides a convenience src_unpack() which does support 10# This eclass provides a convenience src_unpack() which does unpack all
11# working with snapshots generated by various VCS-es. It unpacks those 11# the tarballs in SRC_URI to locations matching their (local) names,
12# to ${WORKDIR}/${P} rather than the original directory containing 12# discarding the original parent directory.
13# the commit id.
14# 13#
15# Note that this eclass handles only unpacking. You need to specify 14# The typical use case are VCS snapshots, coming from github, bitbucket
16# SRC_URI yourself, and call any autoreconfiguration as necessary. 15# and similar services. They have hash appended to the directory name
17# The example does that using autotools-utils eclass. 16# which makes extracting them a painful experience. But if you just use
17# a SRC_URI arrow to rename it (which you're likely have to do anyway),
18# vcs-snapshot will just extract it into a matching directory.
18# 19#
19# Right now, the eclass was tested with github, bitbucket and gitweb 20# Please note that this eclass handles only tarballs (.tar, .tar.gz,
20# snapshots. Feel free to report snapshotting services which aren't 21# .tar.bz2 & .tar.xz). For any other file format (or suffix) it will
21# working. 22# fall back to regular unpack. Support for additional formats may be
23# added at some point so please keep your SRC_URIs clean.
24#
22# @EXAMPLE: 25# @EXAMPLE:
23# 26#
24# @CODE 27# @CODE
25# EAPI=4 28# EAPI=4
26# AUTOTOOLS_AUTORECONF=1 29# AUTOTOOLS_AUTORECONF=1
27# inherit autotools-utils vcs-snapshot 30# inherit autotools-utils vcs-snapshot
28# 31#
29# SRC_URI="http://github.com/example/${PN}/tarball/v${PV} -> ${P}.tar.gz" 32# SRC_URI="http://github.com/example/${PN}/tarball/v${PV} -> ${P}.tar.gz"
30# @CODE 33# @CODE
34#
35# and however the tarball was originally named, all files will appear
36# in ${WORKDIR}/${P}.
31 37
32case ${EAPI:-0} in 38case ${EAPI:-0} in
33 0|1) die "EAPI ${EAPI} unsupported.";; # default(), SRC_URI arrows
34 2|3|4) ;; 39 0|1|2|3|4) ;;
35 *) die "vcs-snapshot.eclass API in EAPI ${EAPI} not yet established." 40 *) die "vcs-snapshot.eclass API in EAPI ${EAPI} not yet established."
36esac 41esac
37 42
38EXPORT_FUNCTIONS src_unpack 43EXPORT_FUNCTIONS src_unpack
39 44
40vcs-snapshot_src_unpack() { 45vcs-snapshot_src_unpack() {
41 default 46 local f
42 47
43 # github, bitbucket: username-projectname-hash 48 for f in ${A}
44 # gitweb: projectname-tagname-hash 49 do
45 mv *-*-[0-9a-f]*[0-9a-f]/ "${WORKDIR}"/${P} || die 50 case "${f}" in
51 *.tar|*.tar.gz|*.tar.bz2|*.tar.xz)
52 local destdir=${WORKDIR}/${f%.tar*}
53
54 # XXX: check whether the directory structure inside is
55 # fine? i.e. if the tarball has actually a parent dir.
56 mkdir "${destdir}" || die
57 tar -C "${destdir}" -x --strip-components 1 \
58 -f "${DISTDIR}/${f}" || die
59 ;;
60 *)
61 # fall back to the default method
62 unpack "${f}"
63 ;;
64 esac
65 done
46} 66}

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.20