summaryrefslogtreecommitdiff
path: root/src/package.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-06-16 09:59:21 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-06-16 09:59:21 +0000
commit20a1217e866f9fe15c4de3ed28144084509e4ffa (patch)
tree2bc0c87439ef575dfd565fc081a51d501f4737ce /src/package.c
parentd8b1b851c713937bdb1a756f9419e3f97516d479 (diff)
downloadapk-tools-20a1217e866f9fe15c4de3ed28144084509e4ffa.tar.gz
apk-tools-20a1217e866f9fe15c4de3ed28144084509e4ffa.tar.bz2
apk-tools-20a1217e866f9fe15c4de3ed28144084509e4ffa.tar.xz
apk-tools-20a1217e866f9fe15c4de3ed28144084509e4ffa.zip
add: support for forced versions
Support version numbers specified with packages. For example: apk add 'busybox<1.14' apk add 'squid=>3.0'
Diffstat (limited to 'src/package.c')
-rw-r--r--src/package.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/package.c b/src/package.c
index 029167d..0cad132 100644
--- a/src/package.c
+++ b/src/package.c
@@ -663,3 +663,36 @@ int apk_pkg_write_index_entry(struct apk_package *info,
return n;
}
+
+struct apk_dependency apk_dep_from_str(struct apk_database *db,
+ char *str)
+{
+ apk_blob_t name = APK_BLOB_STR(str);
+ char *v = str;
+ int mask = APK_DEPMASK_REQUIRE;
+
+ v = strpbrk(str, "<>=");
+ if (v != NULL) {
+ name.len = v - str;
+ mask = apk_version_result_mask(v++);
+ if (*v == '=')
+ v++;
+ }
+ printf("DEBUG: result_mask = %x\n", mask);
+ return (struct apk_dependency) {
+ .name = apk_db_get_name(db, name),
+ .version = v,
+ .result_mask = mask,
+ };
+}
+
+struct apk_dependency apk_dep_from_pkg(struct apk_database *db,
+ struct apk_package *pkg)
+{
+ return (struct apk_dependency) {
+ .name = apk_db_get_name(db, APK_BLOB_STR(pkg->name->name)),
+ .version = pkg->version,
+ .result_mask = APK_VERSION_EQUAL,
+ };
+}
+