]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3254] consistent version output across executables
authorAndrei Pavel <andrei@isc.org>
Tue, 23 Apr 2024 16:57:05 +0000 (19:57 +0300)
committerAndrei Pavel <andrei@isc.org>
Wed, 24 Apr 2024 12:23:48 +0000 (15:23 +0300)
- replace VERSION with PACKAGE_VERSION in src/bin/admin to avoid
  overlap with VERSION used in src/share/database.
- add -V to kea-admin
- add -V to kea-shell
- add -V to keactrl
- add -V to perfdhcp
- removed getVersionAddendum from d2 and added the openssl version to
  the output of other process versions since it's not only used by d2
- make all -V outputs consistent. Some are showing only core version and
  are missing premium version which is fine since they are the
  executables that don't have something to do with premium directly
  anyway.

27 files changed:
configure.ac
doc/sphinx/arm/ddns.rst
doc/sphinx/arm/shell.rst
doc/sphinx/man/kea-admin.8.rst
doc/sphinx/man/kea-ctrl-agent.8.rst
doc/sphinx/man/kea-dhcp-ddns.8.rst
doc/sphinx/man/kea-dhcp4.8.rst
doc/sphinx/man/kea-dhcp6.8.rst
doc/sphinx/man/kea-lfc.8.rst
doc/sphinx/man/kea-netconf.8.rst
doc/sphinx/man/kea-shell.8.rst
doc/sphinx/man/keactrl.8.rst
doc/sphinx/man/perfdhcp.8.rst
src/bin/admin/kea-admin.in
src/bin/d2/d2_controller.cc
src/bin/d2/d2_controller.h
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/keactrl/keactrl.in
src/bin/lfc/lfc_controller.cc
src/bin/perfdhcp/command_options.cc
src/bin/perfdhcp/command_options.h
src/bin/shell/kea-shell.in
src/lib/process/cfgrpt/tests/config_report_unittests.cc
src/lib/process/d_controller.cc
src/lib/process/d_controller.h
src/lib/process/tests/d_controller_unittests.cc

index c7ad92d8c952fd43d6304e6c8e3a01f681971496..f25058c8ca3574b278f83ff1d3bec61ce449409f 100644 (file)
@@ -61,7 +61,7 @@ else
         AC_MSG_RESULT("tarball")
 fi
 
-# Export KEA_SRCID to config.h
+# Export KEA_SRCID to a C++ header.
 # This will be either package version or "tarball" or "git abcd".
 # We do not want to put this in a config.h, because it messes up ccache
 # horribly. When building different branches, the commit-id is different
