#!/usr/bin/make -f # -*- makefile -*- #export DH_VERBOSE=1 export DEB_BUILD_MAINT_OPTIONS = hardening=+all # While -fPIC is often the default, we explicitly enable it for this package # because it is a requirement for successful linking the static libopenvswitch # with shared libraries used for the Python JSON C extension. # # Ref: https://patchwork.ozlabs.org/project/openvswitch/patch/20220725121939.2710272-5-i.maximets@ovn.org/ export DEB_CFLAGS_MAINT_APPEND = -fPIC %: dh $@ execute_after_dh_autoreconf: patch -f --no-backup-if-mismatch -i $(CURDIR)/debian/ltmain-whole-archive.diff build-aux/ltmain.sh ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) PARALLEL = -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) else PARALLEL = endif DEB_HOST_ARCH?=$(shell dpkg-architecture -qDEB_HOST_ARCH) override_dh_auto_configure: test -d _debian || mkdir _debian cd _debian && ( \ test -e Makefile || \ ../configure --prefix=/usr --localstatedir=/var --enable-ssl \ --sysconfdir=/etc \ $(DATAPATH_CONFIGURE_OPTS) \ $(EXTRA_CONFIGURE_OPTS) \ ) ifneq (,$(filter i386 amd64 ppc64el arm64 riscv64 loong64, $(DEB_HOST_ARCH))) test -d _dpdk || mkdir _dpdk cd _dpdk && ( \ test -e Makefile || \ ../configure --prefix=/usr --localstatedir=/var --enable-ssl \ --with-dpdk=shared --sysconfdir=/etc \ $(DATAPATH_CONFIGURE_OPTS) \ $(EXTRA_CONFIGURE_OPTS) \ ) endif # NOTE(jamespage): by default, just run all tests # NOTE(zigo): by default, blacklist non-deterministic tests. Closes:#1108054 # # Rather than hardcoding pre-computed test number ranges (which go stale # every time the upstream testsuite is reordered/extended between # releases), compute TEST_LIST at build time by looking up test # descriptions directly in the generated testsuite script. # # debian/skip-tests.txt lists test descriptions to skip on all # architectures. debian/flaky-tests-$(DEB_HOST_ARCH).txt (if present) # lists additional descriptions to skip only on that architecture. FLAKY_TESTS_FILE := $(if $(wildcard $(CURDIR)/debian/flaky-tests-$(DEB_HOST_ARCH).txt),$(CURDIR)/debian/flaky-tests-$(DEB_HOST_ARCH).txt,/dev/null) TEST_LIST = $(shell \ cat $(CURDIR)/debian/skip-tests.txt $(FLAKY_TESTS_FILE) | \ $(CURDIR)/debian/testlist.py - $(CURDIR)/tests/testsuite) TEST_LIST_DPDK = $(TEST_LIST) # LP: #2090931 DPDK 24.11 increases the residential footprint for binaries # linked with DPDK. # # The OVS build system currently links all binaries with DPDK, consequently # some tests no longer pass in constrained CI environment due to the increased # memory footprint. # # On an installed system with DPDK enabled, all binaries come from the normal # build tree, with the exception of the ovs-vswitchd daemon. # # We mimic this in our build time test for DPDK to avoid the issue. DPDK_AUTOTEST_PATH = $(CURDIR)/_debian/utilities:vswitchd:$(CURDIR)/_debian/ovsdb:$(CURDIR)/_debian/vtep:tests:$(CURDIR)/_debian/ipsec:: override_dh_auto_test: ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) if $(MAKE) -C _debian check TESTSUITEFLAGS='$(PARALLEL) $(TEST_LIST)' || \ $(MAKE) -C _debian check TESTSUITEFLAGS='--recheck'; then :; \ else \ cat _debian/tests/testsuite.log; \ exit 1; \ fi # Skip DPDK testing on arm64 as builders don't have crc32 support # which is used in aarch64 based crc optimization in ovs >= 2.12.0~ ifneq (,$(filter i386 amd64 ppc64el riscv64 loong64, $(DEB_HOST_ARCH))) if $(MAKE) -C _dpdk check TESTSUITEFLAGS='$(PARALLEL) $(TEST_LIST_DPDK)' \ AUTOTEST_PATH=$(DPDK_AUTOTEST_PATH) || \ $(MAKE) -C _dpdk check TESTSUITEFLAGS='--recheck'; then :; \ else \ cat _dpdk/tests/testsuite.log; \ exit 1; \ fi endif # i386/amd64/ppc64el endif # nocheck export PYBUILD_DESTDIR = $(CURDIR)/debian/tmp export PYBUILD_DIR = $(CURDIR)/python pybuild = \ export PKG_CONFIG_PATH=$(CURDIR)/debian/tmp/usr/lib/pkgconfig; \ export PKG_CONFIG_SYSROOT_DIR=$(CURDIR)/debian/tmp; \ export PKG_CONFIG_SYSTEM_INCLUDE_PATH=/; \ export PKG_CONFIG_SYSTEM_LIBRARY_PATH=/; \ enable_shared=no \ extra_cflags="`pkg-config --cflags libopenvswitch`" \ extra_libs="-Wl,-Bstatic -lopenvswitch -Wl,-Bdynamic `pkg-config --libs --static libopenvswitch`" \ pybuild override_dh_auto_build: dh_auto_build --sourcedirectory=_debian -- distdir-am distdir=openvswitch dh_auto_build --sourcedirectory=_debian # We need an extra install here so that we can use pkgconfig to # retrieve accurate CFLAGS and LDFLAGS for building Python extensions. dh_auto_install --sourcedirectory=_debian $(pybuild) --build ifneq (,$(filter i386 amd64 ppc64el arm64 riscv64 loong64, $(DEB_HOST_ARCH))) dh_auto_build --sourcedirectory=_dpdk endif execute_before_dh_auto_clean: find . -name "*.pyc" -delete rm -f package.m4 rm -f python/ovs/dirs.py python/ovs/flow/ofp_fields.py python/ovs/version.py rm -rf python/ovs.egg-info python/ovs_build_helpers/__pycache__ python/build .pybuild rm -f rhel/openvswitch-fedora.spec rhel/openvswitch.spec rm -f tests/ovsdb-cluster-testsuite tests/system-afxdp-testsuite tests/system-dpdk-testsuite tests/system-kmod-testsuite tests/system-offloads-testsuite tests/system-tso-testsuite tests/system-userspace-testsuite tests/testsuite if test -d $(PYBUILD_DIR)/build; then \ pybuild --clean ; \ fi override_dh_auto_install: # We need to use pybuild to install Python extensions. $(pybuild) --install dh_auto_install --sourcedirectory=_debian override_dh_installinit: dh_installinit --restart-after-upgrade dh_installinit -popenvswitch-switch --name=ovsdb-server --no-start dh_installinit -popenvswitch-switch --name=ovs-vswitchd --no-start dh_installinit -popenvswitch-switch --name=ovs-record-hostname --no-start override_dh_installsystemd: dh_installsystemd -popenvswitch-switch --name=ovsdb-server --no-start dh_installsystemd -popenvswitch-switch --name=ovs-vswitchd --no-start dh_installsystemd -popenvswitch-switch --name=ovs-record-hostname --no-start dh_installsystemd --restart-after-upgrade -Xovs-vswitchd.service -Xovsdb-server.service -Xovs-record-hostname.service override_dh_strip: dh_strip --dbgsym-migration='openvswitch-dbg (<< 2.17~)' override_dh_fixperms: dh_fixperms # Remove executable bit from non-executable files chmod -x debian/openvswitch-common/usr/share/bash-completion/completions/ovs-appctl-bashcomp.bash || true chmod -x debian/openvswitch-switch/usr/share/bash-completion/completions/ovs-vsctl-bashcomp.bash || true find debian/openvswitch-source/usr/src/openvswitch -type f -name "*.h" -exec chmod -x {} + || true find debian/openvswitch-source/usr/src/openvswitch -type f -name "*.at" -exec chmod -x {} + || true chmod -x debian/openvswitch-source/usr/src/openvswitch/build-aux/extract-odp-netlink-h || true find debian/openvswitch-test/usr/share/openvswitch/scripts/usdt -type f -name "*.rst" -exec chmod -x {} + || true find debian/openvswitch-test/usr/share/openvswitch/scripts/usdt -type f -name "*.py" -exec chmod -x {} + || true override_dh_python3: DEB_HOST_ARCH=$(DEB_HOST_ARCH) dh_python3 --shebang=/usr/bin/python3 # Helper target for creating snapshots from upstream git DATE=$(shell date +%Y%m%d) # Upstream branch to track BRANCH=branch-3.7 VERSION=3.7.0 get-orig-snapshot: rm -Rf openvswitch-upstream git clone --branch $(BRANCH) --depth 1 https://github.com/openvswitch/ovs openvswitch-upstream cd openvswitch-upstream && \ export COMMIT=`git rev-parse --short HEAD` && \ git archive --format tgz --prefix=openvswitch-$(VERSION)~git$(DATE).$$COMMIT/ \ -o ../../openvswitch_$(VERSION)~git$(DATE).$$COMMIT.orig.tar.gz $(BRANCH) rm -Rf openvswitch-upstream