1 |
When multiple Gentoo machines are used on the local network, and they |
2 |
use the same git ebuilds it may be useful to set a local mirror :). |
3 |
|
4 |
The idea is quite simple -- you set the host to EGIT_CLONE_TYPE=mirror, |
5 |
and then share the EGIT3_STORE_DIR directory. Then you set |
6 |
EGIT_MIRROR_URI on the remaining hosts and they try to fetch from your |
7 |
local mirror first. |
8 |
--- |
9 |
eclass/git-r3.eclass | 22 ++++++++++++++++++++++ |
10 |
1 file changed, 22 insertions(+) |
11 |
|
12 |
diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass |
13 |
index 7c78b66..8462fba 100644 |
14 |
--- a/eclass/git-r3.eclass |
15 |
+++ b/eclass/git-r3.eclass |
16 |
@@ -41,6 +41,20 @@ fi |
17 |
# |
18 |
# EGIT3_STORE_DIR=${DISTDIR}/git3-src |
19 |
|
20 |
+# @ECLASS-VARIABLE: EGIT_MIRROR_URI |
21 |
+# @DEFAULT_UNSET |
22 |
+# @DESCRIPTION: |
23 |
+# 'Top' URI to a local git mirror. If specified, the eclass will try |
24 |
+# to fetch from the local mirror instead of using the remote repository. |
25 |
+# |
26 |
+# The mirror needs to follow EGIT3_STORE_DIR structure. The directory |
27 |
+# created by eclass can be used for that purpose. |
28 |
+# |
29 |
+# Example: |
30 |
+# @CODE |
31 |
+# EGIT_MIRROR_URI="git://mirror.lan/" |
32 |
+# @CODE |
33 |
+ |
34 |
# @ECLASS-VARIABLE: EGIT_REPO_URI |
35 |
# @REQUIRED |
36 |
# @DESCRIPTION: |
37 |
@@ -358,6 +372,14 @@ git-r3_fetch() { |
38 |
local -x GIT_DIR |
39 |
_git-r3_set_gitdir "${repos[0]}" |
40 |
|
41 |
+ # prepend the local mirror if applicable |
42 |
+ if [[ ${EGIT_MIRROR_URI} ]]; then |
43 |
+ repos=( |
44 |
+ "${EGIT_MIRROR_URI%/}/${GIT_DIR##*/}" |
45 |
+ "${repos[@]}" |
46 |
+ ) |
47 |
+ fi |
48 |
+ |
49 |
# try to fetch from the remote |
50 |
local r success |
51 |
for r in "${repos[@]}"; do |
52 |
-- |
53 |
1.8.3.2 |