I gave rebasing Mihai's patch a shot. Seems to build, no word on
functionality yet.
>From 051ded3a7694db6fa882fc48c8e0fe8b4d1cadc3 Mon Sep 17 00:00:00 2001
From: Jo Shields <joshi...@microsoft.com>
Date: Tue, 5 Feb 2019 11:55:48 -0500
Subject: [PATCH] Rebase changes for DNF support (Closes: #889509)
---
debian/control | 1 +
debian/libsolv0-dev.install | 2 +-
debian/libsolv0.symbols | 2 +
debian/libsolvext0.symbols | 2 +
.../patches/1004_cmake-module-path-fix.patch | 22 --
...005_install-cmake-module-into-libdir.patch | 16 +
...s-types.patch => 1006_various-typos.patch} | 76 +++--
...pool.h_c_debian-style-home-dir-rpmdb.patch | 317 ++++++++++++++++++
...v.ver_add-new-pool-homedir-functions.patch | 16 +
...olv.i_add-new-pool-homedir-functions.patch | 20 ++
...-misc_add-new-pool-homedir-functions.patch | 123 +++++++
debian/patches/series | 8 +-
debian/rules | 3 +-
13 files changed, 553 insertions(+), 55 deletions(-)
delete mode 100644 debian/patches/1004_cmake-module-path-fix.patch
create mode 100644 debian/patches/1005_install-cmake-module-into-libdir.patch
rename debian/patches/{1006_various-types.patch => 1006_various-typos.patch} (69%)
create mode 100644 debian/patches/3000_ext-repo_rpmdb.c_src_pool.h_c_debian-style-home-dir-rpmdb.patch
create mode 100644 debian/patches/3010_src-libsolv.ver_add-new-pool-homedir-functions.patch
create mode 100644 debian/patches/3020_bindings-solv.i_add-new-pool-homedir-functions.patch
create mode 100644 debian/patches/3030_doc-misc_add-new-pool-homedir-functions.patch
diff --git a/debian/control b/debian/control
index 95b896e..500a697 100644
--- a/debian/control
+++ b/debian/control
@@ -7,6 +7,7 @@ Build-Depends:
dh-python,
dpkg-dev (>= 1.16.1.1),
cdbs,
+ dh-python,
cmake,
libexpat1-dev,
zlib1g-dev,
diff --git a/debian/libsolv0-dev.install b/debian/libsolv0-dev.install
index 8b2eae2..4857af5 100644
--- a/debian/libsolv0-dev.install
+++ b/debian/libsolv0-dev.install
@@ -26,5 +26,5 @@ usr/include/*/solv/testcase.h
usr/include/*/solv/transaction.h
usr/include/*/solv/util.h
usr/lib/*/libsolv.so
-usr/lib/*/cmake/
+usr/lib/*/cmake/libsolv/FindLibSolv.cmake
usr/lib/*/pkgconfig/libsolv.pc
diff --git a/debian/libsolv0.symbols b/debian/libsolv0.symbols
index ea41865..7f4ec5a 100644
--- a/debian/libsolv0.symbols
+++ b/debian/libsolv0.symbols
@@ -75,6 +75,7 @@ libsolv.so.0 libsolv0 #MINVER#
pool_freewhatprovides@SOLV_1.0 0.6.5
pool_get_flag@SOLV_1.0 0.6.5
pool_get_rootdir@SOLV_1.0 0.6.5
+ pool_get_use_homedir@SOLV_1.1 0.6.30-2~
pool_id2evr@SOLV_1.0 0.6.5
pool_id2langid@SOLV_1.0 0.6.5
pool_id2rel@SOLV_1.0 0.6.5
@@ -105,6 +106,7 @@ libsolv.so.0 libsolv0 #MINVER#
pool_set_installed@SOLV_1.0 0.6.5
pool_set_languages@SOLV_1.0 0.6.5
pool_set_rootdir@SOLV_1.0 0.6.5
+ pool_set_use_homedir@SOLV_1.1 0.6.30-2~
pool_set_whatprovides@SOLV_1.2 0.6.34
pool_setarch@SOLV_1.0 0.6.5
pool_setarchpolicy@SOLV_1.0 0.6.5
diff --git a/debian/libsolvext0.symbols b/debian/libsolvext0.symbols
index 08cdf28..4c36aad 100644
--- a/debian/libsolvext0.symbols
+++ b/debian/libsolvext0.symbols
@@ -1,12 +1,14 @@
libsolvext.so.0 libsolvext0 #MINVER#
SOLV_1.0@SOLV_1.0 0.6.5
pool_findfileconflicts@SOLV_1.0 0.6.5
+ pool_parserpmrichdep@SOLV_1.0 0.6.30
pool_deb_get_autoinstalled@SOLV_1.0 0.6.10
repo_add_arch_local@SOLV_1.0 0.6.5
repo_add_arch_pkg@SOLV_1.0 0.6.5
repo_add_arch_repo@SOLV_1.0 0.6.5
#MISSING: 0.6.24-1# repo_add_autopattern@SOLV_1.0 0.6.5
repo_add_code11_products@SOLV_1.0 0.6.5
+ repo_add_comps@SOLV_1.0 0.6.30-2~
repo_add_content@SOLV_1.0 0.6.5
repo_add_cudf@SOLV_1.0 0.6.5
repo_add_deb@SOLV_1.0 0.6.5
diff --git a/debian/patches/1004_cmake-module-path-fix.patch b/debian/patches/1004_cmake-module-path-fix.patch
deleted file mode 100644
index 6e3f999..0000000
--- a/debian/patches/1004_cmake-module-path-fix.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Description: Rename FindLibSolv.cmake to LibSolvConfig.cmake after installation.
-Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
-
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -1,6 +1,6 @@
- PROJECT (libsolv)
-
--CMAKE_MINIMUM_REQUIRED (VERSION 2.4)
-+CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
-
- OPTION (ENABLE_STATIC "Build a static version of the libraries?" OFF)
- OPTION (DISABLE_SHARED "Do not build a shared version of the libraries?" OFF)
-@@ -73,7 +73,7 @@
-
- # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
- SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
--INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
-+INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake RENAME LibSolvConfig.cmake DESTINATION ${LIB_INSTALL_DIR}/cmake/LibSolv/ )
-
- INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
-
diff --git a/debian/patches/1005_install-cmake-module-into-libdir.patch b/debian/patches/1005_install-cmake-module-into-libdir.patch
new file mode 100644
index 0000000..2c8e64f
--- /dev/null
+++ b/debian/patches/1005_install-cmake-module-into-libdir.patch
@@ -0,0 +1,16 @@
+Description: Install FindLibSolv.cmake into ${libdir}/cmake/libsolv/.
+Author: Mihai Moldovan <io...@ionic.de>
+
+Index: libsolv/CMakeLists.txt
+===================================================================
+--- libsolv.orig/CMakeLists.txt
++++ libsolv/CMakeLists.txt
+@@ -73,7 +73,7 @@ ENDIF (NOT PKGCONFIG_INSTALL_DIR)
+
+ # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
+ SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
+-INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
++INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${LIB_INSTALL_DIR}/cmake/libsolv/ )
+
+ INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
+
diff --git a/debian/patches/1006_various-types.patch b/debian/patches/1006_various-typos.patch
similarity index 69%
rename from debian/patches/1006_various-types.patch
rename to debian/patches/1006_various-typos.patch
index bdf6dd0..297e5ee 100644
--- a/debian/patches/1006_various-types.patch
+++ b/debian/patches/1006_various-typos.patch
@@ -1,9 +1,11 @@
Description: Various typo and grammar fixes
Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
---- a/README
-+++ b/README
-@@ -10,7 +10,7 @@
+Index: libsolv/README
+===================================================================
+--- libsolv.orig/README
++++ libsolv/README
+@@ -10,7 +10,7 @@ This code is based on two major, but ind
resolving package dependencies.
The sat-solver code has been written to aim for the newest packages,
@@ -12,9 +14,11 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
provide the user with suggestions on how to deal with unsolvable
problems. It also takes advantage of the repository storage to
minimize memory usage.
---- a/doc/gen/libsolv-bindings.3
-+++ b/doc/gen/libsolv-bindings.3
-@@ -1988,7 +1988,7 @@
+Index: libsolv/doc/gen/libsolv-bindings.3
+===================================================================
+--- libsolv.orig/doc/gen/libsolv-bindings.3
++++ libsolv/doc/gen/libsolv-bindings.3
+@@ -1988,7 +1988,7 @@ Add the metadata of a single rpm package
.RE
.\}
.sp
@@ -23,7 +27,7 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
.sp
.if n \{\
.RS 4
-@@ -3423,7 +3423,7 @@
+@@ -3423,7 +3423,7 @@ Update the matching installed packages t
.PP
\fBSOLVER_WEAKENDEPS\fR
.RS 4
@@ -32,9 +36,11 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
.RE
.PP
\fBSOLVER_MULTIVERSION\fR
---- a/doc/libsolv-bindings.txt
-+++ b/doc/libsolv-bindings.txt
-@@ -1125,7 +1125,7 @@
+Index: libsolv/doc/libsolv-bindings.txt
+===================================================================
+--- libsolv.orig/doc/libsolv-bindings.txt
++++ libsolv/doc/libsolv-bindings.txt
+@@ -1125,7 +1125,7 @@ Add the metadata of a single rpm package
repo.add_rpmdb_pubkeys()
Add all pubkeys contained in the rpm database to the repository. Note that
@@ -43,7 +49,7 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
of the rpm database.
Solvable add_pubkey(const char *keyfile, int flags = 0)
-@@ -1945,7 +1945,7 @@
+@@ -1945,7 +1945,7 @@ packages to the specified versions. See
updates about more information.
*SOLVER_WEAKENDEPS*::
@@ -52,9 +58,11 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
*SOLVER_MULTIVERSION*::
Mark the matched packages for multiversion install. If they get to be
---- a/doc/libsolv-pool.txt
-+++ b/doc/libsolv-pool.txt
-@@ -850,7 +850,7 @@
+Index: libsolv/doc/libsolv-pool.txt
+===================================================================
+--- libsolv.orig/doc/libsolv-pool.txt
++++ libsolv/doc/libsolv-pool.txt
+@@ -850,7 +850,7 @@ SOLVER_FLAG_ALLOW_VENDORCHANGE flag.
Boolean Dependencies
--------------------
@@ -63,9 +71,11 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
dependencies. Note that depending on the package manager only a subset
of those may be useful. For example, debian currently only allows
an "OR" expression.
---- a/doc/gen/testsolv.1
-+++ b/doc/gen/testsolv.1
-@@ -45,7 +45,7 @@
+Index: libsolv/doc/gen/testsolv.1
+===================================================================
+--- libsolv.orig/doc/gen/testsolv.1
++++ libsolv/doc/gen/testsolv.1
+@@ -45,7 +45,7 @@ Increase the debug level of the solver\&
.RS 4
Write the output in testcase format instead of human readable text\&. The output can then be used in the result section of the test case\&. If the
\fB\-r\fR
@@ -74,9 +84,11 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
.RE
.PP
\fB\-l\fR \fIPKGSPEC\fR
---- a/doc/testsolv.txt
-+++ b/doc/testsolv.txt
-@@ -26,7 +26,7 @@
+Index: libsolv/doc/testsolv.txt
+===================================================================
+--- libsolv.orig/doc/testsolv.txt
++++ libsolv/doc/testsolv.txt
+@@ -26,7 +26,7 @@ multiple times to further increase the a
*-r*::
Write the output in testcase format instead of human readable text.
The output can then be used in the result section of the test case.
@@ -85,9 +97,11 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
verbatim inclusion.
*-l* 'PKGSPEC'::
---- a/src/rules.c
-+++ b/src/rules.c
-@@ -1583,7 +1583,7 @@
+Index: libsolv/src/rules.c
+===================================================================
+--- libsolv.orig/src/rules.c
++++ libsolv/src/rules.c
+@@ -1583,7 +1583,7 @@ solver_addinfarchrules(Solver *solv, Map
if (allowedarchs.count && pool->implicitobsoleteusescolors && installed && bestscore)
{
@@ -96,9 +110,11 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
* if the corresponding installed package is not lock-stepped */
queue_empty(&allowedarchs);
FOR_PROVIDES(p, pp, s->name)
---- a/src/solver.h
-+++ b/src/solver.h
-@@ -145,10 +145,10 @@
+Index: libsolv/src/solver.h
+===================================================================
+--- libsolv.orig/src/solver.h
++++ libsolv/src/solver.h
+@@ -145,10 +145,10 @@ struct _Solver {
* Solver configuration
*-------------------------------------------------------------------------------------------------------------*/
@@ -113,9 +129,11 @@ Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
int allowuninstall; /* allow removal of installed solvables */
int noupdateprovide; /* true: update packages needs not to provide old package */
int needupdateprovide; /* true: update packages must provide old package */
---- a/doc/gen/libsolv-pool.3
-+++ b/doc/gen/libsolv-pool.3
-@@ -1290,7 +1290,7 @@
+Index: libsolv/doc/gen/libsolv-pool.3
+===================================================================
+--- libsolv.orig/doc/gen/libsolv-pool.3
++++ libsolv/doc/gen/libsolv-pool.3
+@@ -1290,7 +1290,7 @@ There can be multiple equivalence classe
You can turn off the architecture replacement checks with the Solver\(cqs SOLVER_FLAG_ALLOW_VENDORCHANGE flag\&.
.SH "BOOLEAN DEPENDENCIES"
.sp
diff --git a/debian/patches/3000_ext-repo_rpmdb.c_src_pool.h_c_debian-style-home-dir-rpmdb.patch b/debian/patches/3000_ext-repo_rpmdb.c_src_pool.h_c_debian-style-home-dir-rpmdb.patch
new file mode 100644
index 0000000..3c829c1
--- /dev/null
+++ b/debian/patches/3000_ext-repo_rpmdb.c_src_pool.h_c_debian-style-home-dir-rpmdb.patch
@@ -0,0 +1,317 @@
+Description: Support rpmdb in home directory.
+Author: Mihai Moldovan <io...@ionic.de>
+
+rpm on Debian is patched to not use the default system-wide rpm database.
+Instead, the dbpath is hardcoded to ~/.rpmdb.
+
+Since libsolv does not use librpm in all cases in order to open rpm database
+files, implement an override in RPMDB handling for databases in home
+directories.
+
+This patch is mostly only useful on Debian, but shouldn't break other distros
+and can thus be upstreamed.
+
+One difference from the Debian rpm behavior exists: if there is no rpmdb in the
+user's home directory, libsolv will fall back to the system-wide rpm database.
+
+To use this new functionality, call pool_set_use_homedir(pool, 1) in your
+applications for each pool that uses RPM and the RPMDB functionality of
+libsolv.
+
+Index: libsolv/ext/repo_rpmdb.c
+===================================================================
+--- libsolv.orig/ext/repo_rpmdb.c
++++ libsolv/ext/repo_rpmdb.c
+@@ -23,6 +23,7 @@
+ #include <assert.h>
+ #include <stdint.h>
+ #include <errno.h>
++#include <pwd.h>
+
+ #ifdef ENABLE_RPMDB
+
+@@ -1216,6 +1217,55 @@ getu32(const unsigned char *dp)
+ return dp[0] << 24 | dp[1] << 16 | dp[2] << 8 | dp[3];
+ }
+
++static char *
++get_homedir(void)
++{
++ char *home_dir = NULL;
++
++ const char *home_env = getenv("HOME");
++
++ if (home_env)
++ {
++ home_dir = solv_strdup(home_env);
++ }
++ else
++ {
++ /* HOME unset, try password database. */
++ struct passwd pwd = { 0 };
++ struct passwd *pwd_res = NULL;
++ char *buf = NULL;
++ long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
++
++ if (-1 == buf_size)
++ {
++ buf_size = 32768;
++ }
++
++ buf = solv_calloc(1, buf_size);
++
++ if (buf)
++ {
++ int ret = getpwuid_r(getuid(), &pwd, buf, buf_size, &pwd_res);
++
++ /*
++ * No pwd_res can either mean that the user ID is unknown
++ * to the system or some other type of error occurred.
++ * Whatever the case, we do not distinguish here, but just
++ * treat it as a common failure.
++ */
++ if ((pwd_res) && (pwd.pw_dir))
++ {
++ home_dir = solv_strdup(pwd.pw_dir);
++ }
++
++ solv_free(buf);
++ buf = NULL;
++ }
++ }
++
++ return home_dir;
++}
++
+ #ifdef ENABLE_RPMDB
+
+ struct rpmdbentry {
+@@ -1245,7 +1295,6 @@ struct rpmdbstate {
+
+ #endif
+
+-
+ #ifndef ENABLE_RPMPKG_LIBRPM
+
+ static int
+@@ -1347,6 +1396,8 @@ rpm_state_create(Pool *pool, const char
+ state->pool = pool;
+ if (rootdir)
+ state->rootdir = solv_strdup(rootdir);
++ state->use_homedir = pool_get_use_homedir(pool);
++ state->open_home_rpmdb = 0;
+ return state;
+ }
+
+@@ -1617,6 +1668,9 @@ repo_add_rpmdb(Repo *repo, Repo *ref, in
+ if (flags & REPO_USE_ROOTDIR)
+ state.rootdir = solv_strdup(pool_get_rootdir(pool));
+
++ state.use_homedir = pool_get_use_homedir(pool);
++ state.open_home_rpmdb = 0;
++
+ data = repo_add_repodata(repo, flags);
+
+ if (ref && !(ref->nsolvables && ref->rpmdbid && ref->pool == repo->pool))
+Index: libsolv/src/pool.c
+===================================================================
+--- libsolv.orig/src/pool.c
++++ libsolv/src/pool.c
+@@ -91,6 +91,8 @@ pool_create(void)
+ pool->obsoleteusesprovides = 1;
+ pool->implicitobsoleteusesprovides = 1;
+ pool->havedistepoch = 1;
++
++ pool->use_homedir = 0;
+ #endif
+ return pool;
+ }
+@@ -2007,6 +2009,18 @@ pool_get_rootdir(Pool *pool)
+ return pool->rootdir;
+ }
+
++void
++pool_set_use_homedir(Pool *pool, int use_homedir)
++{
++ pool->use_homedir = use_homedir;
++}
++
++int
++pool_get_use_homedir(Pool *pool)
++{
++ return pool->use_homedir;
++}
++
+ /* only used in libzypp */
+ void
+ pool_set_custom_vendorcheck(Pool *pool, int (*vendorcheck)(Pool *, Solvable *, Solvable *))
+Index: libsolv/src/pool.h
+===================================================================
+--- libsolv.orig/src/pool.h
++++ libsolv/src/pool.h
+@@ -166,6 +166,7 @@ struct _Pool {
+ Id *whatprovidesauxdata;
+ Offset whatprovidesauxdataoff;
+
++ int use_homedir; /* force usage of private rpmdb in home dir */
+ #endif
+ };
+
+@@ -271,6 +272,9 @@ extern const char *pool_get_rootdir(Pool
+ extern char *pool_prepend_rootdir(Pool *pool, const char *dir);
+ extern const char *pool_prepend_rootdir_tmp(Pool *pool, const char *dir);
+
++extern void pool_set_use_homedir(Pool *pool, int use_homedir);
++extern int pool_get_use_homedir(Pool *pool);
++
+ /**
+ * Solvable management
+ */
+Index: libsolv/ext/repo_rpmdb_bdb.h
+===================================================================
+--- libsolv.orig/ext/repo_rpmdb_bdb.h
++++ libsolv/ext/repo_rpmdb_bdb.h
+@@ -42,6 +42,8 @@ struct rpmdbstate {
+ int dbenvopened; /* database environment opened */
+ int pkgdbopened; /* package database openend */
+ int is_ostree; /* read-only db that lives in /usr/share/rpm */
++ int use_homedir; /* force usage of private rpmdb in home dir */
++ int open_home_rpmdb; /* internal; tracks rpmdb in homedir usage */
+
+ DB_ENV *dbenv; /* database environment */
+ DB *db; /* packages database */
+@@ -53,8 +55,43 @@ struct rpmdbstate {
+ static int
+ stat_database(struct rpmdbstate *state, char *dbname, struct stat *statbuf, int seterror)
+ {
+- char *dbpath;
+- dbpath = solv_dupjoin(state->rootdir, state->is_ostree ? "/usr/share/rpm/" : "/var/lib/rpm/", dbname);
++ char *dbpath = NULL;
++
++ if (state->open_home_rpmdb)
++ {
++ char *home_dir = get_homedir();
++
++ if (home_dir)
++ {
++ char *tmp_path = NULL;
++
++ tmp_path = solv_dupjoin(state->rootdir, "/", home_dir);
++
++ solv_free(home_dir);
++ home_dir = NULL;
++
++ dbpath = solv_dupjoin(tmp_path, "/.rpmdb/", 0);
++
++ solv_free(tmp_path);
++ tmp_path = NULL;
++ }
++ else
++ {
++ if (seterror)
++ pool_error(state->pool, -1, "internal state error: rpmdb in home directory opened, but unable to get home directory path.");
++ return -1;
++ }
++ }
++ else
++ {
++ /*
++ * Assume that if open_home_rpmdb is set, the rpmdb is known to exist.
++ * Do not fall back to the system directory in this case, but only
++ * if the system directory has been explicitly opened beforehand.
++ */
++ dbpath = solv_dupjoin(state->rootdir, state->is_ostree ? "/usr/share/rpm/" : "/var/lib/rpm/", dbname);
++ }
++
+ if (stat(dbpath, statbuf))
+ {
+ if (seterror)
+@@ -105,12 +142,31 @@ rpmdbid2db(unsigned char *db, Id id, int
+ static int
+ serialize_dbenv_ops(struct rpmdbstate *state)
+ {
+- char *lpath;
++ char *lpath = NULL;
+ mode_t oldmask;
+ int fd;
+ struct flock fl;
+
+- lpath = solv_dupjoin(state->rootdir, "/var/lib/rpm/.dbenv.lock", 0);
++ if (state->open_home_rpmdb)
++ {
++ char *home_dir = get_homedir();
++
++ if (home_dir)
++ {
++ lpath = solv_dupjoin(home_env, "/.rpmdb/.dbenv.lock", 0);
++
++ solv_free(home_dir);
++ home_dir = NULL;
++ }
++ else
++ {
++ return -1;
++ }
++ }
++ else
++ {
++ lpath = solv_dupjoin(state->rootdir, "/var/lib/rpm/.dbenv.lock", 0);
++ }
+ oldmask = umask(022);
+ fd = open(lpath, (O_RDWR|O_CREAT), 0644);
+ free(lpath);
+@@ -138,7 +194,7 @@ static int
+ opendbenv(struct rpmdbstate *state)
+ {
+ const char *rootdir = state->rootdir;
+- char *dbpath;
++ char *dbpath = NULL;
+ DB_ENV *dbenv = 0;
+ int r;
+
+@@ -147,7 +203,44 @@ opendbenv(struct rpmdbstate *state)
+ #if (defined(FEDORA) || defined(MAGEIA)) && (DB_VERSION_MAJOR >= 5 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 5))
+ dbenv->set_thread_count(dbenv, 8);
+ #endif
+- dbpath = solv_dupjoin(rootdir, "/var/lib/rpm", 0);
++ if (state->use_homedir)
++ {
++ char *home_dir = get_homedir();
++
++ if (home_dir)
++ {
++ char *tmp_path = NULL;
++
++ tmp_path = solv_dupjoin(rootdir, "/", home_dir);
++
++ solv_free(home_dir);
++ home_dir = NULL;
++
++ dbpath = solv_dupjoin(tmp_path, "/.rpmdb", 0);
++
++ solv_free(tmp_path);
++ tmp_path = NULL;
++ }
++ }
++
++ if (dbpath)
++ {
++ if (-1 == access(dbpath, W_OK))
++ {
++ free(dbpath);
++ dbpath = NULL;
++ }
++ else
++ {
++ state->open_home_rpmdb = 1;
++ }
++ }
++
++ if (!dbpath)
++ {
++ dbpath = solv_dupjoin(rootdir, "/var/lib/rpm", 0);
++ }
++
+ if (access(dbpath, W_OK) == -1)
+ {
+ free(dbpath);
diff --git a/debian/patches/3010_src-libsolv.ver_add-new-pool-homedir-functions.patch b/debian/patches/3010_src-libsolv.ver_add-new-pool-homedir-functions.patch
new file mode 100644
index 0000000..f9accf8
--- /dev/null
+++ b/debian/patches/3010_src-libsolv.ver_add-new-pool-homedir-functions.patch
@@ -0,0 +1,16 @@
+Description: Support rpmdb in home directory. Add public symbols.
+Author: Mihai Moldovan <io...@ionic.de>
+
+Index: libsolv/src/libsolv.ver
+===================================================================
+--- libsolv.orig/src/libsolv.ver
++++ libsolv/src/libsolv.ver
+@@ -423,6 +423,8 @@ SOLV_1.0 {
+
+ SOLV_1.1 {
+ pool_best_solvables;
++ pool_get_use_homedir;
++ pool_set_use_homedir;
+ solver_get_cleandeps;
+ } SOLV_1.0;
+
diff --git a/debian/patches/3020_bindings-solv.i_add-new-pool-homedir-functions.patch b/debian/patches/3020_bindings-solv.i_add-new-pool-homedir-functions.patch
new file mode 100644
index 0000000..b7a8e92
--- /dev/null
+++ b/debian/patches/3020_bindings-solv.i_add-new-pool-homedir-functions.patch
@@ -0,0 +1,20 @@
+Description: Support rpmdb in home directory. Add bindings.
+Author: Mihai Moldovan <io...@ionic.de>
+
+Index: libsolv/bindings/solv.i
+===================================================================
+--- libsolv.orig/bindings/solv.i
++++ libsolv/bindings/solv.i
+@@ -1548,6 +1548,12 @@ typedef struct {
+ const char *get_rootdir(int flag) {
+ return pool_get_rootdir($self);
+ }
++ void set_use_homedir(int use_homedir) {
++ return pool_set_use_homedir($self, use_homedir);
++ }
++ int get_use_homedir() {
++ return pool_get_use_homedir($self);
++ }
+ #if defined(SWIGPYTHON)
+ %{
+ SWIGINTERN int loadcallback(Pool *pool, Repodata *data, void *d) {
diff --git a/debian/patches/3030_doc-misc_add-new-pool-homedir-functions.patch b/debian/patches/3030_doc-misc_add-new-pool-homedir-functions.patch
new file mode 100644
index 0000000..b71531f
--- /dev/null
+++ b/debian/patches/3030_doc-misc_add-new-pool-homedir-functions.patch
@@ -0,0 +1,123 @@
+Description: Support rpmdb in home directory. Add documentation.
+Author: Mihai Moldovan <io...@ionic.de>
+
+Index: libsolv/doc/libsolv-bindings.txt
+===================================================================
+--- libsolv.orig/doc/libsolv-bindings.txt
++++ libsolv/doc/libsolv-bindings.txt
+@@ -410,6 +410,21 @@ to work only in some directory, for exam
+ jail. Note that the rootdir will only be prepended to file paths if the
+ *REPO_USE_ROOTDIR* flag is used.
+
++ void set_use_homedir(int use_homedir)
++ $pool->set_use_homedir(use_homedir);
++ pool.set_use_homedir(use_homedir)
++ pool.set_use_homedir(use_homedir)
++
++ int get_use_homedir()
++ my $use_homedir = $pool->get_use_homedir();
++ use_homedir = pool.get_use_homedir()
++ use_homedir = pool.get_use_homedir()
++
++Set/get whether to use an rpmdb in the user's home directory or in the
++system location. This is mostly interesting for Debian-based systems with
++a patched RPM version that defaults to the user's home directory for the
++RPM dbpath.
++
+ void setarch(const char *arch = 0)
+ $pool->setarch();
+ pool.setarch()
+Index: libsolv/doc/libsolv-pool.txt
+===================================================================
+--- libsolv.orig/doc/libsolv-pool.txt
++++ libsolv/doc/libsolv-pool.txt
+@@ -292,6 +292,15 @@ tells the function to prepend the rootdi
+
+ Return the current value of the root directory.
+
++ void pool_set_use_homedir(Pool *pool, int use_homedir);
++
++Set usage of RPMDB in user's home directory. Mostly useful on Debian-based
++systems that patch rpm to place and use the rpmdb in a user's home directory.
++
++ int pool_get_use_homedir(Pool *pool);
++
++Returns the current value for RPMDB home directory usage.
++
+ char *pool_prepend_rootdir(Pool *pool, const char *dir);
+
+ Prepend the root directory to the _dir_ argument string. The returned
+Index: libsolv/doc/gen/libsolv-bindings.3
+===================================================================
+--- libsolv.orig/doc/gen/libsolv-bindings.3
++++ libsolv/doc/gen/libsolv-bindings.3
+@@ -718,6 +718,34 @@ Set/get the rootdir to use\&. This is us
+ .RS 4
+ .\}
+ .nf
++\fBvoid set_use_homedir(int\fR \fIuse_homedir\fR\fB)\fR
++\fI$pool\fR\fB\->set_use_homedir(\fR\fIuse_homedir\fR\fB)\fR;
++\fIpool\fR\fB\&.set_use_homedir(\fR\fIuse_homedir\fR\fB)\fR
++\fIpool\fR\fB\&.set_use_homedir(\fR\fIuse_homedir\fR\fB)\fR
++.fi
++.if n \{\
++.RE
++.\}
++.sp
++.if n \{\
++.RS 4
++.\}
++.nf
++\fBint get_use_homedir()\fR
++my \fI$use_homedir\fR \fB=\fR \fI$pool\fR\fB\->get_use_homedir()\fR;
++\fIuse_homedir\fR \fB=\fR \fIpool\fR\fB\&.get_use_homedir()\fR
++\fIuse_homedir\fR \fB=\fR \fIpool\fR\fB\&.get_use_homedir()\fR
++.fi
++.if n \{\
++.RE
++.\}
++.sp
++Set/get whether to use an rpmdb in the user\(cqs home directory or in the system location\&. This is mostly interesting for Debian\-based systems with a patched RPM version that defaults to the user\(cqs home directory for the RPM dbpath\&.
++.sp
++.if n \{\
++.RS 4
++.\}
++.nf
+ \fBvoid setarch(const char *\fR\fIarch\fR \fB= 0)\fR
+ \fI$pool\fR\fB\->setarch()\fR;
+ \fIpool\fR\fB\&.setarch()\fR
+Index: libsolv/doc/gen/libsolv-pool.3
+===================================================================
+--- libsolv.orig/doc/gen/libsolv-pool.3
++++ libsolv/doc/gen/libsolv-pool.3
+@@ -423,6 +423,30 @@ Return the current value of the root dir
+ .RS 4
+ .\}
+ .nf
++\fBvoid pool_set_use_homedir(Pool *\fR\fIpool\fR\fB, int\fR \fIuse_homedir\fR\fB)\fR;
++.fi
++.if n \{\
++.RE
++.\}
++.sp
++Set usage of RPMDB in user\(cqs home directory\&. Mostly useful on Debian\-based systems that patch rpm to place and use the rpmdb in a user\(cqs home directory\&.
++.sp
++.if n \{\
++.RS 4
++.\}
++.nf
++\fBint pool_get_use_homedir(Pool *\fR\fIpool\fR\fB)\fR;
++.fi
++.if n \{\
++.RE
++.\}
++.sp
++Returns the current value for RPMDB home directory usage\&.
++.sp
++.if n \{\
++.RS 4
++.\}
++.nf
+ \fBchar *pool_prepend_rootdir(Pool *\fR\fIpool\fR\fB, const char *\fR\fIdir\fR\fB)\fR;
+ .fi
+ .if n \{\
diff --git a/debian/patches/series b/debian/patches/series
index 9a2d352..c7a7175 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,6 @@
-1004_cmake-module-path-fix.patch
-1006_various-types.patch
+1005_install-cmake-module-into-libdir.patch
+1006_various-typos.patch
+3000_ext-repo_rpmdb.c_src_pool.h_c_debian-style-home-dir-rpmdb.patch
+3010_src-libsolv.ver_add-new-pool-homedir-functions.patch
+3020_bindings-solv.i_add-new-pool-homedir-functions.patch
+3030_doc-misc_add-new-pool-homedir-functions.patch
diff --git a/debian/rules b/debian/rules
index 78ef501..5f41d1b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -51,7 +51,8 @@ DEB_CMAKE_EXTRA_FLAGS := \
-DENABLE_PYTHON3=1 \
-DCMAKE_SKIP_RPATH=FALSE \
-DCMAKE_SKIP_INSTALL_RPATH=TRUE \
- -DENABLE_COMPLEX_DEPS=1 \
+ -DENABLE_COMPLEX_DEPS:BOOL=ON \
+ -DENABLE_COMPS:BOOL=ON \
$(NULL)
DEB_MAKE_CHECK_TARGET := test
--
2.17.1