[Debtags-commits] [svn] r1887 - in debtags/1.6.0: . tools

Enrico Zini enrico at costa.debian.org
Sat Sep 2 17:36:46 UTC 2006


Author: enrico
Date: Sat Sep  2 17:36:45 2006
New Revision: 1887

Added:
   debtags/1.6.0/tools/debtags-get   (contents, props changed)
Modified:
   debtags/1.6.0/   (props changed)
   debtags/1.6.0/tools/Ept.h
   debtags/1.6.0/tools/Makefile.am
   debtags/1.6.0/tools/debtags.cc
Log:
 r3273 at viaza:  enrico | 2006-09-02 19:36:16 +0200
 Added debtags-get to download debtags sources from wherever they are
 Ported debtags to the new changes in ept and redid the update function


Modified: debtags/1.6.0/tools/Ept.h
==============================================================================
--- debtags/1.6.0/tools/Ept.h	(original)
+++ debtags/1.6.0/tools/Ept.h	Sat Sep  2 17:36:45 2006
@@ -64,6 +64,7 @@
 public:
 	Ept(bool editable = false) {}
 
+	Aggregator& aggregator() { return agg; }
 	Index& packages() { return agg.index(); }
 	TagMap& tagmap() { return agg.tagMap(); }
 	Vocabulary& vocabulary() { return agg.vocabulary(); }

Modified: debtags/1.6.0/tools/Makefile.am
==============================================================================
--- debtags/1.6.0/tools/Makefile.am	(original)
+++ debtags/1.6.0/tools/Makefile.am	Sat Sep  2 17:36:45 2006
@@ -1,6 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
 bin_PROGRAMS = debtags
+bin_SCRIPTS = debtags-get
 noinst_PROGRAMS = manpage
 
 debtags_SOURCES = \
@@ -17,4 +18,4 @@
 
 INCLUDES = -I.. $(LIBEPT_CFLAGS)
 
-EXTRA_DIST = acqprogress.h ChildProcess.h DebtagsOptions.h Environment.h Exec.h Printer.h Ept.h Ept.tcc
+EXTRA_DIST = acqprogress.h ChildProcess.h DebtagsOptions.h Environment.h Exec.h Printer.h Ept.h Ept.tcc debtags-get

Modified: debtags/1.6.0/tools/debtags.cc
==============================================================================
--- debtags/1.6.0/tools/debtags.cc	(original)
+++ debtags/1.6.0/tools/debtags.cc	Sat Sep  2 17:36:45 2006
@@ -45,7 +45,8 @@
 #include "SmartSearcher.h"
 
 
-#include <apt-pkg/configuration.h>
+#include <ept/cache/debtags/update.h>
+//#include <apt-pkg/configuration.h>
 
 #include <errno.h>
 #include <termios.h>
@@ -125,13 +126,6 @@
 	return auto_ptr<Ept>(new Ept(write));
 }
 
