Skip to content

Commit

Permalink
rhel: Make the version, displayed to the user, customizable.
Browse files Browse the repository at this point in the history
Since on CentOS/RHEL the builds are based on stable branches and not on
tags for debugging purpose it's better to have the downstream version as
version so it's easier to know which commits are included in a build.

This commit adds --with-version-suffix as ./configure option in
order to set an OVS version suffix that should be shown to the user via
ovs-vsctl -V and, so, also on database, on ovs-vsctl show and the other
utilities.

--with-version-suffix is used in Fedora/CentOS/RHEL spec file in order to have
the version be aligned with the downstream one.

Signed-off-by: Timothy Redaelli <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
drizzt authored and igsilya committed Jul 15, 2024
1 parent 1aa9e13 commit 9e6d43e
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 41 deletions.
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
AUTOMAKE_OPTIONS = foreign subdir-objects
ACLOCAL_AMFLAGS = -I m4

AM_DISTCHECK_CONFIGURE_FLAGS = --with-version-suffix="$(VERSION_SUFFIX)"

AM_CPPFLAGS = $(SSL_CFLAGS)
AM_LDFLAGS = $(SSL_LDFLAGS)
AM_LDFLAGS += $(OVS_LDFLAGS)
Expand Down Expand Up @@ -163,6 +165,7 @@ SUFFIXES += .in
-e 's,[@]PYTHON3[@],$(PYTHON3),g' \
-e 's,[@]RUNDIR[@],$(RUNDIR),g' \
-e 's,[@]VERSION[@],$(VERSION),g' \
-e 's,[@]VERSION_SUFFIX[@],$(VERSION_SUFFIX),g' \
-e 's,[@]localstatedir[@],$(localstatedir),g' \
-e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
-e 's,[@]sysconfdir[@],$(sysconfdir),g' \
Expand Down
13 changes: 13 additions & 0 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,19 @@ AC_DEFUN([OVS_CHECK_DPDK], [
AM_CONDITIONAL([DPDK_NETDEV], test "$DPDKLIB_FOUND" = true)
])

dnl Append a version suffix.

AC_DEFUN([OVS_CHECK_VERSION_SUFFIX], [
AC_ARG_WITH([version-suffix],
[AS_HELP_STRING([--with-version-suffix=ver_suffix],
[Specify a string that will be appended
to OVS version])])
AC_DEFINE_UNQUOTED([VERSION_SUFFIX], ["$with_version_suffix"],
[Package version suffix])
AC_SUBST([VERSION_SUFFIX], [$with_version_suffix])
])
])

