@@ -63,57 +63,43 @@ buildPgrxExtension_0_11_3 rec {
6363 echo '${ builtins . concatStringsSep "," previousVersions } ' | sed 's/,/\n/g' > git_tags.txt
6464 '' ;
6565
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
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
7682
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
83+ echo "Creating wrappers.so symlinks to support pg_upgrade..."
84+ lib_file="$out/lib/wrappers-$current_version.so"
9285
93- echo "Creating wrappers.so symlinks to support pg_upgrade..."
94- lib_file="$out/lib/wrappers-$current_version.so"
95-
96- if [ -f "$lib_file" ]; then
97- while read -r previous_version; do
98- if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
99- new_file="$out/lib/wrappers-$previous_version.so"
100- echo "Creating $new_file"
101- ln -s "$lib_file" "$new_file"
102- fi
103- done < git_tags.txt
104- else
105- echo "Warning: $lib_file not found"
106- fi
107-
108- rm git_tags.txt
109- mv $out/lib/wrappers-${ version } .so $out/lib/wrappers.so
110-
111- echo "Contents of updated wrappers.control:"
112- cat "$out/share/postgresql/extension/wrappers.control"
113-
114- echo "List of generated SQL files:"
115- ls -l $out/share/postgresql/extension/wrappers--*.sql
116- '' ;
86+ if [ -f "$lib_file" ]; then
87+ while read -r previous_version; do
88+ if [ "$(printf '%s\n' "$previous_version" "$current_version" | sort -V | head -n1)" = "$previous_version" ] && [ "$previous_version" != "$current_version" ]; then
89+ new_file="$out/lib/wrappers-$previous_version.so"
90+ echo "Creating $new_file"
91+ ln -s "$lib_file" "$new_file"
92+ fi
93+ done < git_tags.txt
94+ else
95+ echo "Warning: $lib_file not found"
96+ fi
97+
98+ rm git_tags.txt
99+ mv $out/lib/wrappers-${ version } .so $out/lib/wrappers.so
100+ echo "Uncommenting module_pathname in wrappers.control..."
101+ sed -i 's/^#module_pathname/module_pathname/' $out/share/postgresql/extension/wrappers.control
102+ '' ;
117103
118104 meta = with lib ; {
119105 description = "Various Foreign Data Wrappers (FDWs) for PostreSQL" ;
0 commit comments