summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-04-14 09:21:30 +0300
committerTimo Teras <timo.teras@iki.fi>2009-04-14 09:21:30 +0300
commitc11b70c7f0f622f7b6c346ed20ed80ba34f6d8ee (patch)
tree9f19dbe1c00e01865ab7cc92b101d42810012794 /src/database.c
parentf4210298adf0950c5ee41d8cc7026db7ba8b1821 (diff)
downloadapk-tools-c11b70c7f0f622f7b6c346ed20ed80ba34f6d8ee.tar.gz
apk-tools-c11b70c7f0f622f7b6c346ed20ed80ba34f6d8ee.tar.bz2
apk-tools-c11b70c7f0f622f7b6c346ed20ed80ba34f6d8ee.tar.xz
apk-tools-c11b70c7f0f622f7b6c346ed20ed80ba34f6d8ee.zip
db: track reverse dependencies
This will be used later by the commit change calculator (for improved changeset calculation, ref #7). Will be also used by "apk info" to show reverse dependencies or "required by" information.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/database.c b/src/database.c
index 976102b..5506ebb 100644
--- a/src/database.c
+++ b/src/database.c
@@ -329,6 +329,25 @@ static void apk_db_file_change_owner(struct apk_database *db,
*after = &file->diri_files_list.next;
}
+static void apk_db_pkg_rdepends(struct apk_database *db, struct apk_package *pkg)
+{
+ int i, j;
+
+ if (pkg->depends == NULL)
+ return;
+
+ for (i = 0; i < pkg->depends->num; i++) {
+ struct apk_name *rname = pkg->depends->item[i].name;
+
+ if (rname->rdepends) {
+ for (j = 0; j < rname->rdepends->num; j++)
+ if (rname->rdepends->item[j] == pkg->name)
+ return;
+ }
+ *apk_name_array_add(&rname->rdepends) = pkg->name;
+ }
+}
+
static struct apk_package *apk_db_pkg_add(struct apk_database *db, struct apk_package *pkg)
{
struct apk_package *idb;
@@ -339,6 +358,7 @@ static struct apk_package *apk_db_pkg_add(struct apk_database *db, struct apk_pa
pkg->id = db->pkg_id++;
apk_hash_insert(&db->available.packages, pkg);
*apk_package_array_add(&pkg->name->pkgs) = pkg;
+ apk_db_pkg_rdepends(db, pkg);
} else {
idb->repos |= pkg->repos;
apk_pkg_free(pkg);