aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2018-01-03 15:17:11 +0200
committerTimo Teräs <timo.teras@iki.fi>2018-01-03 16:00:38 +0200
commit039ff3bd466819909a5295a43e40947a9e0b6c16 (patch)
tree1f22b1a16dd752e48142a0c5aff0697fb100ea78
parentf90af35e9c563bd4f865d8d47a7ae357191494db (diff)
downloadaports-039ff3bd466819909a5295a43e40947a9e0b6c16.tar.bz2
aports-039ff3bd466819909a5295a43e40947a9e0b6c16.tar.xz
split --force to several --force-[type] options
This unloads --force as several of the things are really not wanted together. E.g. --force-refresh is a lot different from --force-broken-world and doing --force to get the other might introduce unwanted behaviour. --force is still kept for backwards compatibility and it enables most things --force was used for.
-rw-r--r--src/add.c6
-rw-r--r--src/apk.c36
-rw-r--r--src/apk_defines.h10
-rw-r--r--src/commit.c6
-rw-r--r--src/database.c12
-rw-r--r--src/fetch.c3
-rw-r--r--src/index.c6
-rw-r--r--src/solver.c2
-rw-r--r--src/upgrade.c3
9 files changed, 60 insertions, 24 deletions
diff --git a/src/add.c b/src/add.c
index 742df07b78..dcaa45ce7b 100644
--- a/src/add.c
+++ b/src/add.c
@@ -60,7 +60,7 @@ static const struct apk_option_group optgroup_applet = {
static int non_repository_check(struct apk_database *db)
{
- if (apk_flags & APK_FORCE)
+ if (apk_force & APK_FORCE_NON_REPOSITORY)
return 0;
if (apk_db_cache_active(db))
return 0;
@@ -69,8 +69,8 @@ static int non_repository_check(struct apk_database *db)
apk_error("You tried to add a non-repository package to system, "
"but it would be lost on next reboot. Enable package caching "
- "(apk cache --help) or use --force if you know what you are "
- "doing.");
+ "(apk cache --help) or use --force-non-repository "
+ "if you know what you are doing.");
return 1;
}
diff --git a/src/apk.c b/src/apk.c
index 73c9f21832..22acf41c69 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -95,7 +95,27 @@ static int option_parse_global(void *ctx, struct apk_db_options *dbopts, int opt
version();
return -ESHUTDOWN;
case 'f':
- apk_flags |= APK_FORCE;
+ apk_force |= APK_FORCE_OVERWRITE | APK_FORCE_OLD_APK
+ | APK_FORCE_BROKEN_WORLD | APK_FORCE_NON_REPOSITORY
+ | APK_FORCE_BINARY_STDOUT;
+ break;
+ case 0x120:
+ apk_force |= APK_FORCE_OVERWRITE;
+ break;
+ case 0x121:
+ apk_force |= APK_FORCE_OLD_APK;
+ break;
+ case 0x122:
+ apk_force |= APK_FORCE_BROKEN_WORLD;
+ break;
+ case 0x123:
+ apk_force |= APK_FORCE_REFRESH;
+ break;
+ case 0x124:
+ apk_force |= APK_FORCE_NON_REPOSITORY;
+ break;
+ case 0x125:
+ apk_force |= APK_FORCE_BINARY_STDOUT;
break;
case 'i':
apk_flags |= APK_INTERACTIVE;
@@ -166,7 +186,13 @@ static const struct apk_option options_global[] = {
{ 'v', "verbose", "Print more information (can be doubled)" },
{ 'i', "interactive", "Ask confirmation for certain operations" },
{ 'V', "version", "Print program version and exit" },
- { 'f', "force", "Do what was asked even if it looks dangerous" },
+ { 'f', "force", "Enable selected --force-* (deprecated)" },
+ { 0x125, "force-binary-stdout", "Continue even if binary data is to be output" },
+ { 0x122, "force-broken-world", "Continue even if 'world' cannot be satisfied" },
+ { 0x124, "force-non-repository", "Continue even if packages may be lost on reboot" },
+ { 0x121, "force-old-apk", "Continue even if packages use unsupported features" },
+ { 0x120, "force-overwrite", "Overwrite files in other packages" },
+ { 0x123, "force-refresh", "Do not use cached files (local or from proxy)" },
{ 'U', "update-cache", "Update the repository cache" },
{ 0x101, "progress", "Show a progress bar" },
{ 0x10f, "progress-fd", "Write progress to fd", required_argument, "FD" },
@@ -182,7 +208,7 @@ static const struct apk_option options_global[] = {
{ 0x108, "repositories-file", "Override repositories file",
required_argument, "REPOFILE" },
{ 0x109, "no-network", "Do not use network (cache is still used)" },
- { 0x115, "no-cache", "Read uncached index from network" },
+ { 0x115, "no-cache", "Do not use any local cache path" },
{ 0x116, "cache-dir", "Override cache directory",
required_argument, "CACHEDIR" },
{ 0x112, "arch", "Use architecture with --root",
@@ -222,7 +248,9 @@ static int option_parse_commit(void *ctx, struct apk_db_options *dbopts, int opt
break;
case 0x118:
dbopts->open_flags |= APK_OPENF_CREATE;
- apk_flags |= APK_FORCE | APK_NO_COMMIT_HOOKS;
+ apk_flags |= APK_NO_COMMIT_HOOKS;
+ apk_force |= APK_FORCE_OVERWRITE | APK_FORCE_OLD_APK
+ | APK_FORCE_BROKEN_WORLD | APK_FORCE_NON_REPOSITORY;
break;
default:
return -ENOTSUP;
diff --git a/src/apk_defines.h b/src/apk_defines.h
index 08a380126a..7e79135b61 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -60,11 +60,10 @@ static inline int IS_ERR_OR_NULL(const void *ptr) { return IS_ERR(ptr) || !ptr;
#endif
extern int apk_verbosity;
-extern unsigned int apk_flags;
+extern unsigned int apk_flags, apk_force;
extern const char *apk_arch;
extern char **apk_argv;
-#define APK_FORCE 0x0001
#define APK_SIMULATE 0x0002
#define APK_CLEAN_PROTECTED 0x0004
#define APK_PROGRESS 0x0008
@@ -79,6 +78,13 @@ extern char **apk_argv;
#define APK_NO_CACHE 0x8000
#define APK_NO_COMMIT_HOOKS 0x00010000
+#define APK_FORCE_OVERWRITE BIT(0)
+#define APK_FORCE_OLD_APK BIT(1)
+#define APK_FORCE_BROKEN_WORLD BIT(2)
+#define APK_FORCE_REFRESH BIT(3)
+#define APK_FORCE_NON_REPOSITORY BIT(4)
+#define APK_FORCE_BINARY_STDOUT BIT(5)
+
/* default architecture for APK packages. */
#if defined(__x86_64__)
#define APK_DEFAULT_ARCH "x86_64"
diff --git a/src/commit.c b/src/commit.c
index af49f5c9fc..e82537f82d 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -266,7 +266,8 @@ int apk_solver_commit_changeset(struct apk_database *db,
int r, errors = 0;
if (apk_db_check_world(db, world) != 0) {
- apk_error("Not committing changes due to missing repository tags. Use --force to override.");
+ apk_error("Not committing changes due to missing repository tags. "
+ "Use --force-broken-world to override.");
return -1;
}
@@ -675,7 +676,8 @@ int apk_solver_commit(struct apk_database *db,
int r;
if (apk_db_check_world(db, world) != 0) {
- apk_error("Not committing changes due to missing repository tags. Use --force to override.");
+ apk_error("Not committing changes due to missing repository tags. "
+ "Use --force-broken-world to override.");
return -1;
}
diff --git a/src/database.c b/src/database.c
index 162ce1ab33..4ea4fb4bec 100644
--- a/src/database.c
+++ b/src/database.c
@@ -47,7 +47,7 @@ enum {
};
int apk_verbosity = 1;
-unsigned int apk_flags = 0;
+unsigned int apk_flags = 0, apk_force = 0;
static apk_blob_t tmpprefix = { .len=8, .ptr = ".apknew." };
@@ -633,7 +633,7 @@ int apk_cache_download(struct apk_database *db, struct apk_repository *repo,
r = apk_repo_format_real_url(db, repo, pkg, url, sizeof(url));
if (r < 0) return r;
- if ((apk_flags & APK_FORCE) ||
+ if ((apk_force & APK_FORCE_REFRESH) ||
fstatat(db->cache_fd, cacheitem, &st, 0) != 0)
st.st_mtime = 0;
@@ -867,13 +867,13 @@ int apk_db_index_read(struct apk_database *db, struct apk_bstream *bs, int repo)
case 's': ipkg->broken_script = 1; break;
case 'x': ipkg->broken_xattr = 1; break;
default:
- if (!(apk_flags & APK_FORCE))
+ if (!(apk_force & APK_FORCE_OLD_APK))
goto old_apk_tools;
}
}
break;
default:
- if (r != 0 && !(apk_flags & APK_FORCE))
+ if (r != 0 && !(apk_force & APK_FORCE_OLD_APK))
goto old_apk_tools;
/* Installed. So mark the package as installable. */
pkg->filename = NULL;
@@ -2033,7 +2033,7 @@ int apk_db_check_world(struct apk_database *db, struct apk_dependency_array *wor
struct apk_dependency *dep;
int bad = 0, tag;
- if (apk_flags & APK_FORCE)
+ if (apk_force & APK_FORCE_BROKEN_WORLD)
return 0;
foreach_array_item(dep, world) {
@@ -2463,7 +2463,7 @@ static int apk_db_install_archive_entry(void *_ctx,
if (pkg_prio >= 0)
break;
- if (!(apk_flags & APK_FORCE)) {
+ if (!(apk_force & APK_FORCE_OVERWRITE)) {
apk_error(PKG_VER_FMT": trying to overwrite %s owned by "PKG_VER_FMT".",
PKG_VER_PRINTF(pkg), ae->name, PKG_VER_PRINTF(opkg));
ipkg->broken_files = 1;
diff --git a/src/fetch.c b/src/fetch.c
index c6622e54d4..f9dc9a10bd 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -319,8 +319,7 @@ static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_arr
ctx->outdir_fd = AT_FDCWD;
if ((args->num == 1) && (strcmp(args->item[0], "coffee") == 0)) {
- if (apk_flags & APK_FORCE)
- return cup();
+ if (apk_force) return cup();
apk_message("Go and fetch your own coffee.");
return 0;
}
diff --git a/src/index.c b/src/index.c
index 4dd69cbcc7..35bd340c42 100644
--- a/src/index.c
+++ b/src/index.c
@@ -118,9 +118,9 @@ static int index_main(void *ctx, struct apk_database *db, struct apk_string_arra
char **parg;
if (isatty(STDOUT_FILENO) && ictx->output == NULL &&
- !(apk_flags & APK_FORCE)) {
- apk_error("Will not write binary index to console "
- "without --force");
+ !(apk_force & APK_FORCE_BINARY_STDOUT)) {
+ apk_error("Will not write binary index to console. "
+ "Use --force-binary-stdout to override.");
return -1;
}
diff --git a/src/solver.c b/src/solver.c
index 851e77e008..91e595821f 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -1022,7 +1022,7 @@ restart:
generate_changeset(ss, world);
- if (ss->errors && (apk_flags & APK_FORCE)) {
+ if (ss->errors && (apk_force & APK_FORCE_BROKEN_WORLD)) {
foreach_array_item(d, world) {
name = d->name;
pkg = name->ss.chosen.pkg;
diff --git a/src/upgrade.c b/src/upgrade.c
index 22839db513..f5fcb41981 100644
--- a/src/upgrade.c
+++ b/src/upgrade.c
@@ -144,7 +144,8 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
int r = 0;
if (apk_db_check_world(db, db->world) != 0) {
- apk_error("Not continuing with upgrade due to missing repository tags. Use --force to override.");
+ apk_error("Not continuing with upgrade due to missing repository tags. "
+ "Use --force-broken-world to override.");
return -1;
}