Added possibility to disable building platforms

Buildkit on arm might not support amd builds
Could detect that automatically from buildx inspect
This commit is contained in:
Michael Chen 2022-11-21 17:41:15 +01:00
parent cb0b6c7aad
commit 5f2c645cb6
Signed by: cnml
GPG Key ID: 5845BF3F82D5F629

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from argparse import ArgumentParser from argparse import ArgumentParser, BooleanOptionalAction
from datetime import datetime from datetime import datetime
from re import search from re import search
from typing import Iterable from typing import Iterable
@ -69,6 +69,8 @@ def parse_arguments():
parser = ArgumentParser("build.py", description="FTB Docker image build helper.") parser = ArgumentParser("build.py", description="FTB Docker image build helper.")
parser.add_argument("modpack", type=int, help="Modpack ID") parser.add_argument("modpack", type=int, help="Modpack ID")
parser.add_argument("--version", "-v", type=str, help="Specific Modpack Version ID, otherwise uses the latest release") parser.add_argument("--version", "-v", type=str, help="Specific Modpack Version ID, otherwise uses the latest release")
parser.add_argument("--amd64", action=BooleanOptionalAction, default=True, help="Build releases for AMD64")
parser.add_argument("--arm64", action=BooleanOptionalAction, default=True, help="Build releases for ARM64")
return parser.parse_args() return parser.parse_args()
def get_version_by_description(modpack: ModPackManifest, version_name: str | None) -> ModPackVersion | None: def get_version_by_description(modpack: ModPackManifest, version_name: str | None) -> ModPackVersion | None:
@ -120,7 +122,10 @@ if __name__ == "__main__":
repo = f"hub.cnml.de/{slug}" repo = f"hub.cnml.de/{slug}"
semver_version_tags = docker.semver_tags(version["name"]) semver_version_tags = docker.semver_tags(version["name"])
platforms: list[docker.Platforms] = ["linux/arm64", "linux/amd64"] platforms: list[docker.Platforms] = list(filter(None, [
"linux/arm64" if args.arm64 else None,
"linux/amd64" if args.amd64 else None
]))
for platform in platforms: for platform in platforms:
installer, checksum = get_installer(modpack, version, platform) installer, checksum = get_installer(modpack, version, platform)
tags = list(f"{ver}-{platform[(platform.rfind('/')+1):]}" for ver in semver_version_tags) tags = list(f"{ver}-{platform[(platform.rfind('/')+1):]}" for ver in semver_version_tags)