From 499892dd2045a4ea55076c01ef16b40d258628c6 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Apr 12 2017 15:48:46 +0000 Subject: import libdnf-0.7.4-3.el7 --- diff --git a/SOURCES/0001-context-try-to-find-releasever-in-RPMDB.patch b/SOURCES/0001-context-try-to-find-releasever-in-RPMDB.patch new file mode 100644 index 0000000..0f446b1 --- /dev/null +++ b/SOURCES/0001-context-try-to-find-releasever-in-RPMDB.patch @@ -0,0 +1,81 @@ +From 9e711da60ac3eabf266356511fc040c69c2bdbce Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Tue, 21 Mar 2017 17:47:00 +0100 +Subject: [PATCH] context: try to find releasever in RPMDB + +That's how YUM/DNF find out releasever.. + +$ rpm -q --provides $(rpm -q --whatprovides "system-release(releasever)") | grep "^system-release(releasever)" +system-release(releasever) = 7Server + +Signed-off-by: Igor Gnatenko + +Closes: #278 +Approved by: ignatenkobrain +--- + libdnf/dnf-context.c | 29 ++++++++++++++++++++++++++++- + 1 file changed, 28 insertions(+), 1 deletion(-) + +diff --git a/libdnf/dnf-context.c b/libdnf/dnf-context.c +index 6ec1040..3d92a5b 100644 +--- a/libdnf/dnf-context.c ++++ b/libdnf/dnf-context.c +@@ -34,6 +34,8 @@ + #include + #include + #include ++#include ++#include + #include + #ifdef RHSM_SUPPORT + #include +@@ -53,6 +55,8 @@ + + #define MAX_NATIVE_ARCHES 12 + ++#define RELEASEVER_PROV "system-release(releasever)" ++ + /* data taken from https://github.com/rpm-software-management/dnf/blob/master/dnf/arch.py */ + static const struct { + const gchar *base; +@@ -1029,13 +1033,36 @@ dnf_context_set_cache_age(DnfContext *context, guint cache_age) + static gboolean + dnf_context_set_os_release(DnfContext *context, GError **error) + { ++ const char *source_root = dnf_context_get_source_root (context); ++ ++ gboolean found_in_rpmdb = FALSE; ++ rpmts ts = rpmtsCreate (); ++ rpmtsSetRootDir (ts, source_root); ++ rpmdbMatchIterator mi = rpmtsInitIterator (ts, RPMTAG_PROVIDENAME, RELEASEVER_PROV, 0); ++ Header hdr; ++ while ((hdr = rpmdbNextIterator (mi)) != NULL) { ++ const char *v = headerGetString (hdr, RPMTAG_VERSION); ++ rpmds ds = rpmdsNew (hdr, RPMTAG_PROVIDENAME, 0); ++ while (rpmdsNext (ds) >= 0) { ++ if (strcmp (rpmdsN (ds), RELEASEVER_PROV) == 0 && rpmdsFlags (ds) == RPMSENSE_EQUAL) ++ v = rpmdsEVR (ds); ++ } ++ found_in_rpmdb = TRUE; ++ dnf_context_set_release_ver (context, v); ++ rpmdsFree (ds); ++ break; ++ } ++ rpmdbFreeIterator (mi); ++ rpmtsFree (ts); ++ if (found_in_rpmdb) ++ return TRUE; ++ + g_autofree gchar *contents = NULL; + g_autofree gchar *maybe_quoted_version = NULL; + g_autofree gchar *version = NULL; + g_autofree gchar *os_release = NULL; + g_autoptr(GString) str = NULL; + g_autoptr(GKeyFile) key_file = NULL; +- const char *source_root = dnf_context_get_source_root(context); + + os_release = g_build_filename(source_root, "etc/os-release", NULL); + if (!dnf_get_file_contents_allow_noent(os_release, &contents, NULL, error)) +-- +2.12.1 + diff --git a/SPECS/libdnf.spec b/SPECS/libdnf.spec index 6015364..f20eb71 100644 --- a/SPECS/libdnf.spec +++ b/SPECS/libdnf.spec @@ -3,15 +3,19 @@ %bcond_with valgrind +%if 0%{?rhel} %bcond_without rhsm +%else +%bcond_with rhsm +%endif %global _cmake_opts \\\ - -DENABLE_RHSM_SUPPORT=OFF \\\ + -DENABLE_RHSM_SUPPORT=%{?with_rhsm:ON}%{!?with_rhsm:OFF} \\\ %{nil} Name: libdnf Version: 0.7.4 -Release: 2%{?dist}.el +Release: 3%{?dist} Summary: Library providing simplified C and Python API to libsolv License: LGPLv2+ URL: https://github.com/rpm-software-management/libdnf @@ -19,6 +23,8 @@ Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz Patch0: 0001-Revert-selector-prefer-obsoletes-Related-RhBug-10965.patch +Patch0001: 0001-context-try-to-find-releasever-in-RPMDB.patch + BuildRequires: cmake BuildRequires: gcc BuildRequires: libsolv-devel >= %{libsolv_version} @@ -31,6 +37,9 @@ BuildRequires: pkgconfig(gio-unix-2.0) >= 2.44.0 BuildRequires: pkgconfig(gtk-doc) BuildRequires: pkgconfig(gobject-introspection-1.0) BuildRequires: rpm-devel >= 4.11.0 +%if %{with rhsm} +BuildRequires: pkgconfig(librhsm) +%endif Requires: libsolv%{?_isa} >= %{libsolv_version} @@ -88,8 +97,8 @@ popd %{_datadir}/gir-1.0/Dnf-*.gir %changelog -* Tue Mar 7 2017 Johnny Hughes - 0.7.4-2 -- Manual CentOS Debranding +* Thu Mar 23 2017 Igor Gnatenko - 0.7.4-3 +- Backport patch to find releasever in RPMDB * Mon Feb 20 2017 Jan Silhan - 0.7.4-2 - 0.7.4