Author: pere Date: 2014-09-29 08:43:54 +0000 (Mon, 29 Sep 2014) New Revision: 15226
Modified: software/ui/README software/ui/debian/changelog software/ui/src/Engine.cpp software/ui/src/Engine.h software/ui/src/goplay.cpp Log: Reduce the dependency on libept and use xapian index directly to avoid downloading popcon data ourself (Closes: 727626). Patch from Enrico Zini. Modified: software/ui/README =================================================================== --- software/ui/README 2014-09-29 01:13:27 UTC (rev 15225) +++ software/ui/README 2014-09-29 08:43:54 UTC (rev 15226) @@ -41,23 +41,15 @@ ./configure make -Running instructions --------------------- +Troubleshooting +--------------- -Before running the first time, you need to setup ept: + * Missing /var/lib/apt-xapian-index/index - apt-get install ept-cache +If goplay complains that /var/lib/apt-xapian-index/index does not exist, it +could be that you just installed apt-xapian-index and the index is still being +built. Just run `update-apt-xapian-index' as root to rebuild the index or see +the progress of a running indexer. -Then run "ept-cache info" and follow the instructions. It is usually something -like this: - apt-get install debtags - debtags update - mkdir /var/lib/popcon/ - cd /var/lib/popcon - wget http://popcon.debian.org/all-popcon-results.txt.gz - ept-cache reindex - -Then you can finally run ./goplay - Enjoy! Modified: software/ui/debian/changelog =================================================================== --- software/ui/debian/changelog 2014-09-29 01:13:27 UTC (rev 15225) +++ software/ui/debian/changelog 2014-09-29 08:43:54 UTC (rev 15226) @@ -6,6 +6,9 @@ to get HTTP download support. * Restructure code, move code to find screen shots to its own function. + * Reduce the dependency on libept and use xapian index directly to + avoid downloading popcon data ourself (Closes: 727626). Patch + from Enrico Zini. [ Miriam Ruiz ] * Added dh-autoreconf to Build-Depends and using it in debian/rules Modified: software/ui/src/Engine.cpp =================================================================== --- software/ui/src/Engine.cpp 2014-09-29 01:13:27 UTC (rev 15225) +++ software/ui/src/Engine.cpp 2014-09-29 08:43:54 UTC (rev 15226) @@ -1,7 +1,7 @@ /* * Backend engine for game installer UI * - * Copyright (C) 2003--2007 Enrico Zini <[email protected]> + * Copyright (C) 2003--2013 Enrico Zini <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include <wibble/string.h> #include <wibble/regexp.h> #include <iostream> +#include <fstream> using namespace std; using namespace wibble; @@ -30,7 +31,7 @@ using namespace ept::debtags; Engine::Engine() - : m_db(ept::axi::path_db()), m_stem("en"), m_filter_state(ANY), m_dirty(true), m_max(0) + : m_db("/var/lib/apt-xapian-index/index"), m_stem("en"), m_filter_state(ANY), m_dirty(true), m_max(0), m_popcon_validx(-1) { m_qp.set_default_op(Xapian::Query::OP_AND); m_qp.set_database(m_db); @@ -39,6 +40,25 @@ m_qp.add_prefix("pkg", "XP"); m_qp.add_boolean_prefix("tag", "XT"); m_qp.add_boolean_prefix("sec", "XS"); + + // Read the Xapian value index used for popcon data + std::ifstream in; + in.open("/var/lib/apt-xapian-index/values", ios::in); + if (!in.is_open() || in.fail()) + m_popcon_validx = -1; + ERegexp match_line("^app-popcon[ \t]+([0-9]+)", 2); + string line; + while (true) + { + getline(in, line); + if (in.fail()) break; + if (in.eof()) break; + if (match_line.match(line)) + { + m_popcon_validx = strtoul(match_line[1].c_str(), 0, 10); + break; + } + } } struct EngineMatchDecider : public Xapian::MatchDecider @@ -147,6 +167,14 @@ return Xapian::Query(Xapian::Query::OP_AND, globalFilter, query); } +float Engine::read_popcon(const Xapian::Document& doc) const +{ + if (m_popcon_validx == -1) return 0; + string val = doc.get_value(m_popcon_validx); + if (val.empty()) return 0; + return Xapian::sortable_unserialise(val); +} + void Engine::recompute() { EngineMatchDecider md(*this); @@ -244,8 +272,9 @@ //break; Result res; - res.name = i.get_document().get_data(); - res.popcon = m_popcon[res.name]; + Xapian::Document doc = i.get_document(); + res.name = doc.get_data(); + res.popcon = read_popcon(doc); res.relevance = i.get_percent(); if (res.popcon > m_res_max) @@ -304,8 +333,9 @@ for (++mi; mi != matches.end(); ++mi) { Result res; - res.name = mi.get_document().get_data(); - res.popcon = m_popcon[res.name]; + Xapian::Document doc = mi.get_document(); + res.name = doc.get_data(); + res.popcon = read_popcon(doc); res.relevance = mi.get_percent(); results.push_back(res); } Modified: software/ui/src/Engine.h =================================================================== --- software/ui/src/Engine.h 2014-09-29 01:13:27 UTC (rev 15225) +++ software/ui/src/Engine.h 2014-09-29 08:43:54 UTC (rev 15226) @@ -24,8 +24,7 @@ #include <ept/apt/apt.h> #include <ept/debtags/debtags.h> #include <ept/debtags/vocabulary.h> -#include <ept/axi/axi.h> -#include <ept/popcon/popcon.h> +#include <xapian.h> #include <string> #include <set> #include <vector> @@ -71,9 +70,6 @@ /// Xapian query parser Xapian::QueryParser m_qp; - /// Popcon scores - ept::popcon::Popcon m_popcon; - std::string m_filter_keywords; std::string m_filter_type; std::string m_filter_iface; @@ -88,9 +84,13 @@ float m_max; float m_res_max; + int m_popcon_validx; + Xapian::Query makeQuery(); void recompute(); + float read_popcon(const Xapian::Document& doc) const; + public: /// Facet to use as the main package type std::string mainFacet; @@ -112,8 +112,8 @@ /// Access the tag vocabulary ept::debtags::Vocabulary& voc() { return m_vocabulary; } - /// Access the popcon data source - ept::popcon::Popcon& popcon() { return m_popcon; } + /// Check if popcon data is available + bool hasPopcon() const { return m_popcon_validx != -1; } /// Get the list of available game types const std::set<std::string>& types() Modified: software/ui/src/goplay.cpp =================================================================== --- software/ui/src/goplay.cpp 2014-09-29 01:13:27 UTC (rev 15225) +++ software/ui/src/goplay.cpp 2014-09-29 08:43:54 UTC (rev 15226) @@ -173,7 +173,7 @@ static int widths_with_popcon[] = { 100, 300, 0 }; // widths for each column static int widths_without_popcon[] = { 100, 0 }; ui.ResultsBrowser->clear(); - if (engine.popcon().hasData()) + if (engine.hasPopcon()) { char empty_string[1] = ""; ui.ResultsBrowser->column_widths(widths_with_popcon); @@ -251,7 +251,7 @@ string desc = string(fmtstr) + rec.package() + "\t" + string(fmtstr) + rec.shortDescription(); - if (engine.popcon().hasData() && i->popcon) + if (engine.hasPopcon() && i->popcon) { desc += "\t" + string(fmtstr); char stars[16]; _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

