Add an option to download packages but do not install/upgrade anything
authorpixdamix <pixdamix@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Tue, 5 Jan 2010 17:18:04 +0000 (17:18 +0000)
committerpixdamix <pixdamix@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Tue, 5 Jan 2010 17:18:04 +0000 (17:18 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@512 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg_conf.c
libopkg/opkg_conf.h
libopkg/opkg_install.c
src/opkg-cl.c

index 9c02cbd4927ea0ec0246c32b3ed7d1d7b7c2a932..bcc79ed16d8d45e2ab7dfb07256dd4646606e161 100644 (file)
@@ -59,6 +59,7 @@ opkg_option_t options[] = {
          { "no_proxy", OPKG_OPT_TYPE_STRING, &_conf.no_proxy },
          { "test", OPKG_OPT_TYPE_BOOL, &_conf.noaction },
          { "noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction },
+         { "download_only", OPKG_OPT_TYPE_BOOL, &_conf.download_only },
          { "nodeps", OPKG_OPT_TYPE_BOOL, &_conf.nodeps },
          { "offline_root", OPKG_OPT_TYPE_STRING, &_conf.offline_root },
          { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd },
index 092686cf4ea7c323ccb16e4805b09c19c59a17c6..0925b81c8b10b69e7bb4a44831bcc681e828a07c 100644 (file)
@@ -79,6 +79,7 @@ struct opkg_conf
      int query_all;
      int verbosity;
      int noaction;
+     int download_only;
      char *cache;
 
 #ifdef HAVE_SSLCURL
index 2ee240fd6400f96fa59ed7e71579be3dad835674..5472ca29583c0cd57bb59a7d26bcf1e33a9e29ab 100644 (file)
@@ -453,25 +453,29 @@ opkg_install_check_downgrade(pkg_t *pkg, pkg_t *old_pkg, int message)
           } 
 
          if (cmp > 0) {
-              opkg_msg(NOTICE,
-                           "Not downgrading package %s on %s from %s to %s.\n",
-                           old_pkg->name, old_pkg->dest->name, old_version, new_version);
+              if(!conf->download_only)
+                  opkg_msg(NOTICE,
+                          "Not downgrading package %s on %s from %s to %s.\n",
+                          old_pkg->name, old_pkg->dest->name, old_version, new_version);
               rc = 1;
          } else if (cmp < 0) {
-              opkg_msg(NOTICE, "%s%s on %s from %s to %s...\n",
-                           message_out, pkg->name, old_pkg->dest->name, old_version, new_version);
+              if(!conf->download_only)
+                  opkg_msg(NOTICE, "%s%s on %s from %s to %s...\n",
+                          message_out, pkg->name, old_pkg->dest->name, old_version, new_version);
               pkg->dest = old_pkg->dest;
               rc = 0;
          } else /* cmp == 0 */ {
               if (conf->force_reinstall) {
-                   opkg_msg(NOTICE, "Reinstalling %s (%s) on %s...\n",
-                                pkg->name, new_version, old_pkg->dest->name);
+               if(!conf->download_only)
+                   opkg_msg(NOTICE, "Reinstalling %s (%s) on %s...\n",
+                           pkg->name, new_version, old_pkg->dest->name);
                    pkg->dest = old_pkg->dest;
                    rc = 0;
               } else {
-                   opkg_msg(NOTICE, "%s (%s) already install on %s."
-                                  " Not reinstalling.\n",
-                                pkg->name, new_version, old_pkg->dest->name);
+                   if(!conf->download_only)
+                       opkg_msg(NOTICE, "%s (%s) already install on %s."
+                               " Not reinstalling.\n",
+                               pkg->name, new_version, old_pkg->dest->name);
                    rc = 1;
               }
          } 
@@ -487,8 +491,9 @@ opkg_install_check_downgrade(pkg_t *pkg, pkg_t *old_pkg, int message)
           strncpy( message_out,"Installing ",strlen("Installing ") );
          char *version = pkg_version_str_alloc(pkg);
       
-         opkg_msg(NOTICE, "%s%s (%s) to %s...\n", message_out,
-                      pkg->name, version, pkg->dest->name);
+      if(!conf->download_only)
+          opkg_msg(NOTICE, "%s%s (%s) to %s...\n", message_out,
+                  pkg->name, version, pkg->dest->name);
          free(version);
          return 0;
      }
@@ -1329,6 +1334,14 @@ opkg_install_pkg(pkg_t *pkg, int from_upgrade)
               free(file_sha256);
      }
 #endif
+     if(conf->download_only) {
+         if (conf->nodeps == 0) {
+             err = satisfy_dependencies_for(pkg);
+             if (err)
+                 return -1;
+         }
+         return 0;
+     }
 
      if (pkg->tmp_unpack_dir == NULL) {
          if (unpack_pkg_control_files(pkg) == -1) {
index 63ebf8cb6c01e57971b86a7ff9849372643ee8db..7a2bbf37cc2b868a120715109bc86b5403a60645 100644 (file)
@@ -40,6 +40,7 @@ enum {
        ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES,
        ARGS_OPT_FORCE_SPACE,
        ARGS_OPT_NOACTION,
+       ARGS_OPT_DOWNLOAD_ONLY,
        ARGS_OPT_NODEPS,
        ARGS_OPT_AUTOREMOVE,
        ARGS_OPT_CACHE,
@@ -74,6 +75,7 @@ static struct option long_options[] = {
        {"force_removal_of_essential_packages", 0, 0,
                ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES},
        {"noaction", 0, 0, ARGS_OPT_NOACTION},
+       {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY},
        {"nodeps", 0, 0, ARGS_OPT_NODEPS},
        {"offline", 1, 0, 'o'},
        {"offline-root", 1, 0, 'o'},
@@ -157,6 +159,9 @@ args_parse(int argc, char *argv[])
                case ARGS_OPT_NOACTION:
                        conf->noaction = 1;
                        break;
+        case ARGS_OPT_DOWNLOAD_ONLY:
+                       conf->download_only = 1;
+                       break;
                case ':':
                        parse_err = -1;
                        break;
@@ -235,6 +240,7 @@ usage()
        printf("\t--force-downgrade     Allow opkg to downgrade packages\n");
        printf("\t--force-space         Disable free space checks\n");
        printf("\t--noaction            No action -- test only\n");
+       printf("\t--download-only       No action -- download only\n");
        printf("\t--nodeps              Do not follow dependences\n");
        printf("\t--force-removal-of-dependent-packages\n");
        printf("\t                      Remove package and all dependencies\n");