From 10347ef2f29bf05db8bf9600c0498113cad48db7 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Fri, 3 Oct 2008 08:17:29 +0000 Subject: [PATCH] - simulate rug ping command (bnc #430756) --- doc/zypper.8 | 11 +++++++++++ src/Command.cc | 2 ++ src/Command.h | 4 +++- src/Zypper.cc | 25 +++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/doc/zypper.8 b/doc/zypper.8 index be4ffd2..1483dad 100644 --- a/doc/zypper.8 +++ b/doc/zypper.8 @@ -1348,6 +1348,17 @@ zypper info -t pattern .I rug product-info zypper info -t product +.SS System Commands +.TP +.I rug ping +zypper ping +.IP +This command just returns 0 without producing any output or doing anything +to the system. Rug's ping command is used to wake up the ZLM daemon +or to check whether it is up and running. Since zypper does no require +ZLM or any other daemon to run, it is safe to always return 0 here to +indicate it is ready for operation. + .SS Other Compatibility Notes .TP diff --git a/src/Command.cc b/src/Command.cc index 8126b3b..75f1a67 100644 --- a/src/Command.cc +++ b/src/Command.cc @@ -86,6 +86,7 @@ const ZypperCommand ZypperCommand::RUG_INFO_CONFLICTS(ZypperCommand::RUG_INFO_CO const ZypperCommand ZypperCommand::RUG_INFO_OBSOLETES(ZypperCommand::RUG_INFO_OBSOLETES_e); const ZypperCommand ZypperCommand::RUG_INFO_REQUIREMENTS(ZypperCommand::RUG_INFO_REQUIREMENTS_e); const ZypperCommand ZypperCommand::RUG_PATCH_SEARCH(ZypperCommand::RUG_PATCH_SEARCH_e); +const ZypperCommand ZypperCommand::RUG_PING(ZypperCommand::RUG_PING_e); ZypperCommand::ZypperCommand(const std::string & strval_r) @@ -162,6 +163,7 @@ ZypperCommand::Command ZypperCommand::parse(const std::string & strval_r) _table["info-conflicts"] = _table["ic"] = ZypperCommand::RUG_INFO_CONFLICTS_e; _table["info-obsoletes"] = _table["io"] = ZypperCommand::RUG_INFO_OBSOLETES_e; _table["patch-search"] = _table["pse"] = ZypperCommand::RUG_PATCH_SEARCH_e; + _table["ping"] = ZypperCommand::RUG_PING_e; } std::map::const_iterator it diff --git a/src/Command.h b/src/Command.h index e18dec1..5041e57 100644 --- a/src/Command.h +++ b/src/Command.h @@ -85,6 +85,7 @@ struct ZypperCommand static const ZypperCommand RUG_INFO_OBSOLETES; static const ZypperCommand RUG_INFO_REQUIREMENTS; static const ZypperCommand RUG_PATCH_SEARCH; + static const ZypperCommand RUG_PING; //!@} enum Command @@ -152,7 +153,8 @@ struct ZypperCommand RUG_INFO_CONFLICTS_e, RUG_INFO_OBSOLETES_e, RUG_INFO_REQUIREMENTS_e, - RUG_PATCH_SEARCH_e + RUG_PATCH_SEARCH_e, + RUG_PING_e }; ZypperCommand(Command command) : _command(command) {} diff --git a/src/Zypper.cc b/src/Zypper.cc index d152119..ffe65f5 100644 --- a/src/Zypper.cc +++ b/src/Zypper.cc @@ -2164,6 +2164,24 @@ void Zypper::processCommandOptions() break; } + case ZypperCommand::RUG_PING_e: + { + static struct option options[] = { + {"help", no_argument, 0, 'h'}, + {"if-active", no_argument, 0, 'a'}, + {0, 0, 0, 0} + }; + specific_options = options; + _command_help = _( + // translators: this is just a rug-compatiblity command + "ping [options]\n" + "\n" + "This command has dummy implementation which always returns 0.\n" + "It is provided for compatibility with rug.\n" + ); + break; + } + default: { if (runningHelp()) @@ -3951,6 +3969,13 @@ void Zypper::doCommand() break; } + // dummy commands + case ZypperCommand::RUG_PING_e: + { + if (runningHelp()) { out().info(_command_help, Out::QUIET); return; } + break; + } + default: // if the program reaches this line, something went wrong setExitCode(ZYPPER_EXIT_ERR_BUG); -- 2.7.4