Skip to content
Snippets Groups Projects
Commit d76213e6 authored by Timo Teräs's avatar Timo Teräs
Browse files

apk: add --force-missing-repositories

parent 701c1279
No related branches found
No related tags found
No related merge requests found
......@@ -122,6 +122,9 @@ The following options are available for all commands.
*--force-broken-world*
Continue even if _world_ cannot be satisfied.
*--force-missing-repositories*
Continue even if some of the repository indexes are not available.
*--force-no-chroot*
Disable chroot for scripts. This can be used for rootfs creation when
chroot is not available. Scripts running outside a chroot environment
......
......@@ -62,6 +62,7 @@ static void version(struct apk_out *out, const char *prefix)
OPT(OPT_GLOBAL_force, APK_OPT_SH("f") "force") \
OPT(OPT_GLOBAL_force_binary_stdout, "force-binary-stdout") \
OPT(OPT_GLOBAL_force_broken_world, "force-broken-world") \
OPT(OPT_GLOBAL_force_missing_repositories, "force-missing-repositories") \
OPT(OPT_GLOBAL_force_no_chroot, "force-no-chroot") \
OPT(OPT_GLOBAL_force_non_repository, "force-non-repository") \
OPT(OPT_GLOBAL_force_old_apk, "force-old-apk") \
......@@ -155,6 +156,9 @@ static int option_parse_global(void *ctx, struct apk_ctx *ac, int opt, const cha
case OPT_GLOBAL_force_binary_stdout:
ac->force |= APK_FORCE_BINARY_STDOUT;
break;
case OPT_GLOBAL_force_missing_repositories:
ac->force |= APK_FORCE_MISSING_REPOSITORIES;
break;
case OPT_GLOBAL_interactive:
ac->flags |= APK_INTERACTIVE;
break;
......
......@@ -37,6 +37,7 @@
#define APK_FORCE_REFRESH BIT(3)
#define APK_FORCE_NON_REPOSITORY BIT(4)
#define APK_FORCE_BINARY_STDOUT BIT(5)
#define APK_FORCE_MISSING_REPOSITORIES BIT(6)
#define APK_OPENF_READ 0x0001
#define APK_OPENF_WRITE 0x0002
......
......@@ -237,6 +237,7 @@ int apk_db_index_read(struct apk_database *db, struct apk_istream *is, int repo)
int apk_db_index_read_file(struct apk_database *db, const char *file, int repo);
int apk_db_index_write(struct apk_database *db, struct apk_ostream *os);
int apk_db_repository_check(struct apk_database *db);
int apk_db_add_repository(apk_database_t db, apk_blob_t repository);
struct apk_repository *apk_db_select_repo(struct apk_database *db,
struct apk_package *pkg);
......
......@@ -188,7 +188,6 @@ static int cache_clean(struct apk_database *db)
static int cache_main(void *ctx, struct apk_ctx *ac, struct apk_string_array *args)
{
struct apk_out *out = &ac->out;
struct apk_database *db = ac->db;
struct cache_ctx *cctx = (struct cache_ctx *) ctx;
char *arg;
......@@ -214,18 +213,14 @@ static int cache_main(void *ctx, struct apk_ctx *ac, struct apk_string_array *ar
actions &= CACHE_CLEAN;
if ((actions & CACHE_DOWNLOAD) && (cctx->solver_flags || cctx->add_dependencies)) {
if (db->repositories.stale || db->repositories.unavailable) {
apk_err(out, "Not continuing due to stale/unavailable repositories.");
r = 3;
goto err;
}
if (apk_db_repository_check(db) != 0) return 3;
}
if (r == 0 && (actions & CACHE_CLEAN))
r = cache_clean(db);
if (r == 0 && (actions & CACHE_DOWNLOAD))
r = cache_download(cctx, db, args);
err:
return r;
}
......
......@@ -171,10 +171,7 @@ static int upgrade_main(void *ctx, struct apk_ctx *ac, struct apk_string_array *
"Use --force-broken-world to override.");
return -1;
}
if (db->repositories.stale || db->repositories.unavailable) {
apk_err(out, "Not continuing due to stale/unavailable repositories.");
return -1;
}
if (apk_db_repository_check(db) != 0) return -1;
solver_flags = APK_SOLVERF_UPGRADE | uctx->solver_flags;
if (!uctx->no_self_upgrade && !args->num) {
......
......@@ -2367,6 +2367,16 @@ int apk_db_index_read_file(struct apk_database *db, const char *file, int repo)
return load_index(db, apk_istream_from_file(AT_FDCWD, file), repo);
}
int apk_db_repository_check(struct apk_database *db)
{
if (db->ctx->force & APK_FORCE_MISSING_REPOSITORIES) return 0;
if (!db->repositories.stale && !db->repositories.unavailable) return 0;
apk_err(&db->ctx->out,
"Not continuing due to stale/unavailable repositories."
"Use --force-missing-repositories to continue.");
return -1;
}
int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository)
{
struct apk_database *db = _db.db;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment