1 |
commit: 2df56853ddc8b2a627c0c6167b8b1c9a2073f135 |
2 |
Author: Manuel Rüger <mrueg <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 25 10:44:07 2015 +0000 |
4 |
Commit: Manuel Rüger <mrueg <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 25 10:44:07 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/dev/mrueg.git/commit/?id=2df56853 |
7 |
|
8 |
[eclass] Initial version of github.eclass. |
9 |
|
10 |
eclass/github.eclass | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 135 insertions(+) |
12 |
|
13 |
diff --git a/eclass/github.eclass b/eclass/github.eclass |
14 |
new file mode 100644 |
15 |
index 0000000..df0263d |
16 |
--- /dev/null |
17 |
+++ b/eclass/github.eclass |
18 |
@@ -0,0 +1,135 @@ |
19 |
+# Copyright 1999-2015 Gentoo Foundation |
20 |
+# Distributed under the terms of the GNU General Public License v2 |
21 |
+# $Header: $ |
22 |
+ |
23 |
+# @ECLASS: github.eclass |
24 |
+# @MAINTAINER: |
25 |
+# mrueg@g.o |
26 |
+# @BLURB: Support eclass for packages hosted on Github. |
27 |
+# @DESCRIPTION: |
28 |
+# The github.eclass provides support for packages hosted on Github. |
29 |
+ |
30 |
+if [[ -z ${_GH_ECLASS} ]]; then |
31 |
+_GH_ECLASS=1 |
32 |
+ |
33 |
+case "${EAPI:-0}" in |
34 |
+ 5) |
35 |
+ ;; |
36 |
+ *) |
37 |
+ die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" |
38 |
+ ;; |
39 |
+esac |
40 |
+ |
41 |
+# @ECLASS-VARIABLE: GH_USER |
42 |
+# @DESCRIPTION: |
43 |
+# Github user, usually a project or user. |
44 |
+: ${GH_USER:=${PN}} |
45 |
+ |
46 |
+# @ECLASS-VARIABLE: GH_REPO |
47 |
+# @DESCRIPTION: |
48 |
+# Github repository name. |
49 |
+: ${GH_REPO:=${PN}} |
50 |
+ |
51 |
+# @ECLASS-VARIABLE: GH_BUILD_TYPE |
52 |
+# @DESCRIPTION: |
53 |
+# Live ebuilds use "live" here. |
54 |
+: ${GH_BUILD_TYPE:=default} |
55 |
+ |
56 |
+# @ECLASS-VARIABLE: GH_PATCHES |
57 |
+# @DEFAULT_UNSET |
58 |
+# @DESCRIPTION: |
59 |
+# Patches to be fetched and applied from Github by commit id. |
60 |
+# Example: |
61 |
+# @CODE |
62 |
+# GH_PATCHES=( "b02c39fb8dec9043b0ac9d23d5caec19b8b0c337" ) |
63 |
+# @CODE |
64 |
+ |
65 |
+# @ECLASS-VARIABLE: GH_TAG |
66 |
+# @DESCRIPTION: |
67 |
+# Tag/commit that is fetched from Github. |
68 |
+: ${GH_TAG:=${PV}} |
69 |
+ |
70 |
+ |
71 |
+inherit eutils |
72 |
+ |
73 |
+if [[ ${PV} == *9999 ]]; then |
74 |
+ GH_BUILD_TYPE=live |
75 |
+fi |
76 |
+ |
77 |
+if [[ ${GH_BUILD_TYPE} = live ]]; then |
78 |
+ inherit git-r3 |
79 |
+fi |
80 |
+ |
81 |
+if [[ ${GH_BUILD_TYPE} = default ]]; then |
82 |
+ inherit vcs-snapshot |
83 |
+fi |
84 |
+ |
85 |
+HOMEPAGE="https://github.com/${GH_USER}/${GH_REPO}" |
86 |
+ |
87 |
+EXPORT_FUNCTIONS src_prepare src_unpack |
88 |
+ |
89 |
+# If patches are fetched, calculate their location |
90 |
+_calculate_patches_uri() { |
91 |
+ if [[ -n $GH_PATCHES ]]; then |
92 |
+ _GH_PATCHES= |
93 |
+ for gh_commit in "${GH_PATCHES[@]}"; do |
94 |
+ SRC_URI=+" https://github.com/${GH_USER}/${GH_REPO}/commit/${gh_commit}.patch -> ${PN}-${gh_commit}.patch" |
95 |
+ _GH_PATCHES+=( "${DISTDIR}"/${PN}-${gh_commit}.patch ) |
96 |
+ done |
97 |
+ fi |
98 |
+} |
99 |
+ |
100 |
+ |
101 |
+# Determine fetch location for tarballs and patches |
102 |
+_calculate_src_uri() { |
103 |
+ debug-print-function ${FUNCNAME} "$@" |
104 |
+ SRC_URI="https://github.com/${GH_USER}/${GH_REPO}/archive/${GH_TAG}.tar.gz -> ${P}.tar.gz" |
105 |
+} |
106 |
+ |
107 |
+# Determine fetch location for live sources |
108 |
+_calculate_live_repo() { |
109 |
+ debug-print-function ${FUNCNAME} "$@" |
110 |
+ |
111 |
+ SRC_URI="" |
112 |
+ # @ECLASS-VARIABLE: EGIT_MIRROR |
113 |
+ # @DESCRIPTION: |
114 |
+ # This variable allows easy overriding of default kde mirror service |
115 |
+ # (anongit) with anything else you might want to use. |
116 |
+ EGIT_MIRROR=${EGIT_MIRROR:=https://github.com} |
117 |
+ |
118 |
+ EGIT_REPO_URI="${EGIT_MIRROR}/${GH_USER}/${GH_REPO}.git" |
119 |
+} |
120 |
+ |
121 |
+ |
122 |
+case ${GH_BUILD_TYPE} in |
123 |
+ live) _calculate_live_repo ;; |
124 |
+ default) _calculate_src_uri ;; |
125 |
+esac |
126 |
+_calculate_patches_uri |
127 |
+ |
128 |
+debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}" |
129 |
+ |
130 |
+# @FUNCTION: github_src_unpack |
131 |
+# @DESCRIPTION: |
132 |
+# Function for unpacking Github packages. |
133 |
+github_src_unpack() { |
134 |
+ debug-print-function ${FUNCNAME} "$@" |
135 |
+ |
136 |
+ if [[ ${GH_BUILD_TYPE} = live ]]; then |
137 |
+ git-r3_src_unpack |
138 |
+ else |
139 |
+ vcs-snapshot_src_unpack |
140 |
+ fi |
141 |
+} |
142 |
+ |
143 |
+ |
144 |
+# @FUNCTION: github_src_unpack |
145 |
+# @DESCRIPTION: |
146 |
+# Function for applying patches to Github packages. |
147 |
+github_src_prepare() { |
148 |
+ [[ $_GH_PATCHES ]] && epatch "${_GH_PATCHES[@]}" |
149 |
+ epatch_user |
150 |
+ default |
151 |
+} |
152 |
+ |
153 |
+fi |