Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build-in-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ only Docker and Python 3 on the host.

# Build a nova hub release package for Debian 12
./build-in-container.py --platform debian-12 --project nova --role hub --build-type RELEASE

# Alternatively, use Jenkins labels (see build-scripts/labels.txt)
./build-in-container.py --label PACKAGES_HUB_x86_64_linux_debian_12 --project nova --build-type RELEASE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this case of HUB you don't need project nova, that is required.

I guess strangely, we don't have a distinction between community and enterprise platform labels. ok.

Might be interesting to consider changing this to --edition (community|enterprise)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```

In the examples above, we run the script from inside `buildscripts/` (with
Expand Down
32 changes: 32 additions & 0 deletions build-in-container.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,21 @@ def cache_label(platform_name, role, arch):
return f"PACKAGES{hub}_{arch_token}_linux_{label_os}"


def platform_role_arch(label):
"""Return the (platform, role, arch) that cache_label() turns into label.

Found by trying every combination rather than by parsing the label. That
keeps cache_label() the only place that knows how a label is spelled, so the
two cannot drift apart.
"""
for platform_name, platform_config in get_config().items():
for role in ("agent", "hub"):
for arch in platform_architectures(platform_config):
if cache_label(platform_name, role, arch) == label:
return platform_name, role, arch
return None


def run_container(args, image_tag, source_dir, script_dir, label):
"""Run the build inside a Docker container."""
# Keep the packages in a directory of their own, so that building several
Expand Down Expand Up @@ -493,6 +508,12 @@ def parse_args():
choices=list(get_config().keys()),
help="Target platform",
)
parser.add_argument(
"--label",
help="Build what this Jenkins build label names, e.g. "
"PACKAGES_HUB_x86_64_linux_debian_12. Sets --platform, --role and "
"--arch, so it replaces all three. See build-scripts/labels.txt.",
)
parser.add_argument(
"--project",
choices=["community", "nova"],
Expand Down Expand Up @@ -593,6 +614,17 @@ def parse_args():
# --platform is optional for these modes; updates all if omitted
return args

if args.label:
if args.tarballs:
parser.error("--label and --tarballs build different things")
if args.platform or args.role or args.arch:
parser.error("--label already sets --platform, --role and --arch")
found = platform_role_arch(args.label)
if not found:
parser.error(f"no platform builds {args.label}")
args.platform, args.role, args.arch = found
log.info(f"{args.label}: {args.platform} {args.role} {args.arch}")

if args.tarballs:
# The tarballs are built from core and masterfiles alone, in an image of
# their own, so the platform, project and role are not choices here. The
Expand Down
Loading