const ZypperCommand ZypperCommand::LIST_UPDATES(ZypperCommand::LIST_UPDATES_e);
const ZypperCommand ZypperCommand::PATCH_CHECK(ZypperCommand::PATCH_CHECK_e);
const ZypperCommand ZypperCommand::SHOW_PATCHES(ZypperCommand::SHOW_PATCHES_e);
+const ZypperCommand ZypperCommand::XML_LIST_UPDATES_PATCHES(ZypperCommand::XML_LIST_UPDATES_PATCHES_e);
const ZypperCommand ZypperCommand::HELP(ZypperCommand::HELP_e);
const ZypperCommand ZypperCommand::SHELL(ZypperCommand::SHELL_e);
_table["list-updates"] = _table["lu"] = ZypperCommand::LIST_UPDATES_e;
_table["patch-check"] = _table["pchk"] = ZypperCommand::PATCH_CHECK_e;
_table["patches"] = _table["pch"] = ZypperCommand::SHOW_PATCHES_e;
+ _table["xml-updates-patches"] = _table["x"] = ZypperCommand::XML_LIST_UPDATES_PATCHES_e;
_table["help"] = ZypperCommand::HELP_e;
_table["shell"] = _table["sh"] = ZypperCommand::SHELL_e;
#include <zypp/RepoManager.h>
#include <zypp/RepoInfo.h>
#include <zypp/repo/RepoException.h>
+#include <zypp/target/store/xml_escape_parser.hpp>
#include "zypper.h"
#include "zypper-misc.h"
return true;
}
+static std::string xml_escape( const std::string &text )
+{
+ iobind::parser::xml_escape_parser parser;
+ return parser.escape(text);
+}
+
+
// this does only resolvables with this _name_.
// we could also act on _provides_
// ----------------------------------------------------------------------------
+void xml_list_patches ()
+{
+ const zypp::ResPool& pool = God->pool();
+ ResPool::byKind_iterator
+ it = pool.byKindBegin<Patch> (),
+ e = pool.byKindEnd<Patch> ();
+
+ for (; it != e; ++it )
+ {
+ ResObject::constPtr res = it->resolvable();
+ if ( it->status().isNeeded() ) {
+ Patch::constPtr patch = asKind<Patch>(res);
+
+ cout << " <update ";
+ cout << "name=\"" << res->name () << "\" " ;
+ cout << "edition=\"" << res->edition ().asString() << "\" ";
+ cout << "category=\"" << patch->category() << "\" ";
+ cout << "pkgmanager=\"" << ((patch->affects_pkg_manager()) ? "true" : "false") << "\" ";
+ cout << "restart=\"" << ((patch->reboot_needed()) ? "true" : "false") << "\" ";
+ cout << "interactive=\"" << ((patch->interactive()) ? "true" : "false") << "\" ";
+ cout << "resolvabletype=\"" << "patch" << "\" ";
+ cout << ">" << endl;
+ cout << " <summary>" << xml_escape(patch->summary()) << " </summary>" << endl;
+ cout << " <description>" << xml_escape(patch->description()) << "</description>" << endl;
+
+ if ( patch->repository() != Repository::noRepository )
+ {
+ cout << " <source url=\"" << *(patch->repository().info().baseUrlsBegin());
+ cout << "\" alias=\"" << patch->repository().info().alias() << "\"/>" << endl;
+ }
+
+ cout << " </update>" << endl;
+ }
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+
void list_patch_updates ()
{
Table tbl;
// ----------------------------------------------------------------------------
+void xml_list_updates()
+{
+ Candidates candidates;
+ find_updates (ResTraits<Package>::kind, candidates);
+
+ Candidates::iterator cb = candidates.begin (), ce = candidates.end (), ci;
+ for (ci = cb; ci != ce; ++ci) {
+ ResObject::constPtr res = ci->resolvable();
+
+ cout << " <update ";
+ cout << "name=\"" << res->name () << "\" " ;
+ cout << "edition=\"" << res->edition ().asString() << "\" ";
+ cout << "resolvabletype=\"" << "package" << "\" ";
+ cout << ">" << endl;
+ cout << " <summary>" << xml_escape(res->summary()) << " </summary>" << endl;
+ cout << " <description>" << xml_escape(res->description()) << "</description>" << endl;
+
+ if ( res->repository() != Repository::noRepository )
+ {
+ cout << " <source url=\"" << *(res->repository().info().baseUrlsBegin());
+ cout << "\" alias=\"" << res->repository().info().alias() << "\"/>" << endl;
+ }
+
+ cout << " </update>" << endl;
+ }
+}
+
+
+
+// ----------------------------------------------------------------------------
+
static
void mark_patch_updates (bool skip_interactive)
{
"\tpatch-check, pchk\tCheck for patches\n"
"\tpatches, pch\t\tList patches\n"
"\tlist-updates, lu\tList updates\n"
+ "\txml-updates-patches, x\tList updates and patches in xml format\n"
"\tupdate, up\t\tUpdate installed resolvables with newer versions.\n"
"\tinfo, if\t\tShow full information for packages\n"
"\tpatch-info\t\tShow full information for patches\n"
return ZYPPER_EXIT_OK;
}
+
+ // -----------------( xml list updates and patches )------------------------
+
+ else if (command == ZypperCommand::XML_LIST_UPDATES_PATCHES) {
+ cond_init_target ();
+ init_repos ();
+ cond_load_resolvables();
+ establish ();
+
+ cout << "<?xml version='1.0'?>" << endl;
+ cout << "<update-status version=\"0.4\">" << endl;
+ cout << "<update-list>" << endl;
+ xml_list_patches ();
+ xml_list_updates ();
+ cout << "</update-list>" << endl;
+ cout << "</update-status>" << endl;
+
+ return ZYPPER_EXIT_OK;
+ }
+
// -----------------------------( update )----------------------------------
else if (command == ZypperCommand::UPDATE) {