It should be possible to produce debian/ files and run package build in a separate isolated environment like pbuilder without going through complete source tree configuration process that includes running `./boot.sh`, `./configure`, and `make` on the build host.
This should shave off some build time and simplify instructions. Signed-off-by: Ihar Hrachyshka <[email protected]> --- .ci/linux-build.sh | 32 -------------- .ci/linux-prepare.sh | 6 --- .github/workflows/build-and-test.yml | 61 ++++++++++++++++---------- Documentation/intro/install/debian.rst | 45 +++++++++++-------- debian/automake.mk | 50 +-------------------- debian/prepare.sh | 22 ++++++++++ 6 files changed, 90 insertions(+), 126 deletions(-) create mode 100755 debian/prepare.sh diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index 702feeb3b..a8ce7623f 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -76,38 +76,6 @@ function clang_analyze() fi; } -if [ "$DEB_PACKAGE" ]; then - ./boot.sh && ./configure --with-dpdk=$DPDK && make debian - mk-build-deps --install --root-cmd sudo --remove debian/control - dpkg-checkbuilddeps - make debian-deb - packages=$(ls $(pwd)/../*.deb) - deps="" - for pkg in $packages; do - _ifs=$IFS - IFS="," - for dep in $(dpkg-deb -f $pkg Depends); do - dep_name=$(echo "$dep"|awk '{print$1}') - # Don't install internal package inter-dependencies from apt - echo $dep_name | grep -q openvswitch && continue - deps+=" $dep_name" - done - IFS=$_ifs - done - # install package dependencies from apt - echo $deps | xargs sudo apt -y install - # install the locally built openvswitch packages - sudo dpkg -i $packages - - # Check that python C extension is built correctly. - python3 -c " -from ovs import _json -import ovs.json -assert ovs.json.from_string('{\"a\": 42}') == {'a': 42}" - - exit 0 -fi - if [ "$DPDK" ] || [ "$DPDK_SHARED" ]; then install_dpdk fi diff --git a/.ci/linux-prepare.sh b/.ci/linux-prepare.sh index 51e5a7e7d..46382d7c5 100755 --- a/.ci/linux-prepare.sh +++ b/.ci/linux-prepare.sh @@ -2,12 +2,6 @@ set -ev -if [ "$DEB_PACKAGE" ]; then - # We're not using sparse for debian packages, tests are skipped and - # all extra dependencies tracked by mk-build-deps. - exit 0 -fi - # Build and install sparse. # # Disabling sqlite support because sindex build fails and we don't diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 5f9e337de..0ee454e31 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -622,12 +622,6 @@ jobs: run: cd ovs && make -j4 build-linux-deb: - env: - deb_dependencies: | - linux-headers-$(uname -r) build-essential fakeroot devscripts equivs - DEB_PACKAGE: yes - DPDK: ${{ matrix.dpdk }} - name: linux deb ${{ matrix.dpdk }} dpdk runs-on: ubuntu-24.04 timeout-minutes: 30 @@ -639,33 +633,56 @@ jobs: - dpdk: no steps: + - name: install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential fakeroot devscripts equivs + - name: checkout uses: actions/checkout@v4 - - name: update PATH - run: | - echo "$HOME/bin" >> $GITHUB_PATH - echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: generate debian metadata + run: | + ./debian/prepare.sh ${{ matrix.dpdk == 'yes' && '--dpdk' || '' }} - - name: update APT cache - run: sudo apt update || true - - name: install dependencies for debian packages - run: sudo apt install -y ${{ env.deb_dependencies }} - - name: install dpdk-dev - if: matrix.dpdk != 'no' - run: sudo apt install -y libdpdk-dev + - name: install build dependencies + run: | + sudo mk-build-deps -i -r -t 'sudo apt-get -y --no-install-recommends' debian/control - - name: prepare - run: ./.ci/linux-prepare.sh + - name: set common DEB_BUILD_OPTIONS + run: | + echo "DEB_BUILD_OPTIONS=nocheck parallel=$(nproc)" >> $GITHUB_ENV - - name: build - run: ./.ci/linux-build.sh + - name: disable DPDK + if: matrix.dpdk != 'yes' + run: | + echo "DEB_BUILD_OPTIONS=$DEB_BUILD_OPTIONS nodpdk" >> $GITHUB_ENV + + - name: build Debian packages + run: | + dpkg-buildpackage -us -uc -b + + - name: install deb packages + run: | + sudo apt-get install -y ../*.deb + + - name: check that python C extension is built correctly + run: | + python3 -c " + from ovs import _json + import ovs.json + assert ovs.json.from_string('{\"a\": 42}') == {'a': 42}" + + - name: collect deb packages + run: | + mkdir -p deb-packages + cp ../*.deb deb-packages/ - name: upload deb packages uses: actions/upload-artifact@v4 with: name: deb-packages-${{ matrix.dpdk }}-dpdk - path: '/home/runner/work/ovs/*.deb' + path: deb-packages/ build-linux-rpm: name: linux rpm fedora diff --git a/Documentation/intro/install/debian.rst b/Documentation/intro/install/debian.rst index d41b228ae..22dad6c4f 100644 --- a/Documentation/intro/install/debian.rst +++ b/Documentation/intro/install/debian.rst @@ -50,38 +50,47 @@ Git tree with these instructions. You do not need to be the superuser to build the Debian packages. -1. Install the "build-essential" and "fakeroot" packages. For example:: +1. Install the "build-essential", "fakeroot", "devscripts", and "equivs" + packages:: - $ apt-get install build-essential fakeroot + $ apt-get install build-essential fakeroot devscripts equivs 2. Obtain and unpack an Open vSwitch source distribution and ``cd`` into its top level directory. -3. Install the build dependencies listed under "Build-Depends:" near the top of - ``debian/control.in``. You can install these any way you like, e.g. with - ``apt-get install``. +3. Generate ``debian/control`` and ``debian/copyright`` from their templates. -4. Prepare the package source. + If you want to build the package with DPDK support:: - If you want to build the package with DPDK support execute the following - command:: - - $ ./boot.sh && ./configure --with-dpdk=shared && make debian + $ ./debian/prepare.sh --dpdk If not:: - $ ./boot.sh && ./configure && make debian + $ ./debian/prepare.sh + +4. Install the build dependencies:: + + $ mk-build-deps -i -r -t 'apt-get -y --no-install-recommends' \ + debian/control + + Check your work by running ``dpkg-checkbuilddeps`` in the top level of your + OVS directory. If you've installed all the dependencies properly, + ``dpkg-checkbuilddeps`` will exit without printing anything. If you forgot + to install some dependencies, it will tell you which ones. + +5. Build the package. + + Without DPDK:: -Check your work by running ``dpkg-checkbuilddeps`` in the top level of your OVS -directory. If you've installed all the dependencies properly, -``dpkg-checkbuilddeps`` will exit without printing anything. If you forgot to -install some dependencies, it will tell you which ones. + $ DEB_BUILD_OPTIONS='nocheck parallel=`nproc` nodpdk' \ + dpkg-buildpackage -us -uc -b -5. Build the package:: + With DPDK:: - $ make debian-deb + $ DEB_BUILD_OPTIONS='nocheck parallel=`nproc`' \ + dpkg-buildpackage -us -uc -b -5. The generated .deb files will be in the parent directory of the Open vSwitch +6. The generated .deb files will be in the parent directory of the Open vSwitch source distribution. Installing .deb Packages diff --git a/debian/automake.mk b/debian/automake.mk index 7ae4e00e5..c684bf52c 100644 --- a/debian/automake.mk +++ b/debian/automake.mk @@ -58,6 +58,7 @@ EXTRA_DIST += \ debian/openvswitch-vtep.init \ debian/openvswitch-vtep.install \ debian/ovs-systemd-reload \ + debian/prepare.sh \ debian/python3-openvswitch.install \ debian/rules \ debian/source/format \ @@ -80,51 +81,4 @@ check-debian-changelog-version: ALL_LOCAL += check-debian-changelog-version DIST_HOOKS += check-debian-changelog-version - -update_deb_copyright = \ - $(AM_V_GEN) \ - { sed -n -e '/%AUTHORS%/q' -e p < $(srcdir)/debian/copyright.in; \ - tail -n +28 $(srcdir)/AUTHORS.rst | sed '1,/^$$/d' | \ - sed -n -e '/^$$/q' -e 's/^/ /p'; \ - sed -e '1,/%AUTHORS%/d' $(srcdir)/debian/copyright.in; \ - } > debian/copyright - -debian/copyright: AUTHORS.rst debian/copyright.in - $(update_deb_copyright) - -CLEANFILES += debian/copyright - - -if DPDK_NETDEV -update_deb_control = \ - $(AM_V_GEN) sed -e 's/^\# DPDK_NETDEV //' \ - < $(srcdir)/debian/control.in > debian/control -DEB_BUILD_OPTIONS ?= nocheck parallel=`nproc` -else -update_deb_control = \ - $(AM_V_GEN) grep -v '^\# DPDK_NETDEV' \ - < $(srcdir)/debian/control.in > debian/control -DEB_BUILD_OPTIONS ?= nocheck parallel=`nproc` nodpdk -endif - -debian/control: $(srcdir)/debian/control.in Makefile - $(update_deb_control) - -CLEANFILES += debian/control - - -debian: debian/copyright debian/control -.PHONY: debian - - -debian-deb: debian - @if test X"$(srcdir)" != X"$(top_builddir)"; then \ - echo "Debian packages should be built from $(abs_srcdir)/"; \ - exit 1; \ - fi - $(MAKE) distclean - $(update_deb_copyright) - $(update_deb_control) - $(AM_V_GEN) fakeroot debian/rules clean - $(AM_V_GEN) DEB_BUILD_OPTIONS="$(DEB_BUILD_OPTIONS)" \ - fakeroot debian/rules binary +CLEANFILES += debian/copyright debian/control diff --git a/debian/prepare.sh b/debian/prepare.sh new file mode 100755 index 000000000..eee2837b3 --- /dev/null +++ b/debian/prepare.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +srcdir=$(dirname "$0")/.. + +# Generate debian/control from control.in. +# With --dpdk, uncomment DPDK_NETDEV lines; without, strip them. +if [ "$1" = "--dpdk" ]; then + sed -e 's/^\# DPDK_NETDEV //' \ + < "$srcdir/debian/control.in" > "$srcdir/debian/control" +else + grep -v '^\# DPDK_NETDEV' \ + "$srcdir/debian/control.in" > "$srcdir/debian/control" +fi + +# Generate debian/copyright from copyright.in and AUTHORS.rst. +{ sed -n -e '/%AUTHORS%/q' -e p < "$srcdir/debian/copyright.in" + tail -n +28 "$srcdir/AUTHORS.rst" | sed '1,/^$/d' | + sed -n -e '/^$/q' -e 's/^/ /p' + sed -e '1,/%AUTHORS%/d' "$srcdir/debian/copyright.in" +} > "$srcdir/debian/copyright" -- 2.52.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
