Example #1
0
def process(args):
    verbose(f"Run script '{args.script}'")
    if args.script == 'all':
        script = get_value_with_default(
            ['scripts', 'all'],
            ['fetch --force', 'init --rebuild-conf', 'build'])
    else:
        script = get_value_with_default(['scripts', args.script])
    if script == None or not isinstance(script, list):
        print(f"Script '{args.script}' not found")
        sys.exit(1)
    for step in script:
        command = _compose_command_prefix(args)
        command.extend(shlex.split(potentially_replace_by_var(step)))
        verbose(f"Run step {' '.join(command)}")
        if dryrun():
            print(f"dry: {' '.join(command)}")
        else:
            try:
                proc = subprocess.Popen(command,
                                        check=True,
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.STDOUT)
                while proc.returncode is None:
                    # handle output by direct access to stdout and stderr
                    for line in process.stdout:
                        print(line)
                    # set returncode if the process has exited
                    process.poll()
            except subprocess.CalledProcessError as err:
                print(f"Error in processing step {err}")
                sys.exit(1)
    verbose(f"Script '{args.script}' successfully finished")
Example #2
0
 def __init__(cls):
     """
     Initialize from Rontofile:
     Rontofile syntax is:
     repo:
       url: git://host/git-manifest-repo.git
       manifest: release-xyz.xml
       branch: master
     """
     if 'repo' in get_model():
         # skip totally if repo is not set.
         is_command_available_or_exit(["repo", "--version"])
         verbose(f"Config base: Google manifest repository")
         cls.url = get_value(['repo', 'url'])
         if cls.url == None:
             print("repo URL cannot be determined", file=sys.stderr)
             sys.exit(1)
         cls.branch = get_value_with_default(["repo", "branch"], 'master')
         cls.manifest = get_value_with_default(["repo", "manifest"],
                                               'default.xml')
Example #3
0
def init_to_source_in() -> str:
    """
    Deliver the commandline that must be sourced as init.

    returns is e.g.  "TEMPLATECONF=template/dir source script build_dir"
    """
    script = get_init_script()
    template_dir = get_value_with_default(["build", "template_dir"])
    build_dir = get_init_build_dir()

    source_line = ""
    if template_dir != None:
        source_line += "TEMPLATECONF="
        source_line += os.path.join(os.getcwd(), template_dir) + " "
    source_line += "source " + script + " " + build_dir + "\n"
    return source_line
Example #4
0
def get_init_build_dir():
    BUILD_DIR = "build"  # default from poky
    return get_value_with_default(["build", "build_dir"], BUILD_DIR)
Example #5
0
 def __init__(self):
     self.sitefile = get_value_with_default(["build", "site", "file"],
                                            "site.conf")
     verbose(f"Use site configuration file: {self.sitefile}")
     self.build_dir = get_init_build_dir()
Example #6
0
def get_init_script():
    INIT_SCRIPT = "sources/poky/oe-init-build-env"  # default from poky
    return get_value_with_default(["build", "init_script"], INIT_SCRIPT)