Remove dependency on libxdg-basedir and pkg-config.

develop
tastytea 3 years ago
parent cae1d99f9a
commit e1ee5d7b37
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
  1. 10
      .drone.yml
  2. 6
      README.adoc
  3. 2
      cmake/packages.cmake
  4. 2
      cmake/remwhareadConfig.cmake.in
  5. 2
      pkg-config/remwharead.pc.in
  6. 4
      src/lib/CMakeLists.txt
  7. 28
      src/lib/sqlite.cpp

@ -24,7 +24,7 @@ steps:
- rm /etc/apt/apt.conf.d/docker-clean
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- apt-get update -q
- apt-get install -qy g++ cmake pkg-config libpoco-dev libxdg-basedir-dev asciidoc catch
- apt-get install -qy g++-7 cmake libpoco-dev asciidoc catch
- rm -rf build && mkdir -p build && cd build
- cmake -DWITH_MOZILLA=YES -DWITH_TESTS=YES ..
- make VERBOSE=1
@ -52,7 +52,7 @@ steps:
- gpg --armor --export 0x60c317803a41ba51845e371a1e9377a2ba9ef27f | apt-key add -
- apt-get update -q
- apt-get install -qy -t bionic g++-9
- apt-get install -qy cmake pkg-config libpoco-dev libxdg-basedir-dev asciidoc catch
- apt-get install -qy cmake libpoco-dev asciidoc catch
- rm -rf build && mkdir -p build && cd build
- cmake -DWITH_MOZILLA=YES ..
- make VERBOSE=1
@ -71,7 +71,7 @@ steps:
- rm /etc/apt/apt.conf.d/docker-clean
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- apt-get update -q
- apt-get install -qy clang-6.0 cmake pkg-config libpoco-dev libxdg-basedir-dev asciidoc catch
- apt-get install -qy clang-6.0 cmake libpoco-dev asciidoc catch
- rm -rf build && mkdir -p build && cd build
- cmake -DWITH_MOZILLA=YES ..
- make VERBOSE=1
@ -90,7 +90,7 @@ steps:
- rm /etc/apt/apt.conf.d/docker-clean
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- apt-get update -q
- apt-get install -qy clang cmake pkg-config libpoco-dev libxdg-basedir-dev asciidoc catch
- apt-get install -qy clang cmake libpoco-dev asciidoc catch
- rm -rf build && mkdir -p build && cd build
- cmake -DWITH_MOZILLA=YES ..
- make VERBOSE=1
@ -140,7 +140,7 @@ steps:
- rm /etc/apt/apt.conf.d/docker-clean
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- apt-get update -q
- apt-get install -qy g++ cmake pkg-config libpoco-dev libxdg-basedir-dev asciidoc catch
- apt-get install -qy g++ cmake libpoco-dev asciidoc catch
- apt-get install -qy build-essential file zip
- rm -rf build && mkdir -p build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr -DWITH_MOZILLA=YES -DMOZILLA_NMH_DIR="lib/mozilla/native-messaging-hosts" -DWITH_DEB=YES ..

@ -12,8 +12,6 @@
:uri-gcc: https://gcc.gnu.org/
:uri-clang: https://clang.llvm.org/
:uri-cmake: https://cmake.org/
:uri-pkgconfig: https://pkgconfig.freedesktop.org/wiki/
:uri-libxdg-basedir: http://repo.or.cz/w/libxdg-basedir.git
:uri-poco: https://pocoproject.org/
:uri-asciidoc: http://asciidoc.org/
:uri-catch: https://github.com/catchorg/Catch2
@ -80,8 +78,6 @@ only.
* Tested OS: Linux
* C++ compiler (tested: {uri-gcc}[gcc] 8/9, {uri-clang}[clang] 6/7)
* {uri-cmake}[cmake] (at least: 3.6)
* {uri-pkgconfig}[pkgconfig] (tested: 0.29)
* {uri-libxdg-basedir}[libxdg-basedir] (tested: 1.2)
* {uri-poco}[POCO] (tested: 1.9 / 1.7)
* Optional:
** Manpage: {uri-asciidoc}[asciidoc] (tested: 8.6)
@ -93,7 +89,7 @@ only.
====
[source,zsh]
----
apt-get install g++ cmake pkg-config libpoco-dev libxdg-basedir-dev asciidoc dpkg
apt-get install g++ cmake libpoco-dev asciidoc dpkg
----
====

