1 |
commit: b65dc4182faa8eddf83fc679855d54443db60049 |
2 |
Author: Manuel Rüger <mrueg <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 25 15:39:03 2015 +0000 |
4 |
Commit: Manuel Rüger <mrueg <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 25 15:39:03 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/dev/mrueg.git/commit/?id=b65dc418 |
7 |
|
8 |
[eclass] Rework patches. Add support for forks. |
9 |
|
10 |
eclass/github.eclass | 85 ++++++++++++++++++++++++++++++++++++++-------------- |
11 |
1 file changed, 62 insertions(+), 23 deletions(-) |
12 |
|
13 |
diff --git a/eclass/github.eclass b/eclass/github.eclass |
14 |
index a80d03d..ab5a66f 100644 |
15 |
--- a/eclass/github.eclass |
16 |
+++ b/eclass/github.eclass |
17 |
@@ -39,22 +39,16 @@ esac |
18 |
# @ECLASS-VARIABLE: GH_PATCHES |
19 |
# @DEFAULT_UNSET |
20 |
# @DESCRIPTION: |
21 |
-# Patches to be fetched and applied from Github by commit id. |
22 |
+# Patches, pull requests, patches from forks to be fetched and applied. |
23 |
+# Prefix: |
24 |
+# f: - Regular patch from FILESDIR |
25 |
+# c: - Patch identified by commit, optional: fork name |
26 |
+# p: - Patch identified by pull request id, optional: fork name |
27 |
# Example: |
28 |
# @CODE |
29 |
-# GH_PATCHES=("b02c39fb8dec9043b0ac9d23d5caec19b8b0c337" "b0c337b02c39fb8dec9043b0ac9d23d5caec19b8" ) |
30 |
+# GH_PATCHES=("c:b02c39fb8dec9043b0ac9d23d5caec19b8b0c337" "c:gentoo/b0c337b02c39fb8dec9043b0ac9d23d5caec19b8" "foo.patch" "p:1" "p:gentoo/17" ) |
31 |
# @CODE |
32 |
|
33 |
-# @ECLASS-VARIABLE: GH_PULLREQS |
34 |
-# @DEFAULT_UNSET |
35 |
-# @DESCRIPTION: |
36 |
-# Pull requests to be fetched and applied from Github by its id. |
37 |
-# Example: |
38 |
-# @CODE |
39 |
-# GH_PULLREQS=(17 19) |
40 |
-# @CODE |
41 |
- |
42 |
- |
43 |
# @ECLASS-VARIABLE: GH_TAG |
44 |
# @DESCRIPTION: |
45 |
# Tag/commit that is fetched from Github. |
46 |
@@ -63,6 +57,10 @@ esac |
47 |
|
48 |
inherit eutils |
49 |
|
50 |
+if [[ ${PV} != *9999 && ${GH_BUILD_TYPE} == live ]]; then |
51 |
+ eqawarn "Uncommon package version for a live ebuild." |
52 |
+fi |
53 |
+ |
54 |
if [[ -z ${GH_BUILD_TYPE} ]]; then |
55 |
if [[ ${PV} == *9999 ]]; then |
56 |
_GH_BUILD_TYPE=live |
57 |
@@ -85,27 +83,68 @@ HOMEPAGE="https://github.com/${GH_USER}/${GH_REPO}" |
58 |
|
59 |
EXPORT_FUNCTIONS src_prepare src_unpack |
60 |
|
61 |
+_patch_calc_commit() { |
62 |
+ debug-print-function ${FUNCNAME} "$@" |
63 |
+ |
64 |
+ local gh_filepatch="$1" |
65 |
+ _GH_PATCHES+=($gh_filepatch) |
66 |
+} |
67 |
+ |
68 |
+_patch_calc_commit() { |
69 |
+ debug-print-function ${FUNCNAME} "$@" |
70 |
+ |
71 |
+ local gh_patch="$1" |
72 |
+ local gh_commit=${gh_patch##*/} |
73 |
+ local gh_fork=${GH_USER} |
74 |
+ local gh_forkedby="" |
75 |
+ if [[ "${gh_patch}" == */* ]]; then |
76 |
+ gh_fork=${gh_patch%%/*} |
77 |
+ gh_forkedby=${gh_fork}- |
78 |
+ fi |
79 |
+ SRC_URI+=" https://github.com/${GH_USER}/${GH_REPO}/commit/${gh_commit}.patch -> ${PN}-${gh_forkedby}${gh_commit}.patch" |
80 |
+ _GH_PATCHES+=("${DISTDIR}"/${PN}-${gh_forkedby}${gh_commit}.patch) |
81 |
+} |
82 |
+ |
83 |
+_patch_calc_pull-request() { |
84 |
+ debug-print-function ${FUNCNAME} "$@" |
85 |
+ |
86 |
+ local gh_patch="$1" |
87 |
+ local gh_pullreq=${gh_patch##*/} |
88 |
+ local gh_fork=${GH_USER} |
89 |
+ local gh_forkedby="" |
90 |
+ |
91 |
+ if [[ "${gh_patch}" == */* ]]; then |
92 |
+ gh_fork=${gh_patch%%/*} |
93 |
+ gh_forkedby=${gh_fork}- |
94 |
+ fi |
95 |
+ |
96 |
+ SRC_URI+=" https://github.com/${gh_fork}/${GH_REPO}/pull/${gh_pullreq}.patch -> ${PN}-pr${gh_forkedby}-${gh_pullreq}.patch" |
97 |
+ _GH_PATCHES+=("${DISTDIR}"/${PN}-pr-${gh_forkedby}${gh_pullreq}.patch) |
98 |
+} |
99 |
|
100 |
# If patches are fetched, calculate their location |
101 |
_calculate_patches_uri() { |
102 |
if [[ -n $GH_PATCHES ]]; then |
103 |
for gh_commit in "${GH_PATCHES[@]}"; do |
104 |
- SRC_URI+=" https://github.com/${GH_USER}/${GH_REPO}/commit/${gh_commit}.patch -> ${PN}-${gh_commit}.patch" |
105 |
- _GH_PATCHES+=("${DISTDIR}"/${PN}-${gh_commit}.patch) |
106 |
+ case ${gh_commit:0:1} in |
107 |
+ f) _patch_calc_filesdir "${gh_commit:2}" |
108 |
+ ;; |
109 |
+ c) _patch_calc_commit "${gh_commit:2}" |
110 |
+ ;; |
111 |
+ p) _patch_calc-pull_request "${gh_commit:2}" |
112 |
+ ;; |
113 |
+ *) die "Wrong patch pattern: ${gh_commit}" |
114 |
+ ;; |
115 |
+ esac |
116 |
done |
117 |
fi |
118 |
- if [[ -n $GH_PULLREQ ]]; then |
119 |
- for gh_pullreq in "${GH_PULLREQS[@]}"; do |
120 |
- SRC_URI+=" https://github.com/${GH_USER}/${GH_REPO}/pull/${gh_pullreq}.patch -> ${PN}-pr-${gh_pullreq}.patch" |
121 |
- _GH_PATCHES+=("${DISTDIR}"/${PN}-pr-${gh_pullreq}.patch) |
122 |
- done |
123 |
- fi |
124 |
} |
125 |
|
126 |
|
127 |
# Determine fetch location for tarballs and patches |
128 |
_calculate_src_uri() { |
129 |
debug-print-function ${FUNCNAME} "$@" |
130 |
+ |
131 |
SRC_URI="https://github.com/${GH_USER}/${GH_REPO}/archive/${GH_TAG}.tar.gz -> ${P}.tar.gz" |
132 |
} |
133 |
|
134 |
@@ -115,9 +154,9 @@ _calculate_live_repo() { |
135 |
|
136 |
SRC_URI="" |
137 |
# @ECLASS-VARIABLE: EGIT_MIRROR |
138 |
- # @DESCRIPTION: |
139 |
- # This variable allows easy overriding of default kde mirror service |
140 |
- # (anongit) with anything else you might want to use. |
141 |
+ # @DESCRIPTION: |
142 |
+ # This variable allows easy overriding of github uri. |
143 |
+ # (uses https) with anything else you might want to use. |
144 |
EGIT_MIRROR=${EGIT_MIRROR:=https://github.com} |
145 |
|
146 |
EGIT_REPO_URI="${EGIT_MIRROR}/${GH_USER}/${GH_REPO}.git" |