Skip to content

Commit d8446f6

Browse files
rutvik-pf9Rutvik Saptarshi
andauthored
PCD-5913 PCD-6245 - Changes to support RPM builds + unify ovn versioning (#17)
now all packages are built on ovn: 24.03.6, ovs: 3.3.6 - ovn control plane components now use ubuntu24 base image all ovn components regardless of OS will share the same `internal version` for use with the failsafe upgrade feature. --------- Co-authored-by: Rutvik Saptarshi <rutviksaptarshi@mac.lan>
1 parent ac63537 commit d8446f6

10 files changed

Lines changed: 232 additions & 144 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*.so
2121
*.suo
2222
**/*.sym
23+
*.rpm
2324
*~
2425
*,cover
2526
.#*
@@ -94,3 +95,5 @@ testsuite.tmp.orig
9495
/.venv
9596
/cxx-check
9697
/*.ovsschema.stamp
98+
.DS_Store
99+
*.deb

build-aux/automake.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
EXTRA_DIST += \
2+
build-aux/automake.mk \
3+
build-aux/build-common.sh \
24
build-aux/build-debs.sh \
35
build-aux/calculate-pipeline-cksum \
6+
build-aux/build-rpms.sh \
47
build-aux/calculate-schema-cksum \
58
build-aux/cccl \
69
build-aux/cksum-pipeline-check \

build-aux/build-common.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Common configuration and helpers for pf9 OVN/OVS builds.
2+
# Source this file; do not execute directly.
3+
4+
TEAMCITY_ROOT="$(pwd)"
5+
ROOT="$(pwd)/pf9-ovn"
6+
7+
OVS_BASE="3.3.6"
8+
OVN_BASE="24.03.6"
9+
10+
pf9_git_setup() {
11+
git config --global --add safe.directory '*'
12+
git config --global url."https://github.com/".insteadOf "git@github.com:"
13+
}
14+
15+
pf9_submodule_update() {
16+
git -C "$ROOT" submodule update --init --recursive
17+
}
18+
19+
pf9_patch_ovn_binary_version() {
20+
# Dots throughout, no epoch, no OS suffix — identical on all platforms.
21+
# configure.ac carries this into OVN_PACKAGE_VERSION and thus ovn-appctl version.
22+
PF9_OVN_BINARY_VERSION=${OVN_BASE}.pf9.${PF9_VERSION}.${BUILD_NUMBER}
23+
sed -i "s/__PF9_OVN_BUILD_VERSION__/${PF9_OVN_BINARY_VERSION}/g" "$ROOT/configure.ac"
24+
}
25+
26+
pf9_build_reset() {
27+
cd "$ROOT"
28+
git reset HEAD --hard
29+
git clean -fdx
30+
31+
cd "$ROOT/ovs"
32+
git reset HEAD --hard
33+
git clean -fdx
34+
}

build-aux/build-debs.sh

Lines changed: 41 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
set -x
2-
set -e # Recommended: Fail immediately if any command fails
2+
set -e
33

44
source pf9-version/pf9-version.rc
5-
6-
TEAMCITY_ROOT="$(pwd)"
7-
ROOT="$(pwd)/pf9-ovn"
5+
source "$(dirname "$0")/build-common.sh"
86

97
# Install dependencies
108
apt-get update
@@ -17,117 +15,47 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \
1715
libsystemd-dev python3 python3-pip curl python3-twisted python3-zope.interface \
1816
libunwind-dev git strongswan kmod uuid-runtime python3-netifaces
1917

20-
# export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
21-
22-
git config --global --add safe.directory '*'
23-
git config --global url."https://github.com/".insteadOf "git@github.com:"
18+
pf9_git_setup
2419

25-
# Cleanup: Remove previous build artifacts and the dist directory
26-
# We run make distclean in ROOT if Makefile exists, otherwise just clean dist
20+
# Cleanup: Remove previous build artifacts
2721
if [ -f "$ROOT/Makefile" ]; then
2822
make -C "$ROOT" distclean
2923
fi
3024
rm -rf "$ROOT/dist"
3125

32-
# ... [Previous setup and make distclean] ...
33-
3426
UBUNTU_VERSION=$1
35-
CURRENT_BRANCH=$(git -C "$ROOT" rev-parse --abbrev-ref HEAD)
36-
37-
if [ "$UBUNTU_VERSION" = "u24" ]; then
38-
# Ubuntu 24.04 (Noble)
39-
OVS_BASE="3.3.6"
40-
OVN_BASE="24.03.6"
41-
42-
# Case 1: Already on a u24 branch - No Switch/Fetch needed
43-
if echo "$CURRENT_BRANCH" | grep -q "u24"; then
44-
echo "Current branch '$CURRENT_BRANCH' is already a u24 branch. Keeping it."
45-
46-
# Case 2: On a u22 branch, try to swap 'u22' for 'u24'
47-
elif echo "$CURRENT_BRANCH" | grep -q "u22"; then
48-
TARGET_BRANCH="${CURRENT_BRANCH/u22/u24}"
49-
echo "Current branch '$CURRENT_BRANCH' contains 'u22'. Fetching..."
50-
51-
# Fetch before switching
52-
git -C "$ROOT" fetch
53-
54-
echo "Attempting switch to '$TARGET_BRANCH'..."
55-
if git -C "$ROOT" checkout "$TARGET_BRANCH"; then
56-
echo "Successfully switched to specific branch '$TARGET_BRANCH'."
57-
else
58-
echo "Branch '$TARGET_BRANCH' not found. Defaulting to 'main-u24'."
59-
git -C "$ROOT" checkout "main-u24"
60-
fi
61-
62-
# Case 3: Generic branch (no u22/u24 in name) -> Default to main-u24
63-
else
64-
echo "Current branch '$CURRENT_BRANCH' does not match u24 patterns. Fetching and defaulting to 'main-u24'."
65-
git -C "$ROOT" fetch
66-
git -C "$ROOT" checkout "main-u24"
67-
fi
68-
69-
elif [ "$UBUNTU_VERSION" = "u22" ] || [ -z "$UBUNTU_VERSION" ]; then
70-
# Ubuntu 22.04 (Jammy)
71-
OVS_BASE="3.3.1"
72-
OVN_BASE="24.03.2"
73-
74-
# Case 1: On a u24 branch, try to swap 'u24' for 'u22'
75-
if echo "$CURRENT_BRANCH" | grep -q "u24"; then
76-
TARGET_BRANCH="${CURRENT_BRANCH/u24/u22}"
77-
echo "Current branch '$CURRENT_BRANCH' contains 'u24'. Fetching..."
78-
79-
# Fetch before switching
80-
git -C "$ROOT" fetch
81-
82-
echo "Attempting switch to '$TARGET_BRANCH'..."
83-
if git -C "$ROOT" checkout "$TARGET_BRANCH"; then
84-
echo "Successfully switched to specific branch '$TARGET_BRANCH'."
85-
else
86-
echo "Branch '$TARGET_BRANCH' not found. Defaulting to 'main'."
87-
git -C "$ROOT" checkout "main"
88-
fi
89-
90-
# Case 2: Already on u22 or generic branch -> Keep it.
91-
else
92-
echo "Current branch '$CURRENT_BRANCH' is appropriate for u22. Keeping it."
93-
fi
94-
95-
else
27+
28+
if [ "$UBUNTU_VERSION" != "u22" ] && [ "$UBUNTU_VERSION" != "u24" ] && [ -n "$UBUNTU_VERSION" ]; then
9629
echo "Error: Invalid Ubuntu version '$UBUNTU_VERSION'. Expected 'u22' or 'u24'."
9730
exit 1
9831
fi
9932

100-
# ... [Submodule update and build logic below] ...
101-
102-
# 2. Initialize and update submodules recursively
103-
# Performed after branch switching to ensure correct submodules are pulled
104-
git -C "$ROOT" submodule update --init --recursive
33+
pf9_submodule_update
10534

10635
# --- OVN CONFIGURATION ---
107-
PF9_OVN_BUILD_VERSION=1:${OVN_BASE}-pf9-$PF9_VERSION-$BUILD_NUMBER
108-
if [ "$UBUNTU_VERSION" = "u22" ]; then
109-
printf '%s\n' "$PF9_OVN_BUILD_VERSION" > $TEAMCITY_ROOT/ovn-deb-version.txt
110-
fi
36+
PF9_OVN_BUILD_VERSION=1:${OVN_BASE}-pf9-$PF9_VERSION-$BUILD_NUMBER+${UBUNTU_VERSION}
37+
printf '%s\n' "1:${OVN_BASE}-pf9-${PF9_VERSION}-${BUILD_NUMBER}" > $TEAMCITY_ROOT/ovn-deb-version.txt
38+
39+
# debian/changelog gets the full epoch-prefixed version for apt dependency resolution
40+
# configure.ac gets the dot-separated binary version via pf9_patch_ovn_binary_version
41+
sed -i "s/__PF9_OVN_BUILD_VERSION__/$PF9_OVN_BUILD_VERSION/g" "$ROOT/debian/changelog"
11142

112-
# Update OVN files
113-
sed -i "s/__PF9_OVN_BUILD_VERSION__/$PF9_OVN_BUILD_VERSION+$UBUNTU_VERSION/g" "$ROOT/debian/changelog"
114-
sed -i "s/__PF9_OVN_BUILD_VERSION__/$PF9_OVN_BUILD_VERSION+$UBUNTU_VERSION/g" "$ROOT/configure.ac"
43+
pf9_patch_ovn_binary_version
11544

11645
# --- OVS CONFIGURATION ---
117-
PF9_OVS_BUILD_VERSION=1:${OVS_BASE}-pf9-$PF9_VERSION-$BUILD_NUMBER
118-
if [ "$UBUNTU_VERSION" = "u22" ]; then
119-
printf '%s' "$PF9_OVS_BUILD_VERSION" >> $TEAMCITY_ROOT/ovn-deb-version.txt
120-
fi
46+
# Static version (no build counter): only bump manually when OVS code changes.
47+
# Epoch 1 beats upstream; omitting build counter means existing CI-versioned
48+
# installs (e.g. 1:3.3.x-pf9-YYYY.M.P-NNN) are already >= this and won't upgrade.
49+
PF9_OVS_BUILD_VERSION=1:${OVS_BASE}-pf9+${UBUNTU_VERSION}
50+
printf '%s' "1:${OVS_BASE}-pf9" >> $TEAMCITY_ROOT/ovn-deb-version.txt
12151

12252
# Update OVS Changelog
123-
sed -i "s/${OVS_BASE}-1/$PF9_OVS_BUILD_VERSION+$UBUNTU_VERSION/g" "$ROOT/ovs/debian/changelog"
124-
125-
# Python setuptools sanitization (Pep 440)
126-
PF9_OVS_PYTHON_VERSION=$(echo "$PF9_OVS_BUILD_VERSION" | sed "s/^1://; s/-/./g; s/${OVS_BASE}./${OVS_BASE}+/")
127-
128-
# Replace the base version in configure.ac
129-
sed -i "s/${OVS_BASE}/$PF9_OVS_PYTHON_VERSION.$UBUNTU_VERSION/g" "$ROOT/ovs/configure.ac"
53+
sed -i "s/${OVS_BASE}-1/$PF9_OVS_BUILD_VERSION/g" "$ROOT/ovs/debian/changelog"
13054

55+
# Python setuptools sanitization (PEP 440)
56+
# Strip epoch and +UBUNTU_VERSION before converting to dot-notation, then re-add + for local segment
57+
PF9_OVS_PYTHON_VERSION=$(echo "$PF9_OVS_BUILD_VERSION" | sed "s/^1://; s/+[^-]*$//; s/-/./g; s/${OVS_BASE}./${OVS_BASE}+/")
58+
sed -i "s/${OVS_BASE}/$PF9_OVS_PYTHON_VERSION/g" "$ROOT/ovs/configure.ac"
13159

13260
# --- BUILD OVS ---
13361
# Note: Artifacts from make debian-deb usually land in the directory ABOVE the build dir.
@@ -159,29 +87,31 @@ export OVSDIR OVSBUILDDIR EXTRA_CONFIGURE_OPTS="--with-ovs-build=$OVSBUILDDIR"
15987
# Build OVN Debs (Artifacts land in parent of $ROOT, i.e., $ROOT/../)
16088
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -us -uc
16189

90+
# Remove bloat packages before artifact collection
91+
find "$ROOT" "$TEAMCITY_ROOT" -maxdepth 1 -name "*.deb" \
92+
\( -name "*-doc_*" -o -name "*-source_*" -o -name "*-test_*" \
93+
-o -name "*-testcontroller_*" -o -name "*-dbgsym_*" \) \
94+
-delete -print
95+
16296
# --- ARTIFACT COLLECTION ---
16397
ARTIFACT_DIR="$TEAMCITY_ROOT/pkgs/$UBUNTU_VERSION"
16498
mkdir -p "$ARTIFACT_DIR"
16599

166-
# Move OVS debs (from ROOT)
167-
mv -v "$ROOT"/*.deb "$ARTIFACT_DIR"
100+
# Move OVS debs (exclude doc/source/test/dbgsym)
101+
find "$ROOT" -maxdepth 1 -name "*.deb" \
102+
! -name "*-doc_*" ! -name "*-source_*" \
103+
! -name "*-test_*" ! -name "*-testcontroller_*" ! -name "*-dbgsym_*" \
104+
-exec mv -v {} "$ARTIFACT_DIR" \;
168105

169-
# Move OVN debs (from ROOT/../)
170-
# Since we are in ROOT, we use ../
171-
mv -v ../*.deb "$ARTIFACT_DIR"
106+
# Move OVN debs (from ROOT/../, exclude doc/source/test/dbgsym)
107+
find "$TEAMCITY_ROOT" -maxdepth 1 -name "*.deb" \
108+
! -name "*-doc_*" ! -name "*-source_*" \
109+
! -name "*-test_*" ! -name "*-testcontroller_*" ! -name "*-dbgsym_*" \
110+
-exec mv -v {} "$ARTIFACT_DIR" \;
172111

173112

174113
# --- CLEANUP ---
175-
cd "$ROOT"
176-
git reset HEAD --hard
177-
git clean -fdx
178-
179-
cd "$ROOT/ovs"
180-
git reset HEAD --hard
181-
git clean -fdx
182-
183-
# Restore original branch to keep CI agent clean
184-
git -C "$ROOT" checkout "${CURRENT_BRANCH}"
114+
pf9_build_reset
185115

186116
cd "$ARTIFACT_DIR"
187117
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

build-aux/build-rpms.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
set -x
2+
set -e
3+
4+
source pf9-version/pf9-version.rc
5+
source "$(dirname "$0")/build-common.sh"
6+
7+
# Enable EPEL and CRB repos for additional packages
8+
dnf install -y epel-release
9+
dnf config-manager --set-enabled crb
10+
11+
# Install dependencies
12+
dnf install -y \
13+
rpm-build rpmdevtools autoconf automake libtool gcc gcc-c++ \
14+
openssl openssl-devel python3-devel systemd-units checkpolicy \
15+
selinux-policy-devel groff graphviz libcap-ng-devel \
16+
unbound unbound-devel procps-ng bzip2 git createrepo_c \
17+
libpcap-devel numactl-devel python3-sphinx python3-sortedcontainers \
18+
libevent-devel json-c-devel libunwind-devel \
19+
desktop-file-utils libbpf-devel libxdp-devel
20+
21+
pf9_git_setup
22+
23+
# Cleanup: Remove previous build artifacts
24+
if [ -f "$ROOT/Makefile" ]; then
25+
make -C "$ROOT" distclean
26+
fi
27+
rm -rf "$ROOT/dist" "$ROOT/rpm"
28+
29+
ROCKY_VERSION=$1
30+
31+
if [ "$ROCKY_VERSION" != "r10" ]; then
32+
echo "Error: Invalid Rocky version '$ROCKY_VERSION'. Expected 'r10'."
33+
exit 1
34+
fi
35+
36+
pf9_submodule_update
37+
38+
# --- OVN CONFIGURATION ---
39+
# RPM Version field does not allow hyphens; use dots throughout
40+
printf '%s\n' "1:${OVN_BASE}.pf9.${PF9_VERSION}.${BUILD_NUMBER}" > $TEAMCITY_ROOT/ovn-rpm-version.txt
41+
42+
# configure.ac gets the dot-separated binary version (no OS suffix)
43+
# RPM package OS indicator comes from %{?dist} macro automatically (e.g. .el10)
44+
pf9_patch_ovn_binary_version
45+
46+
# --- OVS CONFIGURATION ---
47+
# Static version (no build counter): only bump manually when OVS code changes
48+
PF9_OVS_BUILD_VERSION=${OVS_BASE}.pf9
49+
printf '%s' "1:$PF9_OVS_BUILD_VERSION" >> $TEAMCITY_ROOT/ovn-rpm-version.txt
50+
51+
# Update OVS configure.ac
52+
sed -i "s/${OVS_BASE}/${PF9_OVS_BUILD_VERSION}/g" "$ROOT/ovs/configure.ac"
53+
54+
# --- BUILD OVS ---
55+
# Inject Epoch: 1 into the OVS spec on the fly (submodule is not tracked)
56+
sed -i 's/^Version: @VERSION@/Epoch: 1\nVersion: @VERSION@/' "$ROOT/ovs/rhel/openvswitch-fedora.spec.in"
57+
58+
( cd "$ROOT/ovs" && ./boot.sh )
59+
( cd "$ROOT/ovs" && ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --enable-ssl )
60+
( cd "$ROOT/ovs" && make rpm-fedora RPMBUILD_OPT="--without check" )
61+
62+
# Install OVS RPMs required for OVN build
63+
dnf install -y "$ROOT"/ovs/rpm/rpmbuild/RPMS/*/*.rpm || true
64+
65+
# --- BUILD OVN ---
66+
cd "$ROOT"
67+
./boot.sh
68+
69+
OVSDIR=$ROOT/ovs
70+
OVSBUILDDIR="$OVSDIR"
71+
export OVSDIR OVSBUILDDIR OVSVERSION=${OVS_BASE}
72+
73+
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc \
74+
--with-ovs-source="$OVSDIR"
75+
76+
make rpm-fedora RPMBUILD_OPT="--without check"
77+
78+
# Remove bloat packages before artifact collection
79+
find "$ROOT/ovs/rpm/rpmbuild/RPMS" "$ROOT/rpm/rpmbuild/RPMS" -name "*.rpm" \
80+
\( -name "*-debuginfo-*" -o -name "*-debugsource-*" -o -name "*-devel-*" \) \
81+
-delete -print
82+
83+
# --- ARTIFACT COLLECTION ---
84+
ARTIFACT_DIR="$TEAMCITY_ROOT/pkgs/$ROCKY_VERSION"
85+
mkdir -p "$ARTIFACT_DIR"
86+
87+
# Collect OVS RPMs (exclude debug/source/devel)
88+
find "$ROOT/ovs/rpm/rpmbuild/RPMS" -name "*.rpm" \
89+
! -name "*-debuginfo-*" ! -name "*-debugsource-*" ! -name "*-devel-*" \
90+
-exec cp -v {} "$ARTIFACT_DIR" \;
91+
92+
# Collect OVN RPMs (exclude debug/source/devel)
93+
find "$ROOT/rpm/rpmbuild/RPMS" -name "*.rpm" \
94+
! -name "*-debuginfo-*" ! -name "*-debugsource-*" ! -name "*-devel-*" \
95+
-exec cp -v {} "$ARTIFACT_DIR" \;
96+
97+
ls -lh "$ARTIFACT_DIR"
98+
99+
# --- CLEANUP ---
100+
pf9_build_reset
101+
102+
cd "$ARTIFACT_DIR"
103+
createrepo_c .

container/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ubuntu:24.04
22

33
ENV DEBIAN_FRONTEND=noninteractive
44
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
@@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y -qq --no-install-recommends \
1111
&& rm -rf /var/lib/apt/lists/*
1212

1313
# Copy built packages from the build context
14-
COPY pkgs/u22/*.deb /tmp/pkgs/
14+
COPY pkgs/u24/*.deb /tmp/pkgs/
1515

1616
RUN apt-get update \
1717
&& dpkg -i /tmp/pkgs/*.deb || true \

0 commit comments

Comments
 (0)