support new index format without attaching arch

By default the package architecture is attached to the repository url.
With this commit it is possible to define new indexes ending on `.adb`.
If such index file is detected the packages must be in the same folder
as the index.

Signed-off-by: Paul Spooren <mail@aparcar.org>
cute-signatures
Paul Spooren 2022-02-01 10:18:16 +01:00 committed by Timo Teräs
parent aa4880bc04
commit be4ce40797
1 changed files with 20 additions and 8 deletions

View File

@ -594,20 +594,32 @@ int apk_repo_format_real_url(apk_blob_t *default_arch, struct apk_repository *re
struct apk_package *pkg, char *buf, size_t len,
struct apk_url_print *urlp)
{
apk_blob_t uri = APK_BLOB_STR(repo->url);
apk_blob_t arch;
int r;
if (pkg && pkg->arch) arch = *pkg->arch;
else arch = *default_arch;
if (pkg != NULL)
r = snprintf(buf, len, "%s%s" BLOB_FMT "/" PKG_FILE_FMT,
repo->url, repo->url[strlen(repo->url)-1] == '/' ? "" : "/",
BLOB_PRINTF(arch), PKG_FILE_PRINTF(pkg));
else
r = snprintf(buf, len, "%s%s" BLOB_FMT "/%s",
repo->url, repo->url[strlen(repo->url)-1] == '/' ? "" : "/",
BLOB_PRINTF(arch), apkindex_tar_gz);
if (apk_blob_ends_with(uri, APK_BLOB_STR(".adb"))) {
if (pkg != NULL) {
apk_blob_rsplit(uri, '/', &uri, NULL);
r = snprintf(buf, len, BLOB_FMT "/" PKG_FILE_FMT,
BLOB_PRINTF(uri), PKG_FILE_PRINTF(pkg));
} else {
r = snprintf(buf, len, BLOB_FMT, BLOB_PRINTF(uri));
}
} else {
apk_blob_push_fmt(&uri, "/" BLOB_FMT, BLOB_PRINTF(arch));
if (pkg != NULL)
r = snprintf(buf, len, BLOB_FMT "/" BLOB_FMT "/" PKG_FILE_FMT,
BLOB_PRINTF(uri), BLOB_PRINTF(arch), PKG_FILE_PRINTF(pkg));
else
r = snprintf(buf, len, BLOB_FMT "/" BLOB_FMT "/%s",
BLOB_PRINTF(uri), BLOB_PRINTF(arch), apkindex_tar_gz);
}
if (r >= len)
return -ENOBUFS;