11set -x
2- set -e # Recommended: Fail immediately if any command fails
2+ set -e
33
44source 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
108apt-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
2721if [ -f " $ROOT /Makefile" ]; then
2822 make -C " $ROOT " distclean
2923fi
3024rm -rf " $ROOT /dist"
3125
32- # ... [Previous setup and make distclean] ...
33-
3426UBUNTU_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
9831fi
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/../)
16088DEB_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 ---
16397ARTIFACT_DIR=" $TEAMCITY_ROOT /pkgs/$UBUNTU_VERSION "
16498mkdir -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
186116cd " $ARTIFACT_DIR "
187117dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
0 commit comments