diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a13f89e..9b268598 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Expected: October 2024 Users may have to change how they access the system +* New version string on the form: `7.1.0-1+11+g2b25294` * Restconf: Better RFC compliance with Accept errors: 406 vs 415 * Removed YANG line-number in error-messages for memory optimization * Re-enable by setting `YANG_SPEC_LINENR` compile-time option diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index 20cc8537..c83e7b1a 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -561,7 +561,7 @@ main(int argc, help = 1; break; case 'V': - cligen_output(stdout, "Clixon version: %s\n", CLIXON_GITHASH); + cligen_output(stdout, "Clixon version: %s\n", CLIXON_VERSION); print_version++; /* plugins may also print versions w ca-version callback */ break; case 'D' : /* debug */ diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index e29335a1..623ccd21 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -616,7 +616,7 @@ main(int argc, help = 1; break; case 'V': /* version */ - cligen_output(stdout, "Clixon version: %s\n", CLIXON_GITHASH); + cligen_output(stdout, "Clixon version: %s\n", CLIXON_VERSION); print_version++; /* plugins may also print versions w ca-version callback */ break; case 'D' : /* debug, if set here overrides option CLICON_DEBUG */ diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index 10cb561f..2482f9de 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -994,7 +994,7 @@ cli_show_version(clixon_handle h, cvec *cvv, cvec *argv) { - cligen_output(stdout, "Clixon: %s\n", CLIXON_GITHASH); + cligen_output(stdout, "Clixon: %s\n", CLIXON_VERSION); cligen_output(stdout, "CLIgen: %s\n", CLIGEN_VERSION); return 0; } diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index 3a1b4d12..17d76423 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -707,7 +707,7 @@ main(int argc, usage(h, argv[0]); break; case 'V': /* version */ - cligen_output(stdout, "Clixon version: %s\n", CLIXON_GITHASH); + cligen_output(stdout, "Clixon version: %s\n", CLIXON_VERSION); print_version++; /* plugins may also print versions w ca-version callback */ break; case 'D' : /* debug */ diff --git a/apps/restconf/restconf_main_fcgi.c b/apps/restconf/restconf_main_fcgi.c index b5498cb1..c7e7056f 100644 --- a/apps/restconf/restconf_main_fcgi.c +++ b/apps/restconf/restconf_main_fcgi.c @@ -348,7 +348,7 @@ main(int argc, usage(h, argv[0]); break; case 'V': - cligen_output(stdout, "Clixon version: %s\n", CLIXON_GITHASH); + cligen_output(stdout, "Clixon version: %s\n", CLIXON_VERSION); print_version++; /* plugins may also print versions w ca-version callback */ break; case 'D' : { /* debug */ diff --git a/apps/restconf/restconf_main_native.c b/apps/restconf/restconf_main_native.c index 3728e074..c22bb46d 100644 --- a/apps/restconf/restconf_main_native.c +++ b/apps/restconf/restconf_main_native.c @@ -1189,7 +1189,7 @@ main(int argc, usage(h, argv0); break; case 'V': /* version */ - cligen_output(stdout, "Clixon version: %s\n", CLIXON_GITHASH); + cligen_output(stdout, "Clixon version: %s\n", CLIXON_VERSION); print_version++; /* plugins may also print versions w ca-version callback */ break; case 'D' : /* debug. Note this overrides any setting in the config */ diff --git a/apps/snmp/snmp_main.c b/apps/snmp/snmp_main.c index 27c54ad7..75642759 100644 --- a/apps/snmp/snmp_main.c +++ b/apps/snmp/snmp_main.c @@ -381,7 +381,7 @@ main(int argc, usage(h, argv[0]); break; case 'V': /* version */ - cligen_output(stdout, "Clixon version: %s\n", CLIXON_GITHASH); + cligen_output(stdout, "Clixon version: %s\n", CLIXON_VERSION); print_version++; /* plugins may also print versions w ca-version callback */ break; case 'D' : { /* debug */ diff --git a/configure b/configure index b6e16424..161c0032 100755 --- a/configure +++ b/configure @@ -2813,10 +2813,11 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # Use GIT version (what if no git?) -CLIXON_VERSION="$(git log --pretty="format:%(describe) %ci" -n1)" -CLIXON_VERSION_MAJOR="7" -CLIXON_VERSION_MINOR="1" -CLIXON_VERSION_PATCH="0" +CLIXON_VERSION="$(./scripts/version.sh)" +CLIXON_VERSION2=$(echo ${CLIXON_VERSION} | awk -F- '{print $1}') +CLIXON_VERSION_MAJOR=$(echo ${CLIXON_VERSION2} | awk -F. '{print $1}') +CLIXON_VERSION_MINOR=$(echo ${CLIXON_VERSION2} | awk -F. '{print $2}') +CLIXON_VERSION_PATCH=$(echo ${CLIXON_VERSION2} | awk -F. '{print $3}') # Debug flag # Check whether --enable-debug was given. @@ -5304,11 +5305,11 @@ if test x$ac_prog_cxx_stdcxx = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 printf %s "checking for $CXX option to enable C++11 features... " >&6; } -if test ${ac_cv_prog_cxx_11+y} +if test ${ac_cv_prog_cxx_cxx11+y} then : printf %s "(cached) " >&6 else $as_nop - ac_cv_prog_cxx_11=no + ac_cv_prog_cxx_cxx11=no ac_save_CXX=$CXX cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5350,11 +5351,11 @@ if test x$ac_prog_cxx_stdcxx = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 printf %s "checking for $CXX option to enable C++98 features... " >&6; } -if test ${ac_cv_prog_cxx_98+y} +if test ${ac_cv_prog_cxx_cxx98+y} then : printf %s "(cached) " >&6 else $as_nop - ac_cv_prog_cxx_98=no + ac_cv_prog_cxx_cxx98=no ac_save_CXX=$CXX cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6549,7 +6550,7 @@ printf "%s\n" "Generated YANGs from MIB files are expected to be in ${MIB_GENERA fi # Set default config file location -CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml +CLIXON_DEFAULT_CONFIG=${SYSCONFDIR}/clixon.xml # Check whether --with-configfile was given. if test ${with_configfile+y} diff --git a/configure.ac b/configure.ac index 74fd7ceb..5a2e4239 100644 --- a/configure.ac +++ b/configure.ac @@ -49,10 +49,11 @@ AC_CONFIG_SRCDIR([lib/clixon/clixon.h.in]) AC_CONFIG_AUX_DIR(config-aux) # Use GIT version (what if no git?) -CLIXON_VERSION="$(git log --pretty="format:%(describe) %ci" -n1)" -CLIXON_VERSION_MAJOR="7" -CLIXON_VERSION_MINOR="1" -CLIXON_VERSION_PATCH="0" +CLIXON_VERSION="$(./scripts/version.sh)" +CLIXON_VERSION2=$(echo ${CLIXON_VERSION} | awk -F- '{print $1}') +CLIXON_VERSION_MAJOR=$(echo ${CLIXON_VERSION2} | awk -F. '{print $1}') +CLIXON_VERSION_MINOR=$(echo ${CLIXON_VERSION2} | awk -F. '{print $2}') +CLIXON_VERSION_PATCH=$(echo ${CLIXON_VERSION2} | awk -F. '{print $3}') # Debug flag AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[Build with debug symbols, default: no]),[ diff --git a/example/main/example_cli.c b/example/main/example_cli.c index 2c9cb61a..c79f978b 100644 --- a/example/main/example_cli.c +++ b/example/main/example_cli.c @@ -358,7 +358,7 @@ example_cli_errmsg(clixon_handle h, * * A plugin can customize a version (or banner) output on stdout. * Several version strings can be printed if there are multiple callbacks. - * If no registered plugins exist, clixon prints CLIXON_GITHASH + * If no registered plugins exist, clixon prints CLIXON_VERSION * Typically invoked by command-line option -V * @param[in] h Clixon handle * @param[in] f Output file diff --git a/lib/clixon/clixon.h.in b/lib/clixon/clixon.h.in index c0a5e312..329a58cf 100644 --- a/lib/clixon/clixon.h.in +++ b/lib/clixon/clixon.h.in @@ -60,7 +60,6 @@ extern "C" { /* * CLIXON version macros, set in configure and resolved when expanding to * clixon.h - * XXX: use github versioning: CLIXON_GITHASH[] instead */ #undef CLIXON_VERSION_MAJOR #undef CLIXON_VERSION_MINOR @@ -123,7 +122,6 @@ extern "C" { * Global variables generated by Makefile */ extern const char CLIXON_BUILDSTR[]; -extern const char CLIXON_GITHASH[]; extern const char CLIXON_VERSION[]; #ifdef __cplusplus diff --git a/lib/clixon/clixon_plugin.h b/lib/clixon/clixon_plugin.h index b61ff243..d8480591 100644 --- a/lib/clixon/clixon_plugin.h +++ b/lib/clixon/clixon_plugin.h @@ -340,7 +340,7 @@ typedef int (errmsg_t)(clixon_handle h, const char *fn, const int line, * * A plugin can customize a version (or banner) output on stdout. * Several version strings can be printed if there are multiple callbacks. - * If no registered plugins exist, clixon prints CLIXON_GITHASH + * If no registered plugins exist, clixon prints CLIXON_VERSION * Typically invoked by command-line option -V * @param[in] h Clixon handle * @param[in] f Output file diff --git a/lib/src/Makefile.in b/lib/src/Makefile.in index 1fb8fb35..bba0c48d 100644 --- a/lib/src/Makefile.in +++ b/lib/src/Makefile.in @@ -299,7 +299,6 @@ DATELEN = $(shell date +"%Y.%m.%d %H:%M by `whoami` on `hostname`XXXX"|wc -c) build.c: echo "/* This file is generated from the Clixon Makefile */" > $@; date +"const char CLIXON_BUILDSTR[$(DATELEN)]=\"%Y.%m.%d %H:%M by `whoami` on `hostname`"\"\; >> $@; - echo "const char CLIXON_GITHASH[64]=\"$(shell git log --pretty="format:%(describe) %ci" -n1)\""\; >> $@; echo "const char CLIXON_VERSION[64]=\"$(CLIXON_VERSION)\""\; >> $@; # Note: will always be remade since GENOBS is date dependent diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 00000000..b557703e --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Version script +# Usage: +# ./version.sh +# with optional fields: +# PREFIX= INDEX=1 ARCH= SUFFIX= +# Example: +# PREFIX=cligen INDEX=1 ARCH=amd64 SUFFIX=deb ./version.sh +set -eu +: ${PREFIX:=} +: ${INDEX=1} +: ${ARCH=} +: ${SUFFIX=} +# Get version string from default git describe: --g +if [ -f .version ]; then + v1=$(cat .version) +else + v1=$(git describe) +fi +if [ -z $v1 ]; then + echo "No base version" + exit 1 +fi +TAG=$(echo $v1 | awk -F- '{print $1}') +NR=$(echo $v1 | awk -F- '{print $2}') +HASH=$(echo $v1 | awk -F- '{print $3}') +V="" +if [ -n "$PREFIX" ]; then + V="${V}${PREFIX}_" +fi +V="${V}${TAG}" +V="${V}-${INDEX}" +V="${V}+${NR}" +V="${V}+${HASH}" +if [ -n "$ARCH" ]; then + V="${V}_${ARCH}" +fi +if [ -n "$SUFFIX" ]; then + V="${V}.${SUFFIX}" +fi +echo "${V}"