Merge lp:~pfalcon/linaro-android-gerrit-support/manual-create into lp:linaro-android-gerrit-support

Proposed by Paul Sokolovsky
Status: Merged
Approved by: Paul Sokolovsky
Approved revision: 80
Merged at revision: 79
Proposed branch: lp:~pfalcon/linaro-android-gerrit-support/manual-create
Merge into: lp:linaro-android-gerrit-support
Diff against target: 153 lines (+43/-14)
4 files modified
android.git.linaro.org/create-new-projects.sh (+12/-2)
android.git.linaro.org/crontab (+1/-1)
git-gerrit-mirror (+18/-6)
mirror.conf (+12/-5)
To merge this branch: bzr merge lp:~pfalcon/linaro-android-gerrit-support/manual-create
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Approve
Linaro Infrastructure Pending
Review via email: mp+99060@code.launchpad.net

Description of the change

This is follow up to mails I sent to infra@ regarding issues with automatically creating new AOSP projects in our mirror and what to do about them.

With these changes, myself or another Gerrit admin can just run locally:

android.git.linaro.org/create-new-projects.sh --dest=admin

to create needed projects, without requiring to temporarily patch Gerrit group membership or git-gerrit-mirror config files.

To post a comment you must log in.
Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks fine to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'android.git.linaro.org/create-new-projects.sh'
2--- android.git.linaro.org/create-new-projects.sh 2012-03-15 13:49:14 +0000
3+++ android.git.linaro.org/create-new-projects.sh 2012-03-23 16:08:38 +0000
4@@ -15,10 +15,20 @@
5 exit 1
6 }
7
8+# Require explicit flag to clone new projects, to avoid spurious clones when
9+# when run on local system to just create new projects. Should be specified
10+# first, if any other options are given.
11+if [ "$1" == "--clone" ]; then
12+ clone=1
13+ shift
14+fi
15+
16 wget "$MANIFEST" -q -O manifest-for-create.xml || fatal "Error getting $MANIFEST"
17
18 ./git-gerrit-mirror --mirror-dir=$MIRROR_DIR \
19 create --upstream=google --manifest=manifest-for-create.xml $*
20
21-./git-gerrit-mirror --mirror-dir=$MIRROR_DIR \
22- clone --upstream=google --manifest=manifest-for-create.xml $*
23+if [ -n "$clone" ]; then
24+ ./git-gerrit-mirror --mirror-dir=$MIRROR_DIR \
25+ clone --upstream=google --manifest=manifest-for-create.xml $*
26+fi
27
28=== modified file 'android.git.linaro.org/crontab'
29--- android.git.linaro.org/crontab 2012-03-16 15:50:36 +0000
30+++ android.git.linaro.org/crontab 2012-03-23 16:08:38 +0000
31@@ -4,4 +4,4 @@
32
33 0 2,14 * * * (cd ~/linaro-android-gerrit-support; android.git.linaro.org/cron-runner.sh fetch) || echo "Fetch error"
34 30 2,14 * * * (cd ~/linaro-android-gerrit-support; android.git.linaro.org/cron-runner.sh push --force) || echo "Push error"
35-0 15 * * * * (cd ~/linaro-android-gerrit-support; android.git.linaro.org/create-new-projects.sh)
36+0 15 * * * * (cd ~/linaro-android-gerrit-support; android.git.linaro.org/create-new-projects.sh --clone)
37
38=== modified file 'git-gerrit-mirror'
39--- git-gerrit-mirror 2012-03-15 13:47:45 +0000
40+++ git-gerrit-mirror 2012-03-23 16:08:38 +0000
41@@ -9,7 +9,7 @@
42
43
44 # Magic name for mirror destination host
45-DEST = "DESTINATION"
46+DEST_KEYWORD = "DESTINATION"
47
48 log = logging.getLogger(__file__)
49
50@@ -46,7 +46,7 @@
51 if l[0] == "[":
52 self.store_host_exceptions(host, host_vars, host_exceptions)
53 host = l[1:-1]
54- if host != DEST:
55+ if not host.startswith(DEST_KEYWORD):
56 assert "://" in host, "URL schema is required in " + l
57 assert "/" not in host.split("://")[1], "Only hostname (no path) allowed in " + l
58 host_exceptions = {}
59@@ -69,11 +69,14 @@
60 in_file.close()
61
62 def get_hosts(self, substr_match=""):
63- return sorted([h for h in self.host_map.keys() if substr_match in h and h != DEST])
64+ return sorted([h for h in self.host_map.keys() if substr_match in h and not h.startswith(DEST_KEYWORD)])
65
66 def get_var(self, host, var):
67 return self.host_map[host][0].get(var)
68
69+ def has_host(self, host):
70+ return host in self.host_map
71+
72 def get_mirror_repo(self, host, source_repo):
73 """Get mirror path for a repo. By default it is equal
74 to source path, but if exception was defined, it is different."""
75@@ -148,7 +151,7 @@
76
77 for p in projects:
78 run_command("ssh -p %s %s gerrit create-project --name %s" %
79- (conf.get_var(DEST, "gerrit_port"), conf.get_var(DEST, "gerrit_host"), p))
80+ (conf.get_var(options.dest, "gerrit_port"), conf.get_var(options.dest, "gerrit_host"), p))
81
82 def clone_repos(host, basedir, projects):
83 "Clone-mirror repos from remote server"
84@@ -186,7 +189,8 @@
85 mirror_projname = conf.get_mirror_repo(host, projname)
86 os.chdir(abspath)
87 force_opt = " --force" if force else ""
88- cmdline = "git push%s %s/%s.git 'refs/heads/*' 'refs/tags/*'" % (force_opt, conf.get_var(DEST, "repo_root"), mirror_projname)
89+ repo_root = conf.get_var(options.dest, "repo_root")
90+ cmdline = "git push%s %s/%s.git 'refs/heads/*' 'refs/tags/*'" % (force_opt, repo_root, mirror_projname)
91 run_command(cmdline)
92
93 def check_args(optparser, args, expected):
94@@ -212,6 +216,8 @@
95 help="Use manifest for list of upstream projects (overrides $gerrit in config)")
96 optparser.add_option("--upstream", metavar="SUBSTR", default="",
97 help="Process only upstreams matching SUBSTR")
98+optparser.add_option("--dest", default="",
99+ help="Use alternative destination as specified in mirror.conf")
100 optparser.add_option("--force", action="store_true",
101 help="Pass --force to git commands where applicable")
102 optparser.add_option("--dry-run", action="store_true",
103@@ -227,10 +233,16 @@
104
105 options.mirror_dir = os.path.abspath(options.mirror_dir)
106 conf = MirrorConfig(options.config)
107+dest = options.dest
108+if dest:
109+ dest = "-" + dest
110+options.dest = DEST_KEYWORD + dest
111
112 if args[0] == "create":
113 check_args(optparser, args, 1)
114- existing_projects = get_gerrit_projects("%s:%s" % (conf.get_var(DEST, "gerrit_host"), conf.get_var(DEST, "gerrit_port")))
115+ gerrit_host = conf.get_var(options.dest, "gerrit_host")
116+ gerrit_port = conf.get_var(options.dest, "gerrit_port")
117+ existing_projects = get_gerrit_projects("%s:%s" % (gerrit_host, gerrit_port))
118 for host in conf.get_hosts(options.upstream):
119 log.debug("=== Processing: %s ===", host)
120 projects = get_project_map_for_a_host(host).values()
121
122=== modified file 'mirror.conf'
123--- mirror.conf 2012-03-13 16:19:21 +0000
124+++ mirror.conf 2012-03-23 16:08:38 +0000
125@@ -1,16 +1,23 @@
126 [DESTINATION]
127-# Usecase 1: target is Gerrit
128-#$repo_root = ssh://pfalcon@android.git.linaro.org:29418
129-#$gerrit_host = pfalcon@android.git.linaro.org
130+# Usecase 1: target is Gerrit, run as automatic cronjob
131 $repo_root = ssh://linaro-aosp-sync-bot@gerrit-git:29418
132 $gerrit_host = linaro-aosp-sync-bot@gerrit-git
133 $gerrit_port = 29418
134
135+[DESTINATION-admin]
136+# Usecase 2: target is Gerrit, run locally by Gerrit admin
137+# (e.g. to create projects)
138+$repo_root = ssh://android.git.linaro.org:29418
139+$gerrit_host = android.git.linaro.org
140+$gerrit_port = 29418
141+
142+[DESTINATION-git]
143 # Usecase 2: target is a remote tree
144-#$repo_root = ssh://somewhere.org/git
145+$repo_root = ssh://somewhere.org/git
146
147+[DESTINATION-local]
148 # Usecase 3: target is a local tree (e.g. for testing)
149-#$repo_root = /mnt/gerrit-git-snapshot/git
150+$repo_root = /mnt/gerrit-git-snapshot/git
151
152 [git://android.git.kernel.org]
153 $active = false

Subscribers

People subscribed via source and target branches