Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-dev
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: Gentoo Developer Mailing List <gentoo-dev@g.o>
From: Michał Górny <mgorny@g.o>
Subject: RFC: vcs-snapshot-r1.eclass -- a better eclass for VCS snapshots (and others)
Date: Thu, 7 Jun 2012 23:49:52 +0200
Hello,

As it was pointed out, vcs-snapshot is unable to handle multiple
tarballs nicely. As fixing this would involve changing eclass API
(and they are packages which are known to break thanks to it), I'm
posting a new eclass for review. Of course, if the community insists,
I could just update the old eclass and fix the ebuilds broken that way.

The idea with the new eclass is to extract all supported archives
(which means .tar* at the point) into ${WORKDIR} subdirectories
matching their names. In other words, if you've got:

SRC_URI="http://foo/getbar -> ${P}.tar.bz2
	http://foo/getbaz -> ${P}-data.tar.bz2"

You'd get the contents in ${WORKDIR}/${P} and ${WORKDIR}/${P}-data
respectively.

A few things to note:

1) the implemention just dumbly uses 'tar --strip-components'. If it
hits a tarball without a single top-level directory, scary things will
happen;

2) only tarballs are handled, other archives are just passed through
to unpack;

3) at some point the eclass could be extended to handle more formats.
So if you've got other archives in your SRC_URI, please make sure they
are named consistently with the parent dir, so that they would not
relocate when support for that particular format is added.

By the way, the credit for the overall idea goes to hasufell.

-- 
Best regards,
Michał Górny
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: vcs-snapshot-r1.eclass
# @MAINTAINER:
# mgorny@g.o
# @BLURB: support eclass for unpacking VCS snapshot tarballs
# @DESCRIPTION:
# 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.
#
# 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.
#
# @EXAMPLE:
#
# @CODE
# EAPI=4
# AUTOTOOLS_AUTORECONF=1
# inherit autotools-utils vcs-snapshot-r1
#
# 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|2|3|4) ;;
	*) die "vcs-snapshot-r1.eclass API in EAPI ${EAPI} not yet established."
esac

EXPORT_FUNCTIONS src_unpack

vcs-snapshot-r1_src_unpack() {
	local f

	for f in ${A}
	do
		case "${f}" in
			*.tar|*.tar.gz|*.tar.bz2|*.tar.xz)
				local destdir=${WORKDIR}/${f%.tar*}

				# 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
}
Attachment:
signature.asc (PGP signature)
Replies:
Re: RFC: vcs-snapshot-r1.eclass -- a better eclass for VCS snapshots (and others)
-- Michael Weber
Re: RFC: vcs-snapshot-r1.eclass -- a better eclass for VCS snapshots (and others)
-- Michał Górny
Re: RFC: vcs-snapshot-r1.eclass -- a better eclass for VCS snapshots (and others)
-- Michał Górny
Re: RFC: vcs-snapshot-r1.eclass -- a better eclass for VCS snapshots (and others)
-- hasufell
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: [gentoo-commits] gentoo-x86 commit in media-sound/kid3: metadata.xml kid3-2.1.ebuild ChangeLog
Next by thread:
Re: RFC: vcs-snapshot-r1.eclass -- a better eclass for VCS snapshots (and others)
Previous by date:
Re: About forcing rebuilds of other packages issue
Next by date:
Re: About forcing rebuilds of other packages issue


Updated Jun 29, 2012

Summary: Archive of the gentoo-dev mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.