Support listing

This commit is contained in:
Greg Hellings
2023-11-27 10:03:21 -06:00
parent c8510c94aa
commit 149a509803
+16 -13
View File
@@ -17,7 +17,7 @@ parser = ArgumentParser("Build a box")
parser.add_argument("--distro", "-d", help="Name of the distro/ folder")
parser.add_argument("--version", "-v", help="Version of the distro to build")
parser.add_argument("--build", "-b", help="Name of the target build, e.g. qemu.x86_64, virtualbox-iso.x86_64")
parser.add_argument("--list", "-l", help="List all build targets")
parser.add_argument("--list", "-l", help="List all build targets", action="store_true")
parser.add_argument("--all", "-a", help="Build all applicable targets", action="store_true")
parser.add_argument("--upload", "-u", help="Force doing uploads", action="store_true")
parser.add_argument("--headless", help="Run builds headless", action="store_true")
@@ -54,21 +54,24 @@ def do_build(build):
else:
headless = "headless=false"
if args.upload:
if "VAGRANT_CLOUD_TOKEN" not in ${...}:
print("You need to set your cloud token")
sys.exit(1)
packer build -var @(headless) -var @(args.stamp) @(build.var_file) @(build.only) @(BASE / "sources")
if args.list:
print(f"Would build: {build.var_file}")
else:
upload = "-except=upload"
# Skip building file if we already have built it
output = Path(__file__).parent / "output" / get_vagrant_provider(build.provider.name) / f"{build.distro}-{build.version}-{build.provider.arch}.box"
if output.exists():
print(f"Skipping {build} as box already exists")
if args.upload:
if "VAGRANT_CLOUD_TOKEN" not in ${...}:
print("You need to set your cloud token")
sys.exit(1)
packer build -var @(headless) -var @(args.stamp) @(build.var_file) @(build.only) @(BASE / "sources")
else:
packer build -var @(headless) -var @(args.stamp) @(build.var_file) @(build.only) -except=upload @(BASE / "sources")
upload = "-except=upload"
# Skip building file if we already have built it
output = Path(__file__).parent / "output" / get_vagrant_provider(build.provider.name) / f"{build.distro}-{build.version}-{build.provider.arch}.box"
if output.exists():
print(f"Skipping {build} as box already exists")
else:
packer build -var @(headless) -var @(args.stamp) @(build.var_file) @(build.only) -except=upload @(BASE / "sources")
if args.all or (args.distro and args.version and args.build):
if args.all or args.list or (args.distro and args.version and args.build):
process_all()
else:
print("Doing menu stuff")