summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConley Owens <cco3@android.com>2012-10-01 16:12:28 -0700
committerConley Owens <cco3@android.com>2012-10-25 17:48:35 -0700
commitc9129d90deb7377324b5178a231657e3d8c74019 (patch)
treef0dd3f9ade22e48f4ab9cb8447a360e2e01a5aca
parent57365c98cc227255f50ab3d71462204c804eb975 (diff)
downloadgit-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-xmain.py18
-rwxr-xr-xrepo14
-rw-r--r--subcmds/sync.py8
3 files changed, 22 insertions, 18 deletions
diff --git a/main.py b/main.py
index d993ee4e..ba40d56b 100755
--- a/main.py
+++ b/main.py
@@ -23,6 +23,7 @@ if __name__ == '__main__':
23del magic 23del magic
24 24
25import getpass 25import getpass
26import imp
26import netrc 27import netrc
27import optparse 28import optparse
28import os 29import os
@@ -167,16 +168,15 @@ def _MyRepoPath():
167def _MyWrapperPath(): 168def _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
172def WrapperModule():
173 global _wrapper_module
174 if not _wrapper_module:
175 _wrapper_module = imp.load_source('wrapper', _MyWrapperPath())
176 return _wrapper_module
177
170def _CurrentWrapperVersion(): 178def _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
181def _CheckWrapperVersion(ver, repo_path): 181def _CheckWrapperVersion(ver, repo_path):
182 if not repo_path: 182 if not repo_path:
diff --git a/repo b/repo
index 7942851b..5f328a47 100755
--- a/repo
+++ b/repo
@@ -28,7 +28,7 @@ if __name__ == '__main__':
28del magic 28del 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
31VERSION = (1, 17) 31VERSION = (1, 18)
32 32
33# increment this if the MAINTAINER_KEYS block is modified 33# increment this if the MAINTAINER_KEYS block is modified
34KEYRING_VERSION = (1,0) 34KEYRING_VERSION = (1,0)
@@ -80,7 +80,7 @@ TACbBS+Up3RpfYVfd63c1cDdlru13pQAn3NQy/SN858MkxN+zym86UBgOad2
80GIT = 'git' # our git command 80GIT = 'git' # our git command
81MIN_GIT_VERSION = (1, 5, 4) # minimum supported git version 81MIN_GIT_VERSION = (1, 5, 4) # minimum supported git version
82repodir = '.repo' # name of repo's private directory 82repodir = '.repo' # name of repo's private directory
83S_repo = 'repo' # special repo reposiory 83S_repo = 'repo' # special repo repository
84S_manifests = 'manifests' # special manifest repository 84S_manifests = 'manifests' # special manifest repository
85REPO_MAIN = S_repo + '/main.py' # main script 85REPO_MAIN = S_repo + '/main.py' # main script
86 86
@@ -130,7 +130,7 @@ group.add_option('-g', '--groups',
130 metavar='GROUP') 130 metavar='GROUP')
131group.add_option('-p', '--platform', 131group.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
249def _NeedSetupGnuPG(): 249def 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
267def _SetupGnuPG(quiet): 267def 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
47from git_command import GIT 47from git_command import GIT
48from git_refs import R_HEADS, HEAD 48from git_refs import R_HEADS, HEAD
49from main import WrapperModule
49from project import Project 50from project import Project
50from project import RemoteSpec 51from project import RemoteSpec
51from command import Command, MirrorSafeCommand 52from 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
614def _PostRepoUpgrade(manifest): 615def _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()