Blame SOURCES/0003-use-help2man-to-generate-a-man-page.patch

94e8a5
From a8d57daa4b7a98176a98af29e52c1df1295659cb Mon Sep 17 00:00:00 2001
94e8a5
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
94e8a5
Date: Wed, 20 Feb 2019 17:18:00 +0100
94e8a5
Subject: [PATCH 1/4] Reformat the commands listing in --help
94e8a5
94e8a5
Use just spaces as a separator to be consistent with dnf, at least two
94e8a5
spaces are needed so that help2man formats the commands correctly in the
94e8a5
man page.
94e8a5
---
94e8a5
 dnf/dnf-main.c | 6 +++++-
94e8a5
 1 file changed, 5 insertions(+), 1 deletion(-)
94e8a5
94e8a5
diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
94e8a5
index 2381f20..fd6406d 100644
94e8a5
--- a/dnf/dnf-main.c
94e8a5
+++ b/dnf/dnf-main.c
94e8a5
@@ -215,7 +215,11 @@ main (int   argc,
94e8a5
       if (!peas_engine_load_plugin (engine, info))
94e8a5
         continue;
94e8a5
       if (peas_engine_provides_extension (engine, info, DNF_TYPE_COMMAND))
94e8a5
-        g_string_append_printf (cmd_summary, "\n  %s - %s", peas_plugin_info_get_name (info), peas_plugin_info_get_description (info));
94e8a5
+        /*
94e8a5
+         * At least 2 spaces between the command and its description are needed
94e8a5
+         * so that help2man formats it correctly.
94e8a5
+         */
94e8a5
+        g_string_append_printf (cmd_summary, "\n  %-16s     %s", peas_plugin_info_get_name (info), peas_plugin_info_get_description (info));
94e8a5
     }
94e8a5
   g_option_context_set_summary (opt_ctx, cmd_summary->str);
94e8a5
   g_string_free (cmd_summary, TRUE);
94e8a5
-- 
94e8a5
2.24.0
94e8a5
94e8a5
94e8a5
From 838a235bba14d48f65ba760f35f32f9d090043fe Mon Sep 17 00:00:00 2001
94e8a5
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
94e8a5
Date: Mon, 17 Jun 2019 12:48:13 +0200
94e8a5
Subject: [PATCH 2/4] Print only the binary name instead of the full path in
94e8a5
 --help
94e8a5
94e8a5
Removes the directory path from argv[0] for the program name in --help.
94e8a5
This is required for generating the man page with help2man, as the
94e8a5
build directory would appear in the man page.
94e8a5
---
94e8a5
 dnf/dnf-main.c | 5 ++++-
94e8a5
 1 file changed, 4 insertions(+), 1 deletion(-)
