mirror of
git://git.yoctoproject.org/yocto-autobuilder-helper.git
synced 2025-07-19 20:59:02 +02:00
utils: Allow customisation using ABHELPER_JSON from the environment
Usage is documented in README and an example, local-example.json is included. Also clean up the parameter to loadconfig() as its actually not needed. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
0ccbfc0e05
commit
b7cf6d8209
17
README
17
README
|
@ -5,6 +5,23 @@ release and contains the hooks that do the actual build configuration and execut
|
||||||
pre-commit-hook.sh can be used to verify the JSON before committing, symlink this
|
pre-commit-hook.sh can be used to verify the JSON before committing, symlink this
|
||||||
to .git/hooks/pre-commit (ln -s ../../scripts/pre-commit-hook.sh .git/hooks/pre-commit).
|
to .git/hooks/pre-commit (ln -s ../../scripts/pre-commit-hook.sh .git/hooks/pre-commit).
|
||||||
|
|
||||||
|
Its likely most users will end up having to customise this repository for their needs. The
|
||||||
|
scripts themselves should be more generically reusable, the config.json, less so as it
|
||||||
|
represents the Yocto Project Autobuilder test matrix.
|
||||||
|
|
||||||
|
There are two customisation options possible, one is through variable substitution, the other
|
||||||
|
is through overlaying configuration files. The standard config.json tries to at least allow
|
||||||
|
substitution of the paths. A local-example.json is included to show how you could override
|
||||||
|
these from a separate config file, simply passing:
|
||||||
|
|
||||||
|
ABHELPER_JSON="config.json local-example.json"
|
||||||
|
|
||||||
|
into the environment of the autobuilder.
|
||||||
|
|
||||||
|
ABHELPER_JSON="config.json /some/location/local.json"
|
||||||
|
|
||||||
|
would also allow customisation.
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
Richard Purdie <richard.purdie@linuxfoundation.org>
|
Richard Purdie <richard.purdie@linuxfoundation.org>
|
||||||
Joshua Lock <joshua.g.lock@intel.com>
|
Joshua Lock <joshua.g.lock@intel.com>
|
||||||
|
|
|
@ -23,7 +23,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'scripts'))
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
ourconfig = utils.loadconfig(os.path.dirname(__file__) + "/../scripts/dummy")
|
ourconfig = utils.loadconfig()
|
||||||
|
|
||||||
if "TRASH_DIR" not in ourconfig:
|
if "TRASH_DIR" not in ourconfig:
|
||||||
print("Please set TRASH_DIR in the configuration file")
|
print("Please set TRASH_DIR in the configuration file")
|
||||||
|
|
|
@ -17,7 +17,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'scripts'))
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
ourconfig = utils.loadconfig(os.path.dirname(__file__) + "/../scripts/dummy")
|
ourconfig = utils.loadconfig()
|
||||||
|
|
||||||
|
|
||||||
def mkdir(path):
|
def mkdir(path):
|
||||||
|
|
4
local-example.json
Normal file
4
local-example.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"BASE_HOMEDIR" : "/home/someotheruser",
|
||||||
|
"BASE_SHAREDDIR" : "/some/other/shared/dir"
|
||||||
|
}
|
|
@ -22,7 +22,7 @@ targetdir = sys.argv[1]
|
||||||
target = sys.argv[2]
|
target = sys.argv[2]
|
||||||
targetbuilddir = targetdir
|
targetbuilddir = targetdir
|
||||||
|
|
||||||
ourconfig = utils.loadconfig(__file__)
|
ourconfig = utils.loadconfig()
|
||||||
|
|
||||||
def bitbakecmd(targetbuilddir, cmd):
|
def bitbakecmd(targetbuilddir, cmd):
|
||||||
ret = subprocess.call(". ./oe-init-build-env; %s" % cmd, shell=True, cwd=targetbuilddir)
|
ret = subprocess.call(". ./oe-init-build-env; %s" % cmd, shell=True, cwd=targetbuilddir)
|
||||||
|
|
|
@ -25,7 +25,7 @@ publish = None
|
||||||
if sys.argv[3] != "None":
|
if sys.argv[3] != "None":
|
||||||
publish = sys.argv[3]
|
publish = sys.argv[3]
|
||||||
|
|
||||||
ourconfig = utils.loadconfig(__file__)
|
ourconfig = utils.loadconfig()
|
||||||
|
|
||||||
with open(repojson) as f:
|
with open(repojson) as f:
|
||||||
repos = json.load(f)
|
repos = json.load(f)
|
||||||
|
|
|
@ -38,7 +38,7 @@ if sys.argv[8] != "None":
|
||||||
errorurl = sys.argv[8]
|
errorurl = sys.argv[8]
|
||||||
|
|
||||||
scriptsdir = os.path.dirname(os.path.realpath(__file__))
|
scriptsdir = os.path.dirname(os.path.realpath(__file__))
|
||||||
ourconfig = utils.loadconfig(__file__)
|
ourconfig = utils.loadconfig()
|
||||||
|
|
||||||
# Find out the number of steps this target has
|
# Find out the number of steps this target has
|
||||||
maxsteps = 1
|
maxsteps = 1
|
||||||
|
|
|
@ -31,7 +31,7 @@ if send != "True" or publish == "None" or rel_name == "None":
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
scriptsdir = os.path.dirname(os.path.realpath(__file__))
|
scriptsdir = os.path.dirname(os.path.realpath(__file__))
|
||||||
ourconfig = utils.loadconfig(__file__)
|
ourconfig = utils.loadconfig()
|
||||||
|
|
||||||
with open(repojson) as f:
|
with open(repojson) as f:
|
||||||
repos = json.load(f)
|
repos = json.load(f)
|
||||||
|
|
|
@ -31,7 +31,7 @@ reponame = sys.argv[5]
|
||||||
sstate_release = sys.argv[6]
|
sstate_release = sys.argv[6]
|
||||||
buildappsrcrev = sys.argv[7]
|
buildappsrcrev = sys.argv[7]
|
||||||
|
|
||||||
ourconfig = utils.loadconfig(__file__)
|
ourconfig = utils.loadconfig()
|
||||||
|
|
||||||
variables = []
|
variables = []
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ if sys.argv[5] != "None":
|
||||||
|
|
||||||
|
|
||||||
scriptsdir = os.path.dirname(os.path.realpath(__file__))
|
scriptsdir = os.path.dirname(os.path.realpath(__file__))
|
||||||
ourconfig = utils.loadconfig(__file__)
|
ourconfig = utils.loadconfig()
|
||||||
|
|
||||||
stashdir = utils.getconfig("REPO_STASH_DIR", ourconfig)
|
stashdir = utils.getconfig("REPO_STASH_DIR", ourconfig)
|
||||||
|
|
||||||
|
|
|
@ -113,13 +113,32 @@ def expandtemplates(ourconfig):
|
||||||
return ourconfig
|
return ourconfig
|
||||||
|
|
||||||
#
|
#
|
||||||
# Helper to load the config.json file for scripts in the scripts directory (pass in __file__)
|
# Helper to load the json config files
|
||||||
#
|
#
|
||||||
def loadconfig(f):
|
# Defaults to the top level config.json file
|
||||||
scriptsdir = os.path.dirname(os.path.realpath(f))
|
# however this can be customised from the environment, e.g.:
|
||||||
|
# ABHELPER_JSON="config.json local.json"
|
||||||
|
# ABHELPER_JSON="config.json /path/to/local.json"
|
||||||
|
# files without paths are assumed to be in scripts/..
|
||||||
|
#
|
||||||
|
# Values from later files overwrite values from earlier files
|
||||||
|
#
|
||||||
|
def loadconfig():
|
||||||
|
files = "config.json"
|
||||||
|
if "ABHELPER_JSON" in os.environ:
|
||||||
|
files = os.environ["ABHELPER_JSON"]
|
||||||
|
|
||||||
with open(os.path.join(scriptsdir, '..', 'config.json')) as f:
|
scriptsdir = os.path.dirname(os.path.realpath(__file__))
|
||||||
ourconfig = json.load(f)
|
|
||||||
|
ourconfig = {}
|
||||||
|
for f in files.split():
|
||||||
|
p = f
|
||||||
|
if not f.startswith("/"):
|
||||||
|
p = os.path.join(scriptsdir, '..', f)
|
||||||
|
with open(p) as j:
|
||||||
|
config = json.load(j)
|
||||||
|
for c in config:
|
||||||
|
ourconfig[c] = config[c]
|
||||||
|
|
||||||
# Expand templates in the configuration
|
# Expand templates in the configuration
|
||||||
ourconfig = expandtemplates(ourconfig)
|
ourconfig = expandtemplates(ourconfig)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user