Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions common/rpackagelister.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@

#include "i18n.h"

const std::string APT_XAPIAN_INDEX_DIR = "/var/lib/apt-xapian-index";

using namespace std;

RPackageLister::RPackageLister()
: _records(0), _progMeter(new OpProgress)
#ifdef WITH_EPT
#ifdef HAVE_XAPIAN
, _xapianDatabase(0)
#endif
{
Expand All @@ -103,7 +105,7 @@ RPackageLister::RPackageLister()
_views.push_back(_searchView);
// its import that we use "_packages" here instead of _nativeArchPackages
_views.push_back(new RPackageViewArchitecture(_packages));
#ifdef WITH_EPT
#ifdef HAVE_XAPIAN
openXapianIndex();
#endif

Expand Down Expand Up @@ -435,7 +437,15 @@ bool RPackageLister::openCache()
return true;
}

#ifdef WITH_EPT
#ifdef HAVE_XAPIAN
time_t RPackageLister::xapianIndexTimestamp()
{
std::string db = APT_XAPIAN_INDEX_DIR + "/update-timestamp";
struct stat st;
int rv = stat(db.c_str(), &st);
return rv ? 0 : st.st_mtime;
}

bool RPackageLister::xapianIndexNeedsUpdate()
{
struct stat buf;
Expand All @@ -454,10 +464,10 @@ bool RPackageLister::xapianIndexNeedsUpdate()
// compare timestamps, rebuild everytime, its now cheap(er)
// because we use u-a-x-i --update
stat(_config->FindFile("Dir::Cache::pkgcache").c_str(), &buf);
if(ept::axi::timestamp() < buf.st_mtime) {
if(xapianIndexTimestamp() < buf.st_mtime) {
if(_config->FindB("Debug::Synaptic::Xapian",false))
std::cerr << "xapian outdated "
<< buf.st_mtime - ept::axi::timestamp() << std::endl;
<< buf.st_mtime - xapianIndexTimestamp() << std::endl;
return true;
}

Expand All @@ -469,7 +479,7 @@ bool RPackageLister::openXapianIndex()
if(_xapianDatabase)
delete _xapianDatabase;
try {
_xapianDatabase = new Xapian::Database(ept::axi::path_db());
_xapianDatabase = new Xapian::Database(APT_XAPIAN_INDEX_DIR + "/index");
} catch (Xapian::DatabaseOpeningError) {
return false;
};
Expand Down Expand Up @@ -1974,11 +1984,11 @@ bool RPackageLister::addArchiveToCache(string archive, string &pkgname)
}


#ifdef WITH_EPT
#ifdef HAVE_XAPIAN
bool RPackageLister::limitBySearch(string searchString)
{
//cerr << "limitBySearch(): " << searchString << endl;
if (ept::axi::timestamp() == 0)
if (xapianIndexTimestamp() == 0)
return false;
return xapianSearch(searchString);
}
Expand All @@ -1989,7 +1999,7 @@ bool RPackageLister::xapianSearch(string unsplitSearchString)
static const int defaultQualityCutoff = 15;
int qualityCutoff = _config->FindI("Synaptic::Xapian::qualityCutoff",
defaultQualityCutoff);
if (ept::axi::timestamp() == 0)
if (xapianIndexTimestamp() == 0)
return false;

try {
Expand Down
9 changes: 5 additions & 4 deletions common/rpackagelister.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#include <apt-pkg/acquire.h>
#include <apt-pkg/progress.h>

#ifdef WITH_EPT
#include <ept/axi/axi.h>
#ifdef HAVE_XAPIAN
#include <xapian.h>
#endif

#include "rpackagecache.h"
Expand Down Expand Up @@ -107,7 +107,7 @@ class RPackageLister {
pkgRecords *_records;
OpProgress *_progMeter;

#ifdef WITH_EPT
#ifdef HAVE_XAPIAN
Xapian::Database *_xapianDatabase;
#endif

Expand Down Expand Up @@ -348,8 +348,9 @@ class RPackageLister {
bool writeSelections(ostream &out, bool fullState);

RPackageCache* getCache() { return _cache; }
#ifdef WITH_EPT
#ifdef HAVE_XAPIAN
Xapian::Database* xapiandatabase() { return _xapianDatabase; }
time_t xapianIndexTimestamp();
bool xapianIndexNeedsUpdate();
bool openXapianIndex();
#endif
Expand Down
4 changes: 2 additions & 2 deletions common/rpackageview.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#include <string>
#include <map>

#ifdef WITH_EPT
#include <ept/axi/axi.h>
#ifdef HAVE_XAPIAN
#include <xapian.h>
#endif

#include "rpackage.h"
Expand Down
6 changes: 3 additions & 3 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
/* build with VTE as output terminal */
#undef HAVE_VTE

/* xapian based package search feature */
#undef HAVE_XAPIAN

/* Name of package */
#undef PACKAGE

Expand Down Expand Up @@ -129,9 +132,6 @@
/* build with dpkg progress bar */
#undef WITH_DPKG_STATUSFD

/* build with libept */
#undef WITH_EPT

/* build with launchpad-integration */
#undef WITH_LAUNCHPAD_INTEGRATION

Expand Down
18 changes: 10 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,16 @@ AC_CHECK_HEADER(apt-pkg/cdrom.h,
AC_DEFINE(HAVE_APTPKG_CDROM, 1,
[whether apt-pkg/cdrom.h is present]) )

# check and use libept if available
PKG_CHECK_MODULES([LIBEPT], [libept >= 1.0],
[AC_DEFINE(WITH_EPT, 1, [build with libept])
AC_SUBST(LIBEPT_CFLAGS)
AC_SUBST(LIBEPT_LIBS)
],
[AC_MSG_NOTICE([no libept found, building without])
])
# xapian based package search feature
AC_CHECK_PROG(HAVE_XAPIAN,xapian-config,yes,no)
AS_IF([test "x$HAVE_XAPIAN" = "xyes"],[
XAPIAN_CXXFLAGS="$(xapian-config --cxxflags)"
XAPIAN_LIBS="$(xapian-config --libs)"
AC_DEFINE(HAVE_XAPIAN, 1, [xapian based package search feature])
])

AC_SUBST(XAPIAN_CXXFLAGS)
AC_SUBST(XAPIAN_LIBS)

AC_LANG([C])

Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: synaptic
Section: admin
Priority: optional
Maintainer: Michael Vogt <mvo@debian.org>
Build-Depends: debhelper-compat (= 12), libapt-pkg-dev, gettext, libgtk-3-dev, libvte-2.91-dev, intltool, xmlto, libsm-dev , sharutils, lsb-release
Build-Depends: debhelper-compat (= 12), libapt-pkg-dev, gettext, libgtk-3-dev, libvte-2.91-dev, intltool, xmlto, libsm-dev , sharutils, lsb-release, libxapian-dev
Build-Conflicts: librpm-dev
Standards-Version: 4.5.0
Vcs-Git: https://github.com/mvo5/synaptic.git
Expand Down
4 changes: 2 additions & 2 deletions gtk/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ synaptic_LDADD = \
-lapt-pkg -lX11 @RPM_LIBS@ @DEB_LIBS@ \
@GTK_LIBS@ \
@VTE_LIBS@ @LP_LIBS@\
@XAPIAN_LIBS@ \
-lutil \
-lpthread \
$(LIBEPT_LIBS)
-lpthread

synaptic_SOURCES= \
gsynaptic.cc\
Expand Down
6 changes: 3 additions & 3 deletions gtk/rgmainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ RGMainWindow::RGMainWindow(RPackageLister *packLister, string name)
RGPreferencesWindow::applyProxySettings();
}

#ifdef WITH_EPT
#ifdef HAVE_XAPIAN
gboolean RGMainWindow::xapianDoIndexUpdate(void *data)
{
RGMainWindow *me = (RGMainWindow *) data;
Expand Down Expand Up @@ -910,7 +910,7 @@ void RGMainWindow::xapianIndexUpdateFinished(GPid pid, gint status, void* data)
if(_config->FindB("Debug::Synaptic::Xapian",false))
std::cerr << "xapianIndexUpdateFinished: "
<< WEXITSTATUS(status) << std::endl;
#ifdef WITH_EPT
#ifdef HAVE_XAPIAN
me->_lister->openXapianIndex();
#endif
gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(me->_builder,
Expand Down Expand Up @@ -1566,7 +1566,7 @@ void RGMainWindow::buildInterface()
(_builder, "entry_fast_search"));

// only enable fast search if its usable
#ifdef WITH_EPT
#ifdef HAVE_XAPIAN
if(!_lister->xapiandatabase() ||
!FileExists("/usr/sbin/update-apt-xapian-index")) {
gtk_widget_hide(GTK_WIDGET(
Expand Down
4 changes: 2 additions & 2 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ noinst_PROGRAMS = test_rpackage test_rpackageview test_gtkpkglist test_rpackagef
LDADD = \
${top_builddir}/common/libsynaptic.a\
-lapt-pkg -lX11 @RPM_LIBS@ @DEB_LIBS@ \
@GTK_LIBS@ @VTE_LIBS@ @LP_LIBS@\
-lpthread $(LIBEPT_LIBS)
@GTK_LIBS@ @VTE_LIBS@ @LP_LIBS@ @XAPIAN_LIBS@ \
-lpthread

test_rpackage_SOURCES= test_rpackage.cc

Expand Down