summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2023-04-11 20:34:15 +0300
committerTimo Teräs <timo.teras@iki.fi>2023-04-11 21:00:57 +0300
commitd76213e643c39da7d3b4e5534b721238ad7e8baf (patch)
tree1ff201ef19c59962d73015ce3a6b6865c25b7bd1
parent701c1279050f4cfd6752b816b8aa125ccab109fc (diff)
downloadapk-tools-d76213e643c39da7d3b4e5534b721238ad7e8baf.tar.gz
apk-tools-d76213e643c39da7d3b4e5534b721238ad7e8baf.tar.bz2
apk-tools-d76213e643c39da7d3b4e5534b721238ad7e8baf.tar.xz
apk-tools-d76213e643c39da7d3b4e5534b721238ad7e8baf.zip
apk: add --force-missing-repositories
-rw-r--r--doc/apk.8.scd3
-rw-r--r--src/apk.c4
-rw-r--r--src/apk_context.h1
-rw-r--r--src/apk_database.h1
-rw-r--r--src/app_cache.c9
-rw-r--r--src/app_upgrade.c5
-rw-r--r--src/database.c10
7 files changed, 22 insertions, 11 deletions
diff --git a/doc/apk.8.scd b/doc/apk.8.scd
index 47347b3..316bb14 100644
--- a/doc/apk.8.scd
+++ b/doc/apk.8.scd
@@ -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
diff --git a/src/apk.c b/src/apk.c
index a937be8..bc7a124 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -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;
diff --git a/src/apk_context.h b/src/apk_context.h
index 8de3d92..2bf8b6a 100644
--- a/src/apk_context.h
+++ b/src/apk_context.h
@@ -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
diff --git a/src/apk_database.h b/src/apk_database.h
index d0a33a7..e53e13e 100644
--- a/src/apk_database.h
+++ b/src/apk_database.h
@@ -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);
diff --git a/src/app_cache.c b/src/app_cache.c
index ab192cd..ce6c8df 100644
--- a/src/app_cache.c
+++ b/src/app_cache.c
@@ -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;
}
diff --git a/src/app_upgrade.c b/src/app_upgrade.c
index 77f1d2a..5cf6cf8 100644
--- a/src/app_upgrade.c
+++ b/src/app_upgrade.c
@@ -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) {
diff --git a/src/database.c b/src/database.c
index 75ef611..781a443 100644
--- a/src/database.c
+++ b/src/database.c
@@ -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;