From 0a14be72ce1951fed1bd3889a47954a2e97795ed Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Feb 13 2021 06:11:14 +0000 Subject: import createrepo_c-0.16.2-2.el8 --- diff --git a/SOURCES/0001-Never-leave-behind-repodata-lock-on-exit-RhBug-1906831.patch b/SOURCES/0001-Never-leave-behind-repodata-lock-on-exit-RhBug-1906831.patch new file mode 100644 index 0000000..f078b74 --- /dev/null +++ b/SOURCES/0001-Never-leave-behind-repodata-lock-on-exit-RhBug-1906831.patch @@ -0,0 +1,106 @@ +From e21b038a231e2743e30915af9575b8c43e9fda1f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= +Date: Tue, 15 Dec 2020 14:15:39 +0100 +Subject: [PATCH] Never leave behind .repodata lock on exit (RhBug:1906831 + +createrepo_c was removing `.repodata` if `exit_val` was se to failure. +Problem is `exit_val` is set only on a couple of places so most of the +failures (no matter how rare) leave `.repodata` behind. + +However because on a successful run `.repodata` is renamed to normal +output `repodata` we know that if `.repodata` are present there was an +error and we can delete them. +--- + src/createrepo_c.c | 5 +---- + src/createrepo_shared.c | 29 +++++++++-------------------- + 2 files changed, 10 insertions(+), 24 deletions(-) + +diff --git a/src/createrepo_c.c b/src/createrepo_c.c +index 8c90ebd..eeb871c 100644 +--- a/src/createrepo_c.c ++++ b/src/createrepo_c.c +@@ -665,9 +665,6 @@ main(int argc, char **argv) + exit(EXIT_FAILURE); + } + +- // Set exit_value pointer used in cleanup handlers +- cr_set_global_exit_value(&exit_val); +- + // Setup cleanup handlers + if (!cr_set_cleanup_handler(lock_dir, tmp_out_repo, &tmp_err)) { + g_printerr("%s\n", tmp_err->message); +@@ -885,7 +882,7 @@ main(int argc, char **argv) + char *moduleindex_str = modulemd_module_index_dump_to_string (moduleindex, &tmp_err); + g_clear_pointer(&moduleindex, g_object_unref); + if (tmp_err) { +- g_critical("%s: Cannot cannot dump module index: %s", __func__, tmp_err->message); ++ g_critical("%s: Cannot dump module index: %s", __func__, tmp_err->message); + free(moduleindex_str); + g_clear_error(&tmp_err); + exit(EXIT_FAILURE); +diff --git a/src/createrepo_shared.c b/src/createrepo_shared.c +index f8ef998..d1a37bd 100644 +--- a/src/createrepo_shared.c ++++ b/src/createrepo_shared.c +@@ -28,8 +28,6 @@ + #include "misc.h" + #include "cleanup.h" + +-int *global_exit_status = NULL; // pointer to exit_value used in failure_exit_cleanup +- + char *global_lock_dir = NULL; // Path to .repodata/ dir that is used as a lock + char *global_tmp_out_repo = NULL; // Path to temporary repodata directory, + // if NULL that it's same as +@@ -43,18 +41,16 @@ char *global_tmp_out_repo = NULL; // Path to temporary repodata directory, + * + */ + static void +-failure_exit_cleanup() ++exit_cleanup() + { +- if (global_exit_status && *global_exit_status != EXIT_SUCCESS) { +- if (global_lock_dir) { +- g_debug("Removing %s", global_lock_dir); +- cr_remove_dir(global_lock_dir, NULL); +- } ++ if (global_lock_dir) { ++ g_debug("Removing %s", global_lock_dir); ++ cr_remove_dir(global_lock_dir, NULL); ++ } + +- if (global_tmp_out_repo) { +- g_debug("Removing %s", global_tmp_out_repo); +- cr_remove_dir(global_tmp_out_repo, NULL); +- } ++ if (global_tmp_out_repo) { ++ g_debug("Removing %s", global_tmp_out_repo); ++ cr_remove_dir(global_tmp_out_repo, NULL); + } + } + +@@ -65,16 +61,9 @@ static void + sigint_catcher(int sig) + { + g_message("%s caught: Terminating...", strsignal(sig)); +- *global_exit_status = 1; + exit(1); + } + +-void +-cr_set_global_exit_value(int *exit_val) +-{ +- global_exit_status = exit_val; +-} +- + gboolean + cr_set_cleanup_handler(const char *lock_dir, + const char *tmp_out_repo, +@@ -90,7 +79,7 @@ cr_set_cleanup_handler(const char *lock_dir, + global_tmp_out_repo = NULL; + + // Register on exit cleanup function +- if (atexit(failure_exit_cleanup)) ++ if (atexit(exit_cleanup)) + g_warning("Cannot set exit cleanup function by atexit()"); + + // Prepare signal handler configuration diff --git a/SPECS/createrepo_c.spec b/SPECS/createrepo_c.spec index 892b16f..4819f89 100644 --- a/SPECS/createrepo_c.spec +++ b/SPECS/createrepo_c.spec @@ -37,10 +37,11 @@ Summary: Creates a common metadata repository Name: createrepo_c Version: 0.16.2 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ URL: https://github.com/rpm-software-management/createrepo_c Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz +Patch0: 0001-Never-leave-behind-repodata-lock-on-exit-RhBug-1906831.patch BuildRequires: cmake BuildRequires: gcc @@ -261,6 +262,9 @@ ln -sr %{buildroot}%{_bindir}/modifyrepo_c %{buildroot}%{_bindir}/modifyrepo %endif %changelog +* Fri Jan 29 2021 Nicola Sella - 0.16.2-2 +- Never leave behind .repodata lock on exit (RhBug:1906831) + * Mon Nov 09 2020 Nicola Sella - 0.16.2-1 - Update to 0.16.2 - Add module metadata support to createrepo_c (RhBug:1795936)