summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-05-15 07:46:43 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-05-15 07:46:43 +0000
commit7950a2b5a5c1d1da3698f53f520b0acc32ade224 (patch)
tree9e98463645d693d09ebe4175b0a55e3b0e09c7e8
parentb91f9406dacb8585dd2f50548f72a36f378f5933 (diff)
downloadapk-tools-7950a2b5a5c1d1da3698f53f520b0acc32ade224.tar.gz
apk-tools-7950a2b5a5c1d1da3698f53f520b0acc32ade224.tar.bz2
apk-tools-7950a2b5a5c1d1da3698f53f520b0acc32ade224.tar.xz
apk-tools-7950a2b5a5c1d1da3698f53f520b0acc32ade224.zip
add: improve error reporting for virtual packages
By locking all the given dependendencies for virtual packages first we can catch invalid deps and report those. This is alot more helpful than just reporting "Unable to install <virutalpkg>"
-rw-r--r--src/add.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/add.c b/src/add.c
index da83fe0..985c6bc 100644
--- a/src/add.c
+++ b/src/add.c
@@ -47,6 +47,7 @@ static int add_main(void *ctx, int argc, char **argv)
struct apk_state *state = NULL;
struct apk_dependency_array *pkgs = NULL;
struct apk_package *virtpkg = NULL;
+ struct apk_dependency virtdep;
int i, r;
r = apk_db_open(&db, apk_root, actx->open_flags | APK_OPENF_WRITE);
@@ -54,7 +55,6 @@ static int add_main(void *ctx, int argc, char **argv)
return r;
if (actx->virtpkg) {
- struct apk_dependency dep;
virtpkg = apk_pkg_new();
if (virtpkg == NULL) {
apk_error("Failed to allocate virtual meta package");
@@ -63,14 +63,13 @@ static int add_main(void *ctx, int argc, char **argv)
virtpkg->name = apk_db_get_name(&db, APK_BLOB_STR(actx->virtpkg));
virtpkg->version = strdup("0");
virtpkg->description = strdup("virtual meta package");
- dep = (struct apk_dependency) {
+ virtdep = (struct apk_dependency) {
.name = virtpkg->name,
.version = virtpkg->version,
.result_mask = APK_VERSION_EQUAL,
};
- dep.name->flags |= APK_NAME_TOPLEVEL | APK_NAME_VIRTUAL;
+ virtdep.name->flags |= APK_NAME_TOPLEVEL | APK_NAME_VIRTUAL;
virtpkg = apk_db_pkg_add(&db, virtpkg);
- apk_deps_add(&pkgs, &dep);
}
for (i = 0; i < argc; i++) {
@@ -100,10 +99,13 @@ static int add_main(void *ctx, int argc, char **argv)
apk_deps_add(&virtpkg->depends, &dep);
} else {
dep.name->flags |= APK_NAME_TOPLEVEL;
- apk_deps_add(&pkgs, &dep);
}
+ apk_deps_add(&pkgs, &dep);
}
+ if (virtpkg)
+ apk_deps_add(&pkgs, &virtdep);
+
state = apk_state_new(&db);
for (i = 0; i < pkgs->num; i++) {
r = apk_state_lock_dependency(state, &pkgs->item[i]);