This is an automated email from the ASF dual-hosted git repository.
tuhaihe pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry-backup.git
The following commit(s) were added to refs/heads/main by this push:
new 2f74ca93 Package: extract install script generation to template file
(#95)
2f74ca93 is described below
commit 2f74ca93081484faf13457d484a8cca6489b9cae
Author: Dianjin Wang <[email protected]>
AuthorDate: Fri May 15 17:31:44 2026 +0800
Package: extract install script generation to template file (#95)
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
---
.github/workflows/cloudberry-backup-ci.yml | 49 +++++++++++++++++++++++++++++-
Makefile | 37 +++++-----------------
install.sh.template | 48 +++++++++++++++++++++++++++++
3 files changed, 104 insertions(+), 30 deletions(-)
diff --git a/.github/workflows/cloudberry-backup-ci.yml
b/.github/workflows/cloudberry-backup-ci.yml
index 26abfb67..a3216337 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
@@ -477,6 +477,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 gpbackup_exporter; 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 gpbackup_exporter; 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
diff --git a/Makefile b/Makefile
index fa27092c..69675e9d 100644
--- a/Makefile
+++ b/Makefile
@@ -198,35 +198,14 @@ 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 'sudo chmod 755 "$${INSTALL_DIR}/bin/$(EXPORTER)"' >>
$(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' \
+ -e 's/__EXPORTER__/$(EXPORTER)/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..d61963a1
--- /dev/null
+++ b/install.sh.template
@@ -0,0 +1,48 @@
+#!/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__"
+sudo chmod 755 "${INSTALL_DIR}/bin/__EXPORTER__"
+
+echo "Installation complete!"
+echo "__PACKAGE_NAME__ binaries installed to ${INSTALL_DIR}/bin/"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]