| 1 |
mgorny |
1.6 |
# Copyright 1999-2013 Gentoo Foundation
|
| 2 |
mgorny |
1.1 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
mgorny |
1.6 |
# $Header: /var/cvsroot/gentoo-x86/eclass/vcs-snapshot.eclass,v 1.5 2012/09/27 16:35:42 axs Exp $
|
| 4 |
mgorny |
1.1 |
|
| 5 |
|
|
# @ECLASS: vcs-snapshot.eclass
|
| 6 |
|
|
# @MAINTAINER:
|
| 7 |
|
|
# mgorny@gentoo.org
|
| 8 |
mgorny |
1.4 |
# @BLURB: support eclass for unpacking VCS snapshot tarballs
|
| 9 |
mgorny |
1.1 |
# @DESCRIPTION:
|
| 10 |
mgorny |
1.4 |
# This eclass provides a convenience src_unpack() which does unpack all
|
| 11 |
|
|
# the tarballs in SRC_URI to locations matching their (local) names,
|
| 12 |
|
|
# discarding the original parent directory.
|
| 13 |
|
|
#
|
| 14 |
|
|
# The typical use case are VCS snapshots, coming from github, bitbucket
|
| 15 |
|
|
# and similar services. They have hash appended to the directory name
|
| 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.
|
| 19 |
|
|
#
|
| 20 |
|
|
# Please note that this eclass handles only tarballs (.tar, .tar.gz,
|
| 21 |
|
|
# .tar.bz2 & .tar.xz). For any other file format (or suffix) it will
|
| 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 |
|
|
#
|
| 25 |
mgorny |
1.1 |
# @EXAMPLE:
|
| 26 |
|
|
#
|
| 27 |
|
|
# @CODE
|
| 28 |
|
|
# EAPI=4
|
| 29 |
|
|
# AUTOTOOLS_AUTORECONF=1
|
| 30 |
|
|
# inherit autotools-utils vcs-snapshot
|
| 31 |
|
|
#
|
| 32 |
|
|
# SRC_URI="http://github.com/example/${PN}/tarball/v${PV} -> ${P}.tar.gz"
|
| 33 |
|
|
# @CODE
|
| 34 |
mgorny |
1.4 |
#
|
| 35 |
|
|
# and however the tarball was originally named, all files will appear
|
| 36 |
|
|
# in ${WORKDIR}/${P}.
|
| 37 |
mgorny |
1.1 |
|
| 38 |
|
|
case ${EAPI:-0} in
|
| 39 |
axs |
1.5 |
0|1|2|3|4|5) ;;
|
| 40 |
mgorny |
1.2 |
*) die "vcs-snapshot.eclass API in EAPI ${EAPI} not yet established."
|
| 41 |
mgorny |
1.1 |
esac
|
| 42 |
|
|
|
| 43 |
|
|
EXPORT_FUNCTIONS src_unpack
|
| 44 |
|
|
|
| 45 |
mgorny |
1.6 |
# @FUNCTION: vcs-snapshot_src_unpack
|
| 46 |
|
|
# @DESCRIPTION:
|
| 47 |
|
|
# Extract all the archives from ${A}. The .tar, .tar.gz, .tar.bz2
|
| 48 |
|
|
# and .tar.xz archives will be unpacked to directories matching their
|
| 49 |
|
|
# local names. Other archive types will be passed down to regular
|
| 50 |
|
|
# unpack.
|
| 51 |
mgorny |
1.1 |
vcs-snapshot_src_unpack() {
|
| 52 |
mgorny |
1.4 |
local f
|
| 53 |
|
|
|
| 54 |
|
|
for f in ${A}
|
| 55 |
|
|
do
|
| 56 |
|
|
case "${f}" in
|
| 57 |
|
|
*.tar|*.tar.gz|*.tar.bz2|*.tar.xz)
|
| 58 |
|
|
local destdir=${WORKDIR}/${f%.tar*}
|
| 59 |
mgorny |
1.1 |
|
| 60 |
mgorny |
1.4 |
# XXX: check whether the directory structure inside is
|
| 61 |
|
|
# fine? i.e. if the tarball has actually a parent dir.
|
| 62 |
|
|
mkdir "${destdir}" || die
|
| 63 |
|
|
tar -C "${destdir}" -x --strip-components 1 \
|
| 64 |
|
|
-f "${DISTDIR}/${f}" || die
|
| 65 |
|
|
;;
|
| 66 |
|
|
*)
|
| 67 |
|
|
# fall back to the default method
|
| 68 |
|
|
unpack "${f}"
|
| 69 |
|
|
;;
|
| 70 |
|
|
esac
|
| 71 |
|
|
done
|
| 72 |
mgorny |
1.1 |
}
|