adding new flag flag_maintainer
[project/opkg-lede.git] / libopkg / args.c
index 564e05c3074b052e497d94a140c208cd1da9f673..71692f0f928f55163a59e57b890707d717d74f84 100644 (file)
@@ -31,6 +31,7 @@ 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,
@@ -42,7 +43,8 @@ enum long_args_opt
      ARGS_OPT_NODEPS,
      ARGS_OPT_VERBOSITY,
      ARGS_OPT_MULTIPLE_PROVIDERS,
-     ARGS_OPT_AUTOREMOVE
+     ARGS_OPT_AUTOREMOVE,
+     ARGS_OPT_CACHE,
 };
 
 int args_init(args_t *args)
@@ -64,6 +66,7 @@ int args_init(args_t *args)
                   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;
@@ -75,6 +78,7 @@ int args_init(args_t *args)
      args->nodeps = ARGS_DEFAULT_NODEPS;
      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;
@@ -87,11 +91,13 @@ int args_init(args_t *args)
 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;
 }
@@ -104,11 +110,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},
@@ -135,6 +144,8 @@ 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'},
          {"verbosity", 2, 0, 'V'},
@@ -143,7 +154,7 @@ int args_parse(args_t *args, int argc, char *argv[])
      };
 
      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;
 
@@ -161,6 +172,9 @@ int args_parse(args_t *args, int argc, char *argv[])
          case 'o':
               args->offline_root = strdup (optarg);
               break;
+         case 'p':
+              args->offline_root_path = strdup (optarg);
+              break;
          case 'n':
               args->noaction = 1;
               break;
@@ -180,9 +194,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 = strdup(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;
@@ -244,7 +265,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 <pkg>           Download and install <pkg> (and dependencies)\n");
-     printf("\tinstall <file.ipk>      Install package <file.ipk>\n");
+     printf("\tinstall <file.opk>      Install package <file.opk>\n");
      printf("\tconfigure [<pkg>]       Configure unpacked packages\n");
      printf("\tremove <pkg|regexp>     Remove package <pkg|packages following regexp>\n");
      printf("\tflag <flag> <pkg> ...   Flag package(s) <pkg>\n");
@@ -253,6 +274,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 <pkg>             List all files belonging to <pkg>\n");
      printf("\tsearch <file|regexp>            Search for a package providing <file>\n");
      printf("\tinfo [pkg|regexp]               Display all info for <pkg>\n");
@@ -277,6 +299,7 @@ void args_usage(char *complaint)
      printf("\t                         2 informative messages\n");
      printf("\t                         3 debug output\n");
      printf("\t-f <conf_file>          Use <conf_file> as the opkg configuration file\n");
+     printf("\t--cache <directory>     Use a package cache\n");
      printf("\t-conf <conf_file>       Default configuration file location\n");
      printf("                          is %s/%s\n", ARGS_DEFAULT_CONF_FILE_DIR, ARGS_DEFAULT_CONF_FILE_NAME);
      printf("\t-d <dest_name>          Use <dest_name> as the the root directory for\n");
@@ -286,8 +309,10 @@ void args_usage(char *complaint)
      printf("                          directory name in a pinch).\n");
      printf("\t-o <offline_root>       Use <offline_root> as the root directory for\n");
      printf("\t-offline <offline_root> offline installation of packages.\n");
-    
-     printf("\tForce Options (use when opkg is too smart for its own good):\n");
+     printf("\t-p <path>               Path to utilities for runing postinst\n");
+     printf("\t-offline-path <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");