Skip to content

Commit

Permalink
New version string on the form: 7.1.0-1+11+g2b25294
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Oct 18, 2024
1 parent 3cad374 commit 0a37cf3
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/backend_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/cli_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/cli_show.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/netconf/netconf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion apps/restconf/restconf_main_fcgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion apps/restconf/restconf_main_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion apps/snmp/snmp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
19 changes: 10 additions & 9 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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}
Expand Down
9 changes: 5 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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]),[
Expand Down
2 changes: 1 addition & 1 deletion example/main/example_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions lib/clixon/clixon.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/clixon/clixon_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions scripts/version.sh
Original file line number Diff line number Diff line change
@@ -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: <tag>-<nr>-g<hash>
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}"

0 comments on commit 0a37cf3

Please sign in to comment.