Skip to content

Commit

Permalink
feat: add cache to packages
Browse files Browse the repository at this point in the history
Allow to "downgrade" HTTPS connections to be cached by squid. In both
cases, packages indexes are verified by OPKG keys (usign) or APK itself.

Related: #1187

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Feb 4, 2025
1 parent a684959 commit 8d6deba
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions asu/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def build(build_request: BuildRequest, job=None):

image = f"{settings.base_container}:{build_request.target.replace('/', '-')}-{container_version_tag}"

if build_request.version.lower().endswith("snapshot"):
if is_snapshot_build(build_request.version):
environment.update(
{
"TARGET": build_request.target,
Expand All @@ -75,14 +75,15 @@ def build(build_request: BuildRequest, job=None):
.replace("{version}", build_request.version),
}
)
if settings.squid_cache:
environment.update(
{
"UPSTREAM_URL": settings.upstream_url.replace("https", "http"),
"use_proxy": "on",
"http_proxy": "http://127.0.0.1:3128",
}
)

if settings.squid_cache:
environment.update(
{
"UPSTREAM_URL": settings.upstream_url.replace("https", "http"),
"use_proxy": "on",
"http_proxy": "http://127.0.0.1:3128",
}
)

job.meta["imagebuilder_status"] = "container_setup"
job.save_meta()
Expand Down Expand Up @@ -218,6 +219,11 @@ def build(build_request: BuildRequest, job=None):
job.meta["imagebuilder_status"] = "validate_manifest"
job.save_meta()

if settings.squid_cache and not is_snapshot_build(build_request.version):
log.info("Disabling HTTPS for repositories")
# Once APK is used for a stable release, handle `repositories`, too
run_cmd(container, ["sed", "-i", "s|https|http|g", "repositories.conf"])

returncode, job.meta["stdout"], job.meta["stderr"] = run_cmd(
container,
[
Expand Down

0 comments on commit 8d6deba

Please sign in to comment.