osbuild: remove --sit

It's not really useful because it's at the wrong place, after a stage
has torn down all mounts. It also makes the code more complex for too
little benefit.
This commit is contained in:
Lars Karlitski 2019-06-14 18:37:37 +02:00
parent 7ee6571640
commit ce0b01e93d
3 changed files with 9 additions and 29 deletions

View file

@ -13,7 +13,7 @@ BOLD = "\033[1m"
RED = "\033[31m"
def run_interactive(pipeline_path, input_dir, output_dir, sit):
def run_interactive(pipeline_path, input_dir, output_dir):
with open(pipeline_path) as f:
pipeline = json.load(f)
@ -26,7 +26,7 @@ def run_interactive(pipeline_path, input_dir, output_dir, sit):
print("Inspect with:")
print(f"\t# nsenter -a --wd=/root -t `machinectl show {buildroot.machine_name} -p Leader --value`")
print()
buildroot.run_stage(name, options, input_dir, sit)
buildroot.run_stage(name, options, input_dir)
assembler = pipeline.get("assembler")
if assembler:
@ -48,8 +48,6 @@ if __name__ == "__main__":
help="provide the contents of DIRECTORY to the first stage")
parser.add_argument("--output", dest="output_dir", metavar="DIRECTORY", type=os.path.abspath,
help="provide the empty DIRECTORY as output argument to the last stage")
parser.add_argument("--sit", action="store_true",
help="keep the build environment up when a stage failed")
args = parser.parse_args()
os.makedirs("/run/osbuild", exist_ok=True)
@ -59,7 +57,7 @@ if __name__ == "__main__":
sys.exit(1)
try:
run_interactive(args.pipeline_path, args.input_dir, args.output_dir, args.sit)
run_interactive(args.pipeline_path, args.input_dir, args.output_dir)
except KeyboardInterrupt:
print()
print(f"{RESET}{BOLD}{RED}Aborted{RESET}")

View file

@ -71,7 +71,7 @@ class BuildRoot:
*[f"--bind-ro={src}:{dest}" for src, dest in readonly_binds]
] + argv, *args, **kwargs)
def run_stage(self, stage, options={}, input_dir=None, sit=False):
def run_stage(self, stage, options={}, input_dir=None):
options = {
**options,
"tree": "/tmp/tree",
@ -86,18 +86,13 @@ class BuildRoot:
if input_dir:
options["input_dir"] = "/tmp/input"
robinds.append((input_dir, "/tmp/input"))
argv = ["/tmp/run-stage"]
if sit:
argv.append("--sit")
argv.append("/tmp/stage")
try:
self.run(argv, readonly_binds=robinds, input=json.dumps(options), encoding="utf-8", check=True)
self.run(["/tmp/run-stage", "/tmp/stage"], readonly_binds=robinds,
input=json.dumps(options), encoding="utf-8", check=True)
except subprocess.CalledProcessError as error:
raise StageFailed(stage, error.returncode)
def run_assembler(self, name, options, output_dir=None, sit=False):
def run_assembler(self, name, options, output_dir=None):
if output_dir and not os.path.exists(output_dir):
os.makedirs(output_dir)
@ -118,13 +113,8 @@ class BuildRoot:
options["output_dir"] = "/tmp/output"
binds.append((output_dir, "/tmp/output"))
argv = ["/tmp/run-stage"]
if sit:
argv.append("--sit")
argv.append("/tmp/stage")
try:
self.run(argv, binds=binds, readonly_binds=robinds, input=json.dumps(options), encoding="utf-8", check=True)
self.run(["/tmp/run-stage", "/tmp/stage"], binds=binds, readonly_binds=robinds, input=json.dumps(options), encoding="utf-8", check=True)
except subprocess.CalledProcessError as error:
raise StageFailed(stage, error.returncode)

View file

@ -10,7 +10,7 @@ BOLD = "\033[1m"
RED = "\033[31m"
def main(stage, sit):
def main(stage):
# ld.so.conf must exist, or `ldconfig` throws a warning
subprocess.run(["touch", "/etc/ld.so.conf"], check=True)
subprocess.run(["ldconfig"], check=True)
@ -26,19 +26,11 @@ def main(stage, sit):
subprocess.run(["systemd-tmpfiles", "--create"])
r = subprocess.run([stage])
if sit and r.returncode != 0:
import signal
print()
print(f"{RESET}{BOLD}{RED}Stage failed with code {r.returncode}{RESET}")
print("Keeping the build environment running...")
signal.pause()
return r.returncode
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("stage")
parser.add_argument("--sit", action="store_true")
args = parser.parse_args()
sys.exit(main(**vars(args)))