summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-11-08 14:19:24 +0200
committerTimo Teräs <timo.teras@iki.fi>2021-11-09 21:50:11 +0200
commit7d6de2203e1e4865eda4881fd559b963f230bb26 (patch)
treec360bf5bd0ce0aa42aa06a3e750afddc7caa9a3c /src/database.c
parenta6736532001fd625f1ab3dd82abc2a4c5366c79c (diff)
downloadapk-tools-7d6de2203e1e4865eda4881fd559b963f230bb26.tar.gz
apk-tools-7d6de2203e1e4865eda4881fd559b963f230bb26.tar.bz2
apk-tools-7d6de2203e1e4865eda4881fd559b963f230bb26.tar.xz
apk-tools-7d6de2203e1e4865eda4881fd559b963f230bb26.zip
database: support loading v3 indexes
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/database.c b/src/database.c
index a3a5800..4f0722b 100644
--- a/src/database.c
+++ b/src/database.c
@@ -2176,8 +2176,33 @@ static int load_v2index(struct apk_extract_ctx *ectx, apk_blob_t *desc, struct a
return apk_db_index_read(ctx->db, is, ctx->repo);
}
+static int load_v3index(struct apk_extract_ctx *ectx, struct adb_obj *ndx)
+{
+ struct apkindex_ctx *ctx = container_of(ectx, struct apkindex_ctx, ectx);
+ struct apk_database *db = ctx->db;
+ struct apk_repository *repo = &db->repos[ctx->repo];
+ struct apk_package *pkg;
+ struct adb_obj pkgs, pkginfo;
+ int i;
+
+ repo->description = apk_blob_dup(adb_ro_blob(ndx, ADBI_NDX_DESCRIPTION));
+ adb_ro_obj(ndx, ADBI_NDX_PACKAGES, &pkgs);
+
+ for (i = ADBI_FIRST; i <= adb_ra_num(&pkgs); i++) {
+ adb_ro_obj(&pkgs, i, &pkginfo);
+ pkg = apk_pkg_new();
+ if (!pkg) return -ENOMEM;
+ apk_pkg_from_adb(db, pkg, &pkginfo);
+ pkg->repos |= BIT(ctx->repo);
+ if (!apk_db_pkg_add(db, pkg)) return -APKE_ADB_SCHEMA;
+ }
+
+ return 0;
+}
+
static const struct apk_extract_ops extract_index = {
.v2index = load_v2index,
+ .v3index = load_v3index,
};
static int load_index(struct apk_database *db, struct apk_istream *is, int repo)