- dist-upgrade added (experimental) FATE #302460
authorJan Kupec <jkupec@suse.cz>
Mon, 12 Nov 2007 16:43:05 +0000 (16:43 +0000)
committerJan Kupec <jkupec@suse.cz>
Mon, 12 Nov 2007 16:43:05 +0000 (16:43 +0000)
doc/zypper.8
src/zypper-command.cc
src/zypper-command.h
src/zypper.cc

index bd8b45b..eefb849 100644 (file)
@@ -183,6 +183,23 @@ packages for which there is a better version instead, select \fI--type
 package\fR which is also the default in rug compatibility mode.
 
 .TP
+.B dist-upgrade (dup) [options]
+Perform a distribution upgrade. This command performs an update of all packages
+with a special resolver algorithm which takes care of package splits, pattern
+and product updates, etc.
+
+.TP
+\fI\-r, \-\-repo\fR <alias>
+Limit updates to repository specified by alias.
+.TP
+.I \-l, \-\-auto\-agree\-with\-licenses
+Automatically say 'yes' to third party license confirmation prompt. By using this option, you choose to agree with licenses of all third-party software this command will install. This option is particularly useful for administators installing the same set of packages on multiple machines (by an automated process) and have the licenses confirmed before.
+.TP
+.I      \-\-debug\-solver
+Create solver test case for debugging. See the install command for details.
+
+
+.TP
 \fBsearch\fR (\fBse\fR) [\fIoptions\fR] [\fBquerystring\fR] ...
 Search for resolvables matching given strings. * (any substring) and ? (any character) wildcards can also be used within search strings.
 .IP
index 89c1998..92b090b 100644 (file)
@@ -26,6 +26,7 @@ const ZypperCommand ZypperCommand::REFRESH(ZypperCommand::REFRESH_e);
 const ZypperCommand ZypperCommand::INSTALL(ZypperCommand::INSTALL_e);
 const ZypperCommand ZypperCommand::REMOVE(ZypperCommand::REMOVE_e);
 const ZypperCommand ZypperCommand::UPDATE(ZypperCommand::UPDATE_e);
+const ZypperCommand ZypperCommand::DIST_UPGRADE(ZypperCommand::DIST_UPGRADE_e);
 const ZypperCommand ZypperCommand::SRC_INSTALL(ZypperCommand::SRC_INSTALL_e);
 
 const ZypperCommand ZypperCommand::SEARCH(ZypperCommand::SEARCH_e);
@@ -64,6 +65,7 @@ ZypperCommand::Command ZypperCommand::parse(const std::string & strval_r)
     _table["install"] = _table["in"] = ZypperCommand::INSTALL_e;
     _table["remove"] = _table["rm"] = ZypperCommand::REMOVE_e;
     _table["update"] = _table["up"] = ZypperCommand::UPDATE_e;
+    _table["dist-upgrade"] = _table["dup"] = ZypperCommand::DIST_UPGRADE_e;
     _table["source-install"] = _table["si"] = ZypperCommand::SRC_INSTALL_e;
 
     _table["search"] = _table["se"] = ZypperCommand::SEARCH_e;
index 98e0276..94ae478 100644 (file)
@@ -20,6 +20,7 @@ struct ZypperCommand
   static const ZypperCommand INSTALL;
   static const ZypperCommand REMOVE;
   static const ZypperCommand UPDATE;
+  static const ZypperCommand DIST_UPGRADE;
   static const ZypperCommand SRC_INSTALL;
   
   static const ZypperCommand SEARCH;
@@ -54,6 +55,7 @@ struct ZypperCommand
     INSTALL_e,
     REMOVE_e,
     UPDATE_e,
+    DIST_UPGRADE_e,
     SRC_INSTALL_e,
     
     SEARCH_e,
index 7793c96..b45a74c 100644 (file)
@@ -572,6 +572,28 @@ int one_command(int argc, char **argv)
       "-R, --force-resolution          Force the solver to find a solution (even agressive)\n"
     );
   }
+  else if (command == ZypperCommand::DIST_UPGRADE) {
+    static struct option dupdate_options[] = {
+      {"repo",                      required_argument, 0, 'r'},
+      {"auto-agree-with-licenses",  no_argument,       0, 'l'},
+      {"debug-solver",              no_argument,       0, 0},
+      {"help", no_argument, 0, 'h'},
+      {0, 0, 0, 0}
+    };
+    specific_options = dupdate_options;
+    specific_help = _(
+      "dist-upgrade (dup) [options]\n"
+      "\n"
+      "Perform a distribution upgrade.\n"
+      "\n"
+      "  Command options:\n"
+      "\n"
+      "-r, --repo <alias>              Limit the upgrade to the repository specified by the alias.\n"
+      "-l, --auto-agree-with-licenses  Automatically say 'yes' to third party license confirmation prompt.\n"
+      "                                See man zypper for more details.\n"
+      "    --debug-solver              Create solver test case for debugging\n"
+    );
+  }
   else if (command == ZypperCommand::SEARCH) {
     static struct option search_options[] = {
       {"installed-only", no_argument, 0, 'i'},
@@ -1518,6 +1540,58 @@ int one_command(int argc, char **argv)
     return ZYPPER_EXIT_OK; 
   }
 
+  // ----------------------------( dist-upgrade )------------------------------
+
+  else if (command == ZypperCommand::DIST_UPGRADE) {
+    if (ghelp)
+    {
+      cout << specific_help;
+      return ZYPPER_EXIT_OK;
+    }
+
+    // check root user
+    if (geteuid() != 0)
+    {
+      cerr << _("Root privileges are required for performing a distribution upgrade.") << endl;
+      return ZYPPER_EXIT_ERR_PRIVILEGES;
+    }
+
+    // too many arguments
+    if (arguments.size() > 0)
+    {
+      report_too_many_arguments(specific_help);
+      return ZYPPER_EXIT_ERR_INVALID_ARGS;
+    }
+
+    if (copts.count("auto-agree-with-licenses"))
+      gSettings.license_auto_agree = true;
+
+    cond_init_target ();
+    int initret = init_repos();
+    if (initret != ZYPPER_EXIT_OK)
+      return initret;
+    cond_load_resolvables ();
+    establish ();
+    zypp::UpgradeStatistics opt_stats;
+    God->resolver()->doUpgrade(opt_stats);
+
+    if (copts.count("debug-solver"))
+    {
+      cout_n << _("Generating solver test case...") << endl;
+      if (God->resolver()->createSolverTestcase("/var/log/zypper.solverTestCase"))
+        cout_n << _("Solver test case generated successfully.") << endl;
+      else
+        cerr << _("Error creating the solver test case.") << endl;
+    }
+    // commit
+    // returns ZYPPER_EXIT_OK, ZYPPER_EXIT_ERR_ZYPP,
+    // ZYPPER_EXIT_INF_REBOOT_NEEDED, or ZYPPER_EXIT_INF_RESTART_NEEDED
+    else
+      return solve_and_commit();
+
+    return ZYPPER_EXIT_OK; 
+  }
+
   // -----------------------------( info )------------------------------------
 
   else if (command == ZypperCommand::INFO ||