diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-06-19 19:01:15 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-06-19 19:01:15 +0200 |
commit | cb074581f0d65bc43188d3552dd72c405c53e5d9 (patch) | |
tree | fc9c0fdc884884e91c6f616131daf3d04b1a8944 | |
parent | b669e488ed97e16ec4acd769ecaee24fbeffcc7b (diff) | |
download | apk-tools-cb074581f0d65bc43188d3552dd72c405c53e5d9.tar.gz apk-tools-cb074581f0d65bc43188d3552dd72c405c53e5d9.tar.bz2 apk-tools-cb074581f0d65bc43188d3552dd72c405c53e5d9.tar.xz apk-tools-cb074581f0d65bc43188d3552dd72c405c53e5d9.zip |
db: add function apk_repository_update_all
We might want to add an --update-index option to misc applets. For
example:
apk add --update-index -u package
apk version --update-index
-rw-r--r-- | src/apk_database.h | 1 | ||||
-rw-r--r-- | src/database.c | 11 | ||||
-rw-r--r-- | src/update.c | 5 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/apk_database.h b/src/apk_database.h index 523dab5..6f18277 100644 --- a/src/apk_database.h +++ b/src/apk_database.h @@ -130,6 +130,7 @@ int apk_db_index_write(struct apk_database *db, struct apk_ostream *os); int apk_db_add_repository(apk_database_t db, apk_blob_t repository); int apk_repository_update(struct apk_database *db, struct apk_repository *repo); +int apk_repository_update_all(struct apk_database *db); int apk_db_install_pkg(struct apk_database *db, struct apk_package *oldpkg, diff --git a/src/database.c b/src/database.c index 7ec9764..b1cdf85 100644 --- a/src/database.c +++ b/src/database.c @@ -959,6 +959,17 @@ int apk_repository_update(struct apk_database *db, struct apk_repository *repo) return 0; } +int apk_repository_update_all(struct apk_database *db) +{ + int i, ret; + for (i = 0; i < db->num_repos; i++) { + ret = apk_repository_update(db, &db->repos[i]); + if (ret < 0) + return ret; + } + return 0; +} + int apk_db_add_repository(apk_database_t _db, apk_blob_t repository) { struct apk_database *db = _db.db; diff --git a/src/update.c b/src/update.c index 4351653..c34fc07 100644 --- a/src/update.c +++ b/src/update.c @@ -18,14 +18,11 @@ static int update_main(void *ctx, int argc, char **argv) { struct apk_database db; - int i; if (apk_db_open(&db, apk_root, APK_OPENF_READ) < 0) return -1; - for (i = 0; i < db.num_repos; i++) - apk_repository_update(&db, &db.repos[i]); - + apk_repository_update_all(&db); apk_db_close(&db); return 0; |