diff options
author | Conley Owens <cco3@android.com> | 2012-10-01 16:12:28 -0700 |
---|---|---|
committer | Conley Owens <cco3@android.com> | 2012-10-25 17:48:35 -0700 |
commit | c9129d90deb7377324b5178a231657e3d8c74019 (patch) | |
tree | f0dd3f9ade22e48f4ab9cb8447a360e2e01a5aca | |
parent | 57365c98cc227255f50ab3d71462204c804eb975 (diff) | |
download | git-repo-c9129d90deb7377324b5178a231657e3d8c74019.tar.gz |
Update PGP keys during _PostRepoUpgrade in `sync`
Previously, if a key was added, a client wouldn't add the key during
the sync step. This would cause issues if a new key were added and a
subsequent release were signed by that key.
Change-Id: I4fac317573cd9d0e8da62aa42e00faf08bfeb26c
-rwxr-xr-x | main.py | 18 | ||||
-rwxr-xr-x | repo | 14 | ||||
-rw-r--r-- | subcmds/sync.py | 8 |
3 files changed, 22 insertions, 18 deletions
@@ -23,6 +23,7 @@ if __name__ == '__main__': | |||
23 | del magic | 23 | del magic |
24 | 24 | ||
25 | import getpass | 25 | import getpass |
26 | import imp | ||
26 | import netrc | 27 | import netrc |
27 | import optparse | 28 | import optparse |
28 | import os | 29 | import os |
@@ -167,16 +168,15 @@ def _MyRepoPath(): | |||
167 | def _MyWrapperPath(): | 168 | def _MyWrapperPath(): |
168 | return os.path.join(os.path.dirname(__file__), 'repo') | 169 | return os.path.join(os.path.dirname(__file__), 'repo') |
169 | 170 | ||
171 | _wrapper_module = None | ||
172 | def WrapperModule(): | ||
173 | global _wrapper_module | ||
174 | if not _wrapper_module: | ||
175 | _wrapper_module = imp.load_source('wrapper', _MyWrapperPath()) | ||
176 | return _wrapper_module | ||
177 | |||
170 | def _CurrentWrapperVersion(): | 178 | def _CurrentWrapperVersion(): |
171 | VERSION = None | 179 | return WrapperModule().VERSION |
172 | pat = re.compile(r'^VERSION *=') | ||
173 | fd = open(_MyWrapperPath()) | ||
174 | for line in fd: | ||
175 | if pat.match(line): | ||
176 | fd.close() | ||
177 | exec line | ||
178 | return VERSION | ||
179 | raise NameError, 'No VERSION in repo script' | ||
180 | 180 | ||
181 | def _CheckWrapperVersion(ver, repo_path): | 181 | def _CheckWrapperVersion(ver, repo_path): |
182 | if not repo_path: | 182 | if not repo_path: |
@@ -28,7 +28,7 @@ if __name__ == '__main__': | |||
28 | del magic | 28 | del magic |
29 | 29 | ||
30 | # increment this whenever we make important changes to this script | 30 | # increment this whenever we make important changes to this script |
31 | VERSION = (1, 17) | 31 | VERSION = (1, 18) |
32 | 32 | ||
33 | # increment this if the MAINTAINER_KEYS block is modified | 33 | # increment this if the MAINTAINER_KEYS block is modified |
34 | KEYRING_VERSION = (1,0) | 34 | KEYRING_VERSION = (1,0) |
@@ -80,7 +80,7 @@ TACbBS+Up3RpfYVfd63c1cDdlru13pQAn3NQy/SN858MkxN+zym86UBgOad2 | |||
80 | GIT = 'git' # our git command | 80 | GIT = 'git' # our git command |
81 | MIN_GIT_VERSION = (1, 5, 4) # minimum supported git version | 81 | MIN_GIT_VERSION = (1, 5, 4) # minimum supported git version |
82 | repodir = '.repo' # name of repo's private directory | 82 | repodir = '.repo' # name of repo's private directory |
83 | S_repo = 'repo' # special repo reposiory | 83 | S_repo = 'repo' # special repo repository |
84 | S_manifests = 'manifests' # special manifest repository | 84 | S_manifests = 'manifests' # special manifest repository |
85 | REPO_MAIN = S_repo + '/main.py' # main script | 85 | REPO_MAIN = S_repo + '/main.py' # main script |
86 | 86 | ||
@@ -130,7 +130,7 @@ group.add_option('-g', '--groups', | |||
130 | metavar='GROUP') | 130 | metavar='GROUP') |
131 | group.add_option('-p', '--platform', | 131 | group.add_option('-p', '--platform', |
132 | dest='platform', default="auto", | 132 | dest='platform', default="auto", |
133 | help='restrict manifest projects to ones with a specified' | 133 | help='restrict manifest projects to ones with a specified ' |
134 | 'platform group [auto|all|none|linux|darwin|...]', | 134 | 'platform group [auto|all|none|linux|darwin|...]', |
135 | metavar='PLATFORM') | 135 | metavar='PLATFORM') |
136 | 136 | ||
@@ -196,8 +196,8 @@ def _Init(args): | |||
196 | 196 | ||
197 | _CheckGitVersion() | 197 | _CheckGitVersion() |
198 | try: | 198 | try: |
199 | if _NeedSetupGnuPG(): | 199 | if NeedSetupGnuPG(): |
200 | can_verify = _SetupGnuPG(opt.quiet) | 200 | can_verify = SetupGnuPG(opt.quiet) |
201 | else: | 201 | else: |
202 | can_verify = True | 202 | can_verify = True |
203 | 203 | ||
@@ -246,7 +246,7 @@ def _CheckGitVersion(): | |||
246 | raise CloneFailure() | 246 | raise CloneFailure() |
247 | 247 | ||
248 | 248 | ||
249 | def _NeedSetupGnuPG(): | 249 | def NeedSetupGnuPG(): |
250 | if not os.path.isdir(home_dot_repo): | 250 | if not os.path.isdir(home_dot_repo): |
251 | return True | 251 | return True |
252 | 252 | ||
@@ -264,7 +264,7 @@ def _NeedSetupGnuPG(): | |||
264 | return False | 264 | return False |
265 | 265 | ||
266 | 266 | ||
267 | def _SetupGnuPG(quiet): | 267 | def SetupGnuPG(quiet): |
268 | if not os.path.isdir(home_dot_repo): | 268 | if not os.path.isdir(home_dot_repo): |
269 | try: | 269 | try: |
270 | os.mkdir(home_dot_repo) | 270 | os.mkdir(home_dot_repo) |
diff --git a/subcmds/sync.py b/subcmds/sync.py index a4ca344a..a7df7c89 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -46,6 +46,7 @@ except ImportError: | |||
46 | 46 | ||
47 | from git_command import GIT | 47 | from git_command import GIT |
48 | from git_refs import R_HEADS, HEAD | 48 | from git_refs import R_HEADS, HEAD |
49 | from main import WrapperModule | ||
49 | from project import Project | 50 | from project import Project |
50 | from project import RemoteSpec | 51 | from project import RemoteSpec |
51 | from command import Command, MirrorSafeCommand | 52 | from command import Command, MirrorSafeCommand |
@@ -537,7 +538,7 @@ uncommitted changes are present' % project.relpath | |||
537 | mp.PreSync() | 538 | mp.PreSync() |
538 | 539 | ||
539 | if opt.repo_upgraded: | 540 | if opt.repo_upgraded: |
540 | _PostRepoUpgrade(self.manifest) | 541 | _PostRepoUpgrade(self.manifest, opt) |
541 | 542 | ||
542 | if not opt.local_only: | 543 | if not opt.local_only: |
543 | mp.Sync_NetworkHalf(quiet=opt.quiet, | 544 | mp.Sync_NetworkHalf(quiet=opt.quiet, |
@@ -611,7 +612,10 @@ uncommitted changes are present' % project.relpath | |||
611 | if self.manifest.notice: | 612 | if self.manifest.notice: |
612 | print self.manifest.notice | 613 | print self.manifest.notice |
613 | 614 | ||
614 | def _PostRepoUpgrade(manifest): | 615 | def _PostRepoUpgrade(manifest, opt): |
616 | wrapper = WrapperModule() | ||
617 | if wrapper.NeedSetupGnuPG(): | ||
618 | wrapper.SetupGnuPG(opt.quiet) | ||
615 | for project in manifest.projects.values(): | 619 | for project in manifest.projects.values(): |
616 | if project.Exists: | 620 | if project.Exists: |
617 | project.PostRepoUpgrade() | 621 | project.PostRepoUpgrade() |