From 16f81cf0ed747e3d73458af5ddaab1809790eaba Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 28 Aug 2024 15:22:44 +0200 Subject: [PATCH] csfilter-kfp: install a simple man page ... generated from the output of `--help` Related: https://issues.redhat.com/browse/OSH-736 Closes: https://github.com/csutils/csdiff/pull/201 --- doc/csfilter-kfp.h2m | 2 ++ make-srpm.sh | 4 +++- src/CMakeLists.txt | 19 ++++++++++++++++++- src/csfilter-kfp | 4 ++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 doc/csfilter-kfp.h2m diff --git a/doc/csfilter-kfp.h2m b/doc/csfilter-kfp.h2m new file mode 100644 index 00000000..7ed25d1c --- /dev/null +++ b/doc/csfilter-kfp.h2m @@ -0,0 +1,2 @@ +[NAME] +csfilter-kfp - tool to filter out known false positives in scan results diff --git a/make-srpm.sh b/make-srpm.sh index 0363a768..486d1138 100755 --- a/make-srpm.sh +++ b/make-srpm.sh @@ -189,7 +189,8 @@ make version.cc %cmake3 \\ -DCSGREP_STATIC=%{?with_static:ON} \\ -DPYCSDIFF_PYTHON2=%{?with_python2:ON} \\ - -DPYCSDIFF_PYTHON3=%{?with_python3:ON} + -DPYCSDIFF_PYTHON3=%{?with_python3:ON} \\ + -DVERSION='%{name}-%{version}-%{release}' %cmake3_build %install @@ -210,6 +211,7 @@ make version.cc %{_bindir}/cstrans-df-run %{_datadir}/%{name} %{_mandir}/man1/csdiff.1* +%{_mandir}/man1/csfilter-kfp.1* %{_mandir}/man1/csgrep.1* %{_mandir}/man1/cshtml.1* %{_mandir}/man1/cslinker.1* diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 174de791..3104f96d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -83,8 +83,12 @@ install(TARGETS DESTINATION ${CMAKE_INSTALL_BINDIR}) # install the csfilter-kfp script +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/csfilter-kfp + ${CMAKE_CURRENT_BINARY_DIR}/csfilter-kfp + @ONLY) install(PROGRAMS - csfilter-kfp + ${CMAKE_CURRENT_BINARY_DIR}/csfilter-kfp DESTINATION ${CMAKE_INSTALL_BINDIR}) # optionally build statically linked csgrep-static @@ -190,6 +194,19 @@ if(HELP2MAN) create_manpage(cslinker) create_manpage(cssort) create_manpage(cstrans-df-run) + + # create/install the csfilter-kfp.1 man page + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/csfilter-kfp.1" + COMMAND env LC_ALL=C ${HELP2MAN} --no-info --section 1 + --include "${CMAKE_SOURCE_DIR}/doc/csfilter-kfp.h2m" + ${CMAKE_CURRENT_BINARY_DIR}/csfilter-kfp + > csfilter-kfp.1 || rm -f csfilter-kfp.1 + COMMENT "Generating csfilter-kfp man page" + VERBATIM) + add_custom_target(csfilter-kfp.1 ALL DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/csfilter-kfp.1") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/csfilter-kfp.1 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) else() message(STATUS "help2man not found - documentation will NOT be built") endif() diff --git a/src/csfilter-kfp b/src/csfilter-kfp index c4642f59..bf3169a1 100755 --- a/src/csfilter-kfp +++ b/src/csfilter-kfp @@ -209,6 +209,10 @@ def main(): "-n", "--dry-run", action="store_true", help="do not execute anything, only print the shell script that would be executed") + parser.add_argument( + "--version", action="version", version="@VERSION@", + help="print the version string and exit") + # parse command-line arguments args = parser.parse_args()