From 88344fb0277d6bf35c60fcdc37ecc57a3cc96e91 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 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. --- 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); From ee4f02e8c4c0e6696ffe30412c304b576ac416d6 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 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. --- 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; From 85b6f61efd6e16feac4c2fc8baffa3c42e74af8b 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 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. --- 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 From 474c2d7dc8567b49a68a04bafd0b38f233111b18 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 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. --- 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})