@ -45,7 +45,7 @@ if (WITH_RPM)
set(CPACK_RPM_PACKAGE_LICENSE "GPL-3")
set(CPACK_RPM_PACKAGE_URL "https://schlomp.space/tastytea/${PROJECT_NAME}")
set(CPACK_RPM_PACKAGE_REQUIRES
"poco-netssl >= 1.6, poco-sqlite >= 1.6, libxdg-basedir")
"poco-netssl >= 1.6, poco-sqlite >= 1.6")
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-0.${CPACK_PACKAGE_ARCHITECTURE}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME

@ -4,7 +4,5 @@ include(GNUInstallDirs)
find_depencency(Poco
COMPONENTS Foundation Net NetSSL Data DataSQLite JSON XML
CONFIG REQUIRED)
find_dependency(PkgConfig REQUIRED)
pkg_check_modules(libxdg-basedir REQUIRED IMPORTED_TARGET libxdg-basedir)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")

@ -9,5 +9,5 @@ Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -l${name} -lPocoData -lstdc++fs
Requires.private: libxdg-basedir, icu-uc, icu-i18n
Requires.private: icu-uc, icu-i18n
Libs.private: -lPocoFoundation -lPocoNet -lPocoNetSSL -lPocoDataSQLite -lPocoJSON -lPocoXML

@ -1,7 +1,5 @@
include(GNUInstallDirs)
find_package(PkgConfig REQUIRED)
pkg_check_modules(libxdg-basedir REQUIRED IMPORTED_TARGET libxdg-basedir)
# Some distributions do not contain Poco*Config.cmake recipes.
find_package(Poco
COMPONENTS Foundation Net NetSSL Data DataSQLite JSON XML
@ -24,7 +22,7 @@ target_include_directories(${PROJECT_NAME}
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(${PROJECT_NAME}
PRIVATE PkgConfig::libxdg-basedir pthread
PRIVATE pthread
PUBLIC stdc++fs)
# If no Poco*Config.cmake recipes are found, look for headers in standard dirs.

@ -18,8 +18,13 @@
#include "time.hpp"
#include <Poco/Data/SQLite/Connector.h>
#include <Poco/Data/Session.h>
#include <Poco/Version.h>
#if POCO_VERSION >= 0x01090000 // Path::dataHome() is only in 1.9 and above.
#include <Poco/Path.h>
#else
#include <Poco/Environment.h>
#endif
#include <algorithm>
#include <basedir.h>
#include <exception>
#include <iostream>
@ -29,16 +34,29 @@ using std::cerr;
using std::endl;
using namespace Poco::Data::Keywords;
using Poco::Data::Statement;
#if POCO_VERSION < 0x01090000
using Poco::Environment;
#endif
Database::Database()
: _connected(false)
{
try
{
xdgHandle xdg;
xdgInitHandle(&xdg);
_dbpath = xdgDataHome(&xdg) / fs::path("remwharead");
xdgWipeHandle(&xdg);
#if POCO_VERSION >= 0x01090000
_dbpath = Poco::Path::dataHome() / fs::path("remwharead");
#else
if (Environment::has("XDG_DATA_HOME"))
{
_dbpath = Environment::get("XDG_DATA_HOME")
/ fs::path("remwharead");
}
else if (Environment::has("HOME"))
{
_dbpath = Environment::get("HOME")
/ fs::path(".local/share/remwharead");
} // Else use current directory.
#endif
if (!fs::exists(_dbpath))
{

Loading…
Cancel
Save