X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libopkg%2Fargs.c;h=f1f79523a7d883e8b513d723cc6aab523f93b635;hb=f0920f2896c409d519e51744a2e2618a99ec8b8c;hp=29e8852d8787d3857b4cefa2caebd980ef515d9a;hpb=69bae440fd21376d2a717575b1418c962396bd21;p=oweals%2Fopkg-lede.git diff --git a/libopkg/args.c b/libopkg/args.c index 29e8852..f1f7952 100644 --- a/libopkg/args.c +++ b/libopkg/args.c @@ -25,12 +25,14 @@ #include "config.h" #include "args.h" #include "sprintf_alloc.h" +#include "libbb/libbb.h" static void print_version(void); enum long_args_opt { ARGS_OPT_FORCE_DEFAULTS = 129, + ARGS_OPT_FORCE_MAINTAINER, ARGS_OPT_FORCE_DEPENDS, ARGS_OPT_FORCE_OVERWRITE, ARGS_OPT_FORCE_DOWNGRADE, @@ -40,16 +42,16 @@ enum long_args_opt ARGS_OPT_FORCE_SPACE, ARGS_OPT_NOACTION, ARGS_OPT_NODEPS, - ARGS_OPT_VERBOSE_WGET, ARGS_OPT_VERBOSITY, ARGS_OPT_MULTIPLE_PROVIDERS, - ARGS_OPT_AUTOREMOVE + ARGS_OPT_AUTOREMOVE, + ARGS_OPT_CACHE, }; -int args_init(args_t *args) -{ - char *conf_file_dir; +char *conf_file_dir; +void args_init(args_t *args) +{ memset(args, 0, sizeof(args_t)); args->dest = ARGS_DEFAULT_DEST; @@ -58,10 +60,11 @@ int args_init(args_t *args) if (conf_file_dir == NULL || conf_file_dir[0] == '\0') { conf_file_dir = ARGS_DEFAULT_CONF_FILE_DIR; } - sprintf_alloc(&args->conf_file, "%s/%s", conf_file_dir, + sprintf_alloc(&args->conf_file, "%s/%s", OPKGETCDIR, ARGS_DEFAULT_CONF_FILE_NAME); args->force_defaults = ARGS_DEFAULT_FORCE_DEFAULTS; + args->force_maintainer = ARGS_DEFAULT_FORCE_MAINTAINER; args->force_depends = ARGS_DEFAULT_FORCE_DEPENDS; args->force_overwrite = ARGS_DEFAULT_FORCE_OVERWRITE; args->force_downgrade = ARGS_DEFAULT_FORCE_DOWNGRADE; @@ -71,20 +74,26 @@ int args_init(args_t *args) args->autoremove = ARGS_DEFAULT_AUTOREMOVE; args->noaction = ARGS_DEFAULT_NOACTION; args->nodeps = ARGS_DEFAULT_NODEPS; - args->verbose_wget = ARGS_DEFAULT_VERBOSE_WGET; args->verbosity = ARGS_DEFAULT_VERBOSITY; args->offline_root = ARGS_DEFAULT_OFFLINE_ROOT; + args->offline_root_path = ARGS_DEFAULT_OFFLINE_ROOT_PATH; args->offline_root_pre_script_cmd = ARGS_DEFAULT_OFFLINE_ROOT_PRE_SCRIPT_CMD; args->offline_root_post_script_cmd = ARGS_DEFAULT_OFFLINE_ROOT_POST_SCRIPT_CMD; args->multiple_providers = 0; args->nocheckfordirorfile = 0; args->noreadfeedsfile = 0; - - return 1; } void args_deinit(args_t *args) { + free (args->offline_root); + free (args->offline_root_path); + free (args->offline_root_pre_script_cmd); + free (args->offline_root_post_script_cmd); + + free (args->dest); + free (args->tmp_dir); + free (args->cache); free(args->conf_file); args->conf_file = NULL; } @@ -97,11 +106,14 @@ int args_parse(args_t *args, int argc, char *argv[]) static struct option long_options[] = { {"query-all", 0, 0, 'A'}, {"autoremove", 0, 0, ARGS_OPT_AUTOREMOVE}, + {"cache", 1, 0, ARGS_OPT_CACHE}, {"conf-file", 1, 0, 'f'}, {"conf", 1, 0, 'f'}, {"dest", 1, 0, 'd'}, {"force-defaults", 0, 0, ARGS_OPT_FORCE_DEFAULTS}, {"force_defaults", 0, 0, ARGS_OPT_FORCE_DEFAULTS}, + {"force-maintainer", 0, 0, ARGS_OPT_FORCE_MAINTAINER}, + {"force_maintainer", 0, 0, ARGS_OPT_FORCE_MAINTAINER}, {"force-depends", 0, 0, ARGS_OPT_FORCE_DEPENDS}, {"force_depends", 0, 0, ARGS_OPT_FORCE_DEPENDS}, {"force-overwrite", 0, 0, ARGS_OPT_FORCE_OVERWRITE}, @@ -128,17 +140,17 @@ int args_parse(args_t *args, int argc, char *argv[]) {"nodeps", 0, 0, ARGS_OPT_NODEPS}, {"offline", 1, 0, 'o'}, {"offline-root", 1, 0, 'o'}, + {"offline-path", 1, 0, 'p'}, + {"offline-root-path", 1, 0, 'p'}, {"test", 0, 0, ARGS_OPT_NOACTION}, {"tmp-dir", 1, 0, 't'}, - {"verbose-wget", 0, 0, ARGS_OPT_VERBOSE_WGET}, - {"verbose_wget", 0, 0, ARGS_OPT_VERBOSE_WGET}, {"verbosity", 2, 0, 'V'}, {"version", 0, 0, 'v'}, {0, 0, 0, 0} }; while (1) { - c = getopt_long_only(argc, argv, "Ad:f:no:t:vV:", long_options, &option_index); + c = getopt_long_only(argc, argv, "Ad:f:no:p:t:vV:", long_options, &option_index); if (c == -1) break; @@ -147,20 +159,23 @@ int args_parse(args_t *args, int argc, char *argv[]) args->query_all = 1; break; case 'd': - args->dest = optarg; + args->dest = xstrdup(optarg); break; case 'f': free(args->conf_file); - args->conf_file = strdup(optarg); + args->conf_file = xstrdup(optarg); break; case 'o': - args->offline_root = optarg; + args->offline_root = xstrdup(optarg); + break; + case 'p': + args->offline_root_path = xstrdup(optarg); break; case 'n': args->noaction = 1; break; case 't': - args->tmp_dir = strdup(optarg); + args->tmp_dir = xstrdup(optarg); break; case 'v': print_version(); @@ -175,9 +190,16 @@ int args_parse(args_t *args, int argc, char *argv[]) case ARGS_OPT_AUTOREMOVE: args->autoremove = 1; break; + case ARGS_OPT_CACHE: + free(args->cache); + args->cache = xstrdup(optarg); + break; case ARGS_OPT_FORCE_DEFAULTS: args->force_defaults = 1; break; + case ARGS_OPT_FORCE_MAINTAINER: + args->force_maintainer = 1; + break; case ARGS_OPT_FORCE_DEPENDS: args->force_depends = 1; break; @@ -199,9 +221,6 @@ int args_parse(args_t *args, int argc, char *argv[]) case ARGS_OPT_FORCE_SPACE: args->force_space = 1; break; - case ARGS_OPT_VERBOSE_WGET: - args->verbose_wget = 1; - break; case ARGS_OPT_MULTIPLE_PROVIDERS: args->multiple_providers = 1; break; @@ -242,7 +261,7 @@ void args_usage(char *complaint) printf("\tupdate Update list of available packages\n"); printf("\tupgrade Upgrade all installed packages to latest version\n"); printf("\tinstall Download and install (and dependencies)\n"); - printf("\tinstall Install package \n"); + printf("\tinstall Install package \n"); printf("\tconfigure [] Configure unpacked packages\n"); printf("\tremove Remove package \n"); printf("\tflag ... Flag package(s) \n"); @@ -251,6 +270,7 @@ void args_usage(char *complaint) printf("\nInformational Commands:\n"); printf("\tlist List available packages and descriptions\n"); printf("\tlist_installed List all and only the installed packages and description \n"); + printf("\tlist_upgradable List all the installed and upgradable packages\n"); printf("\tfiles List all files belonging to \n"); printf("\tsearch Search for a package providing \n"); printf("\tinfo [pkg|regexp] Display all info for \n"); @@ -275,6 +295,7 @@ void args_usage(char *complaint) printf("\t 2 informative messages\n"); printf("\t 3 debug output\n"); printf("\t-f Use as the opkg configuration file\n"); + printf("\t--cache Use a package cache\n"); printf("\t-conf Default configuration file location\n"); printf(" is %s/%s\n", ARGS_DEFAULT_CONF_FILE_DIR, ARGS_DEFAULT_CONF_FILE_NAME); printf("\t-d Use as the the root directory for\n"); @@ -284,9 +305,10 @@ void args_usage(char *complaint) printf(" directory name in a pinch).\n"); printf("\t-o Use as the root directory for\n"); printf("\t-offline offline installation of packages.\n"); - printf("\t-verbose_wget more wget messages\n"); - - printf("\tForce Options (use when opkg is too smart for its own good):\n"); + printf("\t-p Path to utilities for runing postinst\n"); + printf("\t-offline-path script in offline mode.\n"); + + printf("\nForce Options (use when opkg is too smart for its own good):\n"); printf("\t-force-depends Make dependency checks warnings instead of errors\n"); printf("\t Install/remove package in spite of failed dependences\n"); printf("\t-force-defaults Use default options for questions asked by opkg.\n");