Added new function 'download-only' to source-install (bnc #640403)
authorMatthias Grießmeier <mgriessmeier@suse.de>
Fri, 5 Apr 2013 09:23:47 +0000 (11:23 +0200)
committerMatthias Grießmeier <mgriessmeier@suse.de>
Fri, 5 Apr 2013 13:33:32 +0000 (15:33 +0200)
doc/zypper.8
src/Zypper.cc
src/misc.cc

index efadf21..ddba329 100644 (file)
@@ -412,6 +412,9 @@ Don't install build dependencies.
 Work only with the repository specified by the alias, name, number, or URI. This
 option can be used multiple times.
 .TP
+.I \ \ \ \ \-\-download\-only
+Only download the packages, do not install.
+.TP
 Examples:
 
 Install build dependencies of dbus-1 source package:
index 77b4900..6be9b48 100644 (file)
@@ -1147,6 +1147,7 @@ void Zypper::processCommandOptions()
     static struct option src_install_options[] = {
       {"build-deps-only", no_argument, 0, 'd'},
       {"no-build-deps", no_argument, 0, 'D'},
+      {"download-only", no_argument, 0, 0},
       {"repo", required_argument, 0, 'r'},
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
@@ -1161,6 +1162,7 @@ void Zypper::processCommandOptions()
       "-d, --build-deps-only    Install only build dependencies of specified packages.\n"
       "-D, --no-build-deps      Don't install build dependencies.\n"
       "-r, --repo <alias|#|URI> Install packages only from specified repositories.\n"
+      "    --download-only      Only download the packages, do not install.\n"
     );
     break;
   }
index f78bd14..eb82eb6 100644 (file)
@@ -433,17 +433,28 @@ void install_src_pkgs(Zypper & zypper)
 
     try
     {
-      God->installSrcPackage(srcpkg);
+      if (zypper.cOpts().find("download-only") != zypper.cOpts().end())
+      {
+        God->provideSrcPackage(srcpkg).resetDispose();
 
-      zypper.out().info(boost::str(format(
-          _("Source package %s-%s successfully installed."))
-          % srcpkg->name() % srcpkg->edition()));
+        zypper.out().info(boost::str(format(
+            _("Source package %s-%s successfully retrieved."))
+            % srcpkg->name() % srcpkg->edition()));
+      }         
+      else
+      {
+        God->installSrcPackage(srcpkg);
+
+        zypper.out().info(boost::str(format(
+            _("Source package %s-%s successfully installed."))
+            % srcpkg->name() % srcpkg->edition()));
+      }
     }
     catch (const Exception & ex)
     {
       ZYPP_CAUGHT(ex);
       zypper.out().error(ex,
-        boost::str(format(_("Problem installing source package %s-%s:"))
+          boost::str(format(_("Problem installing source package %s-%s:"))
           % srcpkg->name() % srcpkg->edition()));
 
       zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);