mirror of
https://github.com/vyos/vyos-build.git
synced 2025-10-01 20:28:40 +02:00
build: T3664: fail the build on external command errors
This commit is contained in:
parent
f6b0809f47
commit
7dfd9232da
@ -78,6 +78,8 @@ import utils
|
|||||||
import defaults
|
import defaults
|
||||||
import raw_image
|
import raw_image
|
||||||
|
|
||||||
|
from utils import cmd
|
||||||
|
|
||||||
# argparse converts hyphens to underscores,
|
# argparse converts hyphens to underscores,
|
||||||
# so for lookups in the original options hash we have to convert them back
|
# so for lookups in the original options hash we have to convert them back
|
||||||
def field_to_option(s):
|
def field_to_option(s):
|
||||||
@ -450,7 +452,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
## Clean up earlier build state and artifacts
|
## Clean up earlier build state and artifacts
|
||||||
print("I: Cleaning the build workspace")
|
print("I: Cleaning the build workspace")
|
||||||
os.system("lb clean")
|
cmd("lb clean")
|
||||||
#iter(lambda p: shutil.rmtree(p, ignore_errors=True),
|
#iter(lambda p: shutil.rmtree(p, ignore_errors=True),
|
||||||
# ['config/binary', 'config/bootstrap', 'config/chroot', 'config/common', 'config/source'])
|
# ['config/binary', 'config/bootstrap', 'config/chroot', 'config/common', 'config/source'])
|
||||||
artifacts = functools.reduce(
|
artifacts = functools.reduce(
|
||||||
@ -575,10 +577,7 @@ if __name__ == "__main__":
|
|||||||
print("D: live-build configuration command")
|
print("D: live-build configuration command")
|
||||||
print(lb_config_command)
|
print(lb_config_command)
|
||||||
|
|
||||||
result = os.system(lb_config_command)
|
cmd(lb_config_command)
|
||||||
if result > 0:
|
|
||||||
print("E: live-build config failed")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
## In dry-run mode, exit at this point
|
## In dry-run mode, exit at this point
|
||||||
if build_config["dry_run"]:
|
if build_config["dry_run"]:
|
||||||
@ -595,9 +594,7 @@ if __name__ == "__main__":
|
|||||||
print("I: Starting image build")
|
print("I: Starting image build")
|
||||||
if debug:
|
if debug:
|
||||||
print("D: It's not like I'm building this specially for you or anything!")
|
print("D: It's not like I'm building this specially for you or anything!")
|
||||||
res = os.system("lb build 2>&1")
|
cmd("lb build 2>&1")
|
||||||
if res > 0:
|
|
||||||
sys.exit(res)
|
|
||||||
|
|
||||||
# Copy the image
|
# Copy the image
|
||||||
shutil.copy("live-image-{0}.hybrid.iso".format(build_config["architecture"]), iso_file)
|
shutil.copy("live-image-{0}.hybrid.iso".format(build_config["architecture"]), iso_file)
|
||||||
@ -613,11 +610,11 @@ if __name__ == "__main__":
|
|||||||
# For those cases, we support running a post-build hook on the raw image.
|
# For those cases, we support running a post-build hook on the raw image.
|
||||||
# The image_format field should be 'raw' if a post-build hook is used.
|
# The image_format field should be 'raw' if a post-build hook is used.
|
||||||
hook_path = build_config["post_build_hook"]
|
hook_path = build_config["post_build_hook"]
|
||||||
os.system(f"{hook_path} {raw_image}")
|
cmd(f"{hook_path} {raw_image}")
|
||||||
else:
|
else:
|
||||||
# Most other formats, thankfully, can be produced with just `qemu-img convert`
|
# Most other formats, thankfully, can be produced with just `qemu-img convert`
|
||||||
other_formats = filter(lambda x: x not in ["iso", "raw"], build_config["image_format"])
|
other_formats = filter(lambda x: x not in ["iso", "raw"], build_config["image_format"])
|
||||||
for f in other_formats:
|
for f in other_formats:
|
||||||
target = f"{os.path.splitext(raw_image)[0]}.{f}"
|
target = f"{os.path.splitext(raw_image)[0]}.{f}"
|
||||||
print(f"I: Building {f} file {target}")
|
print(f"I: Building {f} file {target}")
|
||||||
os.system(f"qemu-img convert -f raw -O {f} {raw_image} {target}")
|
cmd(f"qemu-img convert -f raw -O {f} {raw_image} {target}")
|
||||||
|
|||||||
@ -25,11 +25,7 @@ import vyos.utils.process
|
|||||||
SQUASHFS_FILE = 'live/filesystem.squashfs'
|
SQUASHFS_FILE = 'live/filesystem.squashfs'
|
||||||
VERSION_FILE = 'version.json'
|
VERSION_FILE = 'version.json'
|
||||||
|
|
||||||
|
from utils import cmd
|
||||||
def cmd(command):
|
|
||||||
res = vyos.utils.process.call(command, shell=True)
|
|
||||||
if res > 0:
|
|
||||||
raise OSError(f"Command '{command}' failed")
|
|
||||||
|
|
||||||
def mkdir(path):
|
def mkdir(path):
|
||||||
os.makedirs(path, exist_ok=True)
|
os.makedirs(path, exist_ok=True)
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import shutil
|
|||||||
|
|
||||||
# Local modules
|
# Local modules
|
||||||
import defaults
|
import defaults
|
||||||
|
import vyos
|
||||||
|
|
||||||
def check_build_config():
|
def check_build_config():
|
||||||
if not os.path.exists(defaults.BUILD_CONFIG):
|
if not os.path.exists(defaults.BUILD_CONFIG):
|
||||||
@ -76,3 +77,8 @@ def check_system_dependencies(deps):
|
|||||||
raise OSError(checker.format_missing_dependencies())
|
raise OSError(checker.format_missing_dependencies())
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def cmd(command):
|
||||||
|
res = vyos.utils.process.call(command, shell=True)
|
||||||
|
if res > 0:
|
||||||
|
raise OSError(f"Command '{command}' failed")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user