@@ -1823,16 +1823,13 @@ AC_CONFIG_FILES([tools/path_replacer.sh],
 AC_CONFIG_FILES([tools/extract_bnf.sh],
                 [chmod +x tools/extract_bnf.sh])
 
-
-AC_OUTPUT
-
-dnl Print the results
-dnl
-
 EXTENDED_VERSION=${PACKAGE_VERSION}
 if test "$KEA_SRCID" != ""; then
    EXTENDED_VERSION="${EXTENDED_VERSION} ($KEA_SRCID)"
 fi
+AC_SUBST(EXTENDED_VERSION)
+
+AC_OUTPUT
 
 # By default the following variables are defined:
 # - prefix = /usr/local
@@ -1850,6 +1847,7 @@ fi
 libdir_real="$(eval echo ${libdir})"
 libdir_real="$(eval echo ${libdir_real})"
 
+# Print the report.
 cat > config.report << END
 
        Kea source configure results:
index bab8c96a65542a2bec9e220423f3e3930d05b235..df9a4ec7a19c96226038030a089d28187d6e7f26 100644 (file)
@@ -133,6 +133,8 @@ directly. It accepts the following command-line switches:
 
 -  ``-v`` - displays the Kea version and exits.
 
+-  ``-V`` - displays the extended Kea version and exits.
+
 -  ``-W`` - displays the Kea configuration report and exits. The report
    is a copy of the ``config.report`` file produced by ``./configure``;
    it is embedded in the executable binary.
index 62a9900c69996dabfb8171bd2202a1a40c2182aa..377145a3ce7b74e313a80dae923e2fa145f96243 100644 (file)
@@ -66,7 +66,9 @@ Other switches are:
 
 -  ``-h`` - prints a help message.
 
--  ``-v`` - prints the software version.
+-  ``-v`` - displays the Kea version.
+
+-  ``-V`` - displays the extended Kea version.
 
 See :ref:`shell-tls` for new command-line arguments associated with TLS/HTTPS support.
 
index 05f5d16db3183acf93d704c64aaa3f7ca1907b45..ee628bb6d3b13c0a77d364d8cd7012247f4fb887 100644 (file)
@@ -111,7 +111,10 @@ Arguments
    ``lease-dump``.
 
 ``-v|--version``
-   Prints the ``kea-admin`` version and quits.
+   Displays the Kea version.
+
+``-V``
+   Displays the extended Kea version.
 
 ``-4``
    Directs ``kea-admin`` to lease-dump the DHCPv4 leases. Incompatible with
index 815c0e3b9085ad62906d257bda2af2aa0dcb9637..03aeccd44e1e1f067e0246b5367c6d91488641dc 100644 (file)
@@ -34,10 +34,10 @@ Arguments
 The arguments are as follows:
 
 ``-v``
-   Displays the version.
+   Displays the Kea version.
 
 ``-V``
-   Displays the extended version.
+   Displays the extended Kea version.
 
 ``-W``
    Displays the configuration report.
index ecaf3fde01eff6873525593a88b8d601b65ab44b..eba83ac43971c33ac5f9f03f002e0ae01ac16f8e 100644 (file)
@@ -31,10 +31,10 @@ Arguments
 The arguments are as follows:
 
 ``-v``
-   Displays the version.
+   Displays the Kea version.
 
 ``-V``
-   Displays the extended version.
+   Displays the extended Kea version.
 
 ``-W``
    Displays the configuration report.
index 6bc42f46ea661c606744a3d3751d2ec052a903f1..eec7dcba440758497701cb3ad88972dac65a17e5 100644 (file)
@@ -29,10 +29,10 @@ Arguments
 The arguments are as follows:
 
 ``-v``
-   Displays the version.
+   Displays the Kea version.
 
 ``-V``
-   Displays the extended version.
+   Displays the extended Kea version.
 
 ``-W``
    Displays the configuration report.
index d18e7b6b131328b7cb9fe374682df02e3a9a5068..d42f3e1fde0216a2714f3a32ac96d7cb44899349 100644 (file)
@@ -29,10 +29,10 @@ Arguments
 The arguments are as follows:
 
 ``-v``
-   Displays the version.
+   Displays the Kea version.
 
 ``-V``
-   Displays the extended version.
+   Displays the extended Kea version.
 
 ``-W``
    Displays the configuration report.
index d00e97d40aaa55449cc9238ab104ef67814212f4..16d36e3ed41c5629adc022a64bc29b8be60289e2 100644 (file)
@@ -73,10 +73,10 @@ The arguments are as follows:
    if one of the processes was interrupted before completing its task.
 
 ``-v``
-   Causes the version stamp to be printed.
+   Displays the Kea version.
 
 ``-V``
-   Causes a longer form of the version stamp to be printed.
+   Displays the extended Kea version.
 
 ``-W``
    Displays the configuration report.
index d9cf92e9dc0d519b4bdc6cd11592a2921e2d4cf9..30adfbe3f8691e09608c52df9403931a468cb0d8 100644 (file)
@@ -30,10 +30,10 @@ Arguments
 The arguments are as follows:
 
 ``-v``
-   Displays the version.
+   Displays the Kea version.
 
 ``-V``
-   Displays the extended version.
+   Displays the extended Kea version.
 
 ``-W``
    Displays the configuration report.
index d46af789a3305c156d66327fc3180303df3135ae..b591a062a91faca2d494de0a420fa236af320a98 100644 (file)
@@ -38,7 +38,7 @@ The arguments are as follows:
    Displays help regarding command-line parameters.
 
 ``-v``
-   Displays the version.
+   Displays the Kea version.
 
 ``--host``
    Specifies the host to connect to. The Control Agent must be running at the
index ca188e631a0dc5f1f0a74895e79b42578d06d6d6..5b5e4320224cd605e903d5f45f513f106c3f61e7 100644 (file)
@@ -87,7 +87,10 @@ Options
       built. This is the default.
 
 ``-v|--version``
-   Prints the ``keactrl`` version and quits.
+   Displays the Kea version.
+
+``-V``
+   Displays the extended Kea version.
 
 Documentation
 ~~~~~~~~~~~~~
index 465d6f051f334e93c28fb51f571355e199857409..74d0c11e97a99bd132434de0b7a8c9588d8cf7c0 100644 (file)
@@ -287,7 +287,10 @@ Options
    releasing it.
 
 ``-v``
-   Prints the version of this program.
+   Displays the Kea version.
+
+``-V``
+   Displays the extended Kea version.
 
 ``-W exit-wait-time``
    Specifies the exit-wait-time parameter, which causes ``perfdhcp`` to wait for
index 12bcd5a39ab5d872927983935e7312d72dddc721..283e446c47db53cf3c1328c7f64bd8d3cc1c6d20 100644 (file)
@@ -32,7 +32,8 @@ exec_prefix="@exec_prefix@"
 export exec_prefix
 BASENAME=$(basename ${0})
 SCRIPTS_DIR_DEFAULT="@datarootdir@/@PACKAGE@/scripts"
-VERSION="@PACKAGE_VERSION@"
+PACKAGE_VERSION="@PACKAGE_VERSION@"
+EXTENDED_VERSION="@EXTENDED_VERSION@"
 
 assume_yes=0
 
@@ -99,7 +100,7 @@ PARAMETERS: Parameters are optional in general, but may be required
      -i or --input to specify the name of file from which leases will be uploaded
      -o or --output to specify the name of file to which leases will be dumped
      -y or --yes - assume yes on overwriting temporary files
-' "${BASENAME}" "${VERSION}" "${BASENAME}" "${SCRIPTS_DIR_DEFAULT}"
+' "${BASENAME}" "${PACKAGE_VERSION}" "${BASENAME}" "${SCRIPTS_DIR_DEFAULT}"
 }
 
 ### Logging functions ###
