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

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