Author: jkupec
Date: Sat Mar 29 14:47:29 2008
New Revision: 9305
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9305&view=rev
Log:
- 'verify' command added (fate #301178)
Modified:
trunk/zypper/doc/zypper.8
trunk/zypper/src/zypper-command.cc
trunk/zypper/src/zypper-command.h
trunk/zypper/src/zypper-misc.cc
trunk/zypper/src/zypper.cc
Modified: trunk/zypper/doc/zypper.8
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/doc/zypper.8?rev=9305&r1=9304&r2=9305&view=diff
==============================================================================
--- trunk/zypper/doc/zypper.8 (original)
+++ trunk/zypper/doc/zypper.8 Sat Mar 29 14:47:29 2008
@@ -144,6 +144,20 @@
This option can be used multiple times.
.TP
+.B verify (ve) [options]
+Check whether dependencies of installed packages are satisfied.
+
+In case that any dependency problems are found, zypper suggests packages
+to install or remove to fix them.
+
+.TP
+.I \-N, \-\-dry-run
+Test the repair, do not actually do anything to the system.
+.TP
+.I \-r, \-\-repo
+Use only specified repositories to install missing packages.
+
+.TP
.B list-updates (lu) [options]
List available updates.
.TP
@@ -701,6 +715,15 @@
.RE
.TP
+.I rug verify (ve)
+zypper verify (ve)
+.RS
+.TP
+.I \-y, \-\-no\-confirm
+Don't require user interaction. This option is implemented using zypper's non-interactive mode.
+.RE
+
+.TP
.I rug update (up)
zypper update (up)
.RS
Modified: trunk/zypper/src/zypper-command.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-command.cc?rev=9305&r1=9304&r2=9305&view=diff
==============================================================================
--- trunk/zypper/src/zypper-command.cc (original)
+++ trunk/zypper/src/zypper-command.cc Sat Mar 29 14:47:29 2008
@@ -29,6 +29,7 @@
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::VERIFY(ZypperCommand::VERIFY_e);
const ZypperCommand ZypperCommand::SEARCH(ZypperCommand::SEARCH_e);
const ZypperCommand ZypperCommand::INFO(ZypperCommand::INFO_e);
@@ -70,6 +71,7 @@
_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["verify"] = _table["ve"] = ZypperCommand::VERIFY_e;
_table["search"] = _table["se"] = ZypperCommand::SEARCH_e;
_table["info"] = _table["if"] = ZypperCommand::INFO_e;
Modified: trunk/zypper/src/zypper-command.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-command.h?rev=9305&r1=9304&r2=9305&view=diff
==============================================================================
--- trunk/zypper/src/zypper-command.h (original)
+++ trunk/zypper/src/zypper-command.h Sat Mar 29 14:47:29 2008
@@ -23,6 +23,7 @@
static const ZypperCommand UPDATE;
static const ZypperCommand DIST_UPGRADE;
static const ZypperCommand SRC_INSTALL;
+ static const ZypperCommand VERIFY;
static const ZypperCommand SEARCH;
static const ZypperCommand INFO;
@@ -61,6 +62,7 @@
UPDATE_e,
DIST_UPGRADE_e,
SRC_INSTALL_e,
+ VERIFY_e,
SEARCH_e,
INFO_e,
Modified: trunk/zypper/src/zypper-misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=9305&r1=9304&r2=9305&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.cc (original)
+++ trunk/zypper/src/zypper-misc.cc Sat Mar 29 14:47:29 2008
@@ -855,10 +855,17 @@
if (retv == -1 && zypper.runtimeData().srcpkgs_to_install.empty())
{
- zypper.out().info(_("Nothing to do."));
+ if (zypper.command() == ZypperCommand::VERIFY)
+ zypper.out().info(_("Dependencies of all installed packages are satisfied."));
+ else
+ zypper.out().info(_("Nothing to do."));
return retv;
}
+ if (zypper.command() == ZypperCommand::VERIFY)
+ zypper.out().info(_("Some of the dependencies of installed packages are broken."
+ " In order to fix these dependencies, the following actions need to be taken:"));
+
KindToResObjectSet toinstall;
KindToResObjectSet toupgrade;
KindToResObjectSet todowngrade;
@@ -1026,13 +1033,18 @@
full_pool_shown = true;
}
-bool resolve(Zypper & zypper)
+static int apply_locks(Zypper & zypper)
{
int locks = God->applyLocks();
zypper.out().info(
boost::str(format(_PL("%s item locked", "%s items locked", locks)) % locks),
Out::HIGH);
+ return locks;
+}
+bool resolve(Zypper & zypper)
+{
+ apply_locks(zypper);
dump_pool();
// --force-resolution command line parameter value
@@ -1082,6 +1094,20 @@
return God->resolver()->resolvePool();
}
+bool verify(Zypper & zypper)
+{
+ apply_locks(zypper);
+ dump_pool();
+ zypper.out().info(_("Verifying dependencies..."), Out::HIGH);
+ //! \todo should these two setting be optional through command options?
+ // don't force aggressive solutions
+ God->resolver()->setForceResolve(false);
+ // don't drag new packages - just verify the needed ones
+ God->resolver()->setOnlyRequires(true);
+ DBG << "Calling the solver to verify system..." << endl;
+ return God->resolver()->verifySystem();
+}
+
void patch_check ()
{
Out & out = Zypper::instance()->out();
@@ -1686,7 +1712,11 @@
MIL << "solving..." << endl;
while (true) {
- bool success = resolve(zypper);
+ bool success;
+ if (zypper.command() == ZypperCommand::VERIFY)
+ success = verify(zypper);
+ else
+ success = resolve(zypper);
if (success)
break;
@@ -1704,6 +1734,15 @@
bool was_installed = false;
if (retv >= 0 || !zypper.runtimeData().srcpkgs_to_install.empty())
{
+ // check root user
+ if (zypper.command() == ZypperCommand::VERIFY && geteuid() != 0)
+ {
+ zypper.out().error(
+ _("Root privileges are required to fix broken package dependencies."));
+ zypper.setExitCode(ZYPPER_EXIT_ERR_PRIVILEGES);
+ return;
+ }
+
// there are resolvables to install/uninstall
if (read_bool_answer(PROMPT_YN_INST_REMOVE_CONTINUE, _("Continue?"), true))
{
Modified: trunk/zypper/src/zypper.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=9305&r1=9304&r2=9305&view=diff
==============================================================================
--- trunk/zypper/src/zypper.cc (original)
+++ trunk/zypper/src/zypper.cc Sat Mar 29 14:47:29 2008
@@ -170,6 +170,7 @@
"\tshell, sh\t\tAccept multiple commands at once.\n"
"\tinstall, in\t\tInstall packages.\n"
"\tremove, rm\t\tRemove packages.\n"
+ "\tverify, ve\t\tVerify integrity of package dependencies.\n"
"\tsearch, se\t\tSearch for packages matching a pattern.\n"
"\trepos, lr\t\tList all defined repositories.\n"
"\taddrepo, ar\t\tAdd a new repository.\n"
@@ -828,6 +829,29 @@
);
break;
}
+
+ case ZypperCommand::VERIFY_e:
+ {
+ static struct option verify_options[] = {
+ // rug compatibility option, we have global --non-interactive
+ {"no-confirm", no_argument, 0, 'y'},
+ {"dry-run", no_argument, 0, 'N'},
+ {"repo", required_argument, 0, 'r'},
+ {"help", no_argument, 0, 'h'},
+ {0, 0, 0, 0}
+ };
+ specific_options = verify_options;
+ _command_help = _(
+ "verify (ve) [options]\n"
+ "\n"
+ "Check whether dependencies of installed packages are satisfied.\n"
+ "\n"
+ " Command options:\n"
+ "-N, --dry-run Test the repair, do not actually do anything to the system.\n"
+ "-r, --repo Use only specified repositories to install missing packages.\n"
+ );
+ break;
+ }
case ZypperCommand::ADD_REPO_e:
{
@@ -1965,6 +1989,44 @@
return;
}
+ else if (command() == ZypperCommand::VERIFY)
+ {
+ if (runningHelp()) { out().info(_command_help, Out::QUIET); return; }
+
+ // too many arguments
+ if (_arguments.size() > 0)
+ {
+ report_too_many_arguments(_command_help);
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
+ }
+
+ // rug compatibility code
+ // switch on non-interactive mode if no-confirm specified
+ if (copts.count("no-confirm"))
+ _gopts.non_interactive = true;
+
+ init_repos(*this);
+ if (exitCode() != ZYPPER_EXIT_OK)
+ return;
+
+ if ( gData.repos.empty() )
+ {
+ out().error(_("Warning: No repositories defined."
+ " Operating only with the installed resolvables."
+ " Nothing can be installed."));
+ }
+
+ // prepare target
+ init_target(*this);
+ // load metadata
+ load_resolvables(*this);
+
+ solve_and_commit(*this);
+
+ return;
+ }
+
// --------------------------( search )-------------------------------------
else if (command() == ZypperCommand::SEARCH)
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org