aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/layer-config
blob: 93dc7e3e28e34801ffc7eee31491aefe4928870c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
#
# Copyright Linux Foundation, Richard Purdie
#
# SPDX-License-Identifier: GPL-2.0-only
#
# Move the repositories into the correct layout and generate bblayers.conf
#

import os
import sys
import subprocess

import utils


parser = utils.ArgParser(description='Moves the repositories into the correct layout and generates bblayers.conf.')

parser.add_argument('abworkdir',
                    help="The autobuilder working directory")
parser.add_argument('target',
                    help="The target to filter the repos to")

args = parser.parse_args()

ourconfig = utils.loadconfig()

def bitbakecmd(targetdir, cmd):
    subprocess.check_call(". ./oe-init-build-env; %s" % cmd, shell=True, cwd=targetdir)

needrepos = utils.getconfigvar("NEEDREPOS", ourconfig, args.target, None)

callinit = False

repos = utils.getconfig("repo-defaults", ourconfig)

for repo in needrepos:
    repo_basename = repo.split('/')[0]
    checkdir = repo_basename
    if repo_basename in repos:
        if "call-init" in repos[repo_basename] and repos[repo_basename]["call-init"]:
            callinit = True
        if "checkout-dirname" in repos[repo_basename]:
            checkdir = repos[repo_basename]["checkout-dirname"]

    source = args.abworkdir + "/repos/" + repo_basename
    destination = args.abworkdir + "/" + checkdir
    if not os.path.isdir(destination) or callinit:
        utils.mkdir(destination)
        for f in os.listdir(source):
            subprocess.check_call(['mv', source + "/" + f, destination + "/"])

if callinit:
    subprocess.check_call(". ./oe-init-build-env", shell=True, cwd=args.abworkdir)

for repo in needrepos:
    repo_basename = repo.split('/')[0]
    if repo_basename in repos and "no-layer-add" in repos[repo_basename] and repos[repo_basename]["no-layer-add"]:
        continue
    nolayeradd = utils.getconfiglist("NOLAYERADD", ourconfig, args.target, None)
    if repo_basename in nolayeradd:
        continue
    try:
        bitbakecmd(args.abworkdir, "bitbake-layers add-layer %s" % (args.abworkdir + "/" + repo))
    except subprocess.CalledProcessError as e:
        utils.printheader("ERROR: Command %s failed with exit code %d, see errors above." % (e.cmd, e.returncode))
        sys.exit(e.returncode)