Skip to contentSkip to conversation

run-config: generalise auto.conf logging and only show when changed

PATCH New [email protected] 1 participant 2 messages Feb 7, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 run-config: generalise auto.conf logging and only show when changed

From: Ross Burton <[email protected]>

Extract the logging of auto.conf to a new log_file_contents() function, and instead of calling it before _every_ call of bitbake, only show it when actually writing the auto.conf.

---
 scripts/run-config | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
scripts/run-config +14 -10
index 308e954..1c3fb45 100755
@@ -167,6 +167,19 @@ utils.mkdir(errordir)
 
 errorlogs = set()
 
+def log_file_contents(filename, builddir, stepnum, stepname):
+    logfile = logname(builddir, stepnum, stepname)
+    with open(logfile, "a") as outf, open(filename, "r") as f:
+        def log(s):
+            outf.write(s)
+            sys.stdout.write(s)
+
+        log("Contents of %s:\n" % filename)
+        for line in f:
+            log(line)
+        log("\n")
+
+
 def bitbakecmd(builddir, cmd, report, stepnum, stepname, oeenv=True):
     global finalret
     flush()
@@ -191,16 +204,6 @@ def bitbakecmd(builddir, cmd, report, stepnum, stepname, oeenv=True):
     with open(log, "a") as outf:
         writelog("Running '%s' with output to %s\n" % (cmd, log), outf, sys.stdout)
 
-        autoconf = builddir + "/conf/auto.conf"
-        if os.path.exists(autoconf):
-            with open(autoconf, "r") as inf, open(log, "a") as outf:
-                writelog("auto.conf settings:\n", outf, sys.stdout)
-                for line in inf.readlines():
-                    writelog(line, outf, sys.stdout)
-                writelog("\n", outf, sys.stdout)
-
-    flush()
-
     with subprocess.Popen(cmd, shell=True, cwd=builddir + "/..", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=0) as p, open(log, 'ab') as f:
         for line in p.stdout:
             writelog(line, f, sys.stdout.buffer)
@@ -259,6 +262,7 @@ def handle_stepnum(stepnum):
             addstepentry("write-config", "Write config", shortdesc, desc, None, str(stepnum))
         elif args.stepname == "write-config":
             runcmd([scriptsdir + "/setup-config", args.target, str(stepnum - 1), args.builddir, args.branchname, args.reponame, "-s", args.sstateprefix, "-b", args.buildappsrcrev])
+            log_file_contents(args.builddir + "/conf/auto.conf", args.builddir, stepnum, args.stepname)
 
     # Execute the targets for this configuration
     targets = utils.getconfigvar("BBTARGETS", ourconfig, args.target, stepnum)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 run-config: log the contents of bblayers.conf after edits

From: Ross Burton <[email protected]>

This is useful when using large sets of layers to
verify that the right layers have been added in
the right order.

---
 scripts/run-config | 2 ++
 1 file changed, 2 insertions(+)
scripts/run-config +2 -0
index 1c3fb45..a9bb667 100755
@@ -253,6 +253,7 @@ def handle_stepnum(stepnum):
     elif args.stepname == "add-layers":
         for layer in layers:
             bitbakecmd(args.builddir, "bitbake-layers add-layer %s" % layer, report, stepnum, args.stepname)
+        log_file_contents(args.builddir + "/conf/bblayers.conf", args.builddir, stepnum, args.stepname)
 
     flush()
 
@@ -308,6 +309,7 @@ def handle_stepnum(stepnum):
         # Remove any layers we added in a reverse order
         for layer in reversed(layers):
             bitbakecmd(args.builddir, "bitbake-layers remove-layer %s" % layer, report, stepnum, args.stepname)
+        log_file_contents(args.builddir + "/conf/bblayers.conf", args.builddir, stepnum, args.stepname)
 
     if not jcfg:
         sys.exit(finalret)
Signature · 1 line
2.34.1