changeset 60:c8350f7d9834

new class to allow environment to be set using $HOME/buildbot-worker-env
author John W. Eaton <jwe@octave.org>
date Fri, 22 Mar 2024 07:06:14 -0400
parents d26ca1d27a39
children 10c1848313c6
files master.cfg
diffstat 1 files changed, 21 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/master.cfg	Thu Dec 28 13:56:48 2023 -0500
+++ b/master.cfg	Fri Mar 22 07:06:14 2024 -0400
@@ -263,6 +263,17 @@
 from buildbot.steps.shell import Compile
 from buildbot.steps.shell import Test
 
+## A class that allows the worker to use environment variables
+## from a file in ShellCommand steps.  We use this instead of
+## ShellCommand in all rules for the Octave buildbot.
+
+class EnvShellCommand (ShellCommand):
+  def __init__ (self, command = '', **kwargs):
+    kwargs['command'] = [
+      'bash', '-c', 'if [ -f "$HOME/buildbot-worker-env" ]; then source "$HOME/buildbot-worker-env"; fi; %s' % command
+    ]
+    ShellCommand.__init__ (self, **kwargs)
+
 ## Steps we may use in more than one build factory.
 
 def build_cmd_list (cmd, nice = 0, opts = []):
@@ -296,14 +307,14 @@
 
 def mk_octave_bootstrap_step (nice = 0):
   boot_cmd = build_cmd_list ("./bootstrap", nice = nice)
-  return ShellCommand (command = boot_cmd, workdir = "src", env = build_env,
-                       description = "bootstrap")
+  return EnvShellCommand (command = boot_cmd, workdir = "src", env = build_env,
+                          description = "bootstrap")
 
-sh_rm_build_dir = ShellCommand (command = ["rm", "-rf", "build"], workdir = ".",
-                                env = build_env, description = "clean build dir")
+sh_rm_build_dir = EnvShellCommand (command = ["rm", "-rf", "build"], workdir = ".",
+                                   env = build_env, description = "clean build dir")
 
-sh_mk_build_dir = ShellCommand (command = ["mkdir", "build"],
-                                description = "create build dir")
+sh_mk_build_dir = EnvShellCommand (command = ["mkdir", "build"],
+                                   description = "create build dir")
 
 def mk_octave_configure_step (nice = 0, opts = []):
   conf_cmd = build_cmd_list ("../src/configure", nice = nice, opts = opts)
@@ -650,8 +661,8 @@
 
 def mk_mxe_octave_bootstrap_step (nice = 0):
   boot_cmd = build_cmd_list ("./bootstrap", nice = nice)
-  return ShellCommand (command = boot_cmd, workdir = "src", env = build_env,
-                       description = "bootstrap")
+  return EnvShellCommand (command = boot_cmd, workdir = "src", env = build_env,
+                          description = "bootstrap")
 
 
 def mk_mxe_octave_configure_step (nice = 0, branch = "default", opts = []):
@@ -665,8 +676,8 @@
 
 def mk_mxe_octave_clean_step (nice = 0):
   boot_cmd = build_cmd_list (["make", "clean"], nice = nice)
-  return ShellCommand (command = boot_cmd, workdir = "src", env = build_env,
-                       description = "clean")
+  return EnvShellCommand (command = boot_cmd, workdir = "src", env = build_env,
+                          description = "clean")
 
 
 ## Timeout is large for these steps because mxe-octave currently only