1 |
commit: 09891390cbd41240bfcacb32d3feb5bbfd4034aa |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Aug 29 21:03:50 2015 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Aug 30 23:46:19 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=09891390 |
7 |
|
8 |
RsyncSync: add sync-rsync-vcs-ignore option (bug 296085) |
9 |
|
10 |
If "sync-rsync-vcs-ignore = true" is set in repos.conf, then ignore |
11 |
any vcs directories that may be present. It is the user's responsibility |
12 |
to set sync-rsync-extra-opts to protect vcs directories if appropriate. |
13 |
|
14 |
X-Gentoo-Bug: 296085 |
15 |
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=296085 |
16 |
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org> |
17 |
|
18 |
man/portage.5 | 6 ++++++ |
19 |
pym/portage/repository/config.py | 3 ++- |
20 |
pym/portage/sync/modules/rsync/__init__.py | 5 ++++- |
21 |
pym/portage/sync/modules/rsync/rsync.py | 11 ++++++++--- |
22 |
4 files changed, 20 insertions(+), 5 deletions(-) |
23 |
|
24 |
diff --git a/man/portage.5 b/man/portage.5 |
25 |
index e84142a..8e2be4f 100644 |
26 |
--- a/man/portage.5 |
27 |
+++ b/man/portage.5 |
28 |
@@ -1026,6 +1026,12 @@ is provided, Portage no longer uses owner of the directory. |
29 |
Extra options to give to rsync on repository synchronization. It takes |
30 |
precedence over a declaration in [DEFAULT] section, that takes |
31 |
precedence over PORTAGE_RSYNC_EXTRA_OPTS. |
32 |
+.TP |
33 |
+.B sync-rsync-vcs-ignore = true|false |
34 |
+Ignore vcs directories that may be present in the repository. It is the |
35 |
+user's responsibility to set sync-rsync-extra-opts to protect vcs |
36 |
+directories if appropriate. |
37 |
+ |
38 |
.RE |
39 |
|
40 |
.I Example: |
41 |
|
42 |
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py |
43 |
index a416882..f80bee6 100644 |
44 |
--- a/pym/portage/repository/config.py |
45 |
+++ b/pym/portage/repository/config.py |
46 |
@@ -601,7 +601,8 @@ class RepoConfigLoader(object): |
47 |
|
48 |
repo = RepoConfig(sname, optdict, local_config=local_config) |
49 |
for o in portage.sync.module_specific_options(repo): |
50 |
- repo.set_module_specific_opt(o, parser.get(sname, o)) |
51 |
+ if parser.has_option(sname, o): |
52 |
+ repo.set_module_specific_opt(o, parser.get(sname, o)) |
53 |
|
54 |
# Perform repos.conf sync variable validation |
55 |
portage.sync.validate_config(repo, logging) |
56 |
|
57 |
diff --git a/pym/portage/sync/modules/rsync/__init__.py b/pym/portage/sync/modules/rsync/__init__.py |
58 |
index f2bad09..b863463 100644 |
59 |
--- a/pym/portage/sync/modules/rsync/__init__.py |
60 |
+++ b/pym/portage/sync/modules/rsync/__init__.py |
61 |
@@ -23,7 +23,10 @@ module_spec = { |
62 |
'exists': 'Returns a boolean if the specified directory exists', |
63 |
}, |
64 |
'validate_config': CheckSyncConfig, |
65 |
- 'module_specific_options': ('sync-rsync-extra-opts',), |
66 |
+ 'module_specific_options': ( |
67 |
+ 'sync-rsync-extra-opts', |
68 |
+ 'sync-rsync-vcs-ignore', |
69 |
+ ), |
70 |
} |
71 |
} |
72 |
} |
73 |
|
74 |
diff --git a/pym/portage/sync/modules/rsync/rsync.py b/pym/portage/sync/modules/rsync/rsync.py |
75 |
index f08bf5c..8ae8a5c 100644 |
76 |
--- a/pym/portage/sync/modules/rsync/rsync.py |
77 |
+++ b/pym/portage/sync/modules/rsync/rsync.py |
78 |
@@ -55,12 +55,17 @@ class RsyncSync(NewBase): |
79 |
enter_invalid = '--ask-enter-invalid' in opts |
80 |
out = portage.output.EOutput() |
81 |
syncuri = self.repo.sync_uri |
82 |
- vcs_dirs = frozenset(VCS_DIRS) |
83 |
- vcs_dirs = vcs_dirs.intersection(os.listdir(self.repo.location)) |
84 |
+ if self.repo.module_specific_options.get( |
85 |
+ 'sync-rsync-vcs-ignore', 'false').lower() == 'true': |
86 |
+ vcs_dirs = () |
87 |
+ else: |
88 |
+ vcs_dirs = frozenset(VCS_DIRS) |
89 |
+ vcs_dirs = vcs_dirs.intersection(os.listdir(self.repo.location)) |
90 |
|
91 |
for vcs_dir in vcs_dirs: |
92 |
writemsg_level(("!!! %s appears to be under revision " + \ |
93 |
- "control (contains %s).\n!!! Aborting rsync sync.\n") % \ |
94 |
+ "control (contains %s).\n!!! Aborting rsync sync " |
95 |
+ "(override with \"sync-rsync-vcs-ignore = true\" in repos.conf).\n") % \ |
96 |
(self.repo.location, vcs_dir), level=logging.ERROR, noiselevel=-1) |
97 |
return (1, False) |
98 |
self.timeout=180 |