@@ -819,8 +820,13 @@ if test "${command}" = "--help" ; then
 fi
 
 # Check if this is a simple question about version.
-if test "${command}" = "-v" || test "${command}" = "--version" ; then
-    echo "${VERSION}"
+if test "${command}" = "-v" || test "${command}" = "--version"; then
+    echo "${PACKAGE_VERSION}"
+    exit 0
+fi
+
+if test "${command}" = "-V"; then
+    echo "${EXTENDED_VERSION}"
     exit 0
 fi
 
index 0d0d8167915b8922929fbdf48fb52d790d6ff8af..448a6ddb2022e608f8871e285c6de67a24bd0f66 100644 (file)
@@ -144,14 +144,5 @@ D2Controller::parseFile(const std::string& file_name) {
 D2Controller::~D2Controller() {
 }
 
-std::string
-D2Controller::getVersionAddendum() {
-    std::stringstream stream;
-    // Currently the only dependency D2 adds to base is cryptolink
-    stream << isc::cryptolink::CryptoLink::getVersion() << std::endl;
-    return (stream.str());
-
-}
-
 } // end namespace isc::d2
 } // end namespace isc
index 6f61735828a53fc93cebc916b5840fdc9bcaefad..ffd1210e30bb5054ce5cee26c8c6d6b86162e40d 100644 (file)
@@ -53,10 +53,6 @@ public:
     /// @note Does not throw.
     void deregisterCommands();
 
-protected:
-    /// @brief Returns version info specific to D2
-    virtual std::string getVersionAddendum();
-
 private:
     /// @brief Creates an instance of the DHCP-DDNS specific application
     /// process.  This method is invoked during the process initialization
