summaryrefslogtreecommitdiff
path: root/src
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:02:04 +0300
commitd7650fc5e5a0119879d536b2c3c99ce85befd221 (patch)
tree3c3c60bc554dfec3a72b07438840911c51a13556 /src
parent67c0583a5e18c27880e2785536be3e66ff1c4bdd (diff)
downloadapk-tools-d7650fc5e5a0119879d536b2c3c99ce85befd221.tar.gz
apk-tools-d7650fc5e5a0119879d536b2c3c99ce85befd221.tar.bz2
apk-tools-d7650fc5e5a0119879d536b2c3c99ce85befd221.tar.xz
apk-tools-d7650fc5e5a0119879d536b2c3c99ce85befd221.zip
apk: add --force-missing-repositoriestt-stable-wip
Diffstat (limited to 'src')
-rw-r--r--src/apk.c4
-rw-r--r--src/apk_database.h1
-rw-r--r--src/apk_defines.h1
-rw-r--r--src/app_cache.c7
-rw-r--r--src/app_upgrade.c5
-rw-r--r--src/database.c9
6 files changed, 17 insertions, 10 deletions
diff --git a/src/apk.c b/src/apk.c
index a101cf6..7505b1c 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -78,6 +78,7 @@ static struct apk_repository_list *apk_repository_new(const char *url)
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_non_repository, "force-non-repository") \
OPT(OPT_GLOBAL_force_old_apk, "force-old-apk") \
OPT(OPT_GLOBAL_force_overwrite, "force-overwrite") \
@@ -167,6 +168,9 @@ static int option_parse_global(void *ctx, struct apk_db_options *dbopts, int opt
case OPT_GLOBAL_force_binary_stdout:
apk_force |= APK_FORCE_BINARY_STDOUT;
break;
+ case OPT_GLOBAL_force_missing_repositories:
+ apk_force |= APK_FORCE_MISSING_REPOSITORIES;
+ break;
case OPT_GLOBAL_interactive:
apk_flags |= APK_INTERACTIVE;
break;
diff --git a/src/apk_database.h b/src/apk_database.h
index d63da2d..52578d7 100644
--- a/src/apk_database.h
+++ b/src/apk_database.h
@@ -262,6 +262,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/apk_defines.h b/src/apk_defines.h
index 8224acf..a9c06aa 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -91,6 +91,7 @@ extern char **apk_argv;
#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)
/* default architecture for APK packages. */
#if defined(__x86_64__)
diff --git a/src/app_cache.c b/src/app_cache.c
index 13cd6ce..f40c836 100644
--- a/src/app_cache.c
+++ b/src/app_cache.c
@@ -211,18 +211,13 @@ static int cache_main(void *ctx, struct apk_database *db, struct apk_string_arra
actions &= CACHE_CLEAN;
if ((actions & CACHE_DOWNLOAD) && (cctx->solver_flags || cctx->add_dependencies)) {
- if (db->repositories.stale || db->repositories.unavailable) {
- apk_error("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 c618cb6..d201b2e 100644
--- a/src/app_upgrade.c
+++ b/src/app_upgrade.c
@@ -164,10 +164,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
"Use --force-broken-world to override.");
return -1;
}
- if (db->repositories.stale || db->repositories.unavailable) {
- apk_error("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 140a9ef..13ce02f 100644
--- a/src/database.c
+++ b/src/database.c
@@ -2278,6 +2278,15 @@ 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), targz, repo);
}
+int apk_db_repository_check(struct apk_database *db)
+{
+ if (apk_force & APK_FORCE_MISSING_REPOSITORIES) return 0;
+ if (!db->repositories.stale && !db->repositories.unavailable) return 0;
+ apk_error("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;