90
90
91
91
preConfigure = ''
92
92
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"
94
94
95
95
makeFlags="PERL=${ perl } /bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin docdir=$doc/share/doc/${ pname } "
96
96
'' ;
@@ -111,13 +111,19 @@ let
111
111
MIN_MAJ_VERSION=${ lib . concatStringsSep "." ( lib . take 2 ( builtins . splitVersion version ) ) }
112
112
rm $out/bin/postgres
113
113
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)
115
122
for ext in ${ lib . concatStringsSep " " ( cExtensions ++ sqlExtensions ) } ; do
116
123
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
119
126
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
121
127
done
122
128
123
129
# Add function definition and usage to tiger geocoder files
@@ -129,23 +135,32 @@ let
129
135
sed -i "/SELECT topology.AddToSearchPath('topology');/i SELECT topology.AddToSearchPath('extensions');" "$file"
130
136
done
131
137
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
133
139
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
+
134
143
for ext in ${ lib . concatStringsSep " " ( cExtensions ++ sqlExtensions ) } ; do
135
144
{
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
138
147
} > $out/share/postgresql/extension/$ext.control
139
148
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
+
140
155
for prog in $out/bin/*; do # */
141
- ln -s $prog $prog-$MIN_MAJ_VERSION
156
+ ln -s $prog $prog-${ version }
142
157
done
143
158
else
144
159
# remove migration scripts for non-latest version
145
160
find $out/share/postgresql/extension -regex '.*--.*--.*\.sql' -delete
146
161
147
162
for prog in $out/bin/*; do # */
148
- mv $prog $prog-$MIN_MAJ_VERSION
163
+ mv $prog $prog-${ version }
149
164
done
150
165
fi
151
166
@@ -174,13 +189,16 @@ buildEnv {
174
189
] ;
175
190
postBuild = ''
176
191
# 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
+ }
178
196
actualFiles=$(ls -A $out/lib/*${ postgresql . dlSuffix } | wc -l)
179
197
180
198
if [[ "$actualFiles" != "$expectedFiles" ]]; then
181
199
echo "Error: Expected $expectedFiles library files, found $actualFiles"
182
200
echo "Files found:"
183
- ls -la $out/lib/${ pname } *${ postgresql . dlSuffix } || true
201
+ ls -la $out/lib/*${ postgresql . dlSuffix } || true
184
202
exit 1
185
203
fi
186
204
'' ;
0 commit comments