index f504f4cbfcbfdf782ebcc81ede13e4bdb462cbd5..1a63a305b5e4172ab12aad59cf07ae4b97af2769 100644 (file)
@@ -4832,7 +4832,7 @@ Dhcpv4Srv::getVersion(bool extended) {
 
     tmp << VERSION;
     if (extended) {
-        tmp << endl << EXTENDED_VERSION << endl;
+        tmp << " (" << EXTENDED_VERSION << ")" << endl;
         tmp << "premium: " << PREMIUM_EXTENDED_VERSION << endl;
         tmp << "linked with:" << endl;
         tmp << "- " << Logger::getVersion() << endl;
index bef647b15145031c54b4ae875e1db579e7c4cb8c..fe8e34e63a59e02bdfcd2f931bb1e6680208c843 100644 (file)
@@ -4653,7 +4653,7 @@ Dhcpv6Srv::getVersion(bool extended) {
 
     tmp << VERSION;
     if (extended) {
-        tmp << endl << EXTENDED_VERSION << endl;
+        tmp << " (" << EXTENDED_VERSION << ")" << endl;
         tmp << "premium: " << PREMIUM_EXTENDED_VERSION << endl;
         tmp << "linked with:" << endl;
         tmp << "- " << Logger::getVersion() << endl;
index 22a3f9af4a7e5f2f75c017ce2a664315866a5792..cccfdac303156e5957a0f3ac0c94aae79576edf5 100644 (file)
@@ -21,7 +21,8 @@
 # used.
 set -eu
 
-VERSION="@PACKAGE_VERSION@"
+PACKAGE_VERSION="@PACKAGE_VERSION@"
+EXTENDED_VERSION="@EXTENDED_VERSION@"
 
 # Set the have_netconf flag to know if netconf is available.
 if test '@HAVE_NETCONF@' = 'yes'; then
@@ -338,8 +339,13 @@ if [ -z "${command}" ]; then
 fi
 
 # Check if this is a simple question about version.
-if test "${command}" = "-v" || test "${command}" = "--version" ; then
-    echo "${VERSION}"
+if test "${command}" = "-v" || test "${command}" = "--version"; then
+    echo "${PACKAGE_VERSION}"
+    exit 0
+fi
+
+if test "${command}" = "-V"; then
+    echo "${EXTENDED_VERSION}"
     exit 0
 fi
 
@@ -576,7 +582,7 @@ ${args}" 1
         exit 0 ;;
 
     version)
-        echo "keactrl: ${VERSION}"
+        echo "keactrl: ${PACKAGE_VERSION}"
         run_conditional "dhcp4" "print_version kea-dhcp4 ${dhcp4_srv}" 0
         run_conditional "dhcp6" "print_version kea-dhcp6 ${dhcp6_srv}" 0
         run_conditional "dhcp_ddns" "print_version kea-dhcp-ddns ${dhcp_ddns_srv}" 0
index d73e8baec41e36d70150e6a67a828e1bc75d9ec0..4aa06514b573849fa0de4a4888783c24872b803f 100644 (file)
@@ -329,7 +329,7 @@ LFCController::getVersion(const bool extended) const{
             db_version = Memfile_LeaseMgr::getDBVersion(Memfile_LeaseMgr::V6);
         }
 
-        version_stream << std::endl << EXTENDED_VERSION;
+        version_stream << " (" << EXTENDED_VERSION << ")";
         if (!db_version.empty()) {
             db_version = "backend: " + db_version;
             version_stream << std::endl << db_version;
index 068065156bbd532bac95b80d3e9de9139b1f79e0..85d58a2d1b3c1c39c04cfadca72bdd8b60ec72f5 100644 (file)
@@ -5,6 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 #include <config.h>
+#include <kea_version.h>
 
 #include <perfdhcp/command_options.h>
 
@@ -207,7 +208,7 @@ CommandOptions::parse(int argc, char** const argv, bool print_cmd_line) {
     // Reset values of class members
     reset();
 
-    // Informs if program has been run with 'h' or 'v' option.
+    // Informs if program has been run with 'h', 'v' or 'V' option.
     bool help_or_version_mode = initialize(argc, argv, print_cmd_line);
     if (!help_or_version_mode) {
         validate();
@@ -245,7 +246,7 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
     // In this section we collect argument values from command line
     // they will be tuned and validated elsewhere
     while((opt = getopt_long(argc, argv,
-                             "huv46A:r:t:R:b:n:p:d:D:l:P:a:L:N:M:s:iBc1"
+                             "huvV46A:r:t:R:b:n:p:d:D:l:P:a:L:N:M:s:iBc1"
                              "J:T:X:O:o:E:S:I:x:W:w:e:f:F:g:C:y:Y:",
                              long_options, &opt_long_index)) != -1) {
         stream << " -";
@@ -562,6 +563,10 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
             version();
             return (true);
 
+        case 'V':
+            extendedVersion();
+            return (true);
+
         case 'w':
             wrapped_ = nonEmptyString("command for wrapped mode:"
                                       " -w<command> must be specified");
@@ -1365,7 +1370,8 @@ Options:
 -u: Enable checking address uniqueness. Lease valid lifetime should not be
     shorter than test duration and clients should not request address more than
     once without releasing it first.
--v: Report the version number of this program.
+-v: Display the Kea version.
+-V: Display the extended Kea version.
 -W<time>: Specifies exit-wait-time parameter, that makes perfdhcp wait
     for <time> us after an exit condition has been met to receive all
     packets without sending any new packets. Expressed in microseconds.
@@ -1442,7 +1448,12 @@ The exit status is:
 
 void
 CommandOptions::version() const {
-    std::cout << "VERSION: " << VERSION << std::endl;
+    std::cout << VERSION << std::endl;
+}
+
+void
+CommandOptions::extendedVersion() const {
+    cout << VERSION << " (" << EXTENDED_VERSION << ")" << endl;
 }
 
 
index d47f6a1d96b87d7faf4eb98c325e14470bff8ae0..f9840b12ba875aa05386524200a02e13ef68f2d2 100644 (file)
@@ -445,10 +445,11 @@ public:
     static void usage();
 
     /// \brief Print program version.
-    ///
-    /// Prints perfdhcp version.
     void version() const;
 
+    /// @brief Print extended program version.
+    void extendedVersion() const;
+
 private:
     /// \brief Initializes class members based on the command line.
     ///
index 30988619d79f4cf9307202a4d7954c99acb39870..f4e8292423e8066bc761b88106b3a67295042f7f 100644 (file)
@@ -29,6 +29,7 @@ from kea_conn import CARequest  # CAResponse
 
 
 VERSION = "@PACKAGE_VERSION@"
+EXTENDED_VERSION = "@EXTENDED_VERSION@"
 
 
 def timeout_handler(signum, frame):
@@ -81,12 +82,17 @@ def shell_body():
                         help='command to be executed. If not specified, '
                         '"list-commands" is used')
     parser.add_argument('-v', action="store_true", help="Prints version")
+    parser.add_argument('-V', action="store_true", help="Prints extended version")
     cmd_args = parser.parse_args()
 
     if cmd_args.v:
         print(VERSION)
         sys.exit(0)
 
+    if cmd_args.V:
+        print(EXTENDED_VERSION)
+        sys.exit(0)
+
     # Ok, now it's time to put the parameters parsed into the structure to be
     # used by the connection.
     params = CARequest()
index b5e8f5b0e8782020d824ed4a4b55e57ccfa4ec5c..d6b4b2d03f14c2c338c9a083f450be198df7ae14 100644 (file)
@@ -23,5 +23,6 @@ TEST(ConfigReportTest, getConfigReport) {
     // Verify that it is not empty and does contain the
     // extended version number
     ASSERT_FALSE(cfgReport.empty());
-    EXPECT_NE(std::string::npos, cfgReport.find(EXTENDED_VERSION, 0));
+    EXPECT_NE(std::string::npos, cfgReport.find(VERSION));
+    EXPECT_NE(std::string::npos, cfgReport.find(EXTENDED_VERSION));
 }
index 0bfc353f9d688db7980c90e8896b7a7d509a823f..b5f7e14184a48e22fd861a03ffc6da43f61b932e 100644 (file)
@@ -863,11 +863,11 @@ DControllerBase::getVersion(bool extended) {
 
     tmp << VERSION;
     if (extended) {
-        tmp << std::endl << EXTENDED_VERSION << std::endl;
+        tmp << " (" << EXTENDED_VERSION << ")" << std::endl;
         tmp << "premium: " << PREMIUM_EXTENDED_VERSION << std::endl;
         tmp << "linked with:" << std::endl;
         tmp << "- " << isc::log::Logger::getVersion() << std::endl;
-        tmp << getVersionAddendum();
+        tmp << "- " << isc::cryptolink::CryptoLink::getVersion();
     }
 
     return (tmp.str());
index 0bbefda958ac43e77233feeeaffc15bf97e79c16..91b777b786a9cc91ba73828050742af0ce115cbf 100644 (file)
@@ -608,7 +608,7 @@ protected:
     /// version text returned when DControllerBase::getVersion(true) is
     /// invoked.
     /// @return a string containing additional version info
-    virtual std::string getVersionAddendum() { return (""); }
+    virtual std::string getVersionAddendum() { return (std::string()); }
 
     /// @brief Deals with other (i.e. not application name) global objects.
     ///
index e52cbab9db5bae6725e916f15de8305ef3308b40..31989de9e59bc771ffcd50d9496acfb6b39efa6e 100644 (file)
@@ -446,7 +446,6 @@ TEST_F(DStubControllerTest, getVersion) {
     text = controller_->getVersion(true);
     EXPECT_NE(std::string::npos, text.find(VERSION));
     EXPECT_NE(std::string::npos, text.find(EXTENDED_VERSION));
-    EXPECT_NE(std::string::npos, text.find(controller_->getVersionAddendum()));
 }
 
 // Tests that the SIGTERM triggers a normal shutdown.