This removes the possibility of passing in arbitrary input data. We now restrict ourselves to explicitly specified files/directories or a base tree given by its pipeline id. This drops the tar/tree stages/assemblers, as the tree/untree ones are implicit in osbuild, and if we wish to also support compressed trees, then we should add that to osbuild core as an option. Signed-off-by: Tom Gundersen <teg@jklm.no>
46 lines
1.5 KiB
Python
Executable file
46 lines
1.5 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
import osbuild
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
RESET = "\033[0m"
|
|
BOLD = "\033[1m"
|
|
RED = "\033[31m"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Build operating system images")
|
|
parser.add_argument("pipeline_path", metavar="PIPELINE",
|
|
help="json file containing the pipeline that should be built")
|
|
parser.add_argument("--objects", metavar="DIRECTORY", type=os.path.abspath,
|
|
default=".osbuild/objects",
|
|
help="the directory where intermediary os trees are stored")
|
|
requiredNamed = parser.add_argument_group('required named arguments')
|
|
requiredNamed.add_argument("-o", "--output", dest="output_dir", metavar="DIRECTORY", type=os.path.abspath,
|
|
help="provide the empty DIRECTORY as output argument to the last stage", required=True)
|
|
args = parser.parse_args()
|
|
|
|
os.makedirs("/run/osbuild", exist_ok=True)
|
|
|
|
with open(args.pipeline_path) as f:
|
|
pipeline = json.load(f)
|
|
pipeline = osbuild.Pipeline(pipeline, args.objects)
|
|
|
|
print()
|
|
print(f"{RESET}{BOLD}Pipeline: {pipeline.id}{RESET}")
|
|
|
|
try:
|
|
pipeline.run(args.output_dir, interactive=True)
|
|
except KeyboardInterrupt:
|
|
print()
|
|
print(f"{RESET}{BOLD}{RED}Aborted{RESET}")
|
|
sys.exit(130)
|
|
except osbuild.StageFailed as error:
|
|
print()
|
|
print(f"{RESET}{BOLD}{RED}{error.stage} failed with code {error.returncode}{RESET}")
|
|
sys.exit(1)
|