summaryrefslogtreecommitdiff
path: root/src/package.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-01-01 16:58:58 +0200
committerTimo Teräs <timo.teras@iki.fi>2011-01-01 16:58:58 +0200
commit1c7e8d2617d93daac1fe0c38c0279435331bb152 (patch)
treecb801169ccccebad45293071694f877c73447823 /src/package.c
parent65826761508d1b9effd62e7665d6db23b6fabe2f (diff)
downloadapk-tools-1c7e8d2617d93daac1fe0c38c0279435331bb152.tar.gz
apk-tools-1c7e8d2617d93daac1fe0c38c0279435331bb152.tar.bz2
apk-tools-1c7e8d2617d93daac1fe0c38c0279435331bb152.tar.xz
apk-tools-1c7e8d2617d93daac1fe0c38c0279435331bb152.zip
pkg: dependencies to specific package checksum
When package is installed from commandline, we should always install that specific instance of package (never favor repository version if it has difference identity). Otherwise we might not always end-up installing the .apk given on command line. The dependency is now against specific checksum identity (marked with >< dependency comparison). Fixes #492.
Diffstat (limited to 'src/package.c')
-rw-r--r--src/package.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/package.c b/src/package.c
index dfd9cc9..37e4357 100644
--- a/src/package.c
+++ b/src/package.c
@@ -222,11 +222,8 @@ int apk_dep_from_blob(struct apk_dependency *dep, struct apk_database *db,
break;
}
}
- if ((mask & (APK_VERSION_LESS|APK_VERSION_GREATER))
- == (APK_VERSION_LESS|APK_VERSION_GREATER))
- return -EINVAL;
-
- if (!apk_version_validate(bver))
+ if ((mask & APK_DEPMASK_CHECKSUM) != APK_DEPMASK_CHECKSUM &&
+ !apk_version_validate(bver))
return -EINVAL;
blob = bname;
@@ -247,10 +244,16 @@ int apk_dep_from_blob(struct apk_dependency *dep, struct apk_database *db,
void apk_dep_from_pkg(struct apk_dependency *dep, struct apk_database *db,
struct apk_package *pkg)
{
+ char buf[64];
+ apk_blob_t b = APK_BLOB_BUF(buf);
+
+ apk_blob_push_csum(&b, &pkg->csum);
+ b = apk_blob_pushed(APK_BLOB_BUF(buf), b);
+
*dep = (struct apk_dependency) {
.name = pkg->name,
- .version = pkg->version,
- .result_mask = APK_VERSION_EQUAL,
+ .version = apk_blob_atomize_dup(b),
+ .result_mask = APK_DEPMASK_CHECKSUM,
};
}
@@ -273,6 +276,25 @@ static int parse_depend(void *ctx, apk_blob_t blob)
return 0;
}
+int apk_dep_is_satisfied(struct apk_dependency *dep, struct apk_package *pkg)
+{
+ if (dep->name != pkg->name)
+ return 0;
+ if (dep->result_mask == APK_DEPMASK_CHECKSUM) {
+ struct apk_checksum csum;
+ apk_blob_t b = *dep->version;
+
+ apk_blob_pull_csum(&b, &csum);
+ if (apk_checksum_compare(&csum, &pkg->csum) == 0)
+ return 1;
+ } else {
+ if (apk_version_compare_blob(*pkg->version, *dep->version)
+ & dep->result_mask)
+ return 1;
+ }
+ return 0;
+}
+
void apk_deps_parse(struct apk_database *db,
struct apk_dependency_array **depends,
apk_blob_t blob)