diff mbox series

[yocto-autobuilder-helper] prepare-shared-repos: create missing dirs

Message ID 20220922023948.387053-1-benjamin.esquivel@gmail.com
State New
Headers show
Series [yocto-autobuilder-helper] prepare-shared-repos: create missing dirs | expand

Commit Message

Benjamin Esquivel Sept. 22, 2022, 2:39 a.m. UTC
From: Benjamin Esquivel <benjamin.esquivel@gmail.com>

on new autobuilder setups, the tmp and destination tar repo dir are
not created anywhere and this makes the step fail.

also a forward looking change to remove /home/pokybuild* instances in
the script to reduce maintenance while getting these paths from
config.

Signed-off-by: Benjamin Esquivel <benjamin.esquivel@gmail.com>
---
 config.json                     |  2 ++
 scripts/prepare-shared-repos    |  8 ++++++--
 scripts/summarize_top_output.py | 13 +++++++++----
 3 files changed, 17 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/config.json b/config.json
index 9dcc1db..cee0675 100644
--- a/config.json
+++ b/config.json
@@ -24,6 +24,8 @@ 
     "BUILDPERF_STATEDIR" : "${BASE_HOMEDIR}/buildperf",
     "BUILDPERF_RESULTSDIR" : "${BASE_HOMEDIR}/buildperf-results",
 
+    "WORKER_DIR" : "${BASE_HOMEDIR}/yocto-worker",
+
     "defaults" : {
         "NEEDREPOS" : ["poky"],
         "DISTRO" : "poky",
diff --git a/scripts/prepare-shared-repos b/scripts/prepare-shared-repos
index b855d18..e8b123d 100755
--- a/scripts/prepare-shared-repos
+++ b/scripts/prepare-shared-repos
@@ -35,8 +35,12 @@  with open(args.repojson) as f:
     repos = json.load(f)
 
 stashdir = utils.getconfig("REPO_STASH_DIR", ourconfig)
+basetmpdir = os.path.join(utils.getconfig("BASE_HOMEDIR", ourconfig), "tmp")
+sharedsrcdir = os.path.abspath(args.sharedsrcdir)
+utils.mkdir(basetmpdir)
+utils.mkdir(sharedsrcdir)
 
-with tempfile.TemporaryDirectory(prefix="shared-repo-temp-", dir="/home/pokybuild/tmp") as tempdir:
+with tempfile.TemporaryDirectory(prefix="shared-repo-temp-", dir=basetmpdir) as tempdir:
     for repo in sorted(repos.keys()):
         utils.printheader("Intially fetching repo %s" % repo)
         # shallow clones disabled as it doesn't work correctly with revision numbers in the result repo leading to release build failures.
@@ -48,4 +52,4 @@  with tempfile.TemporaryDirectory(prefix="shared-repo-temp-", dir="/home/pokybuil
             utils.publishrepo(tempdir, repo, args.publish_dir)
 
     utils.printheader("Creating shared src tarball")
-    subprocess.check_call("tar -I zstd -cf " + args.sharedsrcdir.rstrip("/") + ".tar.zst ./*", shell=True, cwd=tempdir)
+    subprocess.check_call("tar -I zstd -cf " + sharedsrcdir + ".tar.zst ./*", shell=True, cwd=tempdir)
diff --git a/scripts/summarize_top_output.py b/scripts/summarize_top_output.py
index 618cde1..a0c039c 100755
--- a/scripts/summarize_top_output.py
+++ b/scripts/summarize_top_output.py
@@ -5,8 +5,13 @@ 
 
 import os, sys, glob
 
+import utils
+
+ourconfig = utils.loadconfig()
+
 # constants
-HOME = "/home/pokybuild/yocto-worker/"
+
+workerdir = utils.getconfig("WORKER_DIR", ourconfig)
 top_header = 7
 max_cols = 11
 cpu_hoggers = 5
@@ -18,7 +23,7 @@  special_cmds = ["rm", "tar", "qemu"]
 
 # string substitution to make things easier to read
 subs = {
-    "/home/pokybuild/yocto-worker/" : "~/",
+    workerdir : "~/",
     "/build/build/tmp/work/" : "/...WORK_DIR.../"
 }
 
@@ -64,8 +69,8 @@  def summarize_top(top_outs, target):
         short_summary = top_out[:top_header + cpu_hoggers]
         for line in top_out[top_header:]:
             cmd = line.split(maxsplit=max_cols)[-1]
-            if cmd.startswith(HOME):
-                b = cmd.split(HOME)[1].split("/")[0]
+            if cmd.startswith(workerdir):
+                b = cmd.split(workerdir)[1].split("/")[0]
                 if b not in other_builds:
                     other_builds.append(b)
             if cmd[0] == "[" and cmd[-1] == "]":    # kernel processes