4.6 KiB
Executable File
#!/usr/bin/env python3
Copyright Linux Foundation, Richard Purdie
SPDX-License-Identifier: GPL-2.0-only
Generate an auto.conf and associated other config files for a given autobuilder configuration
import json import os import sys import subprocess import errno import copy
import utils
parser = utils.ArgParser(description='Generates an auto.conf and associated other config files for a given autobuilder configuration.')
parser.add_argument('target', help="The 'nightly' target the autobuilder is running") parser.add_argument('stepnumber', help="The autobuilder step number (a given target can run multiple steps with different configurations)") parser.add_argument('builddir', help="The target build directory to configure") parser.add_argument('branchname', help="The poky branch name the build is running on") parser.add_argument('reponame', help="The name of the repository the build is running on") parser.add_argument('-s', '--sstateprefix', default='', help="The directory prefix to publish sstate into") parser.add_argument('-b', '--buildappsrcrev', default='', help="A build appliance SRCREV to use")
args = parser.parse_args()
stepnum = int(args.stepnumber) + 1 # Our step numbering is 1 2 3 etc., not 0 of buildbot
ourconfig = utils.loadconfig() ourconfig["HELPERBUILDDIR"] = args.builddir
variables = []
autoconf = os.path.join(args.builddir, "conf", "auto.conf") if os.path.exists(autoconf): os.remove(autoconf)
Ensure autoconf's directory exists
utils.mkdir(os.path.dirname(autoconf))
sdkextraconf = os.path.join(args.builddir, "conf", "sdk-extra.conf") if os.path.exists(sdkextraconf): os.remove(sdkextraconf)
for v in ["MACHINE", "DISTRO", "SDKMACHINE", "PACKAGE_CLASSES"]: value = utils.getconfigvar(v, ourconfig, args.target, stepnum) if value and value != "None": variables.append(v + ' = "%s"' % value)
distro = utils.getconfigvar("DISTRO", ourconfig, args.target, stepnum)
for v in ["DLDIR", "PRSERV"]: value = utils.getconfigvar(v, ourconfig, args.target, stepnum) if value: variables.append(value)
Use a separate SSTATE_DIR with the primary
SSTATE_DIR configured as a mirror so that we
have a directory of symlinks to sstate objects
that can be published for the release
key = "SSTATEDIR" if args.sstateprefix: key = "SSTATEDIR_RELEASE" value = utils.getconfigvar(key, ourconfig, args.target, stepnum) for v in value: v = v.replace("@RELEASENUM@", args.sstateprefix) variables.append(v)
if args.buildappsrcrev and args.buildappsrcrev != "DEFAULT": if args.buildappsrcrev == "AUTOREV": args.buildappsrcrev = "${AUTOREV}" value = utils.getconfiglist("BUILDAPP_SRCREV", ourconfig, args.target, stepnum) for v in value: v = v.replace("@SRCREV@", args.buildappsrcrev) variables.append(v)
if utils.getconfigvar("BUILDINFO", ourconfig, args.target, stepnum): infovars = utils.getconfiglist("BUILDINFOVARS", ourconfig, args.target, stepnum) variables.extend(infovars)
extravars = utils.getconfiglistfilter("extravars", ourconfig, args.target, stepnum) if extravars: variables.extend(extravars)
removevars = utils.getconfiglistfilter("removevars", ourconfig, args.target, stepnum) if removevars: for var in variables[:]: for remove in removevars: if remove in var: variables.remove(var)
bh_path, remoterepo, remotebranch, baseremotebranch = utils.getbuildhistoryconfig(ourconfig, args.builddir, args.target, args.reponame, args.branchname, stepnum) if bh_path: variables.append('INHERIT += "buildhistory"') variables.append('BUILDHISTORY_DIR = "%s"' % bh_path) force = "" if remotebranch != baseremotebranch: force = "-f " variables.append('BUILDHISTORY_PUSH_REPO = "%s%s %s:%s"' % (force, remoterepo, remotebranch, remotebranch)) variables.append("BUILDHISTORY_COMMIT = '1'") variables.append('ERROR_QA:remove = "version-going-backwards"')
utils.printheader("Writing %s with contents:" % autoconf) with open(autoconf, "w") as f: for v in variables: print(" " + v) f.write(v + "\n")
utils.printheader("Writing %s with contents:" % sdkextraconf) with open(sdkextraconf, "w") as f: for v in utils.getconfiglist("SDKEXTRAS", ourconfig, args.target, stepnum): replace = "" if args.sstateprefix: replace = args.sstateprefix + "/" v = v.replace("@RELEASENUM@", replace) print(" " + v) f.write(v + "\n")