Skip to content

Commit 630e210

Browse files
committed
Update for new key cashing structure
1 parent 2f0bb3e commit 630e210

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

apko/private/apk.bzl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ def _cachePathFromURL(url):
189189
Mimicks https://github.com/chainguard-dev/go-apk/blob/7b08e8f3b0fcaa0f0a44757aedf23f6778cd8e4f/pkg/apk/cache.go#L326C6-L326C22
190190
Is interprets URL as following path: {repo}/{arch}/{file} [but also used for keyring files that don't obey {arch} part].
191191
192+
For RSA public key files (*.rsa.pub), the file is stored in a directory named after the full filename.
193+
192194
Examples:
193-
https://packages.wolfi.dev/os/wolfi-signing.rsa.pub -> https%3A%2F%2Fpackages.wolfi.dev%2F/os/wolfi-signing.rsa.pub
195+
https://packages.wolfi.dev/os/wolfi-signing.rsa.pub -> https%3A%2F%2Fpackages.wolfi.dev%2F/os/wolfi-signing.rsa.pub/wolfi-signing.rsa.pub
194196
https://packages.wolfi.dev/os/aarch64/sqlite-libs-3.44.0-r0.apk -> https%3A%2F%2Fpackages.wolfi.dev%2Fos/arch64/sqlite-libs-3.44.0-r0.apk
195197
"""
196198
url_split = url.rsplit("/", 2)
@@ -199,7 +201,13 @@ def _cachePathFromURL(url):
199201
# Seems the Apko adds additional "/" if the URL is short.
200202
repo += "/"
201203
repo_escaped = util.url_escape(repo)
202-
return "{}/{}/{}".format(repo_escaped, url_split[1], url_split[2])
204+
filename = url_split[2]
205+
206+
# For RSA public key files, store them in a directory named after the full filename
207+
if filename.endswith(".rsa.pub"):
208+
return "{}/{}/{}/{}".format(repo_escaped, url_split[1], filename, filename)
209+
210+
return "{}/{}/{}".format(repo_escaped, url_split[1], filename)
203211

204212
def _apk_keyring_impl(rctx):
205213
public_key = _cachePathFromURL(rctx.attr.url)

0 commit comments

Comments
 (0)