commit: 2df56853ddc8b2a627c0c6167b8b1c9a2073f135 Author: Manuel Rüger <mrueg <AT> gentoo <DOT> org> AuthorDate: Thu Jun 25 10:44:07 2015 +0000 Commit: Manuel Rüger <mrueg <AT> gentoo <DOT> org> CommitDate: Thu Jun 25 10:44:07 2015 +0000 URL: https://gitweb.gentoo.org/dev/mrueg.git/commit/?id=2df56853
[eclass] Initial version of github.eclass. eclass/github.eclass | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/eclass/github.eclass b/eclass/github.eclass new file mode 100644 index 0000000..df0263d --- /dev/null +++ b/eclass/github.eclass @@ -0,0 +1,135 @@ +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: github.eclass +# @MAINTAINER: +# [email protected] +# @BLURB: Support eclass for packages hosted on Github. +# @DESCRIPTION: +# The github.eclass provides support for packages hosted on Github. + +if [[ -z ${_GH_ECLASS} ]]; then +_GH_ECLASS=1 + +case "${EAPI:-0}" in + 5) + ;; + *) + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" + ;; +esac + +# @ECLASS-VARIABLE: GH_USER +# @DESCRIPTION: +# Github user, usually a project or user. +: ${GH_USER:=${PN}} + +# @ECLASS-VARIABLE: GH_REPO +# @DESCRIPTION: +# Github repository name. +: ${GH_REPO:=${PN}} + +# @ECLASS-VARIABLE: GH_BUILD_TYPE +# @DESCRIPTION: +# Live ebuilds use "live" here. +: ${GH_BUILD_TYPE:=default} + +# @ECLASS-VARIABLE: GH_PATCHES +# @DEFAULT_UNSET +# @DESCRIPTION: +# Patches to be fetched and applied from Github by commit id. +# Example: +# @CODE +# GH_PATCHES=( "b02c39fb8dec9043b0ac9d23d5caec19b8b0c337" ) +# @CODE + +# @ECLASS-VARIABLE: GH_TAG +# @DESCRIPTION: +# Tag/commit that is fetched from Github. +: ${GH_TAG:=${PV}} + + +inherit eutils + +if [[ ${PV} == *9999 ]]; then + GH_BUILD_TYPE=live +fi + +if [[ ${GH_BUILD_TYPE} = live ]]; then + inherit git-r3 +fi + +if [[ ${GH_BUILD_TYPE} = default ]]; then + inherit vcs-snapshot +fi + +HOMEPAGE="https://github.com/${GH_USER}/${GH_REPO}" + +EXPORT_FUNCTIONS src_prepare src_unpack + +# If patches are fetched, calculate their location +_calculate_patches_uri() { + if [[ -n $GH_PATCHES ]]; then + _GH_PATCHES= + for gh_commit in "${GH_PATCHES[@]}"; do + SRC_URI=+" https://github.com/${GH_USER}/${GH_REPO}/commit/${gh_commit}.patch -> ${PN}-${gh_commit}.patch" + _GH_PATCHES+=( "${DISTDIR}"/${PN}-${gh_commit}.patch ) + done + fi +} + + +# Determine fetch location for tarballs and patches +_calculate_src_uri() { + debug-print-function ${FUNCNAME} "$@" + SRC_URI="https://github.com/${GH_USER}/${GH_REPO}/archive/${GH_TAG}.tar.gz -> ${P}.tar.gz" +} + +# Determine fetch location for live sources +_calculate_live_repo() { + debug-print-function ${FUNCNAME} "$@" + + SRC_URI="" + # @ECLASS-VARIABLE: EGIT_MIRROR + # @DESCRIPTION: + # This variable allows easy overriding of default kde mirror service + # (anongit) with anything else you might want to use. + EGIT_MIRROR=${EGIT_MIRROR:=https://github.com} + + EGIT_REPO_URI="${EGIT_MIRROR}/${GH_USER}/${GH_REPO}.git" +} + + +case ${GH_BUILD_TYPE} in + live) _calculate_live_repo ;; + default) _calculate_src_uri ;; +esac +_calculate_patches_uri + +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}" + +# @FUNCTION: github_src_unpack +# @DESCRIPTION: +# Function for unpacking Github packages. +github_src_unpack() { + debug-print-function ${FUNCNAME} "$@" + + if [[ ${GH_BUILD_TYPE} = live ]]; then + git-r3_src_unpack + else + vcs-snapshot_src_unpack + fi +} + + +# @FUNCTION: github_src_unpack +# @DESCRIPTION: +# Function for applying patches to Github packages. +github_src_prepare() { + [[ $_GH_PATCHES ]] && epatch "${_GH_PATCHES[@]}" + epatch_user + default +} + +fi
