1 |
commit: 1c8f9f89ccac3382df4a0bfdddb6918b24489f69 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon May 23 19:51:57 2016 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu May 26 08:58:08 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1c8f9f89 |
7 |
|
8 |
git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164 |
9 |
|
10 |
eclass/git-r3.eclass | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++- |
11 |
1 file changed, 53 insertions(+), 1 deletion(-) |
12 |
|
13 |
diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass |
14 |
index 48249d2..a38472b 100644 |
15 |
--- a/eclass/git-r3.eclass |
16 |
+++ b/eclass/git-r3.eclass |
17 |
@@ -165,6 +165,32 @@ fi |
18 |
# |
19 |
# EGIT_CHECKOUT_DIR=${WORKDIR}/${P} |
20 |
|
21 |
+# @ECLASS-VARIABLE: EGIT_SUBMODULES |
22 |
+# @DEFAULT_UNSET |
23 |
+# @DESCRIPTION: |
24 |
+# An array of inclusive and exclusive wildcards on submodule names, |
25 |
+# stating which submodules are fetched and checked out. Exclusions |
26 |
+# start with '-', and exclude previously matched submodules. |
27 |
+# |
28 |
+# If unset, all submodules are enabled. Empty list disables all |
29 |
+# submodules. In order to use an exclude-only list, start the array |
30 |
+# with '*'. |
31 |
+# |
32 |
+# Remember that wildcards need to be quoted in order to prevent filename |
33 |
+# expansion. |
34 |
+# |
35 |
+# Examples: |
36 |
+# @CODE |
37 |
+# # Disable all submodules |
38 |
+# EGIT_SUBMODULES=() |
39 |
+# |
40 |
+# # Include only foo and bar |
41 |
+# EGIT_SUBMODULES=( foo bar ) |
42 |
+# |
43 |
+# # Use all submodules except for test-* but include test-lib |
44 |
+# EGIT_SUBMODULES=( '*' '-test-*' test-lib ) |
45 |
+# @CODE |
46 |
+ |
47 |
# @FUNCTION: _git-r3_env_setup |
48 |
# @INTERNAL |
49 |
# @DESCRIPTION: |
50 |
@@ -205,6 +231,11 @@ _git-r3_env_setup() { |
51 |
die "Invalid EGIT_MIN_CLONE_TYPE=${EGIT_MIN_CLONE_TYPE}" |
52 |
esac |
53 |
|
54 |
+ if [[ ${EGIT_SUBMODULES[@]+1} && $(declare -p EGIT_SUBMODULES) != "declare -a"* ]] |
55 |
+ then |
56 |
+ die 'EGIT_SUBMODULES must be an array.' |
57 |
+ fi |
58 |
+ |
59 |
local esc_pn livevar |
60 |
esc_pn=${PN//[-+]/_} |
61 |
|
62 |
@@ -243,7 +274,8 @@ _git-r3_env_setup() { |
63 |
if [[ ${EGIT_HAS_SUBMODULES} ]]; then |
64 |
eerror "EGIT_HAS_SUBMODULES has been removed. The eclass no longer needs" |
65 |
eerror "to switch the clone type in order to support submodules and therefore" |
66 |
- eerror "submodules are detected and fetched automatically." |
67 |
+ eerror "submodules are detected and fetched automatically. If you need to" |
68 |
+ eerror "disable or filter submodules, see EGIT_SUBMODULES." |
69 |
die "EGIT_HAS_SUBMODULES is no longer necessary." |
70 |
fi |
71 |
|
72 |
@@ -357,6 +389,26 @@ _git-r3_set_submodules() { |
73 |
l=${l#submodule.} |
74 |
local subname=${l%%.url=*} |
75 |
|
76 |
+ # filter out on EGIT_SUBMODULES |
77 |
+ if declare -p EGIT_SUBMODULES &>/dev/null; then |
78 |
+ local p l_res res= |
79 |
+ for p in "${EGIT_SUBMODULES[@]}"; do |
80 |
+ if [[ ${p} == -* ]]; then |
81 |
+ p=${p#-} |
82 |
+ l_res= |
83 |
+ else |
84 |
+ l_res=1 |
85 |
+ fi |
86 |
+ |
87 |
+ [[ ${subname} == ${p} ]] && res=${l_res} |
88 |
+ done |
89 |
+ |
90 |
+ if [[ ! ${res} ]]; then |
91 |
+ einfo "Skipping submodule \e[1m${subname}\e[22m" |
92 |
+ continue |
93 |
+ fi |
94 |
+ fi |
95 |
+ |
96 |
# skip modules that have 'update = none', bug #487262. |
97 |
local upd=$(echo "${data}" | git config -f /dev/fd/0 \ |
98 |
submodule."${subname}".update) |