From 2dde77ef32cacb0ed0d2d9ea3ad5cf13f425ef53 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 16 May 2023 06:17:49 +0000 Subject: [PATCH] import librhsm-0.0.3-5.el8 --- .gitignore | 1 + .librhsm.metadata | 1 + SOURCES/2.patch | 33 ++++++++++++ SOURCES/4.patch | 28 ++++++++++ SOURCES/5.patch | 130 +++++++++++++++++++++++++++++++++++++++++++++ SPECS/librhsm.spec | 70 ++++++++++++++++++++++++ 6 files changed, 263 insertions(+) create mode 100644 .gitignore create mode 100644 .librhsm.metadata create mode 100644 SOURCES/2.patch create mode 100644 SOURCES/4.patch create mode 100644 SOURCES/5.patch create mode 100644 SPECS/librhsm.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a560613 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/librhsm-0.0.3.tar.gz diff --git a/.librhsm.metadata b/.librhsm.metadata new file mode 100644 index 0000000..fdbe51d --- /dev/null +++ b/.librhsm.metadata @@ -0,0 +1 @@ +72963388eece706d328b84070107e20d322cf0e4 SOURCES/librhsm-0.0.3.tar.gz diff --git a/SOURCES/2.patch b/SOURCES/2.patch new file mode 100644 index 0000000..972d94b --- /dev/null +++ b/SOURCES/2.patch @@ -0,0 +1,33 @@ +From 1335a0a08399960128192651011c4a3ca6233b32 Mon Sep 17 00:00:00 2001 +From: Daniel Mach +Date: Tue, 13 Nov 2018 12:17:58 +0100 +Subject: [PATCH] Enable repos when generating a .repo file based on + entitlement certificate. + +Resolves: rhbz#1638850 +--- + rhsm/rhsm-utils.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/rhsm/rhsm-utils.c b/rhsm/rhsm-utils.c +index 7b6a26b..021d0d8 100644 +--- a/rhsm/rhsm-utils.c ++++ b/rhsm/rhsm-utils.c +@@ -246,9 +246,16 @@ rhsm_utils_yum_repo_from_context (RHSMContext *ctx) + const gchar *id = json_object_get_string_member (repo, "label"); + const gchar *name = json_object_get_string_member (repo, "name"); + const gchar *path = json_object_get_string_member (repo, "path"); +- gboolean enabled = FALSE; ++ ++ /* ++ * The "enabled" option defaults to "true". ++ * If a content (repository) is enabled, the option is missing in the data, ++ * most likely to save limited space in the certificate. ++ */ ++ gboolean enabled = TRUE; + if (json_object_has_member (repo, "enabled")) + enabled = json_object_get_boolean_member (repo, "enabled"); ++ + if (id == NULL || name == NULL || path == NULL) + continue; /* TODO: make some error reporting here */ + diff --git a/SOURCES/4.patch b/SOURCES/4.patch new file mode 100644 index 0000000..67752e7 --- /dev/null +++ b/SOURCES/4.patch @@ -0,0 +1,28 @@ +From 3d7519f2ac9e9f6e0978bc0cfebee6fa56190480 Mon Sep 17 00:00:00 2001 +From: Pavla Kratochvilova +Date: Wed, 20 Mar 2019 18:45:16 +0100 +Subject: [PATCH] Generate repofile for any architecture if "ALL" is specified + (RhBug:1645318) + +The "arches" array can contain special value "ALL" and in that case any +architecture should be accepted. + +https://bugzilla.redhat.com/show_bug.cgi?id=1645318 +--- + rhsm/rhsm-utils.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/rhsm/rhsm-utils.c b/rhsm/rhsm-utils.c +index 7b6a26b..0c8df57 100644 +--- a/rhsm/rhsm-utils.c ++++ b/rhsm/rhsm-utils.c +@@ -230,7 +230,8 @@ rhsm_utils_yum_repo_from_context (RHSMContext *ctx) + if (json_object_has_member (repo, "arches")) + { + JsonArray *arr = json_object_get_array_member (repo, "arches"); +- if (!rhsm_json_array_contains_string (arr, ctx_arch)) ++ if (!rhsm_json_array_contains_string (arr, ctx_arch) ++ && !rhsm_json_array_contains_string (arr, "ALL")) + continue; + } + diff --git a/SOURCES/5.patch b/SOURCES/5.patch new file mode 100644 index 0000000..6b55e0e --- /dev/null +++ b/SOURCES/5.patch @@ -0,0 +1,130 @@ +From c3a333256261545ffe1bd7088c6c54dcb9fb759b Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel +Date: Tue, 21 Apr 2020 08:56:01 +0200 +Subject: [PATCH] Append ctx_baseurl prefix to gpg_url (RhBug:1708628) + +Sometime the gpg_url contains relative path to context baseurl. +In that case the code appends baseurl prefix to gpg_url. The resulting +URI is normalized (solved "//", ".", and "..") + +The new function rhsm_url_base_join() introduce similar results +as utils.url_base_join() in subscription manager. +--- + rhsm/rhsm-utils.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 93 insertions(+), 1 deletion(-) + +diff --git a/rhsm/rhsm-utils.c b/rhsm/rhsm-utils.c +index 6708a43..ee3f296 100644 +--- a/rhsm/rhsm-utils.c ++++ b/rhsm/rhsm-utils.c +@@ -181,6 +181,97 @@ rhsm_json_array_is_subset_of_hash_table (JsonArray *array, + return TRUE; + } + ++/* ++ * Join a baseurl (hostname) and url (full or relpath). ++ * ++ * If url is a full url, just return it. Otherwise combine ++ * it with base, skipping redundant seperators if needed. ++ * ++ * Simulate the behavior of subscription manager. ++ */ ++static gchar * ++rhsm_url_base_join (const gchar *base, ++ const gchar *url) ++{ ++ /* handle special cases similar to subscription manager */ ++ if (!url || *url == '\0') ++ return g_strdup (""); ++ if (strstr (url, "://")) ++ return g_strdup (url); ++ if (!base || *base == '\0') ++ return g_strdup (url); ++ ++ /* parse URI, split to schema, host, and path */ ++ g_autofree gchar *schema = NULL; ++ g_autofree gchar *host = NULL; ++ g_autofree gchar *path = NULL; ++ gchar *tmp = strstr (base, ":"); ++ if (tmp) ++ schema = g_strndup (base, tmp - base); ++ if (schema) ++ { ++ if (tmp[1] == '/' && tmp[2] == '/') ++ { ++ gchar *tmp2 = strstr (tmp + 3, "/"); ++ if (tmp2) ++ { ++ host = g_strndup (tmp + 3, tmp2 - tmp - 3); ++ path = g_strdup (tmp2); ++ } ++ else ++ host = g_strdup (tmp + 3); ++ } ++ else ++ path = g_strdup (tmp + 1); ++ } ++ else ++ path = g_strdup (base); ++ ++ /* full_path is path from base + url */ ++ g_autofree gchar *full_path = NULL; ++ if (path) ++ full_path = g_strconcat (path, "/", url, NULL); ++ else ++ full_path = g_strconcat ("/", url, NULL); ++ ++ /* normalize full_path ++ * split to vector, copy vector but skip empty and "." items, ++ * for each ".." source item remove last item from destination ++ */ ++ g_auto(GStrv) src_split_path = g_strsplit (full_path, "/", -1); ++ guint src_len = g_strv_length (src_split_path); ++ g_autofree gchar **dest_split_path = g_new0 (gchar *, src_len + 1); ++ guint dest_len = 0; ++ for (guint src_idx = 0; src_idx < src_len; ++src_idx) ++ { ++ gchar *src = src_split_path[src_idx]; ++ if (*src == '\0' || strcmp (src, ".") == 0) ++ continue; ++ if (strcmp (src, "..") == 0) ++ { ++ if (dest_len > 0) ++ --dest_len; ++ continue; ++ } ++ dest_split_path[dest_len++] = src; ++ } ++ dest_split_path[dest_len] = NULL; ++ ++ /* construct destination path */ ++ g_autofree gchar *tmp_path = g_strjoinv ("/", dest_split_path); ++ g_autofree gchar *dest_path = NULL; ++ if (g_str_has_suffix (url, "/") || g_str_has_suffix (url, "/.") || g_str_has_suffix (url, "/..")) ++ dest_path = g_strconcat (tmp_path, "/", NULL); ++ else ++ dest_path = g_strdup (tmp_path); ++ ++ /* construct and return final URI */ ++ if (schema) ++ return g_strconcat (schema, "://", host ? host : "", "/", dest_path, NULL); ++ else ++ return g_strconcat ("/", dest_path, NULL); ++} ++ + /** + * rhsm_utils_yum_repo_from_context: + * @ctx: an #RHSMContext. +@@ -275,7 +366,8 @@ rhsm_utils_yum_repo_from_context (RHSMContext *ctx) + if (json_object_has_member (repo, "gpg_url")) + { + const gchar *gpg_url = json_object_get_string_member (repo, "gpg_url"); +- g_key_file_set_string (repofile, id, "gpgkey", gpg_url); ++ g_autofree gchar *gpgkey = rhsm_url_base_join (ctx_baseurl, gpg_url); ++ g_key_file_set_string (repofile, id, "gpgkey", gpgkey); + g_key_file_set_boolean (repofile, id, "gpgcheck", TRUE); + } + else +-- +libgit2 0.28.5 + diff --git a/SPECS/librhsm.spec b/SPECS/librhsm.spec new file mode 100644 index 0000000..8f30722 --- /dev/null +++ b/SPECS/librhsm.spec @@ -0,0 +1,70 @@ +%global libname rhsm + +Name: lib%{libname} +Version: 0.0.3 +Release: 5%{?dist} +Summary: Red Hat Subscription Manager library + +License: LGPLv2+ +URL: https://github.com/rpm-software-management/librhsm +Source: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz +Patch0: 2.patch +Patch1: 4.patch +Patch2: 5.patch + +BuildRequires: meson >= 0.37.0 +BuildRequires: gcc +BuildRequires: pkgconfig(glib-2.0) >= 2.44 +BuildRequires: pkgconfig(gobject-2.0) >= 2.44 +BuildRequires: pkgconfig(gio-2.0) >= 2.44 +BuildRequires: pkgconfig(json-glib-1.0) >= 1.2 +BuildRequires: pkgconfig(openssl) + +%description +%{summary}. + +%package devel +Summary: Development libraries and header files for %{name} +Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} + +%description devel +%{summary}. + +%prep +%autosetup -p1 + +%build +%meson +%meson_build + +%install +%meson_install + +%files +%license COPYING +%doc README.md +%{_libdir}/%{name}.so.* + +%files devel +%{_libdir}/%{name}.so +%{_includedir}/%{libname}/ +%{_libdir}/pkgconfig/%{name}.pc + +%changelog +* Thu Jan 5 2023 Nicola Sella - 0.0.3-5 +- Append ctx_baseurl prefix to gpg_url + +* Wed Jan 6 2021 Marek Blaha - 0.0.3-4 +- Rebuild to ship also librhsm-devel subpackage + +* Wed Jul 10 2019 Daniel Mach - 0.0.3-3 +- Generate repofile for any architecture if "ALL" is specified + +* Tue Nov 13 2018 Daniel Mach - 0.0.3-2 +- Enable repos when generating a .repo file based on entitlement certificate. + +* Mon Jul 09 2018 Igor Gnatenko - 0.0.3-1 +- Update to 0.0.3 + +* Thu Feb 22 2018 Igor Gnatenko - 0.0.2-1 +- Initial release