diff --git a/SOURCES/100.patch b/SOURCES/100.patch new file mode 100644 index 0000000..0eeafb6 --- /dev/null +++ b/SOURCES/100.patch @@ -0,0 +1,32 @@ +From bf9a7e25363e010b50b076cad3505207a757c7d1 Mon Sep 17 00:00:00 2001 +From: Jan Kaluza +Date: Wed, 25 Jul 2018 15:05:11 +0200 +Subject: [PATCH] Fix missing packages in mergerepo_c in case multiple VR + exists for single pkg in repo. + +--- + src/mergerepo_c.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/mergerepo_c.c b/src/mergerepo_c.c +index 94b929c..ad20a84 100644 +--- a/src/mergerepo_c.c ++++ b/src/mergerepo_c.c +@@ -471,7 +471,7 @@ new_merged_metadata_hashtable() + { + GHashTable *hashtable = g_hash_table_new_full(g_str_hash, + g_str_equal, +- NULL, ++ g_free, + free_merged_values); + return hashtable; + } +@@ -824,7 +824,7 @@ add_package(cr_Package *pkg, + repopath_with_protocol = prepend_protocol(repopath); + pkg->location_base = cr_safe_string_chunk_insert(pkg->chunk, repopath_with_protocol); + } +- g_hash_table_insert (merged, (gpointer) pkg->name, (gpointer) list); ++ g_hash_table_insert (merged, (gpointer) g_strdup(pkg->name), (gpointer) list); + return 1; + } + diff --git a/SOURCES/151.patch b/SOURCES/151.patch new file mode 100644 index 0000000..ceb52b5 --- /dev/null +++ b/SOURCES/151.patch @@ -0,0 +1,84 @@ +From 2a4e2782a1faaf8e7bf5d4123e572007e591d24b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= +Date: Tue, 23 Apr 2019 10:07:59 +0200 +Subject: [PATCH] Prevent race condition when --update & we have duplicate pkgs + (RhBug: 1696808) + +--- + src/createrepo_c.c | 2 ++ + src/dumper_thread.c | 12 ++++++++---- + src/dumper_thread.h | 1 + + 3 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/src/createrepo_c.c b/src/createrepo_c.c +index 444d88f..160789b 100644 +--- a/src/createrepo_c.c ++++ b/src/createrepo_c.c +@@ -995,6 +995,7 @@ main(int argc, char **argv) + user_data.id_oth = 0; + user_data.buffer = g_queue_new(); + user_data.mutex_buffer = g_mutex_new(); ++ user_data.mutex_old_md = g_mutex_new(); + user_data.deltas = cmd_options->deltas; + user_data.max_delta_rpm_size= cmd_options->max_delta_rpm_size; + user_data.mutex_deltatargetpackages = g_mutex_new(); +@@ -1049,6 +1050,7 @@ main(int argc, char **argv) + + g_queue_free(user_data.buffer); + g_mutex_free(user_data.mutex_buffer); ++ g_mutex_free(user_data.mutex_old_md); + g_cond_free(user_data.cond_pri); + g_cond_free(user_data.cond_fil); + g_cond_free(user_data.cond_oth); +diff --git a/src/dumper_thread.c b/src/dumper_thread.c +index 27c2493..589ab52 100644 +--- a/src/dumper_thread.c ++++ b/src/dumper_thread.c +@@ -436,9 +436,15 @@ cr_dumper_thread(gpointer data, gpointer user_data) + // Update stuff + if (udata->old_metadata) { + // We have old metadata ++ g_mutex_lock(udata->mutex_old_md); + md = (cr_Package *) g_hash_table_lookup( + cr_metadata_hashtable(udata->old_metadata), + task->filename); ++ // Remove the pkg from the hash table of old metadata, so that no other ++ // thread can use it as CACHE, because later we modify it destructively ++ g_hash_table_steal(cr_metadata_hashtable(udata->old_metadata), ++ task->filename); ++ g_mutex_unlock(udata->mutex_old_md); + + if (md) { + g_debug("CACHE HIT %s", task->filename); +@@ -576,8 +582,7 @@ cr_dumper_thread(gpointer data, gpointer user_data) + write_pkg(task->id, res, pkg, udata); + + // Clean up +- if (pkg != md) +- cr_package_free(pkg); ++ cr_package_free(pkg); + g_free(res.primary); + g_free(res.filelists); + g_free(res.other); +@@ -623,8 +628,7 @@ cr_dumper_thread(gpointer data, gpointer user_data) + // Dump XML and SQLite + write_pkg(buf_task->id, buf_task->res, buf_task->pkg, udata); + // Clean up +- if (!buf_task->pkg_from_md) +- cr_package_free(buf_task->pkg); ++ cr_package_free(buf_task->pkg); + g_free(buf_task->res.primary); + g_free(buf_task->res.filelists); + g_free(buf_task->res.other); +diff --git a/src/dumper_thread.h b/src/dumper_thread.h +index 94a57d8..74d5951 100644 +--- a/src/dumper_thread.h ++++ b/src/dumper_thread.h +@@ -71,6 +71,7 @@ struct UserData { + // Update stuff + gboolean skip_stat; // Skip stat() while updating + cr_Metadata *old_metadata; // Loaded metadata ++ GMutex *mutex_old_md; // Mutex for accessing old metadata + + // Thread serialization + GMutex *mutex_pri; // Mutex for primary metadata diff --git a/SPECS/createrepo_c.spec b/SPECS/createrepo_c.spec index db16ae0..2a5312f 100644 --- a/SPECS/createrepo_c.spec +++ b/SPECS/createrepo_c.spec @@ -1,5 +1,3 @@ -%{!?_licensedir:%global license %%doc} - # Bash completion (we need different approach for RHEL-6) %if 0%{?rhel} == 6 %global bash_completion %config%{_sysconfdir}/bash_completion.d/createrepo_c.bash @@ -7,8 +5,6 @@ %global bash_completion %{_datadir}/bash-completion/completions/* %endif -%{!?python2_sitearch:%global python2_sitearch %{python_sitearch}} - %if 0%{?rhel} && 0%{?rhel} <= 7 %bcond_with python3 %bcond_with drpm @@ -20,7 +16,7 @@ Summary: Creates a common metadata repository Name: createrepo_c Version: 0.10.0 -Release: 18%{?dist} +Release: 20%{?dist} License: GPLv2+ URL: https://github.com/rpm-software-management/createrepo_c Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz @@ -28,6 +24,8 @@ Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz Patch0: createrepo_c-0.10.0-ignorelock-doublefree.patch Patch1: https://patch-diff.githubusercontent.com/raw/rpm-software-management/createrepo_c/pull/64.patch Patch2: https://patch-diff.githubusercontent.com/raw/rpm-software-management/createrepo_c/pull/66.patch +Patch3: https://patch-diff.githubusercontent.com/raw/rpm-software-management/createrepo_c/pull/100.patch +Patch4: https://patch-diff.githubusercontent.com/raw/rpm-software-management/createrepo_c/pull/151.patch BuildRequires: cmake BuildRequires: gcc @@ -156,8 +154,8 @@ pushd build-py3 popd %endif -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig +%post libs -p /sbin/ldconfig +%postun libs -p /sbin/ldconfig %files %doc README.md @@ -190,6 +188,12 @@ popd %endif %changelog +* Mon Oct 21 2019 Ales Matej - 0.10.0-20 +- Backport patch to prevent race condition on update with duplicate pkgs (RhBug: 1696808) + +* Wed Jul 25 2018 Igor Gnatenko - 0.10.0-19 +- Backport patch for multiple packages with same name for mergerepo_c + * Wed Feb 07 2018 Iryna Shcherbina - 0.10.0-18 - Update Python 2 dependency declarations to new packaging standards (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)