From 143471b811f580949f15b63e33750c3c6f33ab2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Wed, 9 Jul 2025 13:51:40 +0200 Subject: [PATCH] Revive "quick filter" by using apt-xapian-index directly without ept Users report the removal of the libept dependency caused loss of the "quick filter" bar which, reportedly, has better usability than Edit>Search feature for some users due to better relevancy of results. (Eg. try "apt" Search will return aapt as the first result whereas quick filter will return "apt" as first result as expected) It seems libept was hastily removed from Debian because of overall deprecation of debbugs, however here in synaptic none of the debbugs parts of libept were really used only the transitive dependency on libxapian-dev and two trivial API functions for xapian database handling where relevant. This commit refactors the code to depend on libxapian-dev directly and pulls in the trivial code to find the apt-xapain-index database file. See commit 21790e0263 ("Build without libept") Closes: #1103351 --- common/rpackagelister.cc | 28 +++++++++++++++++++--------- common/rpackagelister.h | 9 +++++---- common/rpackageview.h | 4 ++-- config.h.in | 6 +++--- configure.ac | 18 ++++++++++-------- debian/control | 2 +- gtk/Makefile.am | 4 ++-- gtk/rgmainwindow.cc | 6 +++--- tests/Makefile.am | 4 ++-- 9 files changed, 47 insertions(+), 34 deletions(-) diff --git a/common/rpackagelister.cc b/common/rpackagelister.cc index 9fdfb1a00..313ef2471 100644 --- a/common/rpackagelister.cc +++ b/common/rpackagelister.cc @@ -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 { @@ -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 @@ -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; @@ -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; } @@ -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; }; @@ -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); } @@ -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 { diff --git a/common/rpackagelister.h b/common/rpackagelister.h index 1f1dd1d63..ab3fc923b 100644 --- a/common/rpackagelister.h +++ b/common/rpackagelister.h @@ -37,8 +37,8 @@ #include #include -#ifdef WITH_EPT -#include +#ifdef HAVE_XAPIAN +#include #endif #include "rpackagecache.h" @@ -107,7 +107,7 @@ class RPackageLister { pkgRecords *_records; OpProgress *_progMeter; -#ifdef WITH_EPT +#ifdef HAVE_XAPIAN Xapian::Database *_xapianDatabase; #endif @@ -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 diff --git a/common/rpackageview.h b/common/rpackageview.h index 343f4ee49..d3a72ffe8 100644 --- a/common/rpackageview.h +++ b/common/rpackageview.h @@ -29,8 +29,8 @@ #include #include -#ifdef WITH_EPT -#include +#ifdef HAVE_XAPIAN +#include #endif #include "rpackage.h" diff --git a/config.h.in b/config.h.in index a7c05526e..be3c870da 100644 --- a/config.h.in +++ b/config.h.in @@ -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 @@ -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 diff --git a/configure.ac b/configure.ac index 3c8174e8a..a36a942e0 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/debian/control b/debian/control index fcc83c11c..4304b4373 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: synaptic Section: admin Priority: optional Maintainer: Michael Vogt -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 diff --git a/gtk/Makefile.am b/gtk/Makefile.am index d2b22d591..70f2cacfa 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -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\ diff --git a/gtk/rgmainwindow.cc b/gtk/rgmainwindow.cc index f23db586f..dc35dc4d7 100644 --- a/gtk/rgmainwindow.cc +++ b/gtk/rgmainwindow.cc @@ -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; @@ -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, @@ -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( diff --git a/tests/Makefile.am b/tests/Makefile.am index 4888444f8..bafd929e9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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