summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-12-21 14:30:33 +0200
committerTimo Teras <timo.teras@iki.fi>2009-12-21 14:30:33 +0200
commitf2a7800b22c6ffb5321f286512c76f286131ac8d (patch)
tree9d714c39cdbd98672c3aa9cedbd5c5412855740e /src/database.c
parentd0909569c639a033a6f1c47a95745886ebe3e093 (diff)
downloadapk-tools-f2a7800b22c6ffb5321f286512c76f286131ac8d.tar.gz
apk-tools-f2a7800b22c6ffb5321f286512c76f286131ac8d.tar.bz2
apk-tools-f2a7800b22c6ffb5321f286512c76f286131ac8d.tar.xz
apk-tools-f2a7800b22c6ffb5321f286512c76f286131ac8d.zip
db: use proper instance for overlay file entries
lookup proper directory instance as the tar output might not be linear.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/src/database.c b/src/database.c
index 3bfefeb..dd64c34 100644
--- a/src/database.c
+++ b/src/database.c
@@ -481,6 +481,31 @@ int apk_cache_download(struct apk_database *db, const char *url,
return 0;
}
+static struct apk_db_dir_instance *find_diri(struct apk_installed_package *ipkg,
+ apk_blob_t dirname,
+ struct apk_db_dir_instance *curdiri,
+ struct hlist_node ***tail)
+{
+ struct hlist_node *n;
+ struct apk_db_dir_instance *diri;
+
+ if (curdiri != NULL &&
+ apk_blob_compare(APK_BLOB_PTR_LEN(curdiri->dir->name,
+ curdiri->dir->namelen),
+ dirname) == 0)
+ return curdiri;
+
+ hlist_for_each_entry(diri, n, &ipkg->owned_dirs, pkg_dirs_list) {
+ if (apk_blob_compare(APK_BLOB_PTR_LEN(diri->dir->name,
+ diri->dir->namelen), dirname) == 0) {
+ if (tail != NULL)
+ *tail = hlist_tail_ptr(&diri->owned_files);
+ return diri;
+ }
+ }
+ return NULL;
+}
+
int apk_db_read_overlay(struct apk_database *db, struct apk_bstream *bs)
{
struct apk_db_dir_instance *diri = NULL;
@@ -508,6 +533,14 @@ int apk_db_read_overlay(struct apk_database *db, struct apk_bstream *bs)
diri = apk_db_diri_new(db, pkg, bdir, &diri_node);
file_diri_node = &diri->owned_files.first;
} else {
+ diri = find_diri(ipkg, bdir, diri, &file_diri_node);
+ if (diri == NULL) {
+ apk_error("overlay: File '%*s' entry without "
+ "directory entry.\n",
+ line.len, line.ptr);
+ return -1;
+ }
+
file = apk_db_file_get(db, diri, bfile, &file_diri_node);
}
}
@@ -1587,31 +1620,6 @@ static int apk_db_run_pending_script(struct install_ctx *ctx)
return r;
}
-static struct apk_db_dir_instance *find_diri(struct apk_installed_package *ipkg,
- apk_blob_t dirname,
- struct apk_db_dir_instance *curdiri,
- struct hlist_node ***tail)
-{
- struct hlist_node *n;
- struct apk_db_dir_instance *diri;
-
- if (curdiri != NULL &&
- apk_blob_compare(APK_BLOB_PTR_LEN(curdiri->dir->name,
- curdiri->dir->namelen),
- dirname) == 0)
- return curdiri;
-
- hlist_for_each_entry(diri, n, &ipkg->owned_dirs, pkg_dirs_list) {
- if (apk_blob_compare(APK_BLOB_PTR_LEN(diri->dir->name,
- diri->dir->namelen), dirname) == 0) {
- if (tail != NULL)
- *tail = hlist_tail_ptr(&diri->owned_files);
- return diri;
- }
- }
- return NULL;
-}
-
static int parse_replaces(void *_ctx, apk_blob_t blob)
{
struct install_ctx *ctx = (struct install_ctx *) _ctx;