[Debtags-commits] [svn] r1536 - central-database/trunk/aptfront

Enrico Zini enrico at costa.debian.org
Wed Feb 1 23:47:07 UTC 2006


Author: enrico
Date: Wed Feb  1 23:47:07 2006
New Revision: 1536

Modified:
   central-database/trunk/aptfront/setup
   central-database/trunk/aptfront/sitegen.cc
Log:
Implemented test 'cat' function using apt-cat code

Modified: central-database/trunk/aptfront/setup
==============================================================================
--- central-database/trunk/aptfront/setup	(original)
+++ central-database/trunk/aptfront/setup	Wed Feb  1 23:47:07 2006
@@ -22,4 +22,5 @@
 deb file://$ABSCACHEDIR/archive unstable main
 EOT
 
-cp $PACKAGES "$CACHE_DIR/archive/dists/unstable/main/binary-$DEB_HOST_ARCH/Packages.gz"
+#zcat $PACKAGES | bzip2 -9 > "$CACHE_DIR/archive/dists/unstable/main/binary-$DEB_HOST_ARCH/Packages.bz2"
+cp $PACKAGES $CACHE_DIR/archive/dists/unstable/main/binary-$DEB_HOST_ARCH/Packages.gz

Modified: central-database/trunk/aptfront/sitegen.cc
==============================================================================
--- central-database/trunk/aptfront/sitegen.cc	(original)
+++ central-database/trunk/aptfront/sitegen.cc	Wed Feb  1 23:47:07 2006
@@ -2,6 +2,7 @@
 #include <apt-front/manager.h>
 #include <apt-front/utils/paths.h>
 #include <apt-front/cache/component/debtags/update.h>
+#include <apt-front/cache/component/packages.h>
 #include <apt-pkg/init.h>
 
 #define CACHE_DIR "./"
@@ -88,7 +89,56 @@
 	aptInit();
 	
 	if (action == "update")
+	{
 		aptUpdate();
+		return 0;
+	}
+
+	cache::Global::get().open(cache::Cache::OpenDefault
+                              | cache::Cache::OpenReadOnly);
+//	cache::Global::get().open(cache::Cache::OpenDefault
+//                              | cache::Cache::OpenReadOnly
+//                              | cache::Cache::OpenDebtags);
+
+	if (action == "cat")
+	{
+		// Access the package cache
+		cache::component::Packages& pc = cache::Global::get().packages();
+	
+		typedef vector<cache::entity::Package> PV;
+		typedef vector<cache::entity::Version> VV;
+		PV l;
+		pc.packages( back_inserter( l ) );
+		for (PV::iterator i = l.begin(); i != l.end(); ++i)
+		{
+			if (!i->candidateVersion().valid())
+			{
+				cout << "Name: " << i->name() << endl;
+				cout << "Section: " << i->section() << endl;
+				//printTags(*i);
+				//cout << "No version" << endl;
+			} else {
+				//List<VersionIterator> versions = i.versionList().begin();
+				//VersionIterator vi = versions.begin();
+				cache::entity::Version cv = i->candidateVersion();
+				string record = cv.completeRecord();
+
+				/* Trim trailing spaces */
+				while (record.size() > 0 && isspace(record[record.size() - 1]))
+					record.resize(record.size() - 1);
+
+				/* Place the tags just after Section */
+				string::size_type pos = record.find("\nSection:");
+				pos = record.find('\n', pos + 1);
+				cout << record.substr(0, pos) << endl;
+				//printTags(*i);
+				cout << record.substr(pos + 1) << endl;
+			}
+			cout << endl;
+		}
+	}
+	
+	return 0;
 
 	return 0;
 }



More information about the Debtags-commits mailing list