summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-01-16 16:25:19 +0200
committerTimo Teras <timo.teras@iki.fi>2009-01-16 16:25:19 +0200
commitedfaac3099a8a2b641523e3f0c9372d0f14f1429 (patch)
treef94194ca23ae3c68faab5a5adb3aa27af19c0a1e /src/database.c
parent82b9cb31fd6bbddc5878cc5bbebdf04b7f2d5649 (diff)
downloadapk-tools-edfaac3099a8a2b641523e3f0c9372d0f14f1429.tar.gz
apk-tools-edfaac3099a8a2b641523e3f0c9372d0f14f1429.tar.bz2
apk-tools-edfaac3099a8a2b641523e3f0c9372d0f14f1429.tar.xz
apk-tools-edfaac3099a8a2b641523e3f0c9372d0f14f1429.zip
db: apk_db_read_state() needs to be before apk_db_add_repository()
Otherwise installed db load fails due to internal reasons. This would cause a lot of other funny stuff happen.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/database.c b/src/database.c
index 4366223..a84f2e6 100644
--- a/src/database.c
+++ b/src/database.c
@@ -645,15 +645,6 @@ int apk_db_open(struct apk_database *db, const char *root)
free(db->root);
return -errno;
}
-
- if (apk_repos == NULL)
- apk_repos = "/etc/apk/repositories";
- blob = apk_blob_from_file(apk_repos);
- if (!APK_BLOB_IS_NULL(blob)) {
- apk_blob_for_each_segment(blob, "\n",
- apk_db_add_repository, db);
- free(blob.ptr);
- }
}
blob = APK_BLOB_STR("etc:-etc/init.d");
@@ -663,6 +654,19 @@ int apk_db_open(struct apk_database *db, const char *root)
if (r != 0)
return r;
+ if (root != NULL) {
+ if (apk_repos == NULL)
+ apk_repos = "/etc/apk/repositories";
+ blob = apk_blob_from_file(apk_repos);
+ if (!APK_BLOB_IS_NULL(blob)) {
+ r = apk_blob_for_each_segment(blob, "\n",
+ apk_db_add_repository, db);
+ free(blob.ptr);
+ if (r != 0)
+ return r;
+ }
+ }
+
if (apk_repository != NULL)
apk_db_add_repository(db, APK_BLOB_STR(apk_repository));