summaryrefslogtreecommitdiff
path: root/src/package.c
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2017-11-02 02:55:17 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2017-11-02 03:08:24 +0000
commitf18c708183ac735d1787ff5b450d36f6596a10b9 (patch)
tree2a8cbb76760ae075b675f15a751d207059a20b56 /src/package.c
parentee3740fcc681b8585b3d8d363453585cae4257aa (diff)
downloadapk-tools-f18c708183ac735d1787ff5b450d36f6596a10b9.tar.gz
apk-tools-f18c708183ac735d1787ff5b450d36f6596a10b9.tar.bz2
apk-tools-f18c708183ac735d1787ff5b450d36f6596a10b9.tar.xz
apk-tools-f18c708183ac735d1787ff5b450d36f6596a10b9.zip
solver: implement support for choosing default virtuals
By introducing a new package metadata field, `provider_priority` (index letter `k`), we can specify default packages to satisfy a virtual. If a user wishes to select an alternative provider for the virtual, a changeset swapping the default provider for the selected provider will be generated by the dependency resolver.
Diffstat (limited to 'src/package.c')
-rw-r--r--src/package.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/package.c b/src/package.c
index be7f269..d851ff0 100644
--- a/src/package.c
+++ b/src/package.c
@@ -812,6 +812,9 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg,
case 'c':
pkg->commit = apk_blob_cstr(value);
break;
+ case 'k':
+ pkg->provider_priority = apk_blob_pull_uint(&value, 10);
+ break;
case 'F': case 'M': case 'R': case 'Z': case 'r': case 'q':
case 'a': case 's': case 'f':
/* installed db entries which are handled in database.c */
@@ -850,6 +853,7 @@ static int read_info_line(void *ctx, apk_blob_t line)
{ "maintainer", 'm' },
{ "builddate", 't' },
{ "commit", 'c' },
+ { "provider_priority", 'k' },
};
struct read_info_ctx *ri = (struct read_info_ctx *) ctx;
apk_blob_t l, r;
@@ -1125,6 +1129,10 @@ int apk_pkg_write_index_entry(struct apk_package *info,
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nc:"));
apk_blob_push_blob(&bbuf, APK_BLOB_STR(info->commit));
}
+ if (info->provider_priority) {
+ apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nk:"));
+ apk_blob_push_uint(&bbuf, info->provider_priority, 10);
+ }
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\n"));
if (APK_BLOB_IS_NULL(bbuf)) {