apk3: conflicts are broken
When you create a package with a dependency constraint like !foo
(i.e. via mkpkg --info "depends:!foo"
) the package is not installable under apk3. For example, in my system:
=> cbuild: installing base-cbuild...
ERROR: unable to select packages:
util-linux (no such package):
required by: util-linux-cbuild-2.37.2-r0[util-linux]
In this case, util-linux-cbuild
has a dependency constraint !util-linux
set, which is written in the adb, but util-linux
package itself does not exist in the repository. This behavior worked correctly in apk2.
Another problem is that the serialization and deserialization for mkpkg
and adbdump
does not actually work. This appears to be unrelated to why it's not installable. I managed to fix the serialization behavior with this patch:
From c33c0d238ff5ac8897a5cf67111de9862f5acaf0 Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Sun, 6 Mar 2022 19:08:06 +0100
Subject: [PATCH] adb: fix serialization and deserialization of conflicts
Ensure not to mask away previously set APK_VERSION_CONFLICT when
serializing.
When deserializing, make sure to actually write out the conflict
flag when no version part is set.
---
src/apk_adb.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/apk_adb.c b/src/apk_adb.c
index ea27a4d..250295e 100644
--- a/src/apk_adb.c
+++ b/src/apk_adb.c
@@ -259,10 +259,17 @@ static apk_blob_t dependency_tostring(struct adb_obj *obj, char *buf, size_t buf
name = adb_ro_blob(obj, ADBI_DEP_NAME);
ver = adb_ro_blob(obj, ADBI_DEP_VERSION);
+ mask = adb_ro_int(obj, ADBI_DEP_MATCH) ?: APK_VERSION_EQUAL;
+
if (APK_BLOB_IS_NULL(name)) return APK_BLOB_NULL;
- if (APK_BLOB_IS_NULL(ver)) return name;
+ if (APK_BLOB_IS_NULL(ver)) {
+ if (mask & APK_VERSION_CONFLICT)
+ return APK_BLOB_PTR_LEN(buf,
+ snprintf(buf, bufsz, "!"BLOB_FMT,
+ BLOB_PRINTF(name)));
+ return name;
+ }
- mask = adb_ro_int(obj, ADBI_DEP_MATCH) ?: APK_VERSION_EQUAL;
return APK_BLOB_PTR_LEN(buf,
snprintf(buf, bufsz, "%s"BLOB_FMT"%s"BLOB_FMT,
(mask & APK_VERSION_CONFLICT) ? "!" : "",
@@ -295,7 +302,7 @@ static int dependency_fromstring(struct adb_obj *obj, apk_blob_t bdep)
if (!apk_blob_spn(bop, apk_spn_dependency_comparer, &bop, &bver))
goto fail;
- mask = 0;
+ mask &= APK_VERSION_CONFLICT;
for (i = 0; i < bop.len; i++) {
switch (bop.ptr[i]) {
case '<':
--
2.35.1
However, that does not fix the actual installation, it only fixes enough so I can see it correctly in adbdump
:
depends: # 3 items
- so:libc.so
- so:libz.so.1
- !util-linux