From b0921ebac5184be14bac6548b9d91afb721da9a8 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 21 Apr 2009 11:39:16 +0000 Subject: info: do not read the repositories as this tool only query the statedb This allows you to query the state db even if you do not have write permissions in cache dir (which is needed if you have remote repositories) This should speed up things and save some memory if you have big and slow remote repositories. --- src/apk_database.h | 1 + src/database.c | 30 ++++++++++++++++-------------- src/info.c | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/apk_database.h b/src/apk_database.h index db8a019..e7bfac9 100644 --- a/src/apk_database.h +++ b/src/apk_database.h @@ -113,6 +113,7 @@ struct apk_db_file *apk_db_file_query(struct apk_database *db, #define APK_OPENF_WRITE 0x0001 #define APK_OPENF_CREATE 0x0002 #define APK_OPENF_EMPTY_STATE 0x0004 +#define APK_OPENF_EMPTY_REPOS 0x0008 int apk_db_open(struct apk_database *db, const char *root, unsigned int flags); int apk_db_write_config(struct apk_database *db); diff --git a/src/database.c b/src/database.c index 94fc3a0..4da547d 100644 --- a/src/database.c +++ b/src/database.c @@ -712,23 +712,25 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags) } } - 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) - goto ret_r; + if (!(flags & APK_OPENF_EMPTY_REPOS)) { + 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) + goto ret_r; + } } } - list_for_each_entry(repo, &apk_repository_list.list, list) { - r = apk_db_add_repository(db, APK_BLOB_STR(repo->url)); - if (r != 0) { - msg = repo->url; - goto ret_r; + if (!(flags & APK_OPENF_EMPTY_REPOS)) { + list_for_each_entry(repo, &apk_repository_list.list, list) { + r = apk_db_add_repository(db, APK_BLOB_STR(repo->url)); + if (r != 0) + goto ret_r; } } diff --git a/src/info.c b/src/info.c index 7a4c519..5dd0e30 100644 --- a/src/info.c +++ b/src/info.c @@ -228,7 +228,7 @@ static int info_main(void *ctx, int argc, char **argv) struct apk_database db; int r; - if (apk_db_open(&db, apk_root, APK_OPENF_READ) < 0) + if (apk_db_open(&db, apk_root, APK_OPENF_READ + APK_OPENF_EMPTY_REPOS) < 0) return -1; if (ictx->action != NULL) -- cgit v1.2.3-70-g09d2