Skip to content

Commit a713e0f

Browse files
committed
fix: handling of versions
1 parent 5be2278 commit a713e0f

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ postgres_major:
1010

1111
# Full version strings for each major version
1212
postgres_release:
13-
postgresorioledb-17: 17.5.1.032-orioledb-postgis-3
14-
postgres17: 17.6.1.011-postgis-3
15-
postgres15: 15.14.1.011-postgis-3
13+
postgresorioledb-17: 17.5.1.032-orioledb-postgis-4
14+
postgres17: 17.6.1.011-postgis-4
15+
postgres15: 15.14.1.011-postgis-4
1616

1717
# Non Postgres Extensions
1818
pgbouncer_release: 1.19.0

nix/ext/postgis.nix

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ let
9090

9191
preConfigure = ''
9292
sed -i 's@/usr/bin/file@${file}/bin/file@' configure
93-
configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --docdir=$doc/share/doc/${pname} --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev} --with-sfcgal --with-library-minor-version"
93+
configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --docdir=$doc/share/doc/${pname} --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev} --with-sfcgal"
9494
9595
makeFlags="PERL=${perl}/bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin docdir=$doc/share/doc/${pname}"
9696
'';
@@ -111,13 +111,19 @@ let
111111
MIN_MAJ_VERSION=${lib.concatStringsSep "." (lib.take 2 (builtins.splitVersion version))}
112112
rm $out/bin/postgres
113113
114-
# move control files
114+
# Rename C extension libraries with full version suffix
115+
for ext in ${lib.concatStringsSep " " cExtensions}; do
116+
if [ -f "$out/lib/$ext-3${postgresql.dlSuffix}" ]; then
117+
mv $out/lib/$ext-3${postgresql.dlSuffix} $out/lib/$ext-${version}${postgresql.dlSuffix}
118+
fi
119+
done
120+
121+
# Create version-specific control files (without default_version, pointing to unversioned library)
115122
for ext in ${lib.concatStringsSep " " (cExtensions ++ sqlExtensions)}; do
116123
sed -e "/^default_version =/d" \
117-
-e "s|^module_pathname = .*|module_pathname = '\$libdir/$ext-$MIN_MAJ_VERSION'|" \
118-
$out/share/postgresql/extension/$ext.control > $out/share/postgresql/extension/$ext--$MIN_MAJ_VERSION.control
124+
-e "s|^module_pathname = .*|module_pathname = '\$libdir/$ext-3'|" \
125+
$out/share/postgresql/extension/$ext.control > $out/share/postgresql/extension/$ext--${version}.control
119126
rm $out/share/postgresql/extension/$ext.control
120-
ln -s $out/share/postgresql/extension/$ext--${version}.sql $out/share/postgresql/extension/$ext--$MIN_MAJ_VERSION.sql
121127
done
122128
123129
# Add function definition and usage to tiger geocoder files
@@ -129,23 +135,32 @@ let
129135
sed -i "/SELECT topology.AddToSearchPath('topology');/i SELECT topology.AddToSearchPath('extensions');" "$file"
130136
done
131137
132-
# For the latest version, create default control file and symlink and copy SQL upgrade scripts
138+
# For the latest version, create default control file and library symlinks
133139
if [[ "${version}" == "${latestVersion}" ]]; then
140+
# Copy all SQL upgrade scripts only for latest version
141+
cp $out/share/postgresql/extension/*.sql $out/share/postgresql/extension/ 2>/dev/null || true
142+
134143
for ext in ${lib.concatStringsSep " " (cExtensions ++ sqlExtensions)}; do
135144
{
136-
echo "default_version = '$MIN_MAJ_VERSION'"
137-
cat $out/share/postgresql/extension/$ext--$MIN_MAJ_VERSION.control
145+
echo "default_version = '${version}'"
146+
cat $out/share/postgresql/extension/$ext--${version}.control
138147
} > $out/share/postgresql/extension/$ext.control
139148
done
149+
150+
# Create symlinks for C extension libraries (latest version becomes the default)
151+
for ext in ${lib.concatStringsSep " " cExtensions}; do
152+
ln -sfn $ext-${version}${postgresql.dlSuffix} $out/lib/$ext-3${postgresql.dlSuffix}
153+
done
154+
140155
for prog in $out/bin/*; do # */
141-
ln -s $prog $prog-$MIN_MAJ_VERSION
156+
ln -s $prog $prog-${version}
142157
done
143158
else
144159
# remove migration scripts for non-latest version
145160
find $out/share/postgresql/extension -regex '.*--.*--.*\.sql' -delete
146161
147162
for prog in $out/bin/*; do # */
148-
mv $prog $prog-$MIN_MAJ_VERSION
163+
mv $prog $prog-${version}
149164
done
150165
fi
151166
@@ -174,13 +189,16 @@ buildEnv {
174189
];
175190
postBuild = ''
176191
# Verify all expected library files are present
177-
expectedFiles=${toString (numberOfVersions * builtins.length cExtensions)}
192+
# We expect: (numberOfVersions * cExtensions) versioned libraries + cExtensions symlinks
193+
expectedFiles=${
194+
toString ((numberOfVersions * builtins.length cExtensions) + builtins.length cExtensions)
195+
}
178196
actualFiles=$(ls -A $out/lib/*${postgresql.dlSuffix} | wc -l)
179197
180198
if [[ "$actualFiles" != "$expectedFiles" ]]; then
181199
echo "Error: Expected $expectedFiles library files, found $actualFiles"
182200
echo "Files found:"
183-
ls -la $out/lib/${pname}*${postgresql.dlSuffix} || true
201+
ls -la $out/lib/*${postgresql.dlSuffix} || true
184202
exit 1
185203
fi
186204
'';

0 commit comments

Comments
 (0)