Skip to content

Commit 61611bc

Browse files
committed
Adding extension pgsql-http
1 parent 35ed539 commit 61611bc

File tree

5 files changed

+153
-0
lines changed

5 files changed

+153
-0
lines changed

http/Resources/conclusion.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Installation Complete</title>
6+
<style>
7+
body {
8+
font-family: -apple-system;
9+
font-size: 13px;
10+
margin: 20px;
11+
line-height: 1.5;
12+
}
13+
h1 {
14+
font-size: 18px;
15+
font-weight: 600;
16+
margin-top: 0;
17+
}
18+
p {
19+
margin-bottom: 1em;
20+
}
21+
tt {
22+
font-family: Menlo, monospace;
23+
}
24+
</style>
25+
</head>
26+
<body>
27+
<h1>Please restart the PostgreSQL server!</h1>
28+
<p>pgsql-http @EXTENSION_VERSION@ for PostgreSQL @PG_MAJOR_VERSION@ has been installed successfully.</p>
29+
<p>
30+
You must stop and restart your PostgreSQL server before using the extension.
31+
After restarting the server, you can enable the extension by running the SQL command <tt>CREATE EXTENSION http;</tt>
32+
</p>
33+
34+
</body>
35+
</html>

http/Resources/welcome.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Welcome</title>
6+
<style>
7+
body {
8+
font-family: -apple-system;
9+
font-size: 13px;
10+
margin: 20px;
11+
line-height: 1.5;
12+
}
13+
h1 {
14+
font-size: 18px;
15+
font-weight: 600;
16+
margin-top: 0;
17+
}
18+
p {
19+
margin-bottom: 1em;
20+
}
21+
</style>
22+
</head>
23+
<body>
24+
<h1>pgsql-http @EXTENSION_VERSION@ for PostgreSQL @PG_MAJOR_VERSION@</h1>
25+
<p>You are about to install the pgsql-http extension.</p>
26+
<p>This installer package is compatible with <strong>Postgres.app 2.8.3 or later</strong>.</p>
27+
<p>After completing the installation, please stop and restart the PostgreSQL server to use the extension.</p>
28+
</body>
29+
</html>

http/Scripts/preinstall

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/zsh
2+
3+
INSTALL_PATH="$2"
4+
5+
if [[ "$INSTALL_PATH" == *"Application Support"/Postgres/Extensions/*/* ]]; then
6+
if [[ -d "$INSTALL_PATH" ]]; then
7+
echo "Deleting directory: $INSTALL_PATH"
8+
rm -rf -- "$INSTALL_PATH"
9+
if [[ $? -ne 0 ]]; then
10+
echo "Error: Failed to delete $INSTALL_PATH" >&2
11+
exit 1
12+
fi
13+
fi
14+
else
15+
echo "Error: Install path does not match expected pattern. Aborting." >&2
16+
exit 1
17+
fi

http/build.zsh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/zsh
2+
3+
set -e
4+
5+
EXTENSION_VERSION=1.6.3
6+
PG_MAJOR_VERSION=18
7+
PREFIX=/Applications/Postgres.app/Contents/Versions/$PG_MAJOR_VERSION
8+
9+
# download and extract extension to pgsql-http-$EXTENSION_VERSION
10+
echo
11+
echo
12+
echo "Downloading Extension Sources"
13+
echo
14+
mkdir -p Build
15+
curl -L https://github.com/pramsey/pgsql-http/archive/refs/tags/v$EXTENSION_VERSION.tar.gz | tar x --cd Build
16+
17+
# build and install the extension
18+
echo
19+
echo
20+
echo "Building Extension..."
21+
echo
22+
make -C Build/pgsql-http-$EXTENSION_VERSION install PG_CONFIG=$PREFIX/bin/pg_config DESTDIR=$PWD/Build
23+
24+
# codesign libraries
25+
codesign --sign "Developer ID Application" --timestamp Build$PREFIX/lib/postgresql/*.dylib
26+
27+
# Build Installer Package
28+
echo
29+
echo
30+
echo "Creating Installer Package..."
31+
echo
32+
mkdir -p Build/Resources
33+
for file in Resources/*.html distribution.xml
34+
do
35+
sed -e "s|@EXTENSION_VERSION@|${EXTENSION_VERSION}|g" -e "s|@PG_MAJOR_VERSION@|${PG_MAJOR_VERSION}|g" $file > Build/$file
36+
done
37+
pkgbuild --root Build$PREFIX --install-location /Library/Application\ Support/Postgres/Extensions/$PG_MAJOR_VERSION/http --identifier com.postgresapp.extension.$PG_MAJOR_VERSION.http --sign "Developer ID Installer" --scripts Scripts http-$PG_MAJOR_VERSION.pkg
38+
productbuild --distribution Build/distribution.xml --resources Build/Resources --sign "Developer ID Installer" http-pg$PG_MAJOR_VERSION-$EXTENSION_VERSION.pkg
39+
rm http-$PG_MAJOR_VERSION.pkg
40+
41+
# Notarize installer package
42+
echo
43+
echo
44+
echo "Notarizing package..."
45+
echo
46+
xcrun notarytool submit http-pg$PG_MAJOR_VERSION-$EXTENSION_VERSION.pkg --keychain-profile postgresapp --wait
47+
xcrun stapler staple http-pg$PG_MAJOR_VERSION-$EXTENSION_VERSION.pkg
48+
49+
echo
50+
echo
51+
echo "Done."
52+
echo

http/distribution.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<installer-gui-script minSpecVersion="1">
3+
<title>pgsql-http for Postgres.app</title>
4+
<welcome file="welcome.html"/>
5+
<conclusion file="conclusion.html"/>
6+
<pkg-ref id="com.postgresapp.extension.@[email protected]"/>
7+
<options customize="never" require-scripts="false" hostArchitectures="x86_64,arm64"/>
8+
<domains enable_currentUserHome="true"/>
9+
<choices-outline>
10+
<line choice="default">
11+
<line choice="com.postgresapp.extension.@[email protected]"/>
12+
</line>
13+
</choices-outline>
14+
<choice id="default"/>
15+
<choice id="com.postgresapp.extension.@[email protected]" visible="false">
16+
<pkg-ref id="com.postgresapp.extension.@[email protected]"/>
17+
</choice>
18+
<pkg-ref id="com.postgresapp.extension.@[email protected]" version="0" onConclusion="none">http-@[email protected]</pkg-ref>
19+
</installer-gui-script>
20+

0 commit comments

Comments
 (0)