94e8a5
94e8a5
diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
94e8a5
index fd6406d..e35ace0 100644
94e8a5
--- a/dnf/dnf-main.c
94e8a5
+++ b/dnf/dnf-main.c
94e8a5
@@ -298,7 +298,10 @@ main (int   argc,
94e8a5
 
94e8a5
   if (cmd_name == NULL && show_help)
94e8a5
     {
94e8a5
-      g_set_prgname (argv[0]);
94e8a5
+      const char *prg_name = strrchr(argv[0], '/') + 1;
94e8a5
+      prg_name = prg_name ? prg_name : argv[0];
94e8a5
+
94e8a5
+      g_set_prgname (prg_name);
94e8a5
       g_autofree gchar *help = g_option_context_get_help (opt_ctx, TRUE, NULL);
94e8a5
       g_print ("%s", help);
94e8a5
       goto out;
94e8a5
-- 
94e8a5
2.24.0
94e8a5
94e8a5
94e8a5
From b00e2adb2520f11442f3a7cf3710e64f5f60dab2 Mon Sep 17 00:00:00 2001
94e8a5
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lukkash@email.cz>
94e8a5
Date: Wed, 20 Feb 2019 15:17:33 +0100
94e8a5
Subject: [PATCH 3/4] Add generating a manpage using help2man to meson.build
94e8a5
94e8a5
Generates a man page using help2man. Note:
94e8a5
94e8a5
- The version in meson.build now needs to be updated on every release,
94e8a5
  it is used in the man page.
94e8a5
94e8a5
- help2man is a new build dependency.
94e8a5
94e8a5
- Packagers should add the generated man page to packages.
94e8a5
---
94e8a5
 dnf/meson.build |  2 +-
94e8a5
 meson.build     | 21 ++++++++++++++++++++-
94e8a5
 2 files changed, 21 insertions(+), 2 deletions(-)
94e8a5
94e8a5
diff --git a/dnf/meson.build b/dnf/meson.build
94e8a5
index fe37998..f8f1bf3 100644
94e8a5
--- a/dnf/meson.build
94e8a5
+++ b/dnf/meson.build
94e8a5
@@ -40,7 +40,7 @@ microdnf_srcs = [
94e8a5
   'plugins/clean/dnf-command-clean.c',
94e8a5
 ]
94e8a5
 
94e8a5
-executable(
94e8a5
+microdnf = executable(
94e8a5
   'microdnf',
94e8a5
   sources : microdnf_srcs,
94e8a5
   dependencies : [
94e8a5
diff --git a/meson.build b/meson.build
94e8a5
index 1f01ae0..a3601aa 100644
94e8a5
--- a/meson.build
94e8a5
+++ b/meson.build
94e8a5
@@ -1,5 +1,5 @@
94e8a5
 project('microdnf', 'c',
94e8a5
-        version : '1',
94e8a5
+        version : '3.0.1',
94e8a5
         license : 'GPL-3.0+',
94e8a5
         default_options : [
94e8a5
           'b_asneeded=True',
94e8a5
@@ -44,3 +44,22 @@ add_project_arguments(
94e8a5
 )
94e8a5
 
94e8a5
 subdir('dnf')
94e8a5
+
94e8a5
+help2man = find_program('help2man', required: true)
94e8a5
+if help2man.found()
94e8a5
+  help2man_opts = [
94e8a5
+    '--version-string=' + meson.project_version(),
94e8a5
+    '--no-info',
94e8a5
+    '--section=8',
94e8a5
+    '--name=Micro DNF',
94e8a5
+  ]
94e8a5
+
94e8a5
+  custom_target('microdnf.8',
94e8a5
+                output: 'microdnf.8',
94e8a5
+                command: [
94e8a5
+                  help2man, help2man_opts, '--output=@OUTPUT@', microdnf
94e8a5
+                ],
94e8a5
+                install: true,
94e8a5
+                install_dir: get_option('mandir') + '/man8',
94e8a5
+  )
94e8a5
+endif
94e8a5
-- 
94e8a5
2.24.0
94e8a5
94e8a5
94e8a5
From a1c777a4383ccc5f35396e86e6f3b0a1af92bc7c Mon Sep 17 00:00:00 2001
94e8a5
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
94e8a5
Date: Mon, 17 Jun 2019 15:10:33 +0200
94e8a5
Subject: [PATCH 4/4] Add generating a manpage using help2man to CMakeLists.txt
94e8a5
94e8a5
Generates a man page using help2man. Note:
94e8a5
94e8a5
- The version in CMakeLists.txt now needs to be updated on every
94e8a5
  release, it is used in the man page.
94e8a5
94e8a5
- help2man is a new build dependency.
94e8a5
94e8a5
- Packagers should add the generated man page to packages.
94e8a5
---
94e8a5
 CMakeLists.txt | 20 ++++++++++++++++++++
94e8a5
 1 file changed, 20 insertions(+)
94e8a5
94e8a5
diff --git a/CMakeLists.txt b/CMakeLists.txt
94e8a5
index 435d7e8..dcf8e2f 100644
94e8a5
--- a/CMakeLists.txt
94e8a5
+++ b/CMakeLists.txt
94e8a5
@@ -1,5 +1,6 @@
94e8a5
 cmake_minimum_required (VERSION 2.8.5)
94e8a5
 project (microdnf C)
94e8a5
+set (PROJECT_VERSION 3.0.1)
94e8a5
 
94e8a5
 list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
94e8a5
 
94e8a5
@@ -25,6 +26,25 @@ set (PKG_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/dnf)
94e8a5
 add_definitions (-DPACKAGE_LIBDIR="${PKG_LIBDIR}")
94e8a5
 add_definitions (-DPACKAGE_DATADIR="${PKG_DATADIR}")
94e8a5
 
94e8a5
+find_file (HELP2MAN_EXECUTABLE help2man)
94e8a5
+if (NOT HELP2MAN_EXECUTABLE)
94e8a5
+  message (FATAL_ERROR "unable to find help2man")
94e8a5
+endif ()
94e8a5
+
94e8a5
+set (MANPAGE ${CMAKE_CURRENT_BINARY_DIR}/microdnf.8)
94e8a5
+add_custom_command (
94e8a5
+  DEPENDS microdnf
94e8a5
+  OUTPUT ${MANPAGE}
94e8a5
+  COMMAND ${HELP2MAN_EXECUTABLE} $<TARGET_FILE:microdnf>
94e8a5
+  --version-string=${PROJECT_VERSION}
94e8a5
+  --no-info
94e8a5
+  --section=8
94e8a5
+  --name="Micro DNF"
94e8a5
+  --output=${MANPAGE}
94e8a5
+)
94e8a5
+add_custom_target (manpage ALL DEPENDS ${MANPAGE})
94e8a5
+install (FILES ${MANPAGE} DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man8)
94e8a5
+
94e8a5
 include_directories (${GLIB_INCLUDE_DIRS})
94e8a5
 include_directories (${GOBJECT_INCLUDE_DIRS})
94e8a5
 include_directories (${PEAS_INCLUDE_DIRS})
94e8a5
-- 
94e8a5
2.24.0
94e8a5