commit 53384595d2962499a0596f3e42a14e63e698f8eb
Author: Duncan Mac-Vicar P
Date: Mon Jan 12 14:05:09 2009 +0100
add program to see locked items from libzypp perspective
---
src/Makefile.am | 2 +
src/zmd-list-locks.cc | 104 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 8713825..0ed1b19 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,6 +21,7 @@ bin_PROGRAMS = \
parse-metadata \
update-status \
zmd-solver-testcase \
+ zmd-list-locks \
transact
zypp_sources_SOURCES = zypp-sources.cc
@@ -31,3 +32,4 @@ transact_SOURCES = transact.cc transactions.cc transactions.h RpmCallbacks.h Med
parse_metadata_SOURCES = parse-metadata.cc KeyRingCallbacks.h
update_status_SOURCES = update-status.cc locks.cc locks.h
zmd_solver_testcase_SOURCES = zmd-solver-testcase.cc transactions.cc transactions.h locks.cc locks.h
+zmd_list_locks_SOURCES = zmd-list-locks.cc locks.cc locks.h
diff --git a/src/zmd-list-locks.cc b/src/zmd-list-locks.cc
new file mode 100644
index 0000000..0b41a1e
--- /dev/null
+++ b/src/zmd-list-locks.cc
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
+#include <iostream>
+#include <string>
+
+#include "dbsource/zmd-backend.h"
+
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+using namespace zypp;
+
+#include
+#undef ZYPP_BASE_LOGGER_LOGGROUP
+#define ZYPP_BASE_LOGGER_LOGGROUP "list-locks"
+
+#include "dbsource/DbAccess.h"
+#include "dbsource/DbSources.h"
+#include "KeyRingCallbacks.h"
+
+#include "transactions.h"
+#include "locks.h"
+#include
+
+using solver::detail::ResolverInfo_Ptr;
+using namespace std;
+
+//-----------------------------------------------------------------------------
+
+int
+main (int argc, char **argv)
+{
+ if (argc < 2)
+ {
+ cerr << "usage: " << argv[0] << " zmd-db" << endl;
+ return 1;
+ }
+
+ const char *logfile = getenv("ZYPP_LOGFILE");
+ if (logfile != NULL)
+ zypp::base::LogControl::instance().logfile( logfile );
+ else
+ zypp::base::LogControl::instance().logfile( ZMD_BACKEND_LOG );
+
+ MIL << "-------------------------------------" << endl;
+ MIL << "START zmd-list-locks " << argv[1] << endl;
+
+ // access the sqlite db
+
+ DbAccess db (argv[1]);
+ if (!db.openDb(false))
+ return 1;
+
+ // we honor zmd locks, so disable autoprotecton of
+ // foreign vendors
+ zypp::VendorAttr::disableAutoProtect();
+
+ ZYpp::Ptr God = backend::getZYpp( true );
+ KeyRingCallbacks keyring_callbacks;
+ DigestCallbacks digest_callbacks;
+
+ Target_Ptr target = backend::initTarget( God );
+
+ // load the catalogs and resolvables from sqlite db
+ DbSources dbs(db.db());
+
+ const SourcesList & sources = dbs.sources();
+
+ bool success = true;
+
+ for (SourcesList::const_iterator it = sources.begin(); it != sources.end(); ++it)
+ {
+ zypp::ResStore store = it->resolvables();
+ MIL << "Catalog " << it->id() << " contributing " << store.size() << " resolvables" << endl;
+ God->addResolvables( store, (it->id() == "@system") );
+ }
+
+ // update-status is supposed to do this
+ // but resolvables dont have a status yet
+ God->resolver()->establishPool();
+
+ // now the pool is complete, add transactions
+
+ // read locks first
+ read_locks (God->pool(), db.db());
+
+ for( ResPool::const_iterator it = God->pool().begin();
+ it != God->pool().end();
+ ++it )
+ {
+ if ( it->status().isLocked() )
+ cout << *it << endl;
+ }
+
+ db.closeDb();
+
+ MIL << "END zmd-testcase, result " << (success ? 0 : 1) << endl;
+
+ return (success ? 0 : 1);
+}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org