From e752b55942e3693504a18abdf5491110a4af7d78 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Tue, 28 Apr 2026 14:28:04 +0800 Subject: [PATCH 1/2] Package: extract install script generation to template file Extract install script generation from Makefile to a separate template file for better maintainability and readability. - Add install.sh.template with Apache License header - Simplify Makefile package target using sed for template substitution --- Makefile | 35 +++++++-------------------------- install.sh.template | 47 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 28 deletions(-) create mode 100644 install.sh.template diff --git a/Makefile b/Makefile index 12b5fd44..95f7415e 100644 --- a/Makefile +++ b/Makefile @@ -189,34 +189,13 @@ package: @cp NOTICE $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/ @cp DISCLAIMER $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/ @echo "Creating install script..." - @echo '#!/bin/bash' > $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'set -e' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo '' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo '# Use GPHOME if set, otherwise use default path' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'if [ -n "$$GPHOME" ]; then' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo ' INSTALL_DIR="$$GPHOME"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'elif [ -n "$$INSTALL_DIR" ]; then' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo ' INSTALL_DIR="$$INSTALL_DIR"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'else' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo ' INSTALL_DIR="/usr/local"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'fi' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo '' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'SCRIPT_DIR="$$(cd "$$(dirname "$${BASH_SOURCE[0]}")" && pwd)"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo '' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'echo "Installing $(PACKAGE_NAME) to $$INSTALL_DIR..."' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo '' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo '# Install binary files' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'sudo cp "$${SCRIPT_DIR}/bin/"* "$${INSTALL_DIR}/bin/"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo '' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo '# Set permissions' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'sudo chmod 755 "$${INSTALL_DIR}/bin/$(BACKUP)"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'sudo chmod 755 "$${INSTALL_DIR}/bin/$(RESTORE)"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'sudo chmod 755 "$${INSTALL_DIR}/bin/$(HELPER)"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'sudo chmod 755 "$${INSTALL_DIR}/bin/$(S3PLUGIN)"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'sudo chmod 755 "$${INSTALL_DIR}/bin/$(GPBACKMAN)"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo '' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'echo "Installation complete!"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh - @echo 'echo "$(PACKAGE_NAME) binaries installed to $${INSTALL_DIR}/bin/"' >> $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh + @sed -e 's/__PACKAGE_NAME__/$(PACKAGE_NAME)/g' \ + -e 's/__BACKUP__/$(BACKUP)/g' \ + -e 's/__RESTORE__/$(RESTORE)/g' \ + -e 's/__HELPER__/$(HELPER)/g' \ + -e 's/__S3PLUGIN__/$(S3PLUGIN)/g' \ + -e 's/__GPBACKMAN__/$(GPBACKMAN)/g' \ + install.sh.template > $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh @chmod +x $(BUILD_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/install.sh @echo "Creating tar.gz package..." @cd $(BUILD_DIR) && tar -czf $(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH).tar.gz $(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(GOOS)-$(GOARCH)/ diff --git a/install.sh.template b/install.sh.template new file mode 100644 index 00000000..c6e9412f --- /dev/null +++ b/install.sh.template @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# ====================================================================== +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ====================================================================== + +set -e + +# Use GPHOME if set, otherwise use default path +if [ -n "$GPHOME" ]; then + INSTALL_DIR="$GPHOME" +elif [ -n "$INSTALL_DIR" ]; then + INSTALL_DIR="$INSTALL_DIR" +else + INSTALL_DIR="/usr/local" +fi + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +echo "Installing __PACKAGE_NAME__ to $INSTALL_DIR..." + +# Install binary files +sudo cp "${SCRIPT_DIR}/bin/"* "${INSTALL_DIR}/bin/" + +# Set permissions +sudo chmod 755 "${INSTALL_DIR}/bin/__BACKUP__" +sudo chmod 755 "${INSTALL_DIR}/bin/__RESTORE__" +sudo chmod 755 "${INSTALL_DIR}/bin/__HELPER__" +sudo chmod 755 "${INSTALL_DIR}/bin/__S3PLUGIN__" +sudo chmod 755 "${INSTALL_DIR}/bin/__GPBACKMAN__" + +echo "Installation complete!" +echo "__PACKAGE_NAME__ binaries installed to ${INSTALL_DIR}/bin/" From 230e511c5b58a367098f2118509cf2870ee9fefe Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Tue, 28 Apr 2026 14:51:57 +0800 Subject: [PATCH 2/2] Add make package to the Ci workflow --- .github/workflows/cloudberry-backup-ci.yml | 49 +++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cloudberry-backup-ci.yml b/.github/workflows/cloudberry-backup-ci.yml index f6b72086..85697b4b 100644 --- a/.github/workflows/cloudberry-backup-ci.yml +++ b/.github/workflows/cloudberry-backup-ci.yml @@ -187,7 +187,7 @@ jobs: strategy: fail-fast: false matrix: - test_target: [smoke, unit, integration, end_to_end, s3_plugin_e2e, regression, scale] + test_target: [smoke, unit, integration, end_to_end, s3_plugin_e2e, regression, scale, package_install] steps: - name: Free Disk Space @@ -474,6 +474,53 @@ jobs: chmod +x "${CLOUDBERRY_BACKUP_SRC}/.github/workflows/scale-tests-cloudberry-ci.bash" "${CLOUDBERRY_BACKUP_SRC}/.github/workflows/scale-tests-cloudberry-ci.bash" 2>&1 | tee "${TEST_LOG_ROOT}/cloudberry-backup-scale.log" ;; + package_install) + set -e + echo "Running package and install tests..." + + # Clean up previously installed binaries + echo "=== Cleaning up existing installations ===" + for binary in gpbackup gprestore gpbackup_helper gpbackup_s3_plugin gpbackman; do + rm -f "${GPHOME}/bin/${binary}" + done + echo "Cleanup complete" + + # Create package + echo "=== Creating package ===" + make package 2>&1 | tee "${TEST_LOG_ROOT}/cloudberry-backup-package.log" + + # Find and extract package + package_file=$(ls -1 build/*.tar.gz 2>/dev/null | head -n 1) + if [ -z "${package_file}" ]; then + echo "ERROR: Package file not found" + exit 1 + fi + echo "Package created: ${package_file}" + + tar -xzf "${package_file}" + extracted_dir=$(ls -1d apache-cloudberry-backup-incubating-*/ 2>/dev/null | head -n 1) + echo "Package extracted" + ls -lh "${extracted_dir}" + + # Install using install.sh + echo "=== Installing via install.sh ===" + cd "${extracted_dir}" + chmod +x install.sh + GPHOME="${GPHOME}" ./install.sh 2>&1 | tee "${TEST_LOG_ROOT}/cloudberry-backup-install.log" + + # Test installed binaries + echo "=== Testing installed binaries ===" + for binary in gpbackup gprestore gpbackup_helper gpbackup_s3_plugin gpbackman; do + version_output=$("${GPHOME}/bin/${binary}" --version 2>&1) + if [ $? -ne 0 ]; then + echo "ERROR: ${binary} --version failed" + exit 1 + fi + echo "${binary}: ${version_output}" + done + + echo "=== Package and install tests passed ===" + ;; *) echo "unknown test target: ${TEST_TARGET}" exit 2