Skip to content

Commit 6418de8

Browse files
FIX (deployments): Use binaries instead of symlinks on PostgreSQL download
1 parent 230f66b commit 6418de8

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

backend/tools/download_linux.sh

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,27 @@ for version in $versions; do
5959
version_dir="$POSTGRES_DIR/postgresql-$version"
6060
mkdir -p "$version_dir/bin"
6161

62-
# Create symlinks to the version-specific installed binaries
63-
# PostgreSQL packages create versioned binaries like pg_dump-13, pg_dump-14, etc.
64-
if [ -f "/usr/bin/pg_dump-$version" ]; then
65-
ln -sf "/usr/bin/pg_dump-$version" "$version_dir/bin/pg_dump"
66-
ln -sf "/usr/bin/pg_dumpall-$version" "$version_dir/bin/pg_dumpall"
67-
ln -sf "/usr/bin/psql-$version" "$version_dir/bin/psql"
68-
ln -sf "/usr/bin/pg_restore-$version" "$version_dir/bin/pg_restore"
69-
ln -sf "/usr/bin/createdb-$version" "$version_dir/bin/createdb"
70-
ln -sf "/usr/bin/dropdb-$version" "$version_dir/bin/dropdb"
62+
# On Debian/Ubuntu, PostgreSQL binaries are located in /usr/lib/postgresql/{version}/bin/
63+
pg_bin_dir="/usr/lib/postgresql/$version/bin"
64+
65+
if [ -d "$pg_bin_dir" ] && [ -f "$pg_bin_dir/pg_dump" ]; then
66+
# Create symlinks to the version-specific binaries
67+
ln -sf "$pg_bin_dir/pg_dump" "$version_dir/bin/pg_dump"
68+
ln -sf "$pg_bin_dir/pg_dumpall" "$version_dir/bin/pg_dumpall"
69+
ln -sf "$pg_bin_dir/psql" "$version_dir/bin/psql"
70+
ln -sf "$pg_bin_dir/pg_restore" "$version_dir/bin/pg_restore"
71+
ln -sf "$pg_bin_dir/createdb" "$version_dir/bin/createdb"
72+
ln -sf "$pg_bin_dir/dropdb" "$version_dir/bin/dropdb"
7173

7274
echo "PostgreSQL $version client tools installed successfully"
7375
else
74-
echo "Error: PostgreSQL $version versioned binaries not found. Expected /usr/bin/pg_dump-$version"
75-
echo "Available pg_dump binaries:"
76-
ls -la /usr/bin/pg_dump* 2>/dev/null || echo "No pg_dump binaries found"
76+
echo "Error: PostgreSQL $version binaries not found in expected location: $pg_bin_dir"
77+
echo "Available PostgreSQL directories:"
78+
ls -la /usr/lib/postgresql/ 2>/dev/null || echo "No PostgreSQL directories found in /usr/lib/postgresql/"
79+
if [ -d "$pg_bin_dir" ]; then
80+
echo "Contents of $pg_bin_dir:"
81+
ls -la "$pg_bin_dir" 2>/dev/null || echo "Directory exists but cannot list contents"
82+
fi
7783
exit 1
7884
fi
7985
echo
@@ -90,7 +96,7 @@ for version in $versions; do
9096
if [ -f "$version_dir/bin/pg_dump" ]; then
9197
echo " postgresql-$version: $version_dir/bin/"
9298
# Verify the correct version
93-
version_output=$("$version_dir/bin/pg_dump" --version 2>/dev/null | grep -o "pg_dump (PostgreSQL) [0-9]\+")
99+
version_output=$("$version_dir/bin/pg_dump" --version 2>/dev/null | grep -o "pg_dump (PostgreSQL) [0-9]\+\.[0-9]\+")
94100
echo " Version check: $version_output"
95101
fi
96102
done

backend/tools/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This directory is needed only for development.
1+
This directory is needed only for development and CI\CD.
22

33
We have to download and install all the PostgreSQL versions from 13 to 17 locally.
44
This is needed so we can call pg_dump, pg_dumpall, etc. on each version of the PostgreSQL database.

0 commit comments

Comments
 (0)