The best practice for creating a pipeline should be to include at least one level of build-pipelines. This makes sure that the tools used to generate the target image are well-defined. In principle one could add several layers, though in pracite, one would hope that the envinment used to build the buildroot does not affect the final image (and as we anyway cannot recurr indefinitely, we fall back to simply using the host system in this case). This only makes sense, if the contents of the host system truly does not affect the generated image, and as such we do not include any information about the host when computing the hash that identifies a pipeline. In fact, any image could be used in its place, as long as the required tools are present. This commit takes advantage of that fact. Rather than run a pipeline with the host as the build root, take a second pipeline to generate the buildroot, but do not include this when computing the pipeline id (so it is different from simply editing the original JSON). This is necessary so we can use the same pipelines on significantly different host systems (run with different --bulid-pipeline arguments). In particular, it allows our test pipelines that generate f30 images to be run unmodified on Travis (which runs Ubuntu). Signed-off-by: Tom Gundersen <teg@jklm.no>
27 lines
825 B
Python
27 lines
825 B
Python
import logging
|
|
import subprocess
|
|
import sys
|
|
|
|
from .config import *
|
|
|
|
|
|
def run_osbuild(pipeline: str, build_pipeline: str, check=True):
|
|
cmd = OSBUILD + ["--store", OBJECTS, "-o", OUTPUT_DIR, pipeline]
|
|
if build_pipeline:
|
|
cmd += ["--build-pipeline", build_pipeline]
|
|
logging.info(f"Running osbuild: {cmd}")
|
|
osbuild = subprocess.run(cmd, capture_output=True)
|
|
if osbuild.returncode != 0:
|
|
logging.error(f"{RED}osbuild failed!{RESET}")
|
|
print(f"{BOLD}STDERR{RESET}")
|
|
print(osbuild.stderr.decode())
|
|
print(f"{BOLD}STDOUT{RESET}")
|
|
print(osbuild.stdout.decode())
|
|
if check:
|
|
sys.exit(1)
|
|
|
|
return osbuild.returncode
|
|
|
|
|
|
def build_testing_image(pipeline_full_path, build_pipeline_full_path):
|
|
run_osbuild(pipeline_full_path, build_pipeline_full_path)
|