commit 276befcd0a7e345222ea72abd3b3fbd0f568e62b Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 10:55:46 2019 -0400 Package init diff --git a/0001-Modify-solver_describe_decision-to-report-cleaned-RhBug1486749.patch b/0001-Modify-solver_describe_decision-to-report-cleaned-RhBug1486749.patch new file mode 100644 index 0000000..9a99191 --- /dev/null +++ b/0001-Modify-solver_describe_decision-to-report-cleaned-RhBug1486749.patch @@ -0,0 +1,40 @@ +From 83a0b5f289fd9461b68b1afab525c0f4ca6015b1 Mon Sep 17 00:00:00 2001 +From: Jaroslav Mracek +Date: Mon, 15 Oct 2018 21:27:15 +0200 +Subject: [PATCH] Modify solver_describe_decision to report cleaned (RhBug:1486749) + +--- + libdnf/goal/Goal.cpp | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/libdnf/goal/Goal.cpp b/libdnf/goal/Goal.cpp +index 50fef5c..7d17a49 100644 +--- a/libdnf/goal/Goal.cpp ++++ b/libdnf/goal/Goal.cpp +@@ -647,7 +647,8 @@ Goal::getReason(DnfPackage *pkg) + if (!pImpl->solv) + return HY_REASON_USER; + Id info; +- int reason = solver_describe_decision(pImpl->solv, dnf_package_get_id(pkg), &info); ++ const Id pkgID = dnf_package_get_id(pkg); ++ int reason = solver_describe_decision(pImpl->solv, pkgID, &info); + + if ((reason == SOLVER_REASON_UNIT_RULE || + reason == SOLVER_REASON_RESOLVE_JOB) && +@@ -658,6 +659,13 @@ Goal::getReason(DnfPackage *pkg) + return HY_REASON_CLEAN; + if (reason == SOLVER_REASON_WEAKDEP) + return HY_REASON_WEAKDEP; ++ IdQueue cleanDepsQueue; ++ solver_get_cleandeps(pImpl->solv, cleanDepsQueue.getQueue()); ++ for (int i = 0; i < cleanDepsQueue.size(); ++i) { ++ if (cleanDepsQueue[i] == pkgID) { ++ return HY_REASON_CLEAN; ++ } ++ } + return HY_REASON_DEP; + } + +-- +libgit2 0.26.6 + diff --git a/0002-history-Fix-crash-in-TransactionItemaddReplacedBy.patch b/0002-history-Fix-crash-in-TransactionItemaddReplacedBy.patch new file mode 100644 index 0000000..c8e4447 --- /dev/null +++ b/0002-history-Fix-crash-in-TransactionItemaddReplacedBy.patch @@ -0,0 +1,25 @@ +From cc7776ba7e33770ad5744a67d32b03aaece992f8 Mon Sep 17 00:00:00 2001 +From: Daniel Mach +Date: Wed, 17 Oct 2018 12:12:18 +0200 +Subject: [PATCH] [history] Fix crash in TransactionItem::addReplacedBy(). + +--- + libdnf/transaction/TransactionItem.hpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libdnf/transaction/TransactionItem.hpp b/libdnf/transaction/TransactionItem.hpp +index dc4e2c8..72684f7 100644 +--- a/libdnf/transaction/TransactionItem.hpp ++++ b/libdnf/transaction/TransactionItem.hpp +@@ -110,7 +110,7 @@ public: + // int64_t getTransactionId() const noexcept { return trans.getId(); } + + const std::vector< TransactionItemPtr > &getReplacedBy() const noexcept { return replacedBy; } +- void addReplacedBy(TransactionItemPtr value) { replacedBy.push_back(value); } ++ void addReplacedBy(TransactionItemPtr value) { if (value) replacedBy.push_back(value); } + + void save(); + void saveReplacedBy(); +-- +libgit2 0.26.6 + diff --git a/0003-swdb-create-persistent-WAL-files-RhBug1640235.patch b/0003-swdb-create-persistent-WAL-files-RhBug1640235.patch new file mode 100644 index 0000000..a8b355f --- /dev/null +++ b/0003-swdb-create-persistent-WAL-files-RhBug1640235.patch @@ -0,0 +1,37 @@ +From dbe553c3846061f022dae906276b77a8430cce6a Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel +Date: Thu, 18 Oct 2018 16:06:55 +0200 +Subject: [PATCH] [swdb] create persistent WAL files (RhBug:1640235) + +--- + libdnf/utils/sqlite3/Sqlite3.cpp | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +diff --git a/libdnf/utils/sqlite3/Sqlite3.cpp b/libdnf/utils/sqlite3/Sqlite3.cpp +index 021b5d2..27fed56 100644 +--- a/libdnf/utils/sqlite3/Sqlite3.cpp ++++ b/libdnf/utils/sqlite3/Sqlite3.cpp +@@ -30,9 +30,17 @@ SQLite3::open() + sqlite3_close(db); + throw LibException(result, "Open failed"); + } +- // sqlite doesn't behave correctly in chroots without following line: +- // turn foreign key checking on +- exec("PRAGMA locking_mode = NORMAL; PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;"); ++#if SQLITE_VERSION_NUMBER >= 3022000 ++ int enabled = 1; ++ sqlite3_file_control(db, "main", SQLITE_FCNTL_PERSIST_WAL, &enabled); ++ if (sqlite3_db_readonly(db, "main") == 1) ++ exec("PRAGMA locking_mode = NORMAL; PRAGMA foreign_keys = ON;"); ++ else ++ exec("PRAGMA locking_mode = NORMAL; PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;"); ++#else ++ // Journal mode WAL in readonly mode is supported from sqlite version 3.22.0 ++ exec("PRAGMA locking_mode = NORMAL; PRAGMA journal_mode = TRUNCATE; PRAGMA foreign_keys = ON;"); ++#endif + sqlite3_busy_timeout(db, 10000); + } + } +-- +libgit2 0.26.7 + diff --git a/0004-Relocate-ModuleContainer-save-hook-RhBug1632518.patch b/0004-Relocate-ModuleContainer-save-hook-RhBug1632518.patch new file mode 100644 index 0000000..acc0da3 --- /dev/null +++ b/0004-Relocate-ModuleContainer-save-hook-RhBug1632518.patch @@ -0,0 +1,58 @@ +From 744a95e49b6f29aa65bc5b28e0e821c38c481581 Mon Sep 17 00:00:00 2001 +From: Jaroslav Mracek +Date: Fri, 19 Oct 2018 15:44:39 +0200 +Subject: [PATCH] Relocate ModuleContainer save hook (RhBug:1632518) + +--- + libdnf/dnf-context.cpp | 5 +---- + libdnf/dnf-transaction.cpp | 5 +++++ + 2 files changed, 6 insertions(+), 4 deletions(-) + +diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp +index 141af3a..db1741c 100644 +--- a/libdnf/dnf-context.cpp ++++ b/libdnf/dnf-context.cpp +@@ -1879,10 +1879,7 @@ dnf_context_run(DnfContext *context, GCancellable *cancellable, GError **error) + error); + if (!ret) + return FALSE; +- auto moduleContainer = dnf_sack_get_module_container(priv->sack); +- if (moduleContainer) { +- moduleContainer->save(); +- } ++ + /* this sack is no longer valid */ + g_object_unref(priv->sack); + priv->sack = NULL; +diff --git a/libdnf/dnf-transaction.cpp b/libdnf/dnf-transaction.cpp +index 5c078a0..0d948d7 100644 +--- a/libdnf/dnf-transaction.cpp ++++ b/libdnf/dnf-transaction.cpp +@@ -38,12 +38,14 @@ + #include "dnf-package.h" + #include "dnf-rpmts.h" + #include "dnf-sack.h" ++#include "dnf-sack-private.hpp" + #include "dnf-transaction.h" + #include "dnf-types.h" + #include "dnf-utils.h" + #include "hy-query.h" + #include "hy-util-private.hpp" + ++#include "module/ModulePackageContainer.hpp" + #include "transaction/Swdb.hpp" + #include "transaction/Transformer.hpp" + #include "utils/bgettext/bgettext-lib.h" +@@ -1435,6 +1437,9 @@ dnf_transaction_commit(DnfTransaction *transaction, HyGoal goal, DnfState *state + goto out; + } + ++ if (auto moduleContainer = dnf_sack_get_module_container(dnf_context_get_sack(priv->context))) ++ moduleContainer->save(); ++ + /* all sacks are invalid now */ + dnf_context_invalidate_full(priv->context, + "transaction performed", +-- +libgit2 0.26.7 + diff --git a/0005-Test-if-sack-is-present-and-run-save-module-persistor-RhBug1632518.patch b/0005-Test-if-sack-is-present-and-run-save-module-persistor-RhBug1632518.patch new file mode 100644 index 0000000..72ccc6c --- /dev/null +++ b/0005-Test-if-sack-is-present-and-run-save-module-persistor-RhBug1632518.patch @@ -0,0 +1,30 @@ +From 1e7118d01d9ba92f759cd9669f9d0dd5af0619d6 Mon Sep 17 00:00:00 2001 +From: Jaroslav Mracek +Date: Sat, 20 Oct 2018 01:13:49 +0200 +Subject: [PATCH] Test if sack is present and run save module persistor (RhBug:1632518) + +--- + libdnf/dnf-transaction.cpp | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/libdnf/dnf-transaction.cpp b/libdnf/dnf-transaction.cpp +index 0d948d7..b89eace 100644 +--- a/libdnf/dnf-transaction.cpp ++++ b/libdnf/dnf-transaction.cpp +@@ -1437,8 +1437,11 @@ dnf_transaction_commit(DnfTransaction *transaction, HyGoal goal, DnfState *state + goto out; + } + +- if (auto moduleContainer = dnf_sack_get_module_container(dnf_context_get_sack(priv->context))) +- moduleContainer->save(); ++ if (DnfSack * sack = hy_goal_get_sack(goal)) { ++ if (auto moduleContainer = dnf_sack_get_module_container(sack)) { ++ moduleContainer->save(); ++ } ++ } + + /* all sacks are invalid now */ + dnf_context_invalidate_full(priv->context, +-- +libgit2 0.26.7 + diff --git a/libdnf-0.22.0.tar.gz b/libdnf-0.22.0.tar.gz new file mode 100644 index 0000000..64d7420 Binary files /dev/null and b/libdnf-0.22.0.tar.gz differ diff --git a/libdnf.spec b/libdnf.spec new file mode 100644 index 0000000..c653876 --- /dev/null +++ b/libdnf.spec @@ -0,0 +1,174 @@ +%global libsolv_version 0.6.30-1 +%global libmodulemd_version 1.6.1 +%global dnf_conflict 3.7.1 +%global swig_version 3.0.12 + +%bcond_with valgrind +%bcond_without python3 +%bcond_without python2 + +%global _cmake_opts \\\ + -DENABLE_RHSM_SUPPORT=%{?with_rhsm:ON}%{!?with_rhsm:OFF} \\\ + %{nil} + +Name: libdnf +Version: 0.22.0 +Release: 7 +Summary: Library providing simplified C and Python API to libsolv +License: LGPLv2+ +URL: https://github.com/rpm-software-management/libdnf +Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz +Patch0001: 0001-Modify-solver_describe_decision-to-report-cleaned-RhBug1486749.patch +Patch0002: 0002-history-Fix-crash-in-TransactionItemaddReplacedBy.patch +Patch0003: 0003-swdb-create-persistent-WAL-files-RhBug1640235.patch +Patch0004: 0004-Relocate-ModuleContainer-save-hook-RhBug1632518.patch +Patch0005: 0005-Test-if-sack-is-present-and-run-save-module-persistor-RhBug1632518.patch + +BuildRequires: cmake gcc gcc-c++ libsolv-devel >= %{libsolv_version} pkgconfig(librepo) pkgconfig(check) +BuildRequires: pkgconfig(gio-unix-2.0) >= 2.46.0 pkgconfig(gtk-doc) pkgconfig(sqlite3) pkgconfig(json-c) +BuildRequires: rpm-devel >= 4.11.0 pkgconfig(cppunit) pkgconfig(smartcols) +BuildRequires: pkgconfig(modulemd) >= %{libmodulemd_version} gettext gpgme-devel +Requires: libmodulemd%{?_isa} >= %{libmodulemd_version} +Requires: libsolv%{?_isa} >= %{libsolv_version} + +%description +A Library providing simplified C and Python API to libsolv. + +%package devel +Summary: Development files for %{name} +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: libsolv-devel%{?_isa} >= %{libsolv_version} + +%description devel +Development files for %{name}. + +%if %{with python2} +%package -n python2-libdnf +%{?python_provide:%python_provide python2-%{name}} +Summary: Python 2 bindings for the libdnf library. +Requires: %{name}%{?_isa} = %{version}-%{release} +BuildRequires: python2-devel swig >= %{swig_version} + +%description -n python2-libdnf +Python 2 bindings for the libdnf library. +%endif + +%package -n python3-libdnf +%{?python_provide:%python_provide python3-%{name}} +Summary: Python 3 bindings for the libdnf library. +Requires: %{name}%{?_isa} = %{version}-%{release} +BuildRequires: python3-devel swig >= %{swig_version} + +%description -n python3-libdnf +Python 3 bindings for the libdnf library. + +%if %{with python2} +%package -n python2-hawkey +Summary: Python 2 bindings for the hawkey library +%{?python_provide:%python_provide python2-hawkey} +BuildRequires: python2-devel python2-nose +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: python2-%{name} = %{version}-%{release} +Conflicts: python2-dnf < %{dnf_conflict} +Conflicts: python-dnf < %{dnf_conflict} + +%description -n python2-hawkey +Python 2 bindings for the hawkey library. +%endif + +%package -n python3-hawkey +Summary: Python 3 bindings for the hawkey library +%{?python_provide:%python_provide python3-hawkey} +BuildRequires: python3-devel python3-nose +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: python3-%{name} = %{version}-%{release} +Conflicts: python3-dnf < %{dnf_conflict} +Obsoletes: platform-python-hawkey < %{version}-%{release} + +%description -n python3-hawkey +Python 3 bindings for the hawkey library. + +%prep +%autosetup -p1 +%if %{with python2} +mkdir build-py2 +%endif +mkdir build-py3 + +%build +%if %{with python2} +pushd build-py2 + %cmake -DPYTHON_DESIRED:FILEPATH=%{__python2} -DWITH_MAN=OFF ../ %{!?with_valgrind:-DDISABLE_VALGRIND=1} %{_cmake_opts} + %make_build +popd +%endif + +%if %{with python3} +pushd build-py3 + %cmake -DPYTHON_DESIRED:FILEPATH=%{__python3} -DWITH_GIR=0 -DWITH_MAN=0 -Dgtkdoc=0 ../ %{!?with_valgrind:-DDISABLE_VALGRIND=1} %{_cmake_opts} + %make_build +popd +%endif + +%check +if [ "$(id -u)" == "0" ] ; then + cat <&2 +Package tests cannot be run under superuser account. +Please build the package as non-root user. +ERROR + exit 1 +fi + +%if %{with python2} +pushd build-py2 + make ARGS="-V" test +popd +%endif +pushd build-py3/python/hawkey/tests + make ARGS="-V" test +popd + +%install +%if %{with python2} +pushd build-py2 + %make_install +popd +%endif +pushd build-py3 + %make_install +popd + +%find_lang %{name} + +%ldconfig_scriptlets + +%files -f %{name}.lang +%license COPYING +%doc README.md AUTHORS +%doc %{_datadir}/gtk-doc/html/%{name}/ +%{_libdir}/%{name}.so.* + +%files devel +%{_libdir}/%{name}.so +%{_libdir}/pkgconfig/%{name}.pc +%{_includedir}/%{name}/ + +%if %{with python2} +%files -n python2-%{name} +%{python2_sitearch}/%{name}/ +%endif + +%files -n python3-%{name} +%{python3_sitearch}/%{name}/ + +%if %{with python2} +%files -n python2-hawkey +%{python2_sitearch}/hawkey/ +%endif + +%files -n python3-hawkey +%{python3_sitearch}/hawkey/ + +%changelog +* Wed Sep 18 2019 openEuler Buildteam - 0.22.0-7 +- Package init