Skip to content

Commit

Permalink
WIP: Add args for platform / commit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
apyrgio committed Feb 6, 2025
1 parent a5a7bdf commit efc7495
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions dev_scripts/reproduce-image.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,18 @@ def diffoci_diff(runtime, source, local_target):
)


def build_image(tag, use_cache=False):
def build_image(tag, use_cache=False, platform=None, runtime=None):
"""Build the Dangerzone container image with a special tag."""
platform_args = [] if not platform else ["--platform", platform]
runtime_args = [] if not runtime else ["--runtime", runtime]
run(
"python3",
"./install/common/build-image.py",
"--no-save",
"--use-cache",
str(use_cache),
*platform_args,
*runtime_args,
"--tag",
tag,
)
Expand All @@ -161,6 +165,11 @@ def parse_args():
prog=sys.argv[0],
description="Dev script for verifying container image reproducibility",
)
parser.add_argument(
"--platform",
default=None,
help=f"The platform for building the image (default: current platform)",
)
parser.add_argument(
"--runtime",
choices=["docker", "podman"],
Expand All @@ -182,6 +191,12 @@ def parse_args():
action="store_true",
help="Whether to reuse the build cache (off by default for better reproducibility)",
)
parser.add_argument(
"--skip-check-commit",
default=False,
action="store_true",
help="Skip checking if the source image tag contains the current Git commit",
)
return parser.parse_args()


Expand All @@ -193,17 +208,18 @@ def main():
)
args = parse_args()

logger.info(f"Ensuring that current Git commit matches image '{args.source}'")
commit = git_commit_get()
git_verify(commit, args.source)
if not args.skip_check_commit:
logger.info(f"Ensuring that current Git commit matches image '{args.source}'")
git_verify(commit, args.source)

if not diffoci_is_installed():
diffoci_download()

tag = f"reproduce-{commit}"
target = f"{IMAGE_NAME}:{tag}"
logger.info(f"Building container image and tagging it as '{target}'")
build_image(tag, args.use_cache)
build_image(tag, args.use_cache, args.platform, args.runtime)

logger.info(
f"Ensuring that source image '{args.source}' is semantically identical with"
Expand Down

0 comments on commit efc7495

Please sign in to comment.