Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH] sync: allow overriding sync-umask for the repository
Date: Sun, 07 Dec 2014 09:00:14
Message-Id: 1417942801-21893-1-git-send-email-mgorny@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH 1/4] sync: allow overriding sync-umask for the repository by Zac Medico
1 ---
2 Changes:
3 * added a entry in the manpage
4
5 man/portage.5 | 5 +++++
6 pym/portage/repository/config.py | 16 ++++++++++++----
7 pym/portage/sync/controller.py | 3 +++
8 3 files changed, 20 insertions(+), 4 deletions(-)
9
10 diff --git a/man/portage.5 b/man/portage.5
11 index 150294b..8c3d389 100644
12 --- a/man/portage.5
13 +++ b/man/portage.5
14 @@ -901,6 +901,11 @@ Valid non\-empty values: cvs, git, rsync
15 This attribute can be set to empty value to disable synchronization of given
16 repository. Empty value is default.
17 .TP
18 +.B sync\-umask
19 +Specifies umask used to synchronize the repository.
20 +.br
21 +Takes an octal permission mask, e.g. 022.
22 +.TP
23 .B sync\-uri
24 Specifies URI of repository used for synchronization performed by `emerge
25 \-\-sync`.
26 diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
27 index d37ce6a..678cc68 100644
28 --- a/pym/portage/repository/config.py
29 +++ b/pym/portage/repository/config.py
30 @@ -85,8 +85,9 @@ class RepoConfig(object):
31 'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name',
32 'name', 'portage1_profiles', 'portage1_profiles_compat', 'priority',
33 'profile_formats', 'sign_commit', 'sign_manifest', 'sync_cvs_repo',
34 - 'sync_type', 'sync_uri', 'thin_manifest', 'update_changelog',
35 - 'user_location', '_eapis_banned', '_eapis_deprecated', '_masters_orig')
36 + 'sync_type', 'sync_umask', 'sync_uri', 'thin_manifest',
37 + 'update_changelog', 'user_location', '_eapis_banned',
38 + '_eapis_deprecated', '_masters_orig')
39
40 def __init__(self, name, repo_opts, local_config=True):
41 """Build a RepoConfig with options in repo_opts
42 @@ -154,6 +155,11 @@ class RepoConfig(object):
43 sync_type = sync_type.strip()
44 self.sync_type = sync_type or None
45
46 + sync_umask = repo_opts.get('sync-umask')
47 + if sync_umask is not None:
48 + sync_umask = sync_umask.strip()
49 + self.sync_umask = sync_umask or None
50 +
51 sync_uri = repo_opts.get('sync-uri')
52 if sync_uri is not None:
53 sync_uri = sync_uri.strip()
54 @@ -375,6 +381,8 @@ class RepoConfig(object):
55 repo_msg.append(indent + "sync-cvs-repo: " + self.sync_cvs_repo)
56 if self.sync_type:
57 repo_msg.append(indent + "sync-type: " + self.sync_type)
58 + if self.sync_umask:
59 + repo_msg.append(indent + "sync-umask: " + self.sync_umask)
60 if self.sync_uri:
61 repo_msg.append(indent + "sync-uri: " + self.sync_uri)
62 if self.masters:
63 @@ -464,7 +472,7 @@ class RepoConfigLoader(object):
64 # repos.conf is allowed to override.
65 for k in ('aliases', 'auto_sync', 'eclass_overrides',
66 'force', 'masters', 'priority', 'sync_cvs_repo',
67 - 'sync_type', 'sync_uri',
68 + 'sync_type', 'sync_umask', 'sync_uri',
69 ):
70 v = getattr(repos_conf_opts, k, None)
71 if v is not None:
72 @@ -915,7 +923,7 @@ class RepoConfigLoader(object):
73 def config_string(self):
74 str_or_int_keys = ("auto_sync", "format", "location",
75 "main_repo", "priority", "sync_cvs_repo",
76 - "sync_type", "sync_uri")
77 + "sync_type", "sync_umask", "sync_uri")
78 str_tuple_keys = ("aliases", "eclass_overrides", "force")
79 repo_config_tuple_keys = ("masters",)
80 keys = str_or_int_keys + str_tuple_keys + repo_config_tuple_keys
81 diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py
82 index 41f3830..1c8c756 100644
83 --- a/pym/portage/sync/controller.py
84 +++ b/pym/portage/sync/controller.py
85 @@ -221,6 +221,9 @@ class SyncManager(object):
86 if not st.st_mode & 0o020:
87 umask = umask | 0o020
88 spawn_kwargs["umask"] = umask
89 + # override the defaults when sync_umask is set
90 + if repo.sync_umask is not None:
91 + spawn_kwargs["umask"] = int(repo.sync_umask, 8)
92 self.spawn_kwargs = spawn_kwargs
93
94 if self.usersync_uid is not None:
95 --
96 2.2.0