# 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.2 2012/03/19 08:52:49 mgorny Exp $ # @ECLASS: vcs-snapshot.eclass # @MAINTAINER: # mgorny@gentoo.org # @BLURB: support eclass for VCS (github, bitbucket, gitweb) snapshots # @DESCRIPTION: # This eclass provides a convenience src_unpack() which does support # working with snapshots generated by various VCS-es. It unpacks all tarballs # and zipballs according to their name into ${WORKDIR}/${name} # rather than the original directory containing commit id. # See example below. # # 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. # # Right now, the eclass was tested with github, bitbucket and gitweb # snapshots. Feel free to report snapshotting services which aren't # working. # @EXAMPLE: # # @CODE # EAPI=4 # AUTOTOOLS_AUTORECONF=1 # inherit autotools-utils vcs-snapshot # # SRC_URI="http://github.com/example/${PN}/tarball/v${PV} -> ${P}.tar.gz" # # # line above unpacks into: ${WORKDIR}/${P} # # SRC_URI="http://github.com/example/${PN}/tarball/v${PV} -> ${P}-src.tar.gz" # # would unpack into: ${WORKDIR}/${P}-src # @CODE case ${EAPI:-0} in 0|1) die "EAPI ${EAPI} unsupported.";; # default(), SRC_URI arrows 2|3|4) ;; *) die "vcs-snapshot.eclass API in EAPI ${EAPI} not yet established." esac EXPORT_FUNCTIONS src_unpack vcs-snapshot_src_unpack() { # github, bitbucket: username-projectname-hash # gitweb: projectname-tagname-hash local i local _tmpdir=${T}/_tmp mkdir "${_tmpdir}" || die pushd "${_tmpdir}" > /dev/null || die for i in ${A} ; do unpack ${i} case ${i} in *.tar.gz) mv "${_tmpdir}"/*/ "${WORKDIR}"/${i%.tar.gz} || die ;; *.tar.xz) mv "${_tmpdir}"/*/ "${WORKDIR}"/${i%.tar.xz} || die ;; *.tar.bz2) mv "${_tmpdir}"/*/ "${WORKDIR}"/${i%.tar.bz2} || die ;; *.zip) mv "${_tmpdir}"/*/ "${WORKDIR}"/${i%.zip} || die ;; *) mv "${_tmpdir}"/* "${WORKDIR}"/ ;; esac done popd > /dev/null }