From 32e620fe70aaa6be5fb00168aa04acae79984253 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Wed, 11 Mar 2026 16:25:15 +0800 Subject: [PATCH 1/5] Fix compliance issues for RPM and DEB packages As an Apache incubating project, convenience binaries must include LICENSE, NOTICE, and DISCLAIMER files. This commit adds these mandatory compliance files into the spec and rules definitions to ensure they are properly distributed with the binary RPM and DEB packages. Additionally, this commit: - Automates the cp of the .spec file into the ~/rpmbuild tree to prevent build failures for new users. --- devops/build/packaging/deb/build-deb.sh | 36 ++++++++++++++--- devops/build/packaging/deb/ubuntu22.04/rules | 7 ++++ .../rpm/apache-cloudberry-db-incubating.spec | 9 +++++ devops/build/packaging/rpm/build-rpm.sh | 40 ++++++++++++++++++- 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/devops/build/packaging/deb/build-deb.sh b/devops/build/packaging/deb/build-deb.sh index 1f5aef2258a..3bcd967fa5a 100755 --- a/devops/build/packaging/deb/build-deb.sh +++ b/devops/build/packaging/deb/build-deb.sh @@ -139,10 +139,29 @@ export CBDB_PKG_VERSION=${CBDB_FULL_VERSION}-${BUILD_NUMBER}-${OS_DISTRO} # Check if required commands are available check_commands -# Define the control file path -CONTROL_FILE=debian/control +# Find project root (assumed to be four levels up from scripts directory: devops/build/packaging/deb/) +PROJECT_ROOT="$(cd "$(dirname "$0")/../../../../" && pwd)" + +# Define where the debian metadata is located +DEBIAN_SRC_DIR="$(dirname "$0")/${OS_DISTRO}" + +# Prepare the debian directory at the project root (required by dpkg-buildpackage) +if [ -d "$DEBIAN_SRC_DIR" ]; then + echo "Preparing debian directory from $DEBIAN_SRC_DIR..." + mkdir -p "$PROJECT_ROOT/debian" + # Use /. to copy directory contents if target exists instead of nested directories + cp -rf "$DEBIAN_SRC_DIR"/. "$PROJECT_ROOT/debian/" +else + if [ ! -d "$PROJECT_ROOT/debian" ]; then + echo "Error: Debian metadata not found at $DEBIAN_SRC_DIR and no debian/ directory exists at root." + exit 1 + fi +fi + +# Define the control file path (at the project root) +CONTROL_FILE="$PROJECT_ROOT/debian/control" -# Check if the spec file exists +# Check if the control file exists if [ ! -f "$CONTROL_FILE" ]; then echo "Error: Control file not found at $CONTROL_FILE." exit 1 @@ -160,10 +179,15 @@ if [ "${DRY_RUN:-false}" = true ]; then exit 0 fi -# Run debbuild with the provided options -echo "Building DEB with Version $CBDB_FULL_VERSION ..." +# Run debbuild from the project root +echo "Building DEB with Version $CBDB_FULL_VERSION in $PROJECT_ROOT ..." -print_changelog > debian/changelog +print_changelog > "$PROJECT_ROOT/debian/changelog" + +# Only cd if we are not already at the project root +if [ "$(pwd)" != "$PROJECT_ROOT" ]; then + cd "$PROJECT_ROOT" +fi if ! eval "$DEBBUILD_CMD"; then echo "Error: deb build failed." diff --git a/devops/build/packaging/deb/ubuntu22.04/rules b/devops/build/packaging/deb/ubuntu22.04/rules index cb387d209e6..91a31258cca 100755 --- a/devops/build/packaging/deb/ubuntu22.04/rules +++ b/devops/build/packaging/deb/ubuntu22.04/rules @@ -20,6 +20,13 @@ include /usr/share/dpkg/default.mk gpinstall: make install DESTDIR=${DEBIAN_DESTINATION} prefix= + # Copy Apache compliance files + mkdir -p ${DEBIAN_DESTINATION}${CBDB_BIN_PATH} + cp -a LICENSE NOTICE DISCLAIMER ${DEBIAN_DESTINATION}${CBDB_BIN_PATH}/ + cp -a licenses ${DEBIAN_DESTINATION}${CBDB_BIN_PATH}/ + # Create debian/copyright for Debian policy compliance + mkdir -p $(shell pwd)/debian + cat LICENSE NOTICE > $(shell pwd)/debian/copyright override_dh_auto_install: gpinstall # the staging directory for creating a debian is NOT the right GPHOME. diff --git a/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec b/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec index 03fa0a34570..f907f50bc4b 100644 --- a/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec +++ b/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec @@ -152,6 +152,12 @@ mkdir -p %{buildroot}%{cloudberry_install_dir}-%{version} cp -R %{cloudberry_install_dir}/* %{buildroot}%{cloudberry_install_dir}-%{version} +# Copy Apache mandatory compliance files from the SOURCES directory into the installation directory +cp %{_sourcedir}/LICENSE %{buildroot}%{cloudberry_install_dir}-%{version}/ +cp %{_sourcedir}/NOTICE %{buildroot}%{cloudberry_install_dir}-%{version}/ +cp %{_sourcedir}/DISCLAIMER %{buildroot}%{cloudberry_install_dir}-%{version}/ +cp -R %{_sourcedir}/licenses %{buildroot}%{cloudberry_install_dir}-%{version}/ + # Create the symbolic link ln -sfn %{cloudberry_install_dir}-%{version} %{buildroot}%{cloudberry_install_dir} @@ -160,6 +166,9 @@ ln -sfn %{cloudberry_install_dir}-%{version} %{buildroot}%{cloudberry_install_di %{prefix} %license %{cloudberry_install_dir}-%{version}/LICENSE +%doc %{cloudberry_install_dir}-%{version}/NOTICE +%doc %{cloudberry_install_dir}-%{version}/DISCLAIMER +%{cloudberry_install_dir}-%{version}/licenses/ %debug_package diff --git a/devops/build/packaging/rpm/build-rpm.sh b/devops/build/packaging/rpm/build-rpm.sh index ceb7d18d392..6ec7d1d640e 100755 --- a/devops/build/packaging/rpm/build-rpm.sh +++ b/devops/build/packaging/rpm/build-rpm.sh @@ -118,10 +118,46 @@ fi # Check if required commands are available check_commands -# Define the spec file path +# Define the source spec file path (assuming it is in the same directory as the script) +SOURCE_SPEC_FILE="$(dirname "$0")/apache-cloudberry-db-incubating.spec" + +# Ensure rpmbuild SPECS and SOURCES directories exist +mkdir -p ~/rpmbuild/SPECS +mkdir -p ~/rpmbuild/SOURCES + +# Find project root (assumed to be four levels up from scripts directory: devops/build/packaging/rpm/) +PROJECT_ROOT="$(cd "$(dirname "$0")/../../../../" && pwd)" + +# Copy the spec file to rpmbuild/SPECS if the source exists and is different +if [ -f "$SOURCE_SPEC_FILE" ]; then + # Avoid copying if SPEC_FILE is already a symlink/file pointing to SOURCE_SPEC_FILE (common in CI) + if [ ! "$SOURCE_SPEC_FILE" -ef "$SPEC_FILE" ]; then + cp -f "$SOURCE_SPEC_FILE" "$SPEC_FILE" + fi +else + echo "Warning: Source spec file not found at $SOURCE_SPEC_FILE, assuming it is already in ~/rpmbuild/SPECS/" +fi + +# Copy Apache mandatory compliance files to rpmbuild/SOURCES +echo "Copying compliance files from $PROJECT_ROOT to ~/rpmbuild/SOURCES..." +for f in LICENSE NOTICE DISCLAIMER; do + if [ -f "$PROJECT_ROOT/$f" ]; then + cp -af "$PROJECT_ROOT/$f" ~/rpmbuild/SOURCES/ + else + echo "Warning: $f not found in $PROJECT_ROOT" + fi +done + +if [ -d "$PROJECT_ROOT/licenses" ]; then + cp -af "$PROJECT_ROOT/licenses" ~/rpmbuild/SOURCES/ +else + echo "Warning: licenses directory not found in $PROJECT_ROOT" +fi + +# Define the target spec file path SPEC_FILE=~/rpmbuild/SPECS/apache-cloudberry-db-incubating.spec -# Check if the spec file exists +# Check if the spec file exists at the target location before proceeding if [ ! -f "$SPEC_FILE" ]; then echo "Error: Spec file not found at $SPEC_FILE." exit 1 From 8f76bdb9ad0f6e00a58419361420949aae2ad740 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Wed, 11 Mar 2026 17:54:41 +0800 Subject: [PATCH 2/5] Fix build error --- devops/build/packaging/deb/ubuntu22.04/compat | 2 +- devops/build/packaging/deb/ubuntu22.04/rules | 7 +++---- .../packaging/rpm/apache-cloudberry-db-incubating.spec | 5 ----- devops/build/packaging/rpm/build-rpm.sh | 6 +++--- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/devops/build/packaging/deb/ubuntu22.04/compat b/devops/build/packaging/deb/ubuntu22.04/compat index ec635144f60..b1bd38b62a0 100644 --- a/devops/build/packaging/deb/ubuntu22.04/compat +++ b/devops/build/packaging/deb/ubuntu22.04/compat @@ -1 +1 @@ -9 +13 diff --git a/devops/build/packaging/deb/ubuntu22.04/rules b/devops/build/packaging/deb/ubuntu22.04/rules index 91a31258cca..4e0174468e1 100755 --- a/devops/build/packaging/deb/ubuntu22.04/rules +++ b/devops/build/packaging/deb/ubuntu22.04/rules @@ -20,10 +20,9 @@ include /usr/share/dpkg/default.mk gpinstall: make install DESTDIR=${DEBIAN_DESTINATION} prefix= - # Copy Apache compliance files - mkdir -p ${DEBIAN_DESTINATION}${CBDB_BIN_PATH} - cp -a LICENSE NOTICE DISCLAIMER ${DEBIAN_DESTINATION}${CBDB_BIN_PATH}/ - cp -a licenses ${DEBIAN_DESTINATION}${CBDB_BIN_PATH}/ + # Copy Apache compliance files into the build staging directory + cp -a LICENSE NOTICE DISCLAIMER ${DEBIAN_DESTINATION}/ + cp -a licenses ${DEBIAN_DESTINATION}/ # Create debian/copyright for Debian policy compliance mkdir -p $(shell pwd)/debian cat LICENSE NOTICE > $(shell pwd)/debian/copyright diff --git a/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec b/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec index f907f50bc4b..cafb057c351 100644 --- a/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec +++ b/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec @@ -165,11 +165,6 @@ ln -sfn %{cloudberry_install_dir}-%{version} %{buildroot}%{cloudberry_install_di %{prefix}-%{version} %{prefix} -%license %{cloudberry_install_dir}-%{version}/LICENSE -%doc %{cloudberry_install_dir}-%{version}/NOTICE -%doc %{cloudberry_install_dir}-%{version}/DISCLAIMER -%{cloudberry_install_dir}-%{version}/licenses/ - %debug_package %post diff --git a/devops/build/packaging/rpm/build-rpm.sh b/devops/build/packaging/rpm/build-rpm.sh index 6ec7d1d640e..2c490166f45 100755 --- a/devops/build/packaging/rpm/build-rpm.sh +++ b/devops/build/packaging/rpm/build-rpm.sh @@ -128,6 +128,9 @@ mkdir -p ~/rpmbuild/SOURCES # Find project root (assumed to be four levels up from scripts directory: devops/build/packaging/rpm/) PROJECT_ROOT="$(cd "$(dirname "$0")/../../../../" && pwd)" +# Define the target spec file path +SPEC_FILE=~/rpmbuild/SPECS/apache-cloudberry-db-incubating.spec + # Copy the spec file to rpmbuild/SPECS if the source exists and is different if [ -f "$SOURCE_SPEC_FILE" ]; then # Avoid copying if SPEC_FILE is already a symlink/file pointing to SOURCE_SPEC_FILE (common in CI) @@ -154,9 +157,6 @@ else echo "Warning: licenses directory not found in $PROJECT_ROOT" fi -# Define the target spec file path -SPEC_FILE=~/rpmbuild/SPECS/apache-cloudberry-db-incubating.spec - # Check if the spec file exists at the target location before proceeding if [ ! -f "$SPEC_FILE" ]; then echo "Error: Spec file not found at $SPEC_FILE." From 7c0df9a7c9a1183c89245ddefa971fad4360593d Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Wed, 11 Mar 2026 18:31:29 +0800 Subject: [PATCH 3/5] update --- devops/build/packaging/deb/ubuntu22.04/compat | 2 +- devops/build/packaging/deb/ubuntu22.04/rules | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/devops/build/packaging/deb/ubuntu22.04/compat b/devops/build/packaging/deb/ubuntu22.04/compat index b1bd38b62a0..ec635144f60 100644 --- a/devops/build/packaging/deb/ubuntu22.04/compat +++ b/devops/build/packaging/deb/ubuntu22.04/compat @@ -1 +1 @@ -13 +9 diff --git a/devops/build/packaging/deb/ubuntu22.04/rules b/devops/build/packaging/deb/ubuntu22.04/rules index 4e0174468e1..463486cf03f 100755 --- a/devops/build/packaging/deb/ubuntu22.04/rules +++ b/devops/build/packaging/deb/ubuntu22.04/rules @@ -19,7 +19,16 @@ include /usr/share/dpkg/default.mk dh $@ --parallel gpinstall: - make install DESTDIR=${DEBIAN_DESTINATION} prefix= + # If the build staging directory is empty, copy from the pre-installed location. + # In CI, BUILD_DESTINATION already points here so it will be populated. + # For local manual packaging, copy from the installed Cloudberry path. + @mkdir -p ${DEBIAN_DESTINATION} + @if [ -z "$$(ls -A ${DEBIAN_DESTINATION} 2>/dev/null)" ]; then \ + echo "Copying pre-built binaries from ${CBDB_BIN_PATH} to ${DEBIAN_DESTINATION}..."; \ + cp -a ${CBDB_BIN_PATH}/* ${DEBIAN_DESTINATION}/; \ + else \ + echo "Build staging directory already populated, skipping copy."; \ + fi # Copy Apache compliance files into the build staging directory cp -a LICENSE NOTICE DISCLAIMER ${DEBIAN_DESTINATION}/ cp -a licenses ${DEBIAN_DESTINATION}/ From ec375ad96ea3e986c36e6fc8f053d2fe692bb1d5 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Wed, 11 Mar 2026 18:51:20 +0800 Subject: [PATCH 4/5] Update --- devops/build/packaging/deb/ubuntu22.04/compat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devops/build/packaging/deb/ubuntu22.04/compat b/devops/build/packaging/deb/ubuntu22.04/compat index ec635144f60..b1bd38b62a0 100644 --- a/devops/build/packaging/deb/ubuntu22.04/compat +++ b/devops/build/packaging/deb/ubuntu22.04/compat @@ -1 +1 @@ -9 +13 From f0f3b1bf6b03d01e4e0bfff634c88f5d46f69a6a Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Fri, 13 Mar 2026 13:53:25 +0800 Subject: [PATCH 5/5] Revert "Update" This reverts commit ec375ad96ea3e986c36e6fc8f053d2fe692bb1d5. --- devops/build/packaging/deb/ubuntu22.04/compat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devops/build/packaging/deb/ubuntu22.04/compat b/devops/build/packaging/deb/ubuntu22.04/compat index b1bd38b62a0..ec635144f60 100644 --- a/devops/build/packaging/deb/ubuntu22.04/compat +++ b/devops/build/packaging/deb/ubuntu22.04/compat @@ -1 +1 @@ -13 +9