yocto-autobuilder-helper/scripts/shared-repo-unpack
Alexander Kanavin 15ac842396 scripts/shared-repo-unpack: account for --build-dir -> --setup-dir renames in bitbake-setup
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2025-11-04 13:16:47 +00:00

4.2 KiB
Executable File

#!/usr/bin/env python3

Copyright Linux Foundation, Richard Purdie

SPDX-License-Identifier: GPL-2.0-only

Unpack a shared directory of repos to the autobuilder working directory

import json import os import sys import subprocess import errno import time import random

import utils

parser = utils.ArgParser(description='Unpacks a shared directory of repos to the autobuilder working directory.')

parser.add_argument('repojson', help="The json file containing the repositories to use") parser.add_argument('abworkdir', help="The autobuilder working directory") parser.add_argument('target', help="The target we want to unpack repos for") parser.add_argument('-c', '--cache-dir', action='store', help="The shared cache directory where the repos may be transferred from") parser.add_argument('-p', '--publish-dir', action='store', help="Where to publish artefacts to (optional)") parser.add_argument('--workername', action='store', default=None, help="the name of the worker the build is running on")

args = parser.parse_args()

scriptsdir = os.path.dirname(os.path.realpath(file)) ourconfig = utils.loadconfig()

stashdir = utils.getconfig("REPO_STASH_DIR", ourconfig)

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

layerjson = args.repojson bbsetup_json = args.repojson.replace("layerinfo.json", "bbsetup-overrides.json")

with open(layerjson) as f: repos = json.load(f)

utils.filterrepojson(repos, args.target)

bitbake_setup = False

targetsubdir = args.abworkdir + "/repos" needrepos_baseddirs = [r.split('/')[0] for r in needrepos] for repo in sorted(repos.keys()): if repo not in needrepos_baseddirs: continue if args.cache_dir: utils.printheader("Copying in repo %s" % repo) utils.mkdir(targetsubdir) if args.target in ["a-full", "a-quick"]: # full/quick need all repo data due to send_qa_email.py subprocess.check_call(["tar", "-I", "zstd", "-C", targetsubdir, "-xf", "%s.tar.zst" % args.cache_dir]) else: subprocess.check_call(["tar", "-I", "zstd", "-C", targetsubdir, "-xf", "%s.tar.zst" % args.cache_dir, "./" + repo]) else: utils.printheader("Fetching repo %s" % repo) utils.fetchgitrepo(targetsubdir, repo, repos[repo], stashdir) if args.publish_dir: utils.publishrepo(targetsubdir, repo, args.publish_dir) utils.flush()

utils.setup_buildtools_tarball(ourconfig, args.workername, args.abworkdir + "/buildtools")

if "bitbake" not in repos: sys.exit(0)

try: bbs_dldir = utils.getconfigvar("BBSETUP_DLDIR", ourconfig, args.target, None) bbs_config = utils.getconfiglist("BBSETUP_CONFIG", ourconfig, args.target, None) bbs_fragments = utils.getconfiglist("BBSETUP_FRAGMENTS", ourconfig, args.target, None) machine = utils.getconfigvar("MACHINE", ourconfig, args.target, None) if machine: bbs_fragments.append("machine/" + machine) distro = utils.getconfigvar("DISTRO", ourconfig, args.target, None) if distro: bbs_fragments.append("distro/" + distro)

cmd = [targetsubdir + "/bitbake/bin/bitbake-setup",
       "--setting", "default", "top-dir-prefix",  os.path.dirname(os.path.dirname(args.abworkdir)),
       "--setting", "default", "top-dir-name", os.path.basename(os.path.dirname(args.abworkdir)),
       "--setting", "default", "dl-dir", bbs_dldir,
       "--global-settings", args.abworkdir + "/settings.conf",
       "init",
       "--skip-selection", "machine",
       "--skip-selection", "distro",
       "--source-overrides", bbsetup_json,
       "--setup-dir-name", "build",
       "--non-interactive",
       ] + bbs_config + bbs_fragments
print("Running command %s" % " ".join(cmd))
utils.flush()
subprocess.check_call(cmd)
layercmd = [scriptsdir + "/layer-config", args.abworkdir, args.target]
print("Running command %s" % " ".join(layercmd))
utils.flush()
subprocess.check_call(layercmd)

except subprocess.CalledProcessError as e: sys.exit(e.returncode)