From bb7b82b115ad53c48f26ac5641d4910ad501a202 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 16 Jul 2019 19:12:29 +0200 Subject: [PATCH] phase1: automatically setup shared work directory symlink Until now, the shared work directory symlinks had to be provisioned manually, this commits automates the setup when work directory sharing is enabled for the slave. Signed-off-by: Jo-Philipp Wich --- phase1/master.cfg | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/phase1/master.cfg b/phase1/master.cfg index a8abbc6..ff2f3e2 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -251,9 +251,11 @@ def IsMakeCleanRequested(pattern): return CheckCleanProperty +def IsSharedWorkdir(step): + return bool(step.getProperty("shared_wd")) + def IsCleanupRequested(step): - shared_wd = step.getProperty("shared_wd") - if shared_wd: + if IsSharedWorkdir(step): return False do_cleanup = step.getProperty("do_cleanup") if do_cleanup: @@ -262,8 +264,7 @@ def IsCleanupRequested(step): return False def IsExpireRequested(step): - shared_wd = step.getProperty("shared_wd") - if shared_wd: + if IsSharedWorkdir(step): return False else: return not IsCleanupRequested(step) @@ -464,6 +465,15 @@ for target in targets: factory = BuildFactory() + # setup shared work directory if required + factory.addStep(ShellCommand( + name = "sharedwd", + description = "Setting up shared work directory", + command = 'test -L "$PWD" || (mkdir -p "../shared-workdir" && rm -rf "$PWD" && ln -s shared-workdir "$PWD")', + workdir = ".", + haltOnFailure = True, + doStepIf = IsSharedWorkdir)) + # find number of cores factory.addStep(SetPropertyFromCommand( name = "nproc", -- 2.30.2