@@ -63,27 +63,42 @@ buildPgrxExtension_0_11_3 rec {
63
63
echo '${ builtins . concatStringsSep "," previousVersions } ' | sed 's/,/\n/g' > git_tags.txt
64
64
'' ;
65
65
66
- postInstall = ''
67
- echo "Creating SQL files for previous versions..."
68
- current_version="${ version } "
69
- sql_file="$out/share/postgresql/extension/wrappers--$current_version.sql"
70
-
71
- if [ -f "$sql_file" ]; then
72
- while read -r previous_version; do
73
- if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
74
- new_file="$out/share/postgresql/extension/wrappers--$previous_version--$current_version.sql"
75
- echo "Creating $new_file"
76
- cp "$sql_file" "$new_file"
77
- fi
78
- done < git_tags.txt
79
- else
80
- echo "Warning: $sql_file not found"
81
- fi
82
- rm git_tags.txt
83
- mv $out/lib/wrappers-${ version } .so $out/lib/wrappers.so
84
- echo "Uncommenting module_pathname in wrappers.control..."
85
- sed -i 's/^#module_pathname/module_pathname/' $out/share/postgresql/extension/wrappers.control
86
- '' ;
66
+ postInstall = ''
67
+ echo "Modifying main SQL file to use unversioned library name..."
68
+ current_version="${ version } "
69
+ main_sql_file="$out/share/postgresql/extension/wrappers--$current_version.sql"
70
+ if [ -f "$main_sql_file" ]; then
71
+ sed -i 's|$libdir/wrappers-[0-9.]*|$libdir/wrappers|g' "$main_sql_file"
72
+ echo "Modified $main_sql_file"
73
+ else
74
+ echo "Warning: $main_sql_file not found"
75
+ fi
76
+
77
+ echo "Creating and modifying SQL files for previous versions..."
78
+
79
+ if [ -f "$main_sql_file" ]; then
80
+ while read -r previous_version; do
81
+ if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
82
+ new_file="$out/share/postgresql/extension/wrappers--$previous_version--$current_version.sql"
83
+ echo "Creating $new_file"
84
+ cp "$main_sql_file" "$new_file"
85
+ sed -i 's|$libdir/wrappers-[0-9.]*|$libdir/wrappers|g' "$new_file"
86
+ echo "Modified $new_file"
87
+ fi
88
+ done < git_tags.txt
89
+ else
90
+ echo "Warning: $main_sql_file not found"
91
+ fi
92
+
93
+ rm git_tags.txt
94
+ mv $out/lib/wrappers-${ version } .so $out/lib/wrappers.so
95
+
96
+ echo "Contents of updated wrappers.control:"
97
+ cat "$out/share/postgresql/extension/wrappers.control"
98
+
99
+ echo "List of generated SQL files:"
100
+ ls -l $out/share/postgresql/extension/wrappers--*.sql
101
+ '' ;
87
102
88
103
meta = with lib ; {
89
104
description = "Various Foreign Data Wrappers (FDWs) for PostreSQL" ;
0 commit comments