Fixing duplicated flags in swupd

Some swupd flags from subcommands clash with some global flags.

This commit fixes the issue by renaming the duplicated flags in the
subcommands.

Closes #946
Closes #950

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit is contained in:
Castulo Martinez
2019-07-12 14:28:05 -07:00
committed by Otavio Pontes
parent e63dc805cf
commit 10bc311e4c
5 changed files with 22 additions and 23 deletions
+5 -5
View File
@@ -168,7 +168,7 @@ SUBCOMMANDS
are available. It will return 0 with succeeded and a different value
of 0 with failed.
- `-d, --deps={bundle}`
- `--deps={bundle}`
Lists all bundle dependencies of the passed bundle, including
recursively included bundles.
@@ -281,7 +281,7 @@ SUBCOMMANDS
<path>/etc/swupd/mirror_contenturl and
<path>/etc/swupd/mirror_versionurl
- `-u, --unset`
- `-U, --unset`
Remove the content and version URL configuration by removing
<path>/etc/swupd
@@ -378,7 +378,7 @@ SUBCOMMANDS
Only runs the repair operation on the os-core and vi bundles.
``search {string}``
``search-file {string}``
Search for matching paths in manifest data. The specified {string}
is matched in any part of the path listed in manifests, and all
@@ -396,7 +396,7 @@ SUBCOMMANDS
Restrict search to designated dynamic shared library paths.
- `-b, --binary`
- `-B, --binary`
Restrict search to designated program binary paths.
@@ -433,7 +433,7 @@ SUBCOMMANDS
available on the version url server, and what version number is
available.
- `-d, --download`
- `--download`
Do not perform an update, instead download all resources needed
to perform the update, and exit.
+5 -3
View File
@@ -28,6 +28,8 @@
#include "config.h"
#include "swupd.h"
#define DEPS_FLAG 1000
static bool cmdline_option_all = false;
static char *cmdline_option_has_dep = NULL;
static char *cmdline_option_deps = NULL;
@@ -54,14 +56,14 @@ static void print_help(void)
print("Options:\n");
print(" -a, --all List all available bundles for the current version of Clear Linux\n");
print(" -d, --deps=[BUNDLE] List bundles included by BUNDLE\n");
print(" -D, --has-dep=[BUNDLE] List dependency tree of all bundles which have BUNDLE as a dependency\n");
print(" --deps=[BUNDLE] List bundles included by BUNDLE\n");
print("\n");
}
static const struct option prog_opts[] = {
{ "all", no_argument, 0, 'a' },
{ "deps", required_argument, 0, 'd' },
{ "deps", required_argument, 0, DEPS_FLAG },
{ "has-dep", required_argument, 0, 'D' },
};
@@ -77,7 +79,7 @@ static bool parse_opt(int opt, char *optarg)
atexit(free_has_dep);
cmdline_local = false;
return true;
case 'd':
case DEPS_FLAG:
string_or_die(&cmdline_option_deps, "%s", optarg);
atexit(free_deps);
cmdline_local = false;
+3 -3
View File
@@ -44,13 +44,13 @@ static void print_help(void)
print("Options:\n");
print(" -s, --set set mirror url\n");
print(" -u, --unset unset mirror url\n");
print(" -U, --unset unset mirror url\n");
print("\n");
}
static const struct option prog_opts[] = {
{ "set", required_argument, 0, 's' },
{ "unset", no_argument, 0, 'u' },
{ "unset", no_argument, 0, 'U' },
};
static bool parse_opt(int opt, char *optarg)
@@ -63,7 +63,7 @@ static bool parse_opt(int opt, char *optarg)
}
set = optarg;
return true;
case 'u':
case 'U':
if (set != NULL) {
error("cannot set and unset at the same time\n");
return false;
+3 -3
View File
@@ -488,7 +488,7 @@ static void print_help(void)
print("Options:\n");
print(" -l, --library Search paths where libraries are located for a match\n");
print(" -b, --binary Search paths where binaries are located for a match\n");
print(" -B, --binary Search paths where binaries are located for a match\n");
print(" -T, --top=[NUM] Only display the top NUM results for each bundle\n");
print(" -m, --csv Output all results in CSV format (machine-readable)\n");
print(" -i, --init Download all manifests then return, no search done\n");
@@ -498,7 +498,7 @@ static void print_help(void)
}
static const struct option prog_opts[] = {
{ "binary", no_argument, 0, 'b' },
{ "binary", no_argument, 0, 'B' },
{ "csv", no_argument, 0, 'm' },
{ "init", no_argument, 0, 'i' },
{ "library", no_argument, 0, 'l' },
@@ -538,7 +538,7 @@ static bool parse_opt(int opt, char *optarg)
case 'i':
init = true;
return true;
case 'b':
case 'B':
search_type |= SEARCH_TYPE_BIN;
return true;
default:
+6 -9
View File
@@ -38,7 +38,7 @@
#include "swupd.h"
static int requested_version = -1;
static bool download_only;
static int download_only = 0;
int nonpack;
@@ -87,7 +87,7 @@ static int update_loop(struct list *updates, struct manifest *server_manifest)
return ret;
}
if (download_only) {
if (download_only == 1) {
return 0;
}
@@ -443,7 +443,7 @@ version_check:
updates = list_sort(updates, file_sort_filename);
ret = update_loop(updates, server_manifest);
if (ret == 0 && !download_only) {
if (ret == 0 && download_only == 0) {
/* Failure to write the version file in the state directory
* should not affect exit status. */
(void)update_device_latest_version(server_version);
@@ -527,7 +527,7 @@ clean_curl:
if (nonpack > 0) {
info("%i files were not in a pack\n", nonpack);
}
if (!download_only) {
if (download_only == 0) {
if (current_version < server_version) {
print("Update successful. System updated from version %d to version %d\n",
current_version, server_version);
@@ -572,7 +572,7 @@ clean_curl:
static bool cmd_line_status = false;
static const struct option prog_opts[] = {
{ "download", no_argument, 0, 'd' },
{ "download", no_argument, &download_only, 1 },
{ "version", required_argument, 0, 'V' },
{ "manifest", required_argument, 0, 'm' },
{ "status", no_argument, 0, 's' },
@@ -594,12 +594,12 @@ static void print_help(void)
// so it is not visible but the option must remain available in the back so we don't break users
print("Options:\n");
print(" -V, --version=V Update to version V, also accepts 'latest' (default)\n");
print(" -d, --download Download all content, but do not actually install the update\n");
print(" -s, --status Show current OS version and latest version available on server. Equivalent to \"swupd check-update\"\n");
print(" -k, --keepcache Do not delete the swupd state directory content after updating the system\n");
print(" -T, --migrate Migrate to augmented upstream/mix content\n");
print(" -a, --allow-mix-collisions Ignore and continue if custom user content conflicts with upstream provided content\n");
print(" -m, --manifest=V NOTE: this flag has been superseded. Please use -V instead\n");
print(" --download Download all content, but do not actually install the update\n");
print("\n");
}
@@ -624,9 +624,6 @@ static bool parse_opt(int opt, char *optarg)
case 'a':
allow_mix_collisions = true;
return true;
case 'd':
download_only = true;
return true;
case 's':
cmd_line_status = true;
return true;