summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Spooren <mail@aparcar.org>2022-02-01 10:18:16 +0100
committerTimo Teräs <timo.teras@iki.fi>2022-02-14 17:21:51 +0000
commitbe4ce40797af9056c79be4dc74ff978f1f4957e4 (patch)
tree8a148d3745ba03831a9898b9ee1667fab207087b
parentaa4880bc046af5ce30b226adbc0ce88fd2b0ae7f (diff)
downloadapk-tools-be4ce40797af9056c79be4dc74ff978f1f4957e4.tar.gz
apk-tools-be4ce40797af9056c79be4dc74ff978f1f4957e4.tar.bz2
apk-tools-be4ce40797af9056c79be4dc74ff978f1f4957e4.tar.xz
apk-tools-be4ce40797af9056c79be4dc74ff978f1f4957e4.zip
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>
-rw-r--r--src/database.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/database.c b/src/database.c
index a122d91..72fd482 100644
--- a/src/database.c
+++ b/src/database.c
@@ -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;