@@ -524,39 +524,34 @@ jobs:
524524 echo "Installing baseline RPM: ${BASELINE_RPM}"
525525 # Use dnf to auto-resolve dependencies (like libssh)
526526 dnf install -y "${BASELINE_RPM}"
527-
528- # Move to expected location if prefix not respected by dnf (dnf doesn't easily support relocatable installs with dependencies?)
529- # Actually, Cloudberry RPMs are usually not relocatable?
530- # Wait, check if the RPM was built as relocatable. The spec file defines Prefix: /usr/local/cloudberry-db
531- # rpm -ivh --prefix works. dnf install --setopt=install_weak_deps=False ... usually installs to default location.
532- # The previous error was about dependencies.
533- # If we use dnf, we might install to /usr/local/cloudberry-db-2.0.0...
534- # We need to ensure we can find it.
535-
536- # Let's try dnf install first.
537-
538- # Since we cannot easily use --prefix with dnf/yum for local files with dependencies,
539- # we will let it install to its default location (likely /usr/local/cloudberry-db-VERSION)
540- # and then symlink or move if necessary.
541-
542- # BUT, we need strict paths for the test script.
543- # The spec file installs to /usr/local/cloudberry-db-%{version} and symlinks /usr/local/cloudberry-db
544-
545- # To support the binary swap, we need "BASELINE_INSTALL_DIR" to point to where it actually installed.
546- # Let's see where it goes.
547-
548- # Check installed location
549- INSTALLED_DIR=$(rpm -ql apache-cloudberry-db-incubating | { head -1; cat >/dev/null; } | cut -d/ -f1-4)
550- echo "Installed to: ${INSTALLED_DIR}"
551-
552- # If we need it at BASELINE_INSTALL_DIR (/usr/local/cloudberry-db-baseline), we can move it or symlink.
553- if [ "${INSTALLED_DIR}" != "${BASELINE_INSTALL_DIR}" ]; then
554- echo "Relocating to ${BASELINE_INSTALL_DIR}..."
555- mv "${INSTALLED_DIR}" "${BASELINE_INSTALL_DIR}"
527+
528+ # Check installed location based on where bin/postgres ended up
529+ INSTALLED_PG=$(rpm -ql apache-cloudberry-db-incubating | grep "bin/postgres$" | head -1)
530+ if [ -z "$INSTALLED_PG" ]; then
531+ echo "::error::Could not find bin/postgres in installed RPM"
532+ exit 1
556533 fi
557534
535+ # Get the installation root (parent of bin)
536+ INSTALLED_DIR=$(dirname $(dirname "$INSTALLED_PG"))
537+ echo "Detected installation at: ${INSTALLED_DIR}"
538+
539+ # Prepare target directory
540+ # If target doesn't exist, we can just move.
541+ if [ ! -d "${BASELINE_INSTALL_DIR}" ]; then
542+ echo "Moving ${INSTALLED_DIR} to ${BASELINE_INSTALL_DIR}..."
543+ mv "${INSTALLED_DIR}" "${BASELINE_INSTALL_DIR}"
544+ elif [ "${INSTALLED_DIR}" != "${BASELINE_INSTALL_DIR}" ]; then
545+ # If target exists (maybe empty dir created previously?), remove it and move
546+ echo "Target ${BASELINE_INSTALL_DIR} exists, cleaning up..."
547+ rm -rf "${BASELINE_INSTALL_DIR}"
548+ mv "${INSTALLED_DIR}" "${BASELINE_INSTALL_DIR}"
549+ else
550+ echo "Already installed at target location."
551+ fi
552+
558553 chown -R gpadmin:gpadmin "${BASELINE_INSTALL_DIR}"
559-
554+
560555 # Verify Installation
561556 echo "Verifying Baseline Installation..."
562557 rpm -qi apache-cloudberry-db-incubating
@@ -571,39 +566,10 @@ jobs:
571566 set -eo pipefail
572567 CURRENT_RPM=$(ls "${GITHUB_WORKSPACE}"/current_rpm/*.rpm | head -1)
573568 echo "Installing current RPM: ${CURRENT_RPM}"
574-
575- # If previous RPM is installed (same package name), dnf might complain or upgrade.
576- # We probably need to force install or rely on them being different versions?
577- # Actually, if the package name 'apache-cloudberry-db-incubating' is the same, dnf verifies.
578- # This is "Binary Swap", so we actully want them side-by-side.
579- # But RPM usually doesn't allow same package name side-by-side unless kernel.
580-
581- # WORKAROUND: Extract RPM content manually if dependency install is too tricky with conflicts?
582- # NO, the user wants "Robust".
583-
584- # Since we are installing "Baseline" then "Current", and they likely share the package name,
585- # standard RPM DB won't like it.
586- # However, previously we used rpm -ivh --prefix.
587-
588- # STRATEGY:
589- # 1. Install dependencies first using dnf (dummy check or explicitly install missing ones).
590- # 2. Then use rpm -ivh --prefix --nodeps (since we installed deps).
591-
592- # Let's try finding dependencies and installing them.
593- echo "Installing dependencies for ${CURRENT_RPM}..."
594- dnf -y install libssh perl apr bzip2 iproute rsync xz || true
595-
596- # Install using rpm with --prefix and --nodeps (assuming we got deps)
597- # OR just rely on rpm -ivh --prefix forcing it? No, that failed deps.
598-
599- # BETTER STRATEGY: dnf install dependencies explicitly.
600- # libssh is missing.
601- dnf install -y libssh
602-
603- # Revert to rpm -ivh --prefix but now dependencies are satisfied.
569+
604570 rpm -ivh "${CURRENT_RPM}" --prefix="${CURRENT_INSTALL_DIR}"
605571 chown -R gpadmin:gpadmin "${CURRENT_INSTALL_DIR}"
606-
572+
607573 # Verify Installation
608574 echo "Verifying Current Installation..."
609575 if [ ! -f "${CURRENT_INSTALL_DIR}/bin/postgres" ]; then
@@ -636,7 +602,11 @@ jobs:
636602
637603 ln -sfn "${BASELINE_INSTALL_DIR}" "${CBDB_INSTALL_DIR}"
638604 su - gpadmin -c "
639- source ${CBDB_INSTALL_DIR}/cloudberry-env.sh
605+ if [ -f ${CBDB_INSTALL_DIR}/cloudberry-env.sh ]; then
606+ source ${CBDB_INSTALL_DIR}/cloudberry-env.sh
607+ else
608+ source ${CBDB_INSTALL_DIR}/greenplum_path.sh
609+ fi
640610 cd ${GITHUB_WORKSPACE}/gpAux/gpdemo
641611 make cluster
642612 gpstop -a
0 commit comments