forked from gambit/gambit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-phase2.in
executable file
·168 lines (124 loc) · 4.81 KB
/
build-phase2.in
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#! /bin/sh
# Copyright (c) 1994-2009 by Marc Feeley, All Rights Reserved.
herefromroot="prebuilt/macosx"
rootfromhere="../.."
PACKAGE_SHORTNAME="@PACKAGE_SHORTNAME@"
PACKAGE_NAME="@PACKAGE_NAME@"
PACKAGE_VERSION="@PACKAGE_VERSION@"
PACKAGE_STRING="@PACKAGE_STRING@"
PACKAGE_BUGREPORT="@PACKAGE_BUGREPORT@"
PACKAGE_TARNAME="@PACKAGE_TARNAME@"
PKGM="/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"
VARIANT="$1"
RUN_TESTS="$2"
SOURCE_DIR="$INSTALL_PREFIX"
INSTALL_DIR="$INSTALL_PREFIX"
BIN_DIR="/usr/bin"
LIB_DIR="/usr/lib"
INCLUDE_DIR="/usr/include"
TITLE="$PACKAGE_STRING ($VARIANT variant)"
VERSION="`echo $PACKAGE_VERSION | sed -e s/^v//g`"
PKG_FILE="`pwd`/$PACKAGE_TARNAME-macosx-$VARIANT.pkg"
DMG_FILE="`pwd`/$PACKAGE_TARNAME-macosx-$VARIANT.dmg"
BACKGROUND_FILE="`pwd`/gambc.tif"
PMPROJ_FILE="`pwd`/gambc.pmproj"
WELCOME_FILE="`pwd`/welcome.html"
README_FILE="`pwd`/readme.html"
CONCLUSION_FILE="`pwd`/conclusion.html"
EXTRAS_DIR="`pwd`/extras"
DESCRIPTION="This is the $TITLE installer"
PROGRAMS="gsc gsc-script gsi gsi-script scheme-ieee-1178-1990 scheme-r4rs scheme-r5rs scheme-srfi-0 six six-script gambc-cc.bat gambc-doc.bat uninstall-gambc"
LIBRARIES="libgambc@LIB_EXTENSION@ libgambcgsi@LIB_EXTENSION@ libgambcgsc@LIB_EXTENSION@"
INCLUDES="gambit.h"
instantiate_file() # input, output
{
sed -e "s|@BIN_DIR@|$BIN_DIR|g" -e "s|@LIB_DIR@|$LIB_DIR|g" -e "s|@INCLUDE_DIR@|$INCLUDE_DIR|g" -e "s|@SOURCE_DIR@|$SOURCE_DIR|g" -e "s|@INSTALL_DIR@|$INSTALL_DIR|g" -e "s|@VERSION@|$VERSION|g" -e "s|@PACKAGE_VERSION@|$PACKAGE_VERSION|g" -e "s|@TITLE@|$TITLE|g" -e "s|@DESCRIPTION@|$DESCRIPTION|g" -e "s|@PROGRAMS@|$PROGRAMS|g" -e "s|@LIBRARIES@|$LIBRARIES|g" -e "s|@INCLUDES@|$INCLUDES|g" -e "s|@BACKGROUND_FILE@|$BACKGROUND_FILE|g" -e "s|@WELCOME_FILE@|$WELCOME_FILE|g" -e "s|@README_FILE@|$README_FILE|g" -e "s|@CONCLUSION_FILE@|$CONCLUSION_FILE|g" -e "s|@EXTRAS_DIR@|$EXTRAS_DIR|g" -e "s|@NAME@|$PACKAGE_NAME|g" -e "s|@VARIANT@|$VARIANT|g" "$1" > "$2"
}
cleanup()
{
rm -rf "$PMPROJ_FILE" "$WELCOME_FILE" "$README_FILE" "$CONCLUSION_FILE" "$PKG_FILE" "$SOURCE_DIR" "$EXTRAS_DIR"
}
install_gambc()
{
cd "$rootfromhere"
make clean
make
make install
if [ "$RUN_TESTS" == "0" ] ; then
echo "************ TESTS SKIPPED ($VARIANT variant)"
else
TESTS_SUCCESS=0
make check > build-phase2-tests.out
cat build-phase2-tests.out
if fgrep "============ ALL TESTS SUCCESSFUL" build-phase2-tests.out > /dev/null; then
TESTS_SUCCESS=1
fi
rm -f build-phase2-tests.out
if [ "$TESTS_SUCCESS" == "1" ] ; then
echo "************ TESTS SUCCESSFUL ($VARIANT variant)"
else
echo "************ TESTS FAILED ($VARIANT variant)"
cleanup
exit 1
fi
fi
cd "$herefromroot"
}
uninstall_gambc()
{
"$SOURCE_DIR/$PACKAGE_VERSION/bin/uninstall-gambc"
}
create_uninstaller()
{
rm -f "$SOURCE_DIR/$PACKAGE_VERSION/bin/uninstall-gambc"
instantiate_file "uninstall-gambc.in" "$SOURCE_DIR/$PACKAGE_VERSION/bin/uninstall-gambc"
chmod 755 "$SOURCE_DIR/$PACKAGE_VERSION/bin/uninstall-gambc"
}
create_extras()
{
mkdir "$EXTRAS_DIR"
touch "$EXTRAS_DIR/InstallationCheck.strings"
i=0
for f in $PROGRAMS ; do
echo "\"`expr $i + 16`\" = \"The installation process is being aborted because the file $BIN_DIR/$f exists and it was not created by the Gambit-C installer. A possible solution is to remove this file manually and restart the installer.\";" >> "$EXTRAS_DIR/InstallationCheck.strings"
i=`expr $i + 1`
done
for f in $LIBRARIES ; do
echo "\"`expr $i + 16`\" = \"The installation process is being aborted because the file $LIB_DIR/$f exists and it was not created by the Gambit-C installer. A possible solution is to remove this file manually and restart the installer.\";" >> "$EXTRAS_DIR/InstallationCheck.strings"
i=`expr $i + 1`
done
for f in $INCLUDES ; do
echo "\"`expr $i + 16`\" = \"The installation process is being aborted because the file $INCLUDE_DIR/$f exists and it was not created by the Gambit-C installer. A possible solution is to remove this file manually and restart the installer.\";" >> "$EXTRAS_DIR/InstallationCheck.strings"
i=`expr $i + 1`
done
for file in InstallationCheck postflight ; do
instantiate_file "$file.in" "$EXTRAS_DIR/$file"
chmod 755 "$EXTRAS_DIR/$file"
done
}
create_pmproj()
{
for file in "$PMPROJ_FILE" "$WELCOME_FILE" "$README_FILE" "$CONCLUSION_FILE" ; do
instantiate_file "$file.in" "$file"
done
plutil -convert binary1 "$PMPROJ_FILE"
}
create_pkg()
{
$PKGM -build -proj "$PMPROJ_FILE" -p "$PKG_FILE"
}
create_dmg()
{
hdiutil create -srcfolder "$PKG_FILE" -volname "$PACKAGE_STRING" -fs HFS+ "$DMG_FILE"
}
cd "`dirname $0`"
cleanup
rm -f "$DMG_FILE"
install_gambc
create_uninstaller
create_extras
create_pmproj
create_pkg
create_dmg
mv "$DMG_FILE" "$rootfromhere"
cleanup