This is an automated email from the ASF dual-hosted git repository.
djwang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push:
new da9a5ae083b Fix compliance issues for RPM and DEB packages
da9a5ae083b is described below
commit da9a5ae083ba5fd3636a16a436bf17c6e596ffcf
Author: Dianjin Wang <[email protected]>
AuthorDate: Fri Apr 3 21:17:59 2026 +0800
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.
- Dynamically locates debian metadata from OS-specific
directories and copies to project root for dpkg-buildpackage.
- Generates debian/copyright file by combining LICENSE
and NOTICE to meet Debian policy requirements.
---
devops/build/packaging/deb/build-deb.sh | 47 ++++++++++++++++++----
devops/build/packaging/deb/ubuntu22.04/rules | 17 +++++++-
.../rpm/apache-cloudberry-db-incubating.spec | 8 +++-
devops/build/packaging/rpm/build-rpm.sh | 40 +++++++++++++++++-
4 files changed, 99 insertions(+), 13 deletions(-)
diff --git a/devops/build/packaging/deb/build-deb.sh
b/devops/build/packaging/deb/build-deb.sh
index 1f5aef2258a..61a29e50fc9 100755
--- a/devops/build/packaging/deb/build-deb.sh
+++ b/devops/build/packaging/deb/build-deb.sh
@@ -109,7 +109,7 @@ export CBDB_FULL_VERSION=$VERSION
# Set version if not provided
if [ -z "${VERSION}" ]; then
- export CBDB_FULL_VERSION=$(./getversion | cut -d'-' -f 1 | cut -d'+' -f 1)
+ export CBDB_FULL_VERSION=$(./getversion 2>/dev/null | cut -d'-' -f 1 | cut
-d'+' -f 1 || echo "unknown")
fi
if [[ ! $CBDB_FULL_VERSION =~ ^[0-9] ]]; then
@@ -127,22 +127,48 @@ fi
# Detect OS distribution (e.g., ubuntu22.04, debian12)
if [ -z ${OS_DISTRO+x} ]; then
if [ -f /etc/os-release ]; then
+ # Temporarily disable unbound variable check for sourcing os-release
+ set +u
. /etc/os-release
- OS_DISTRO=$(echo "${ID}${VERSION_ID}" | tr '[:upper:]' '[:lower:]')
+ set -u
+ # Ensure ID and VERSION_ID are set before using them
+ OS_DISTRO=$(echo "${ID:-unknown}${VERSION_ID:-}" | tr '[:upper:]'
'[:lower:]')
else
OS_DISTRO="unknown"
fi
fi
+# Ensure OS_DISTRO is exported and not empty
+export OS_DISTRO=${OS_DISTRO:-unknown}
+
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 +186,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 > "$PROJECT_ROOT/debian/changelog"
-print_changelog > 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..463486cf03f 100755
--- a/devops/build/packaging/deb/ubuntu22.04/rules
+++ b/devops/build/packaging/deb/ubuntu22.04/rules
@@ -19,7 +19,22 @@ 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}/
+ # 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 517b35212bf..e228f8fe76a 100644
--- a/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec
+++ b/devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec
@@ -155,6 +155,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}
@@ -162,8 +168,6 @@ ln -sfn %{cloudberry_install_dir}-%{version}
%{buildroot}%{cloudberry_install_di
%{prefix}-%{version}
%{prefix}
-%license %{cloudberry_install_dir}-%{version}/LICENSE
-
%debug_package
%post
diff --git a/devops/build/packaging/rpm/build-rpm.sh
b/devops/build/packaging/rpm/build-rpm.sh
index ceb7d18d392..2c490166f45 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)"
+
+# Define the target spec file path
SPEC_FILE=~/rpmbuild/SPECS/apache-cloudberry-db-incubating.spec
-# Check if the spec file exists
+# 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
+
+# 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]