Commit cb074581 authored by Natanael Copa's avatar Natanael Copa

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
parent b669e488
......@@ -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,
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment