Skip to content

Commit e0360ba

Browse files
committed
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.
1 parent a6a7579 commit e0360ba

4 files changed

Lines changed: 90 additions & 11 deletions

File tree

devops/build/packaging/deb/build-deb.sh

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,29 @@ export CBDB_PKG_VERSION=${CBDB_FULL_VERSION}-${BUILD_NUMBER}-${OS_DISTRO}
139139
# Check if required commands are available
140140
check_commands
141141

142-
# Define the control file path
143-
CONTROL_FILE=debian/control
142+
# Find project root (assumed to be four levels up from scripts directory: devops/build/packaging/deb/)
143+
PROJECT_ROOT="$(cd "$(dirname "$0")/../../../../" && pwd)"
144+
145+
# Define where the debian metadata is located
146+
DEBIAN_SRC_DIR="$(dirname "$0")/${OS_DISTRO}"
147+
148+
# Prepare the debian directory at the project root (required by dpkg-buildpackage)
149+
if [ -d "$DEBIAN_SRC_DIR" ]; then
150+
echo "Preparing debian directory from $DEBIAN_SRC_DIR..."
151+
mkdir -p "$PROJECT_ROOT/debian"
152+
# Use /. to copy directory contents if target exists instead of nested directories
153+
cp -rf "$DEBIAN_SRC_DIR"/. "$PROJECT_ROOT/debian/"
154+
else
155+
if [ ! -d "$PROJECT_ROOT/debian" ]; then
156+
echo "Error: Debian metadata not found at $DEBIAN_SRC_DIR and no debian/ directory exists at root."
157+
exit 1
158+
fi
159+
fi
160+
161+
# Define the control file path (at the project root)
162+
CONTROL_FILE="$PROJECT_ROOT/debian/control"
144163

145-
# Check if the spec file exists
164+
# Check if the control file exists
146165
if [ ! -f "$CONTROL_FILE" ]; then
147166
echo "Error: Control file not found at $CONTROL_FILE."
148167
exit 1
@@ -160,10 +179,15 @@ if [ "${DRY_RUN:-false}" = true ]; then
160179
exit 0
161180
fi
162181

163-
# Run debbuild with the provided options
164-
echo "Building DEB with Version $CBDB_FULL_VERSION ..."
182+
# Run debbuild from the project root
183+
echo "Building DEB with Version $CBDB_FULL_VERSION in $PROJECT_ROOT ..."
165184

166-
print_changelog > debian/changelog
185+
print_changelog > "$PROJECT_ROOT/debian/changelog"
186+
187+
# Only cd if we are not already at the project root
188+
if [ "$(pwd)" != "$PROJECT_ROOT" ]; then
189+
cd "$PROJECT_ROOT"
190+
fi
167191

168192
if ! eval "$DEBBUILD_CMD"; then
169193
echo "Error: deb build failed."

devops/build/packaging/deb/ubuntu22.04/rules

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,22 @@ include /usr/share/dpkg/default.mk
1919
dh $@ --parallel
2020

2121
gpinstall:
22-
make install DESTDIR=${DEBIAN_DESTINATION} prefix=
22+
# If the build staging directory is empty, copy from the pre-installed location.
23+
# In CI, BUILD_DESTINATION already points here so it will be populated.
24+
# For local manual packaging, copy from the installed Cloudberry path.
25+
@mkdir -p ${DEBIAN_DESTINATION}
26+
@if [ -z "$$(ls -A ${DEBIAN_DESTINATION} 2>/dev/null)" ]; then \
27+
echo "Copying pre-built binaries from ${CBDB_BIN_PATH} to ${DEBIAN_DESTINATION}..."; \
28+
cp -a ${CBDB_BIN_PATH}/* ${DEBIAN_DESTINATION}/; \
29+
else \
30+
echo "Build staging directory already populated, skipping copy."; \
31+
fi
32+
# Copy Apache compliance files into the build staging directory
33+
cp -a LICENSE NOTICE DISCLAIMER ${DEBIAN_DESTINATION}/
34+
cp -a licenses ${DEBIAN_DESTINATION}/
35+
# Create debian/copyright for Debian policy compliance
36+
mkdir -p $(shell pwd)/debian
37+
cat LICENSE NOTICE > $(shell pwd)/debian/copyright
2338

2439
override_dh_auto_install: gpinstall
2540
# the staging directory for creating a debian is NOT the right GPHOME.

devops/build/packaging/rpm/apache-cloudberry-db-incubating.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,19 @@ mkdir -p %{buildroot}%{cloudberry_install_dir}-%{version}
152152

153153
cp -R %{cloudberry_install_dir}/* %{buildroot}%{cloudberry_install_dir}-%{version}
154154

155+
# Copy Apache mandatory compliance files from the SOURCES directory into the installation directory
156+
cp %{_sourcedir}/LICENSE %{buildroot}%{cloudberry_install_dir}-%{version}/
157+
cp %{_sourcedir}/NOTICE %{buildroot}%{cloudberry_install_dir}-%{version}/
158+
cp %{_sourcedir}/DISCLAIMER %{buildroot}%{cloudberry_install_dir}-%{version}/
159+
cp -R %{_sourcedir}/licenses %{buildroot}%{cloudberry_install_dir}-%{version}/
160+
155161
# Create the symbolic link
156162
ln -sfn %{cloudberry_install_dir}-%{version} %{buildroot}%{cloudberry_install_dir}
157163

158164
%files
159165
%{prefix}-%{version}
160166
%{prefix}
161167

162-
%license %{cloudberry_install_dir}-%{version}/LICENSE
163-
164168
%debug_package
165169

166170
%post

devops/build/packaging/rpm/build-rpm.sh

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,46 @@ fi
118118
# Check if required commands are available
119119
check_commands
120120

121-
# Define the spec file path
121+
# Define the source spec file path (assuming it is in the same directory as the script)
122+
SOURCE_SPEC_FILE="$(dirname "$0")/apache-cloudberry-db-incubating.spec"
123+
124+
# Ensure rpmbuild SPECS and SOURCES directories exist
125+
mkdir -p ~/rpmbuild/SPECS
126+
mkdir -p ~/rpmbuild/SOURCES
127+
128+
# Find project root (assumed to be four levels up from scripts directory: devops/build/packaging/rpm/)
129+
PROJECT_ROOT="$(cd "$(dirname "$0")/../../../../" && pwd)"
130+
131+
# Define the target spec file path
122132
SPEC_FILE=~/rpmbuild/SPECS/apache-cloudberry-db-incubating.spec
123133

124-
# Check if the spec file exists
134+
# Copy the spec file to rpmbuild/SPECS if the source exists and is different
135+
if [ -f "$SOURCE_SPEC_FILE" ]; then
136+
# Avoid copying if SPEC_FILE is already a symlink/file pointing to SOURCE_SPEC_FILE (common in CI)
137+
if [ ! "$SOURCE_SPEC_FILE" -ef "$SPEC_FILE" ]; then
138+
cp -f "$SOURCE_SPEC_FILE" "$SPEC_FILE"
139+
fi
140+
else
141+
echo "Warning: Source spec file not found at $SOURCE_SPEC_FILE, assuming it is already in ~/rpmbuild/SPECS/"
142+
fi
143+
144+
# Copy Apache mandatory compliance files to rpmbuild/SOURCES
145+
echo "Copying compliance files from $PROJECT_ROOT to ~/rpmbuild/SOURCES..."
146+
for f in LICENSE NOTICE DISCLAIMER; do
147+
if [ -f "$PROJECT_ROOT/$f" ]; then
148+
cp -af "$PROJECT_ROOT/$f" ~/rpmbuild/SOURCES/
149+
else
150+
echo "Warning: $f not found in $PROJECT_ROOT"
151+
fi
152+
done
153+
154+
if [ -d "$PROJECT_ROOT/licenses" ]; then
155+
cp -af "$PROJECT_ROOT/licenses" ~/rpmbuild/SOURCES/
156+
else
157+
echo "Warning: licenses directory not found in $PROJECT_ROOT"
158+
fi
159+
160+
# Check if the spec file exists at the target location before proceeding
125161
if [ ! -f "$SPEC_FILE" ]; then
126162
echo "Error: Spec file not found at $SPEC_FILE."
127163
exit 1

0 commit comments

Comments
 (0)