summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-08-06 16:39:09 +0300
committerTimo Teras <timo.teras@iki.fi>2009-08-06 16:39:09 +0300
commitbf7b80662d75181caf1619c047078dafe80346f9 (patch)
treebbb13a031c2805a8c45fd79f079b46624812f8d5 /src
parentf02f326238fd1e6424bf914e102ce265e7c156ec (diff)
downloadapk-tools-bf7b80662d75181caf1619c047078dafe80346f9.tar.gz
apk-tools-bf7b80662d75181caf1619c047078dafe80346f9.tar.bz2
apk-tools-bf7b80662d75181caf1619c047078dafe80346f9.tar.xz
apk-tools-bf7b80662d75181caf1619c047078dafe80346f9.zip
state: do not look into world in state_new
instead enforce world dependencies when the package name is first referenced upon.
Diffstat (limited to 'src')
-rw-r--r--src/database.c3
-rw-r--r--src/state.c43
2 files changed, 25 insertions, 21 deletions
diff --git a/src/database.c b/src/database.c
index d7bcb2d..425fb46 100644
--- a/src/database.c
+++ b/src/database.c
@@ -854,8 +854,6 @@ static int add_protected_path(void *ctx, apk_blob_t blob)
static int apk_db_create(struct apk_database *db)
{
- apk_blob_t deps = APK_BLOB_STR("busybox alpine-baselayout "
- "apk-tools alpine-conf");
int fd;
mkdirat(db->root_fd, "tmp", 01777);
@@ -868,7 +866,6 @@ static int apk_db_create(struct apk_database *db)
fd = openat(db->root_fd, "var/lib/apk/world", O_CREAT|O_RDWR|O_TRUNC, 0644);
if (fd < 0)
return -errno;
- write(fd, deps.ptr, deps.len);
close(fd);
return 0;
diff --git a/src/state.c b/src/state.c
index f18b005..a46fc4f 100644
--- a/src/state.c
+++ b/src/state.c
@@ -82,9 +82,11 @@ static struct apk_name_choices *ns_to_choices(apk_name_state_t name)
return (struct apk_name_choices *) name;
}
-static struct apk_name_choices *name_choices_new(struct apk_name *name)
+static struct apk_name_choices *name_choices_new(struct apk_database *db,
+ struct apk_name *name)
{
struct apk_name_choices *nc;
+ int i, j;
if (name->pkgs == NULL)
return NULL;
@@ -98,6 +100,26 @@ static struct apk_name_choices *name_choices_new(struct apk_name *name)
nc->num = name->pkgs->num;
memcpy(nc->pkgs, name->pkgs->item,
name->pkgs->num * sizeof(struct apk_package *));
+
+ /* Check for global dependencies */
+ for (i = 0; db->world != NULL && i < db->world->num; i++) {
+ struct apk_dependency *dep = &db->world->item[i];
+
+ if (dep->name != name)
+ continue;
+
+ for (j = 0; j < nc->num; ) {
+ if (apk_version_compare(nc->pkgs[j]->version, dep->version)
+ & dep->result_mask) {
+ j++;
+ } else {
+ nc->pkgs[i] = nc->pkgs[nc->num - 1];
+ nc->num--;
+ }
+ }
+
+ }
+
return nc;
}
@@ -136,7 +158,7 @@ static void ns_free(apk_name_state_t name)
struct apk_state *apk_state_new(struct apk_database *db)
{
struct apk_state *state;
- int num_bytes, i, r;
+ int num_bytes;
num_bytes = sizeof(struct apk_state) + db->name_id * sizeof(char *);
state = (struct apk_state*) calloc(1, num_bytes);
@@ -145,22 +167,7 @@ struct apk_state *apk_state_new(struct apk_database *db)
state->db = db;
list_init(&state->change_list_head);
- /* Instantiate each 'name' target in world, and lockout incompatible
- * choices */
- for (i = 0; db->world != NULL && i < db->world->num; i++) {
- r = apk_state_prune_dependency(state, &db->world->item[i]);
- if (r < 0 && apk_verbosity && !(apk_flags & APK_FORCE)) {
- apk_error("Top level dependencies for %s are "
- "conflicting or unsatisfiable.",
- db->world->item[i].name->name);
- goto err;
- }
- }
-
return state;
-err:
- free(state);
- return NULL;
}
struct apk_state *apk_state_dup(struct apk_state *state)
@@ -217,7 +224,7 @@ int apk_state_prune_dependency(struct apk_state *state,
/* This name has not been visited yet.
* Construct list of candidates. */
- state->name[name->id] = ns_from_choices(name_choices_new(name));
+ state->name[name->id] = ns_from_choices(name_choices_new(state->db, name));
}
if (ns_locked(state->name[name->id])) {