summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2022-02-06 21:08:09 +0200
committerTimo Teräs <timo.teras@iki.fi>2022-02-21 10:24:05 +0200
commitf69ae302722d5792bc99292112abc06e1ba216c7 (patch)
tree38a30313e26ad8406aaed396f4597d34adaa89eb /src
parent9089edcc44fe12003f9d13d5868fa26b2e980a18 (diff)
downloadapk-tools-f69ae302722d5792bc99292112abc06e1ba216c7.tar.gz
apk-tools-f69ae302722d5792bc99292112abc06e1ba216c7.tar.bz2
apk-tools-f69ae302722d5792bc99292112abc06e1ba216c7.tar.xz
apk-tools-f69ae302722d5792bc99292112abc06e1ba216c7.zip
db: sort world dependencies to layers
Diffstat (limited to 'src')
-rw-r--r--src/apk_database.h1
-rw-r--r--src/apk_package.h3
-rw-r--r--src/database.c13
-rw-r--r--src/package.c12
-rw-r--r--src/solver.c5
5 files changed, 27 insertions, 7 deletions
diff --git a/src/apk_database.h b/src/apk_database.h
index 88107d3..f0f6ba5 100644
--- a/src/apk_database.h
+++ b/src/apk_database.h
@@ -101,6 +101,7 @@ struct apk_name {
unsigned is_dependency : 1;
unsigned auto_select_virtual: 1;
unsigned priority : 2;
+ unsigned layer : 4;
unsigned int foreach_genid;
union {
struct apk_solver_name_state ss;
diff --git a/src/apk_package.h b/src/apk_package.h
index e7e0a53..8d9cba4 100644
--- a/src/apk_package.h
+++ b/src/apk_package.h
@@ -48,6 +48,7 @@ struct apk_dependency {
unsigned conflict : 1;
unsigned result_mask : 4;
unsigned fuzzy : 1;
+ unsigned layer : 4; // solver sets for 'world' dependencies only
};
APK_ARRAY(apk_dependency_array, struct apk_dependency);
@@ -120,6 +121,8 @@ void apk_blob_push_deps(apk_blob_t *to, struct apk_database *, struct apk_depend
void apk_blob_pull_dep(apk_blob_t *from, struct apk_database *, struct apk_dependency *);
void apk_blob_pull_deps(apk_blob_t *from, struct apk_database *, struct apk_dependency_array **);
+int apk_deps_write_layer(struct apk_database *db, struct apk_dependency_array *deps,
+ struct apk_ostream *os, apk_blob_t separator, unsigned layer);
int apk_deps_write(struct apk_database *db, struct apk_dependency_array *deps,
struct apk_ostream *os, apk_blob_t separator);
diff --git a/src/database.c b/src/database.c
index 781cf99..1e674d7 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1819,11 +1819,16 @@ static int apk_db_write_layers(struct apk_database *db)
ld->installed = apk_ostream_to_file(ld->fd, "installed", 0644);
ld->scripts = apk_ostream_to_file(ld->fd, "scripts.tar", 0644);
ld->triggers = apk_ostream_to_file(ld->fd, "triggers", 0644);
- }
- os = apk_ostream_to_file(db->root_fd, apk_world_file, 0644);
- if (!IS_ERR(os)) {
- apk_deps_write(db, db->world, os, APK_BLOB_PTR_LEN("\n", 1));
+ if (i == 0)
+ os = apk_ostream_to_file(db->root_fd, apk_world_file, 0644);
+ else
+ os = apk_ostream_to_file(ld->fd, "world", 0644);
+ if (IS_ERR(os)) {
+ if (!rr) rr = PTR_ERR(os);
+ continue;
+ }
+ apk_deps_write_layer(db, db->world, os, APK_BLOB_PTR_LEN("\n", 1), i);
apk_ostream_write(os, "\n", 1);
r = apk_ostream_close(os);
if (!rr) rr = r;
diff --git a/src/package.c b/src/package.c
index eef5dd5..cc86192 100644
--- a/src/package.c
+++ b/src/package.c
@@ -423,7 +423,7 @@ void apk_blob_push_deps(apk_blob_t *to, struct apk_database *db, struct apk_depe
}
}
-int apk_deps_write(struct apk_database *db, struct apk_dependency_array *deps, struct apk_ostream *os, apk_blob_t separator)
+int apk_deps_write_layer(struct apk_database *db, struct apk_dependency_array *deps, struct apk_ostream *os, apk_blob_t separator, unsigned layer)
{
apk_blob_t blob;
char tmp[256];
@@ -433,9 +433,10 @@ int apk_deps_write(struct apk_database *db, struct apk_dependency_array *deps, s
return 0;
for (i = 0; i < deps->num; i++) {
+ if (layer != -1 && deps->item[i].layer != layer) continue;
+
blob = APK_BLOB_BUF(tmp);
- if (i)
- apk_blob_push_blob(&blob, separator);
+ if (n) apk_blob_push_blob(&blob, separator);
apk_blob_push_dep(&blob, db, &deps->item[i]);
blob = apk_blob_pushed(APK_BLOB_BUF(tmp), blob);
@@ -449,6 +450,11 @@ int apk_deps_write(struct apk_database *db, struct apk_dependency_array *deps, s
return n;
}
+int apk_deps_write(struct apk_database *db, struct apk_dependency_array *deps, struct apk_ostream *os, apk_blob_t separator)
+{
+ return apk_deps_write_layer(db, deps, os, separator, -1);
+}
+
void apk_dep_from_adb(struct apk_dependency *dep, struct apk_database *db, struct adb_obj *d)
{
*dep = (struct apk_dependency) {
diff --git a/src/solver.c b/src/solver.c
index 2ea7f3f..3283659 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -1093,6 +1093,11 @@ restart:
goto restart;
}
+ foreach_array_item(d, world) {
+ if (!d->name->ss.chosen.pkg) continue;
+ d->layer = d->name->ss.chosen.pkg->layer;
+ }
+
apk_hash_foreach(&db->available.names, free_name, NULL);
apk_hash_foreach(&db->available.packages, free_package, NULL);
dbg_printf("solver done, errors=%d\n", ss->errors);