-void wantTagDatabase() throw ()
-{
-	if (!TagMap::hasTagDatabase())
-		fatal_error(
-				"The tag database has not yet been generated: you need to run \"debtags update\" (as root) before using the package tags\n");
-}
-
 template<typename OUT>
 void readCollection(const string& file, const OUT& out)
 {
@@ -1014,7 +1008,6 @@
 		else if (opts.foundCommand() == opts.cat)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 			TagMap& debtags = ept->tagmap();
 			int count = 0;
 
@@ -1041,7 +1034,6 @@
 		else if (opts.foundCommand() == opts.dumpavail)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 			int count = 0;
 
 			auto_ptr<PackagePrinter> printer;
@@ -1069,7 +1061,6 @@
 		{
 			// TODO: complain if no expression found
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 			int count = 0;
 
 			auto_ptr<PackagePrinter> printer;
@@ -1097,7 +1088,6 @@
 		{
 			// TODO: complain if no expression found
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 			TagMap& debtags = ept->tagmap();
 			int count = 0;
 
@@ -1126,7 +1116,6 @@
 		{
 			auto_ptr<Ept> ept = debtagsInit();
 			Vocabulary& voc = ept->vocabulary();
-			wantTagDatabase();
 
 			std::set<Facet> facets = voc.facets();
 			for (std::set<Facet>::const_iterator i = facets.begin();
@@ -1146,7 +1135,6 @@
 		else if (opts.foundCommand() == opts.tagshow)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			string tag = opts.next();
 
@@ -1167,7 +1155,6 @@
 		else if (opts.foundCommand() == opts.tagsearch)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			SubstringTagMatcher match;
 
@@ -1215,7 +1202,6 @@
 		else if (opts.foundCommand() == opts.show)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			while (opts.hasNext())
 			{
@@ -1248,7 +1234,6 @@
 			using namespace wibble::operators;
 
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			int maxdist = 0;
 			if (opts.misc_distance->boolValue())
@@ -1336,7 +1321,6 @@
 		else if (opts.foundCommand() == opts.maintainers)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			// Gather maintainer informations
 			coll::Simple<string, string> maints;
@@ -1357,7 +1341,6 @@
 			if (cmd == "add" || cmd == "rm")
 			{
 				auto_ptr<Ept> ept = debtagsInit(true);
-				wantTagDatabase();
 
 				string name = opts.next();
 
@@ -1395,7 +1378,6 @@
 			else if (cmd == "ls")
 			{
 				auto_ptr<Ept> ept = debtagsInit();
-				wantTagDatabase();
 
 				string name = opts.next();
 				Package pkg = ept->packages().packageByName(name);
@@ -1420,7 +1402,6 @@
 		else if (opts.foundCommand() == opts.submit)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			if (opts.hasNext())
 			{
@@ -1438,7 +1419,6 @@
 		else if (opts.foundCommand() == opts.todo)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 			int count = 0;
 
 			auto_ptr<PackagePrinter> printer;
@@ -1460,7 +1440,6 @@
 		else if (opts.foundCommand() == opts.stats)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			int pkgCount = ept->packages().packageCount();
 			printf("Total count of packages: %d\n", pkgCount);
@@ -1504,7 +1483,6 @@
 		else if (opts.foundCommand() == opts.check)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			if (!opts.hasNext())
 				throw wibble::exception::BadOption("you should specify the file with the collection to check");
@@ -1528,7 +1506,6 @@
 		else if (opts.foundCommand() == opts.score)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			// Compute package scores
 			PackageScore score;
@@ -1543,7 +1520,6 @@
 		else if (opts.foundCommand() == opts.diff)
 		{
 			auto_ptr<Ept> ept = debtagsInit();
-			wantTagDatabase();
 
 			string file = opts.next();
 
@@ -1581,31 +1557,32 @@
 				searcher.interact();
 			}
 		}
-#if 0
 		// update
 		// Updates the package tag database (requires root)
 		else if (opts.foundCommand() == opts.update)
 		{
-			if (geteuid() != 0)
-			{
-				throw ConsistencyCheckException("You must be root to update the system debtags database");
-			}
-			struct winsize ws;
-			unsigned int ScreenWidth;
+			verbose("System source directory: %s\n", ept::Path::debtagsSourceDir().c_str());
+			verbose("User source directory: %s\n", ept::Path::debtagsUserSourceDir().c_str());
 
-			if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5)
-				ScreenWidth = ws.ws_col - 1;
-
-			AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
-			//Debtags::Environment::get().updateDebtagsDatabase(&Stat);
-			mode_t prev_umask = umask(022);
-			//debtags::updateDatabase(&Stat);
-			if (!opts.update.local->boolValue())
-				debtags::fetchNewData(&Stat);
-			debtagsInit();
-			umask(prev_umask);
+			typedef ept::t::cache::debtags::IndexManager<> IndexManager;
+			std::string a, b;
+
+			auto_ptr<Ept> ept = debtagsInit();
+
+			IndexManager::obtainWorkingPkgidx<ept::configuration::Apt>(ept->aggregator(), a);
+			verbose("Package ID index: %s\n", a.c_str());
+
+			IndexManager::obtainWorkingVocabulary(a, b);
+			verbose("Vocabulary: %s\n", a.c_str());
+			verbose("Vocabulary index: %s\n", b.c_str());
+
+			IndexManager::obtainWorkingTagdb<ept::configuration::Apt>(ept->aggregator(), a, b);
+			verbose("Tag database: %s\n", a.c_str());
+			verbose("Tag database index: %s\n", b.c_str());
+
+			//mode_t prev_umask = umask(022);
+			//umask(prev_umask);
 		}
-#endif
 #if 0
 		// todoreport
 		// Print a report of packages needing work



More information about the Debtags-commits mailing list