dnl Checks for net/if_dl.h.
dnl
dnl (We use this as a proxy for checking whether we're building on FreeBSD
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ OVS_CHECK_LINUX_SCTP_CT
OVS_CHECK_LINUX_VIRTIO_TYPES
OVS_CHECK_DPDK
OVS_CHECK_PRAGMA_MESSAGE
OVS_CHECK_VERSION_SUFFIX
AC_SUBST([CFLAGS])
AC_SUBST([OVS_CFLAGS])
AC_SUBST([OVS_LDFLAGS])
Expand Down
2 changes: 1 addition & 1 deletion include/openvswitch/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define OPENVSWITCH_VERSION_H 1

#define OVS_PACKAGE_STRING "@PACKAGE_STRING@"
#define OVS_PACKAGE_VERSION "@PACKAGE_VERSION@"
#define OVS_PACKAGE_VERSION "@PACKAGE_VERSION@@VERSION_SUFFIX@"

#define OVS_LIB_VERSION @LT_CURRENT@
#define OVS_LIB_REVISION @LT_REVISION@
Expand Down
2 changes: 1 addition & 1 deletion lib/ovsdb-error.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ovsdb_internal_error(struct ovsdb_error *inner_error,
ds_put_char(&ds, ')');
}

ds_put_format(&ds, " (%s %s)", program_name, VERSION);
ds_put_format(&ds, " (%s %s)", program_name, VERSION VERSION_SUFFIX);

if (inner_error) {
char *s = ovsdb_error_to_string_free(inner_error);
Expand Down
8 changes: 5 additions & 3 deletions lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,14 @@ ovs_set_program_name(const char *argv0, const char *version)
program_name = basename;

free(program_version);
if (!strcmp(version, VERSION)) {
program_version = xasprintf("%s (Open vSwitch) "VERSION,
if (!strcmp(version, VERSION VERSION_SUFFIX)) {
program_version = xasprintf("%s (Open vSwitch) "VERSION
VERSION_SUFFIX,
program_name);
} else {
program_version = xasprintf("%s %s\n"
"Open vSwitch Library "VERSION,
"Open vSwitch Library "VERSION
VERSION_SUFFIX,
program_name, version);
}
}
Expand Down
3 changes: 2 additions & 1 deletion ovsdb/ovsdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,8 @@ main(int argc, char *argv[])
/* ovsdb-server is usually a long-running process, in which case it
* makes plenty of sense to log the version, but --run makes
* ovsdb-server more like a command-line tool, so skip it. */
VLOG_INFO("%s (Open vSwitch) %s", program_name, VERSION);
VLOG_INFO("%s (Open vSwitch) %s", program_name,
VERSION VERSION_SUFFIX);
}

unixctl_command_register("exit", "", 0, 0, ovsdb_server_exit, &exiting);
Expand Down
1 change: 1 addition & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/
*.egg-info
setup.py
22 changes: 15 additions & 7 deletions python/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,24 @@ EXTRA_DIST += \
EXTRA_DIST += \
python/ovs/compat/sortedcontainers/LICENSE \
python/README.rst \
python/setup.py \
python/test_requirements.txt

# C extension support.
EXTRA_DIST += python/ovs/_json.c

PYFILES = $(ovs_pyfiles) python/ovs/dirs.py $(ovstest_pyfiles) $(ovs_pytests)
PYFILES = $(ovs_pyfiles) python/ovs/dirs.py python/setup.py $(ovstest_pyfiles) $(ovs_pytests)

EXTRA_DIST += $(PYFILES)
PYCOV_CLEAN_FILES += $(PYFILES:.py=.py,cover)

FLAKE8_PYFILES += \
$(filter-out python/ovs/compat/% python/ovs/dirs.py,$(PYFILES)) \
$(filter-out python/ovs/compat/% python/ovs/dirs.py python/setup.py,$(PYFILES)) \
python/ovs_build_helpers/__init__.py \
python/ovs_build_helpers/extract_ofp_fields.py \
python/ovs_build_helpers/nroff.py \
python/ovs_build_helpers/soutil.py \
python/ovs/dirs.py.template \
python/setup.py
python/setup.py.template

nobase_pkgdata_DATA = $(ovs_pyfiles) $(ovstest_pyfiles)
ovs-install-data-local:
Expand All @@ -113,7 +112,7 @@ ovs-install-data-local:
rm python/ovs/dirs.py.tmp

.PHONY: python-sdist
python-sdist: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py
python-sdist: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py python/setup.py
cd python/ && $(PYTHON3) -m build --sdist

.PHONY: pypi-upload
Expand All @@ -129,8 +128,8 @@ ovs-uninstall-local:
ALL_LOCAL += $(srcdir)/python/ovs/version.py
$(srcdir)/python/ovs/version.py: config.status
$(AM_V_GEN)$(ro_shell) > $(@F).tmp && \
echo 'VERSION = "$(VERSION)"' >> $(@F).tmp && \
if cmp -s $(@F).tmp $@; then touch $@; rm $(@F).tmp; else mv $(@F).tmp $@; fi
echo 'VERSION = "$(VERSION)$(VERSION_SUFFIX)"' >> $(@F).tmp && \
if cmp -s $(@F).tmp $@; then touch $@; else cp $(@F).tmp $@; fi; rm $(@F).tmp

ALL_LOCAL += $(srcdir)/python/ovs/dirs.py
$(srcdir)/python/ovs/dirs.py: python/ovs/dirs.py.template
Expand All @@ -147,6 +146,15 @@ $(srcdir)/python/ovs/dirs.py: python/ovs/dirs.py.template
EXTRA_DIST += python/ovs/dirs.py.template
CLEANFILES += python/ovs/dirs.py

ALL_LOCAL += $(srcdir)/python/setup.py
$(srcdir)/python/setup.py: python/setup.py.template config.status
$(AM_V_GEN)sed \
-e 's,[@]VERSION[@],$(VERSION),g' \
< $(srcdir)/python/setup.py.template > $(@F).tmp && \
if cmp -s $(@F).tmp $@; then touch $@; else cp $(@F).tmp $@; fi; rm $(@F).tmp
EXTRA_DIST += python/setup.py.template
CLEANFILES += python/setup.py

EXTRA_DIST += python/TODO.rst

$(srcdir)/python/ovs/flow/ofp_fields.py: $(srcdir)/build-aux/gen_ofp_field_decoders include/openvswitch/meta-flow.h
Expand Down
28 changes: 10 additions & 18 deletions python/setup.py → python/setup.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,16 @@

import setuptools

VERSION = "unknown"

try:
# Try to set the version from the generated ovs/version.py
exec(open("ovs/version.py").read())
except IOError:
print("Ensure version.py is created by running make python/ovs/version.py",
file=sys.stderr)
sys.exit(-1)

try:
# Try to open generated ovs/dirs.py. However, in this case we
# don't need to exec()
open("ovs/dirs.py")
except IOError:
print("Ensure dirs.py is created by running make python/ovs/dirs.py",
file=sys.stderr)
sys.exit(-1)
VERSION = "@VERSION@"

for x in ("version.py", "dirs.py"):
try:
# Try to open generated ovs/{version,dirs}.py
open(f"ovs/{x}")
except IOError:
print(f"Ensure {x} is created by running make python/ovs/{x}",
file=sys.stderr)
sys.exit(-1)

ext_errors = (CCompilerError, ExecError, PlatformError)
if sys.platform == 'win32':
Expand Down
1 change: 1 addition & 0 deletions rhel/openvswitch-fedora.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ This package provides IPsec tunneling support for OVS tunnels.
--disable-static \
--enable-shared \
--with-pkidir=%{_sharedstatedir}/openvswitch/pki \
--with-version-suffix=-%{release} \
PYTHON3=%{__python3}

build-aux/dpdkstrip.py \
Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-dpctl-top.in
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def args_get():
# None is a special value indicating to read flows from stdin.
# This handles the case
# ovs-dpctl dump-flows | ovs-dpctl-flows.py
parser.add_argument("-v", "--version", version="@VERSION@",
parser.add_argument("-v", "--version", version="@VERSION@@VERSION_SUFFIX@",
action="version", help="show version")
parser.add_argument("-f", "--flow-file", dest="flowFiles", default=None,
action="append",
Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-lib.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ovs_ctl () {
esac
}

VERSION='@VERSION@'
VERSION='@VERSION@@VERSION_SUFFIX@'

DAEMON_CWD=/

Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-parse-backtrace.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def addr2line(binary, addr):


def main():
parser = optparse.OptionParser(version='@VERSION@',
parser = optparse.OptionParser(version='@VERSION@@VERSION_SUFFIX@',
usage="usage: %prog [binary]",
description="""\
Parses the output of ovs-appctl backtrace producing a more human readable
Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-pcap.in
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ if __name__ == "__main__":
if key in ['-h', '--help']:
usage()
elif key in ['-V', '--version']:
print("ovs-pcap (Open vSwitch) @VERSION@")
print("ovs-pcap (Open vSwitch) @VERSION@@VERSION_SUFFIX@")
else:
sys.exit(0)

Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-pki.in
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ EOF
exit 0
;;
-V|--version)
echo "ovs-pki (Open vSwitch) @VERSION@"
echo "ovs-pki (Open vSwitch) @VERSION@@VERSION_SUFFIX@"
exit 0
;;
--di*=*)
Expand Down
4 changes: 2 additions & 2 deletions utilities/ovs-tcpdump.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ try:
from ovs.fatal_signal import add_hook
except Exception:
print("ERROR: Please install the correct Open vSwitch python support")
print(" libraries (version @VERSION@).")
print(" libraries (version @VERSION@@VERSION_SUFFIX@).")
print(" Alternatively, check that your PYTHONPATH is pointing to")
print(" the correct location.")
sys.exit(1)
Expand Down Expand Up @@ -453,7 +453,7 @@ def main():
if cur in ['-h', '--help']:
usage()
elif cur in ['-V', '--version']:
print("ovs-tcpdump (Open vSwitch) @VERSION@")
print("ovs-tcpdump (Open vSwitch) @VERSION@@VERSION_SUFFIX@")
sys.exit(0)
elif cur in ['--db-sock']:
db_sock = nxt
Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-tcpundump.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if __name__ == "__main__":
if key in ['-h', '--help']:
usage()
elif key in ['-V', '--version']:
print("ovs-tcpundump (Open vSwitch) @VERSION@")
print("ovs-tcpundump (Open vSwitch) @VERSION@@VERSION_SUFFIX@")
sys.exit(0)
else:
sys.exit(0)
Expand Down
2 changes: 1 addition & 1 deletion utilities/ovs-vlan-test.in
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def main():
usage()
return 0
elif key in ['-V', '--version']:
print_safe('ovs-vlan-test (Open vSwitch) @VERSION@')
print_safe('ovs-vlan-test (Open vSwitch) @VERSION@@VERSION_SUFFIX@')
return 0
elif key in ['-s', '--server']:
server = True
Expand Down
3 changes: 2 additions & 1 deletion vswitchd/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3470,7 +3470,8 @@ bridge_run(void)

vlog_enable_async();

VLOG_INFO_ONCE("%s (Open vSwitch) %s", program_name, VERSION);
VLOG_INFO_ONCE("%s (Open vSwitch) %s", program_name,
VERSION VERSION_SUFFIX);
}
}

Expand Down

0 comments on commit 9e6d43e

Please sign in to comment.