diff options
author | Enrico Zini <enrico@enricozini.org> | 2015-09-10 15:20:37 +0200 |
---|---|---|
committer | Enrico Zini <enrico@enricozini.org> | 2015-09-10 15:20:37 +0200 |
commit | f6cc4a1633ab4fdd8f58b7399b8e853c18d04d46 (patch) | |
tree | cf0e0abaab7bd2d84848cb0eeb6d06d08aed6318 | |
parent | 6be162556859100387ad791421bcbbab605327da (diff) | |
download | libept-f6cc4a1633ab4fdd8f58b7399b8e853c18d04d46.tar.gz |
Builds without wibble
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | debian/control | 4 | ||||
-rw-r--r-- | debian/debuild.opts | 1 | ||||
-rwxr-xr-x | debian/rules | 8 | ||||
-rw-r--r-- | ept/debtags/coll/TextFormat.cc | 6 | ||||
-rw-r--r-- | ept/debtags/coll/TextFormat.h | 8 | ||||
-rw-r--r-- | ept/debtags/coll/fast.cc | 11 | ||||
-rw-r--r-- | ept/debtags/coll/operators.h | 201 | ||||
-rw-r--r-- | ept/debtags/coll/set.h | 2 | ||||
-rw-r--r-- | ept/debtags/debtags-test.cc | 9 | ||||
-rw-r--r-- | ept/debtags/debtags.cc | 10 | ||||
-rw-r--r-- | ept/debtags/vocabulary.cc | 170 | ||||
-rw-r--r-- | ept/debtags/vocabulary.h | 13 | ||||
-rw-r--r-- | ept/libept.pc.in | 1 |
15 files changed, 290 insertions, 163 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index db91197..7c61299 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,8 +22,6 @@ set( APT_INCLUDES "/usr/include/" CACHE STRING "apt include path" ) set( APT_LINKDIRS "/usr/lib/" CACHE STRING "apt library path" ) set( OPT_FLAGS "-O0 -g" CACHE STRING "optimization level" ) -pkg_check_modules( WIBBLE REQUIRED "libwibble >= 1.0" ) - add_subdirectory( ept ) add_subdirectory( tools ) add_subdirectory( doc ) diff --git a/debian/changelog b/debian/changelog index e45d7f2..2284c45 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +libept (1.0.15) UNRELEASED; urgency=medium + + * Removed need of tagcoll and wibble + * Removed popcon/ support + + -- Enrico Zini <enrico@debian.org> Thu, 10 Sep 2015 15:19:23 +0200 + libept (1.0.14) unstable; urgency=medium * New version that includes Matthias' changes diff --git a/debian/control b/debian/control index 7146325..63c22de 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,6 @@ Build-Depends: debhelper (>= 9), dh-exec, dh-buildinfo, cmake (>= 2.6), pkg-config, doxygen, libapt-pkg-dev (>= 1.0.10), - libwibble-dev (>= 1.1-1+b1), libwibble-dev (<< 2.0), libxapian-dev (>= 1.2.21-1.2) Standards-Version: 3.9.6.0 Vcs-Git: git://git.debian.org/git/debtags/libept.git @@ -19,9 +18,7 @@ Architecture: any Recommends: pkg-config Depends: libept1.4.16 (= ${binary:Version}), - libwibble-dev (>= 1.1-1+b1), libwibble-dev (<< 2.0), libapt-pkg-dev (>= 1.0.10), libxapian-dev (>= 1.2.21-1.2), ${misc:Depends} -Built-Using: ${libwibble:Source} Description: High-level library for managing Debian package information The library defines a very minimal framework in which many sources of data about Debian packages can be implemented and queried together. @@ -40,7 +37,6 @@ Section: libs Architecture: any Multi-Arch: same Depends: ${shlibs:Depends}, ${misc:Depends} -Built-Using: ${libwibble:Source} Description: High-level library for managing Debian package information The library defines a very minimal framework in which many sources of data about Debian packages can be implemented and queried together. diff --git a/debian/debuild.opts b/debian/debuild.opts deleted file mode 100644 index b962575..0000000 --- a/debian/debuild.opts +++ /dev/null @@ -1 +0,0 @@ --i_darcs -I_darcs -iwibble -Iwibble diff --git a/debian/rules b/debian/rules index 9c9cd65..e689b30 100755 --- a/debian/rules +++ b/debian/rules @@ -2,9 +2,6 @@ BUILDDIR = $(CURDIR)/debian/build -libwibble_source = $(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W libwibble-dev) -tagcoll2_source = $(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W libtagcoll2-dev) - %: dh $@ --buildsystem=cmake --builddirectory=$(BUILDDIR) @@ -22,11 +19,6 @@ override_dh_auto_install: dh_installdocs -plibept-dev -n $(BUILDDIR)/doc/html dh_installdocs -plibept-dev -n $(BUILDDIR)/doc/libept.doxytags -override_dh_gencontrol: - dh_gencontrol -- \ - -Vlibwibble:Source="$(libwibble_source)" \ - -Vtagcoll2:Source="$(tagcoll2_source)" - debsrc: debian/check_versions gbp buildpackage --git-pristine-tar -S -us -uc diff --git a/ept/debtags/coll/TextFormat.cc b/ept/debtags/coll/TextFormat.cc index 1592289..7681d3d 100644 --- a/ept/debtags/coll/TextFormat.cc +++ b/ept/debtags/coll/TextFormat.cc @@ -20,15 +20,13 @@ #include "TextFormat.h" #include "fast.h" -#include <wibble/exception.h> -#include <wibble/operators.h> +#include "operators.h" #include <stdexcept> #include <system_error> #include <set> using namespace std; -using namespace wibble; -using namespace wibble::operators; +using namespace ept::debtags::coll::operators; namespace ept { namespace debtags { diff --git a/ept/debtags/coll/TextFormat.h b/ept/debtags/coll/TextFormat.h index a35f664..663711d 100644 --- a/ept/debtags/coll/TextFormat.h +++ b/ept/debtags/coll/TextFormat.h @@ -1,5 +1,5 @@ -#ifndef TAGCOLL_TEXTFORMAT_H -#define TAGCOLL_TEXTFORMAT_H +#ifndef EPT_DEBTAGS_COLL_TEXTFORMAT_H +#define EPT_DEBTAGS_COLL_TEXTFORMAT_H /** \file * Serialize and deserialize a tagged collection to a text file @@ -23,10 +23,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <wibble/mixin.h> -#include <wibble/empty.h> -#include <wibble/singleton.h> #include <cstdio> +#include <string> //#define TRACE_PARSE diff --git a/ept/debtags/coll/fast.cc b/ept/debtags/coll/fast.cc index 47bbf67..43ee143 100644 --- a/ept/debtags/coll/fast.cc +++ b/ept/debtags/coll/fast.cc @@ -20,10 +20,10 @@ #include <ept/debtags/coll/fast.h> #include <ept/debtags/coll/set.h> -#include <wibble/operators.h> +#include <ept/debtags/coll/operators.h> using namespace std; -using namespace wibble::operators; +using namespace ept::debtags::coll::operators; namespace ept { namespace debtags { @@ -31,8 +31,6 @@ namespace coll { void Fast::insert(const std::set<std::string>& items, const std::set<std::string>& tags) { - using namespace wibble::operators; - if (tags.empty()) return; @@ -42,8 +40,6 @@ void Fast::insert(const std::set<std::string>& items, const std::set<std::string void Fast::insert(const std::string& item, const std::set<std::string>& tags) { - using namespace wibble::operators; - if (tags.empty()) return; @@ -66,8 +62,6 @@ void Fast::insert(const std::string& item, const std::set<std::string>& tags) void Fast::insert(const std::set<std::string>& items, const std::string& tag) { - using namespace wibble::operators; - for (typename std::set<std::string>::const_iterator i = items.begin(); i != items.end(); ++i) { @@ -96,7 +90,6 @@ std::set<std::string> Fast::getItemsHavingTag(const std::string& tag) const std::set<std::string> Fast::getItemsHavingTags(const std::set<std::string>& tags) const { - using namespace wibble::operators; if (tags.empty()) return std::set<std::string>(); diff --git a/ept/debtags/coll/operators.h b/ept/debtags/coll/operators.h new file mode 100644 index 0000000..2fecbad --- /dev/null +++ b/ept/debtags/coll/operators.h @@ -0,0 +1,201 @@ +// -*- C++ -*- + +#ifndef EPT_DEBTAGS_COLL_OPERATORS_H +#define EPT_DEBTAGS_COLL_OPERATORS_H + +#include <set> +#include <algorithm> + +namespace ept { +namespace debtags { +namespace coll { +namespace operators { + +/* +template< typename S, typename VT > struct IsContainer { + typedef S T; +}; + +template< typename S > +typename IsContainer< S, typename S::value_type >::T operator &&( const S &a, const S &b ) { + S ret; + std::set_intersection( a.begin(), a.end(), b.begin(), b.end(), + std::inserter( ret, ret.begin() ) ); + return ret; +} +*/ + +template< typename T > +T operator+( const T &i, typename T::difference_type o ) { + T r = i; + std::advance( r, o ); + return r; +} + +template< typename T > +std::set< T > operator &( const std::set< T > &a, const std::set< T > &b ) { + std::set< T > ret; + std::set_intersection( a.begin(), a.end(), b.begin(), b.end(), + std::inserter( ret, ret.begin() ) ); + return ret; +} + +template< typename T > +std::set< T > operator &( const std::set< T > &a, const T &b ) { + std::set< T > ret; + if ( a.find( b ) != a.end() ) { + std::set< T > r; + r.insert( b ); + return r; + } + return std::set< T >(); +} + +template< typename T > +std::set< T > operator |( const std::set< T > &a, const T& item ) { + std::set< T > ret = a; + ret.insert(item); + return ret; +} + +template< typename T > +std::set< T > operator |( const std::set< T > &a, const std::set< T > &b ) { + std::set< T > ret; + std::set_union( a.begin(), a.end(), b.begin(), b.end(), + std::inserter( ret, ret.begin() ) ); + return ret; +} + +template< typename T > +std::set< T > operator -( const std::set< T > &a, const std::set< T > &b ) { + std::set< T > ret; + std::set_difference( a.begin(), a.end(), b.begin(), b.end(), + std::inserter(ret, ret.begin() ) ); + return ret; +} + +template< typename T > +std::set< T > operator -( const std::set< T > &a, const T& item ) { + std::set< T > ret = a; + ret.erase(item); + return ret; +} + +template< typename T > +std::set< T > &operator|=( std::set< T > &a, const T& item ) +{ + a.insert(item); + return a; +} + +// General case +template< typename T, typename SEQ > +std::set< T > &operator|=( std::set< T > &a, const SEQ& items ) +{ + for (typename SEQ::const_iterator i = items.begin(); + i != items.end(); ++i) + a.insert(*i); + return a; +} + +// Little optimization in case a is empty +template< typename T > +std::set< T > &operator |=( std::set< T > &a, const std::set< T > &b ) { + if (a.empty()) + return a = b; + + for (typename std::set<T>::const_iterator i = b.begin(); + i != b.end(); ++i) + a.insert(*i); + return a; +} + +// General case, but assumes that b is sorted +template< typename T, typename SEQ > +std::set< T > &operator &=( std::set< T > &a, const SEQ& b ) { + // Little optimization: if b is empty, we avoid a run through a + if (b.empty()) + { + a.clear(); + return a; + } + + typename std::set<T>::iterator ia = a.begin(); + typename SEQ::const_iterator ib = b.begin(); + while (ia != a.end()) + { + if (ib != b.end() && *ib < *ia) + { + ++ib; + } + else if (ib == b.end() || *ia != *ib) + { + typename std::set<T>::iterator tmp = ia; + ++ia; + a.erase(tmp); + } + else + { + ++ia; + ++ib; + } + } + return a; +} + +template< typename T > +std::set< T > &operator-=( std::set< T > &a, const T& item ) +{ + a.erase(item); + return a; +} + +// General case, but works only if b is sorted +template< typename T, typename SEQ > +std::set< T > &operator -=( std::set< T > &a, const SEQ& b ) +{ + typename std::set<T>::iterator ia = a.begin(); + typename SEQ::const_iterator ib = b.begin(); + while (ia != a.end() && ib != b.end()) + { + if (*ia == *ib) + { + typename std::set<T>::iterator tmp = ia; + ++ia; + ++ib; + a.erase(tmp); + } + else if (*ia < *ib) + ++ia; + else + ++ib; + } + return a; +} + +template< typename T > +bool operator<=( const T &a, const std::set< T > &b ) { + return b.find( a ) != b.end(); +} + +template< typename T > +bool operator<=( const std::set< T > &a, const std::set< T > &b ) { + typename std::set<T>::const_iterator x = a.begin(); + + for ( typename std::set<T>::const_iterator y = b.begin(); y != b.end(); ++y ) + if ( x == a.end() ) + return true; + else if (*x == *y) + ++x; + else if (*x < *y) + return false; + + return x == a.end(); +} + +} +} +} +} + +#endif diff --git a/ept/debtags/coll/set.h b/ept/debtags/coll/set.h index cabd939..bcc9934 100644 --- a/ept/debtags/coll/set.h +++ b/ept/debtags/coll/set.h @@ -23,7 +23,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <wibble/operators.h> +#include <ept/debtags/coll/operators.h> #include <set> namespace ept { diff --git a/ept/debtags/debtags-test.cc b/ept/debtags/debtags-test.cc index c03d3a2..9ed1eb6 100644 --- a/ept/debtags/debtags-test.cc +++ b/ept/debtags/debtags-test.cc @@ -1,13 +1,13 @@ +#include "ept/test.h" #include "debtags.h" -#include <ept/test.h> -#include <wibble/operators.h> +#include "coll/operators.h" #include <cstdio> using namespace std; using namespace ept; using namespace ept::debtags; using namespace ept::tests; -using namespace wibble::operators; +using namespace ept::debtags::coll::operators; #define testfile TEST_ENV_DIR "debtags/package-tags" @@ -153,9 +153,6 @@ class Tests : public TestCase set<std::string> res = empty.getTagsOfItem("apt"); wassert(actual(res.empty()).istrue()); - // TODO: currently does not compile because of a bug in tagcoll - //res = empty.getTagsOfItems(wibble::singleton(string("apt"))); - //assert(res.empty()); res = empty.getAllTags(); wassert(actual(res.empty()).istrue()); diff --git a/ept/debtags/debtags.cc b/ept/debtags/debtags.cc index 9aed835..62cc382 100644 --- a/ept/debtags/debtags.cc +++ b/ept/debtags/debtags.cc @@ -23,10 +23,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <ept/debtags/debtags.h> +#include "debtags.h" +#include "ept/utils/sys.h" #include "coll/TextFormat.h" -#include <wibble/sys/fs.h> -#include <wibble/string.h> #include <system_error> #include <iostream> #include <sstream> @@ -36,7 +35,6 @@ #include <unistd.h> // getuid using namespace std; -using namespace wibble; namespace ept { namespace debtags { @@ -45,7 +43,7 @@ Debtags::Debtags() : m_timestamp(0) { string src = pathname(); - if (!sys::fs::exists(src)) + if (!sys::exists(src)) return; load(src); } @@ -73,7 +71,7 @@ void Debtags::load(const std::string& pathname) fclose(in); // Read the timestamp - m_timestamp = sys::fs::timestamp(pathname, 0); + m_timestamp = sys::timestamp(pathname, 0); } string Debtags::pathname() diff --git a/ept/debtags/vocabulary.cc b/ept/debtags/vocabulary.cc index f2575f9..78e2833 100644 --- a/ept/debtags/vocabulary.cc +++ b/ept/debtags/vocabulary.cc @@ -18,10 +18,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <ept/debtags/vocabulary.h> -#include <ept/debtags/maint/debdbparser.h> -#include <wibble/exception.h> -#include <wibble/sys/fs.h> +#include "vocabulary.h" +#include "maint/debdbparser.h" +#include "ept/utils/sys.h" #include <system_error> #include <cassert> #include <cstring> @@ -32,7 +31,6 @@ #include <unistd.h> using namespace std; -using namespace wibble; namespace ept { namespace debtags { @@ -113,7 +111,7 @@ string Vocabulary::pathname() void Vocabulary::load(const std::string& pathname) { - if (!sys::fs::exists(pathname)) return; + if (!sys::exists(pathname)) return; // Read uncompressed data FILE* in = fopen(pathname.c_str(), "rt"); if (!in) @@ -126,7 +124,7 @@ void Vocabulary::load(const std::string& pathname) throw; } fclose(in); - m_timestamp = sys::fs::timestamp(pathname, 0); + m_timestamp = sys::timestamp(pathname, 0); } voc::TagData& voc::FacetData::obtainTag(const std::string& name) @@ -271,116 +269,68 @@ void Vocabulary::write() void Vocabulary::write(const std::string& fname) { - // Build the temp file template - char tmpfname[fname.size() + 7]; - strncpy(tmpfname, fname.c_str(), fname.size()); - strncpy(tmpfname + fname.size(), ".XXXXXX", 8); - - // Create and open the temporary file - int fd = mkstemp(tmpfname); - if (fd < 0) - throw wibble::exception::File(tmpfname, "opening file"); - - // Read the current umask - mode_t cur_umask = umask(0); - umask(cur_umask); - - // Give the file the right permissions - if (fchmod(fd, 0666 & ~cur_umask) < 0) - throw wibble::exception::File(tmpfname, "setting file permissions"); - - // Pass the file descriptor to stdio - FILE* out = fdopen(fd, "wt"); - if (!out) - throw wibble::exception::File(tmpfname, "fdopening file"); - - // Write out the merged vocabulary data - write(out); - - // Flush stdio's buffers - fflush(out); - - // Flush OS buffers - fdatasync(fd); - - // Close the file - fclose(out); - - // Rename the successfully written file to its final name - if (rename(tmpfname, fname.c_str()) == -1) - throw wibble::exception::System(string("renaming ") + tmpfname + " to " + fname); + // Serialize the merged vocabulary data + std::stringstream str; + write(str); + // Write it out atomically + sys::write_file_atomically(fname, str.str(), 0666); } -static void writeDebStyleField(FILE* out, const string& name, const string& val) throw () +static void writeDebStyleField(std::ostream& out, const string& name, const string& val) throw () { - fprintf(out, "%s: ", name.c_str()); - - // Properly escape newlines - bool was_nl = false; - for (string::const_iterator s = val.begin(); s != val.end(); s++) - if (was_nl) - // \n\n -> \n .\n - if (*s == '\n') - { - fputc(' ', out); - fputc('.', out); - fputc(*s, out); - } - // \n([^ \t]) -> \n \1 - else if (*s != ' ' && *s != '\t') - { - fputc(' ', out); - fputc(*s, out); - was_nl = false; - } - // \n[ \t] goes unchanged - else - { - fputc(*s, out); - was_nl = false; - } - else - if (*s == '\n') - { - fputc(*s, out); - was_nl = true; - } - else - fputc(*s, out); - - fputc('\n', out); + out << name << ": "; + + // Properly escape newlines + bool was_nl = false; + for (string::const_iterator s = val.begin(); s != val.end(); s++) + if (was_nl) + // \n\n -> \n .\n + if (*s == '\n') + out << " ." << *s; + // \n([^ \t]) -> \n \1 + else if (*s != ' ' && *s != '\t') + { + out << " " << *s; + was_nl = false; + } + // \n[ \t] goes unchanged + else + { + out << *s; + was_nl = false; + } + else + if (*s == '\n') + { + out << *s; + was_nl = true; + } + else + out << *s; + + out << endl; } -void Vocabulary::write(FILE* out) +void Vocabulary::write(std::ostream& out) { - long start_ofs = ftell(out); - int facetid = 0; - int tagid = 0; - - //fprintf(stderr, "Write\n"); - for (std::map<std::string, voc::FacetData>::iterator f = m_facets.begin(); f != m_facets.end(); ++f) - { - //fprintf(stderr, "Writing facet %.*s\n", PFSTR(f->first)); - writeDebStyleField(out, "Facet", f->first); - for (std::map<std::string, std::string>::const_iterator j = f->second.begin(); - j != f->second.end(); j++) - writeDebStyleField(out, j->first, j->second); - fputc('\n', out); - - for (std::map<std::string, voc::TagData>::iterator t = f->second.m_tags.begin(); - t != f->second.m_tags.end(); t++) - { - //fprintf(stderr, "Writing tag %.*s\n", PFSTR(t->first)); - writeDebStyleField(out, "Tag", t->first); - for (std::map<std::string, std::string>::const_iterator j = t->second.begin(); - j != t->second.end(); j++) - writeDebStyleField(out, j->first, j->second); - fputc('\n', out); - } - } + for (const auto& f: m_facets) + { + //fprintf(stderr, "Writing facet %.*s\n", PFSTR(f->first)); + writeDebStyleField(out, "Facet", f.first); + for (const auto& j : f.second) + writeDebStyleField(out, j.first, j.second); + out << endl; + + for (const auto& t : f.second.m_tags) + { + //fprintf(stderr, "Writing tag %.*s\n", PFSTR(t->first)); + writeDebStyleField(out, "Tag", t.first); + for (const auto& j : t.second) + writeDebStyleField(out, j.first, j.second); + out << endl; + } + } } } } - -// vim:set ts=4 sw=4: diff --git a/ept/debtags/vocabulary.h b/ept/debtags/vocabulary.h index 5c5cd32..0cc9449 100644 --- a/ept/debtags/vocabulary.h +++ b/ept/debtags/vocabulary.h @@ -29,6 +29,7 @@ #include <set> #include <map> #include <cstdio> +#include <iosfwd> namespace ept { namespace debtags { @@ -155,7 +156,12 @@ protected: voc::FacetData& obtainFacet(const std::string& name); voc::TagData& obtainTag(const std::string& fullname); - + + /** + * Write the vocabulary data to the given output stream + */ + void write(std::ostream& out); + public: /** * Instantiate the Debtags vocabulary @@ -240,11 +246,6 @@ public: */ void write(const std::string& fname); - /** - * Write the vocabulary data to the given output stream - */ - void write(FILE* out); - /** * Return the default pathname for the vocabulary. * diff --git a/ept/libept.pc.in b/ept/libept.pc.in index d5db288..265f032 100644 --- a/ept/libept.pc.in +++ b/ept/libept.pc.in @@ -6,6 +6,5 @@ includedir=@includedir@ Name: libept Description: Access various data sources about software packages Version: @EPT_VERSION@ -Requires: libwibble Cflags: -I${includedir} Libs: -L${libdir} -lept -lapt-pkg -lxapian -lz |