-
Notifications
You must be signed in to change notification settings - Fork 398
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·152 lines (114 loc) · 5.24 KB
/
build.sh
File metadata and controls
executable file
·152 lines (114 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
# Call this script like this:
# POSTGRESAPP_SHORT_VERSION=2.x.x POSTGRESAPP_BUILD_VERSION=xx PG_BINARIES_VERSIONS=10_11_12 PG_BINARIES_DIR=$HOME/PostgresApp/Binaries LATEST_STABLE_PG_VERSION=12 BUILD_DIR=$HOME/PostgresApp/Build ./build.sh
set -e
set -o pipefail
export NSUnbufferedIO=YES
export PYTHONUNBUFFERED=1
trap 'if [[ $? -ne 0 ]]; then echo "Error"; echo "Check Log For Details"; fi' EXIT
if [ "x$POSTGRESAPP_SHORT_VERSION" = x ]
then
echo "Please set the environment variable POSTGRESAPP_SHORT_VERSION"
exit 1
fi
if [ "x$POSTGRESAPP_BUILD_VERSION" = x ]
then
echo "Please set the environment variable POSTGRESAPP_BUILD_VERSION"
exit 1
fi
if [ "x$PG_BINARIES_VERSIONS" = x ]
then
echo "Please set the environment variable PG_BINARIES_VERSIONS"
exit 1
fi
if [ "x$PG_BINARIES_DIR" = x ]
then
echo "Please set the environment variable PG_BINARIES_DIR"
exit 1
fi
if [ "x$LATEST_STABLE_PG_VERSION" = x ]
then
echo "Please set the environment variable LATEST_STABLE_PG_VERSION"
exit 1
fi
if [ "x$BUILD_DIR" = x ]
then
echo "Please set BUILD_DIR"
exit 1
fi
PROJECT_ROOT=$(dirname $(pwd))
PROJECT_FILE="$PROJECT_ROOT"/Postgres.xcodeproj
LOG_DIR="$BUILD_DIR/log"
ARCHIVE_PATH="$BUILD_DIR"/Postgres.xcarchive
BGIMG_PATH=background-image/folder_bg.png
EXPORT_PATH="$BUILD_DIR"/Postgres-export
DMG_SRC_PATH="$BUILD_DIR"/Postgres
DMG_DST_PATH="$BUILD_DIR"/Postgres-$POSTGRESAPP_SHORT_VERSION-${PG_BINARIES_VERSIONS//_/-}.dmg
SIGNATURE_PATH="$BUILD_DIR"/Postgres-$POSTGRESAPP_SHORT_VERSION-${PG_BINARIES_VERSIONS//_/-}-signature.txt
APPCAST_PATH="$BUILD_DIR"/updates_$PG_BINARIES_VERSIONS.xml
DERIVED_DATA_PATH="$BUILD_DIR"/DerivedData
mkdir -p "$LOG_DIR"
echo "Log Directory: $LOG_DIR"
env >"$LOG_DIR/env"
# get signing identity
CODE_SIGN_IDENTITY=$(security find-certificate -a -c "Developer ID Application" -Z | grep -o -e 'Developer ID [^"]*' | head -n 1)
echo "Using Certificate \"$CODE_SIGN_IDENTITY\""
# build the archive
echo -n "Archive... "
xcodebuild archive -project "$PROJECT_FILE" -scheme Postgres -archivePath "$ARCHIVE_PATH" -derivedDataPath "$DERIVED_DATA_PATH" POSTGRESAPP_SHORT_VERSION="$POSTGRESAPP_SHORT_VERSION" POSTGRESAPP_BUILD_VERSION="$POSTGRESAPP_BUILD_VERSION" PG_BINARIES_VERSIONS="$PG_BINARIES_VERSIONS" PG_BINARIES_DIR="$PG_BINARIES_DIR" LATEST_STABLE_PG_VERSION="$LATEST_STABLE_PG_VERSION" CODE_SIGN_IDENTITY="$CODE_SIGN_IDENTITY">"$LOG_DIR/archive.out" 2>"$LOG_DIR/archive.err"
echo "Done"
# Delete Derived Data
rm -r "$DERIVED_DATA_PATH" || echo "INFO: Deleting $DERIVED_DATA_PATH failed"
# export and code sign
echo -n "Export Archive... "
xcodebuild -exportArchive -archivePath "$ARCHIVE_PATH" -exportPath "$EXPORT_PATH" -exportOptionsPlist exportOptions.plist >"$LOG_DIR/exportArchive.out" 2>"$LOG_DIR/exportArchive.err"
echo "Done"
echo -n "Enabling Hardened Runtime... "
APP="$EXPORT_PATH"/Postgres.app
for VERSION in ${PG_BINARIES_VERSIONS//_/ }; do
find "$APP"/Contents/Versions/$VERSION/bin/ \( -name postgres -o -name postmaster \) -type f -exec \
codesign --force --options runtime --sign "$CODE_SIGN_IDENTITY" \
--entitlements postgres.entitlements \
{} \; >>"$LOG_DIR/codesign.out" 2>>"$LOG_DIR/codesign.err"
find "$APP"/Contents/Versions/$VERSION/bin/ \( -not -name postgres -and -not -name postmaster \) -type f -exec \
codesign --force --options runtime --sign "$CODE_SIGN_IDENTITY" \
{} \; >>"$LOG_DIR/codesign.out" 2>>"$LOG_DIR/codesign.err"
find "$APP"/Contents/Versions/$VERSION/lib/postgresql/pgxs \( -name isolationtester -or -name pg_isolation_regress \) -type f -exec \
codesign --force --options runtime --sign "$CODE_SIGN_IDENTITY" \
{} \; >>"$LOG_DIR/codesign.out" 2>>"$LOG_DIR/codesign.err"
codesign --force --options runtime --sign "$CODE_SIGN_IDENTITY" \
"$APP"/Contents/Versions/$VERSION/lib/postgresql/pgxs/src/test/regress/pg_regress \
"$APP"/Contents/Versions/$VERSION/lib/*.a \
>>"$LOG_DIR/codesign.out" 2>>"$LOG_DIR/codesign.err"
done
codesign --force --options runtime --sign "$CODE_SIGN_IDENTITY" \
"$APP"/Contents/Frameworks/Sparkle.framework/Versions/A/Resources/Autoupdate.app/Contents/MacOS/Autoupdate \
"$APP"/Contents/Frameworks/Sparkle.framework/Versions/A/Sparkle \
"$APP"/Contents/MacOS/PostgresMenuHelper.app \
"$APP"/Contents/Library/LoginItems/PostgresLoginHelper.app \
>>"$LOG_DIR/codesign.out" 2>>"$LOG_DIR/codesign.err"
codesign --force --options runtime --sign "$CODE_SIGN_IDENTITY" \
"$APP"/Contents/MacOS/PostgresPermissionDialog \
>>"$LOG_DIR/codesign.out" 2>>"$LOG_DIR/codesign.err"
codesign --force --options runtime --sign "$CODE_SIGN_IDENTITY" \
--entitlements PostgresApp.entitlements \
"$APP"/Contents/MacOS/Postgres \
"$APP" \
>>"$LOG_DIR/codesign.out" 2>>"$LOG_DIR/codesign.err"
echo "Done"
echo -n "Creating Disk Image... "
mkdir "$DMG_SRC_PATH"
mv "$EXPORT_PATH"/Postgres.app "$DMG_SRC_PATH"
rm -r "$EXPORT_PATH" || echo "INFO: Deleting $EXPORT_PATH failed"
vendor/create-dmg-master/create-dmg \
--window-pos 200 150 \
--window-size 512 320 \
--icon Postgres.app 110 150 \
--app-drop-link 400 150 \
--text-size 12 \
--icon-size 128 \
--background "$BGIMG_PATH" \
"$DMG_DST_PATH" \
"$DMG_SRC_PATH" >"$LOG_DIR/create-dmg.out" 2>"$LOG_DIR/create-dmg.err"
rm -r "$DMG_SRC_PATH" || echo "INFO: Deleting $DMG_SRC_PATH failed"
echo "Done"