@@ -94,6 +94,9 @@ if os.environ["ENVIRON"] == "DEV":
9494# worker name and password must be configured on the worker.
9595c ["workers" ] = []
9696
97+ # Docker workers
98+ GALERA_PACKAGES = os .environ ["GALERA_PACKAGES_DIR" ]
99+
97100c ["workers" ].append (
98101 worker .DockerLatentWorker (
99102 "hz-bbw1-docker-galera-trigger" ,
@@ -107,6 +110,7 @@ c["workers"].append(
107110 hostconfig = {"shm_size" : "1G" },
108111 max_builds = 1 ,
109112 build_wait_timeout = 0 ,
113+ volumes = [GALERA_PACKAGES + "/:/packages" ],
110114 )
111115)
112116
@@ -123,12 +127,10 @@ c["workers"].append(
123127 hostconfig = {"shm_size" : "1G" },
124128 max_builds = 1 ,
125129 build_wait_timeout = 0 ,
130+ volumes = [GALERA_PACKAGES + "/:/packages" ],
126131 )
127132)
128133
129- # Docker workers
130- GALERA_PACKAGES = os .environ ["GALERA_PACKAGES_DIR" ]
131-
132134workers = defaultdict (list )
133135
134136
@@ -241,6 +243,13 @@ def dpkgDeb():
241243 )
242244
243245
246+ def isPushToSavedBranch (step ):
247+ return step .getProperty ("event" ) == "push" and any (
248+ fnmatch .fnmatch (step .getProperty ("branch" ), pattern )
249+ for pattern in SAVED_PACKAGE_BRANCHES_GALERA
250+ )
251+
252+
244253def rpmSave ():
245254 return steps .ShellCommand (
246255 name = "move rpm files" ,
@@ -273,6 +282,51 @@ f_trigger_builds.addStep(
273282 doStepIf = waitIfStaging ,
274283 )
275284)
285+ f_trigger_builds .addStep (
286+ steps .GitHub (
287+ repourl = util .Property ("repository" ),
288+ mode = "full" ,
289+ method = "clobber" ,
290+ workdir = "build" ,
291+ submodules = True ,
292+ )
293+ )
294+ f_trigger_builds .addStep (
295+ steps .ShellCommand (
296+ name = "build source archive" ,
297+ haltOnFailure = True ,
298+ workdir = "build" ,
299+ command = [
300+ "bash" ,
301+ "-xc" ,
302+ """set -e
303+ ./scripts/build.sh -a
304+ galera_version=$(basename galera-*.tar.gz .tar.gz)
305+ dest=$PWD/$galera_version
306+ # build.sh's gen_source_archive uses `git checkout-index`, which is
307+ # submodule-unaware and leaves submodule dirs empty (the same gap GitHub
308+ # Releases tarballs have). Copy each submodule's checked-out content in
309+ # before repacking, so the archive is actually self-contained.
310+ git submodule foreach 'cp -rvi * "'"$dest"'/${path}/"'
311+ tar czf ${galera_version}.tar.gz ${galera_version}/
312+ """ ,
313+ ],
314+ )
315+ )
316+ f_trigger_builds .addStep (
317+ steps .ShellCommand (
318+ name = "save_source_archive" ,
319+ timeout = 7200 ,
320+ haltOnFailure = True ,
321+ command = util .Interpolate (
322+ """set -e
323+ mkdir -p /packages/%(prop:branch)s/%(prop:revision)s
324+ cp -v galera-*.tar.gz /packages/%(prop:branch)s/%(prop:revision)s/
325+ """
326+ ),
327+ doStepIf = (lambda step : isPushToSavedBranch (step )),
328+ )
329+ )
276330
277331## f_deb_build - create source tarball
278332f_deb_build = util .BuildFactory ()
0 commit comments