diff --git a/SOURCES/0001-Fix-minor-memory-leaks-RhBug1702283.patch b/SOURCES/0001-Fix-minor-memory-leaks-RhBug1702283.patch new file mode 100644 index 0000000..dad7377 --- /dev/null +++ b/SOURCES/0001-Fix-minor-memory-leaks-RhBug1702283.patch @@ -0,0 +1,35 @@ +From 854119bb3cd790333cd7ed135fdc5c9cdca1d551 Mon Sep 17 00:00:00 2001 +From: Aleš Matěj +Date: Tue, 28 May 2019 15:07:11 +0200 +Subject: [PATCH] Fix minor memory leaks, RhBug:1702283 + +--- + dnf/dnf-utils.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/dnf/dnf-utils.c b/dnf/dnf-utils.c +index ea067ad..14f1667 100644 +--- a/dnf/dnf-utils.c ++++ b/dnf/dnf-utils.c +@@ -48,7 +48,9 @@ dnf_utils_add_transaction_packages (struct libscols_table *tb, + struct libscols_line *ln = scols_table_new_line (tb, parent); + scols_line_set_data (ln, COL_NEVRA, dnf_package_get_nevra (pkg)); + scols_line_set_data (ln, COL_REPO, dnf_package_get_reponame (pkg)); +- scols_line_set_data (ln, COL_SIZE, g_format_size (dnf_package_get_size (pkg))); ++ char *formatted_pkg_size = g_format_size (dnf_package_get_size (pkg)); ++ scols_line_set_data (ln, COL_SIZE, formatted_pkg_size); ++ g_free(formatted_pkg_size); + } + } + +@@ -135,6 +137,7 @@ dnf_utils_print_transaction (DnfContext *ctx) + } + + scols_print_table (tb); ++ scols_unref_symbols (sb); + scols_unref_table (tb); + + g_print ("Transaction Summary:\n"); +-- +libgit2 0.27.8 + diff --git a/SOURCES/0002-use-help2man-to-generate-a-man-page.patch b/SOURCES/0002-use-help2man-to-generate-a-man-page.patch new file mode 100644 index 0000000..22d5ba3 --- /dev/null +++ b/SOURCES/0002-use-help2man-to-generate-a-man-page.patch @@ -0,0 +1,202 @@ +From 0b64bc3e081baece71a523c2953456589196a782 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= +Date: Wed, 20 Feb 2019 17:18:00 +0100 +Subject: [PATCH 1/4] Reformat the commands listing in --help (RhBug:1612520) + +Use just spaces as a separator to be consistent with dnf, at least two +spaces are needed so that help2man formats the commands correctly in the +man page. + +https://bugzilla.redhat.com/show_bug.cgi?id=1612520 +--- + dnf/dnf-main.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c +index ef5a04e..08a1ab4 100644 +--- a/dnf/dnf-main.c ++++ b/dnf/dnf-main.c +@@ -210,7 +210,11 @@ main (int argc, + if (!peas_engine_load_plugin (engine, info)) + continue; + if (peas_engine_provides_extension (engine, info, DNF_TYPE_COMMAND)) +- g_string_append_printf (cmd_summary, "\n %s - %s", peas_plugin_info_get_name (info), peas_plugin_info_get_description (info)); ++ /* ++ * At least 2 spaces between the command and its description are needed ++ * so that help2man formats it correctly. ++ */ ++ g_string_append_printf (cmd_summary, "\n %-16s %s", peas_plugin_info_get_name (info), peas_plugin_info_get_description (info)); + } + g_option_context_set_summary (opt_ctx, cmd_summary->str); + g_string_free (cmd_summary, TRUE); +-- +2.21.0 + + +From 92953688100c394aafd3dccc44bece6dea474268 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= +Date: Mon, 17 Jun 2019 12:48:13 +0200 +Subject: [PATCH 2/4] Print only the binary name instead of the full path in + --help (RhBug:1612520) + +Removes the directory path from argv[0] for the program name in --help. +This is required for generating the man page with help2man, as the +build directory would appear in the man page. + +https://bugzilla.redhat.com/show_bug.cgi?id=1612520 +--- + dnf/dnf-main.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c +index 08a1ab4..8417f5a 100644 +--- a/dnf/dnf-main.c ++++ b/dnf/dnf-main.c +@@ -278,7 +278,10 @@ main (int argc, + + if (cmd_name == NULL && show_help) + { +- g_set_prgname (argv[0]); ++ const char *prg_name = strrchr(argv[0], '/') + 1; ++ prg_name = prg_name ? prg_name : argv[0]; ++ ++ g_set_prgname (prg_name); + g_autofree gchar *help = g_option_context_get_help (opt_ctx, TRUE, NULL); + g_print ("%s", help); + goto out; +-- +2.21.0 + + +From 358a19c61cd469ad7c178da797835f653f8a9ad1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= +Date: Wed, 20 Feb 2019 15:17:33 +0100 +Subject: [PATCH 3/4] Add generating a manpage using help2man to meson.build + (RhBug:1612520) + +Generates a man page using help2man. Note: + +- The version in meson.build now needs to be updated on every release, + it is used in the man page. + +- help2man is a new build dependency. + +- Packagers should add the generated man page to packages. + +https://bugzilla.redhat.com/show_bug.cgi?id=1612520 +--- + dnf/meson.build | 2 +- + meson.build | 21 ++++++++++++++++++++- + 2 files changed, 21 insertions(+), 2 deletions(-) + +diff --git a/dnf/meson.build b/dnf/meson.build +index fe37998..f8f1bf3 100644 +--- a/dnf/meson.build ++++ b/dnf/meson.build +@@ -40,7 +40,7 @@ microdnf_srcs = [ + 'plugins/clean/dnf-command-clean.c', + ] + +-executable( ++microdnf = executable( + 'microdnf', + sources : microdnf_srcs, + dependencies : [ +diff --git a/meson.build b/meson.build +index 1f01ae0..a3601aa 100644 +--- a/meson.build ++++ b/meson.build +@@ -1,5 +1,5 @@ + project('microdnf', 'c', +- version : '1', ++ version : '3.0.1', + license : 'GPL-3.0+', + default_options : [ + 'b_asneeded=True', +@@ -44,3 +44,22 @@ add_project_arguments( + ) + + subdir('dnf') ++ ++help2man = find_program('help2man', required: true) ++if help2man.found() ++ help2man_opts = [ ++ '--version-string=' + meson.project_version(), ++ '--no-info', ++ '--section=8', ++ '--name=Micro DNF', ++ ] ++ ++ custom_target('microdnf.8', ++ output: 'microdnf.8', ++ command: [ ++ help2man, help2man_opts, '--output=@OUTPUT@', microdnf ++ ], ++ install: true, ++ install_dir: get_option('mandir') + '/man8', ++ ) ++endif +-- +2.21.0 + + +From 8719ff443ad3ec96068e8fe316da6f3d1282bee3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= +Date: Mon, 17 Jun 2019 15:10:33 +0200 +Subject: [PATCH 4/4] Add generating a manpage using help2man to CMakeLists.txt + (RhBug:1612520) + +Generates a man page using help2man. Note: + +- The version in CMakeLists.txt now needs to be updated on every + release, it is used in the man page. + +- help2man is a new build dependency. + +- Packagers should add the generated man page to packages. + +https://bugzilla.redhat.com/show_bug.cgi?id=1612520 +--- + CMakeLists.txt | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 435d7e8..dcf8e2f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,6 @@ + cmake_minimum_required (VERSION 2.8.5) + project (microdnf C) ++set (PROJECT_VERSION 3.0.1) + + list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + +@@ -25,6 +26,25 @@ set (PKG_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/dnf) + add_definitions (-DPACKAGE_LIBDIR="${PKG_LIBDIR}") + add_definitions (-DPACKAGE_DATADIR="${PKG_DATADIR}") + ++find_file (HELP2MAN_EXECUTABLE help2man) ++if (NOT HELP2MAN_EXECUTABLE) ++ message (FATAL_ERROR "unable to find help2man") ++endif () ++ ++set (MANPAGE ${CMAKE_CURRENT_BINARY_DIR}/microdnf.8) ++add_custom_command ( ++ DEPENDS microdnf ++ OUTPUT ${MANPAGE} ++ COMMAND ${HELP2MAN_EXECUTABLE} $ ++ --version-string=${PROJECT_VERSION} ++ --no-info ++ --section=8 ++ --name="Micro DNF" ++ --output=${MANPAGE} ++) ++add_custom_target (manpage ALL DEPENDS ${MANPAGE}) ++install (FILES ${MANPAGE} DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man8) ++ + include_directories (${GLIB_INCLUDE_DIRS}) + include_directories (${GOBJECT_INCLUDE_DIRS}) + include_directories (${PEAS_INCLUDE_DIRS}) +-- +2.21.0 + diff --git a/SOURCES/0003-Fix-microdnf---help-coredump.patch b/SOURCES/0003-Fix-microdnf---help-coredump.patch new file mode 100644 index 0000000..16780d1 --- /dev/null +++ b/SOURCES/0003-Fix-microdnf---help-coredump.patch @@ -0,0 +1,30 @@ +From 958cb3f52a128c0c1720d2a40a5b98a0c7625ee0 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel +Date: Fri, 23 Aug 2019 12:42:42 +0200 +Subject: [PATCH] Fix "microdnf --help" coredump + +There was a bug that causes coredump during comand "microdnf --help". +The bug was in the code that removes the directory path from argv[0] +(in case argv[0] does not contain '/' character). +--- + dnf/dnf-main.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c +index 8417f5a..a615e37 100644 +--- a/dnf/dnf-main.c ++++ b/dnf/dnf-main.c +@@ -278,8 +278,8 @@ main (int argc, + + if (cmd_name == NULL && show_help) + { +- const char *prg_name = strrchr(argv[0], '/') + 1; +- prg_name = prg_name ? prg_name : argv[0]; ++ const char *prg_name = strrchr(argv[0], '/'); ++ prg_name = prg_name ? prg_name + 1 : argv[0]; + + g_set_prgname (prg_name); + g_autofree gchar *help = g_option_context_get_help (opt_ctx, TRUE, NULL); +-- +libgit2 0.28.2 + diff --git a/SPECS/microdnf.spec b/SPECS/microdnf.spec index 75a27b9..96a8169 100644 --- a/SPECS/microdnf.spec +++ b/SPECS/microdnf.spec @@ -1,11 +1,14 @@ Name: microdnf Version: 3.0.1 -Release: 1%{?dist} +Release: 3%{?dist} Summary: Micro DNF License: GPLv3+ URL: https://github.com/rpm-software-management/microdnf Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz +Patch0: 0001-Fix-minor-memory-leaks-RhBug1702283.patch +Patch1: 0002-use-help2man-to-generate-a-man-page.patch +Patch2: 0003-Fix-microdnf---help-coredump.patch BuildRequires: gcc BuildRequires: meson >= 0.36.0 @@ -14,6 +17,7 @@ BuildRequires: pkgconfig(gobject-2.0) >= 2.44.0 BuildRequires: pkgconfig(libpeas-1.0) >= 1.20.0 BuildRequires: pkgconfig(libdnf) >= 0.7.0 BuildRequires: pkgconfig(smartcols) +BuildRequires: help2man %description %{summary}. @@ -35,8 +39,16 @@ BuildRequires: pkgconfig(smartcols) %license COPYING %doc README.md %{_bindir}/%{name} +%{_mandir}/man8/%{name}.8* %changelog +* Fri Aug 30 2019 Pavla Kratochvilova - 3.0.1-3 +- Fix microdnf --help coredump (RhBug:1744979) + +* Thu Aug 01 2019 Pavla Kratochvilova - 3.0.1-2 +- Fix minor memory leaks (RhBug:1702283) +- Use help2man to generate a man page (RhBug:1612520) + * Wed Jun 27 2018 Jaroslav Mracek - 3.0.1-1 - Update to 3.0.1