From d9cae3724ff3e7690a2703cc535920afbf838ebb Mon Sep 17 00:00:00 2001 From: Mario Alfredo Carrillo Arevalo Date: Tue, 31 Jan 2017 17:25:02 -0600 Subject: [PATCH] Add bundle-list environment options This adds are required standard options to select content server, version server, format, and so on. Options added: -u, url for version string and content file downloads -c, url for content file downloads -v, url for version string download -p, path to verify -F, format suffix for version file downloads -n, Do not attempt to enforce certificate or signature checking -S, Specify alternate swupd state directory -C, Specify alternate path to swupd certificates Signed-off-by: Mario Alfredo Carrillo Arevalo --- src/clr_bundle_ls.c | 71 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/src/clr_bundle_ls.c b/src/clr_bundle_ls.c index 59ffc7ad..c6fb0845 100644 --- a/src/clr_bundle_ls.c +++ b/src/clr_bundle_ls.c @@ -34,12 +34,30 @@ static void print_help(const char *name) printf("Help Options:\n"); printf(" -h, --help Show help options\n"); printf(" -a, --all List all available bundles for the current version of Clear Linux\n"); + printf(" -u, --url=[URL] RFC-3986 encoded url for version string and content file downloads\n"); + printf(" -c, --contenturl=[URL] RFC-3986 encoded url for content file downloads\n"); + printf(" -v, --versionurl=[URL] RFC-3986 encoded url for version string download\n"); + printf(" -p, --path=[PATH...] Use [PATH...] as the path to verify (eg: a chroot or btrfs subvol\n"); + printf(" -F, --format=[staging,1,2,etc.] the format suffix for version file downloads\n"); + printf(" -n, --nosigcheck Do not attempt to enforce certificate or signature checking\n"); + printf(" -S, --statedir Specify alternate swupd state directory\n"); + printf(" -C, --certpath Specify alternate path to swupd certificates\n"); + printf("\n"); } static const struct option prog_opts[] = { { "help", no_argument, 0, 'h'}, { "all", no_argument, 0, 'a' }, + { "url", required_argument, 0, 'u' }, + { "contenturl", required_argument, 0, 'c' }, + { "versionurl", required_argument, 0, 'v' }, + { "path", required_argument, 0, 'p' }, + { "format", required_argument, 0, 'F' }, + { "nosigcheck", no_argument, 0, 'n' }, + { "statedir", required_argument, 0, 'S' }, + { "certpath", required_argument, 0, 'C' }, + { 0, 0, 0, 0 } }; @@ -47,7 +65,7 @@ static bool parse_options(int argc, char **argv) { int opt; - while ((opt = getopt_long(argc, argv, "ha", prog_opts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "hanu:c:v:p:F:S:C:", prog_opts, NULL)) != -1) { switch (opt) { case '?': case 'h': @@ -56,6 +74,57 @@ static bool parse_options(int argc, char **argv) case 'a': return list_installable_bundles(); break; + case 'u': + if (!optarg) { + printf("error: invalid --url argument\n\n"); + goto err; + } + set_version_url(optarg); + set_content_url(optarg); + break; + case 'c': + if (!optarg) { + printf("Invalid --contenturl argument\n\n"); + goto err; + } + set_content_url(optarg); + break; + case 'v': + if (!optarg) { + printf("Invalid --versionurl argument\n\n"); + goto err; + } + set_version_url(optarg); + break; + case 'p': /* default empty path_prefix verifies the running OS */ + if (!optarg || !set_path_prefix(optarg)) { + printf("Invalid --path argument\n\n"); + goto err; + } + break; + case 'F': + if (!optarg || !set_format_string(optarg)) { + printf("Invalid --format argument\n\n"); + goto err; + } + break; + case 'n': + sigcheck = false; + break; + case 'S': + if (!optarg || !set_state_dir(optarg)) { + printf("Invalid --statedir argument\n\n"); + goto err; + } + break; + case 'C': + if (!optarg) { + printf("Invalid --certpath argument\n\n"); + goto err; + } + set_cert_path(optarg); + break; + default: printf("error: unrecognized option\n\n"); goto err;