Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 331 lines (281 sloc) 10.59 kb
22b433a Don't assume that bash is in /bin
Frédéric Perrin authored
1 #!/usr/bin/env bash
2
3 set -e
4 set -u
fccc685 Initial open-source release
MLstate authored
5
6 #PREFIX=/usr
7 INSTALLDIR=$PWD/release_install_root
8
9 # VERSION_MAJOR must be a version number, not text !!
ab0b5b4 Rudy Sicard [feature] version: move to 0.9.0 & S4
OpaOnWindowsNow authored
10 VERSION_MAJOR=$(cat buildinfos/version_major.txt)
9f59881 Frederic Ye [enhance] package: keep official version name for Mac package
Aqua-Ye authored
11 OFFICIAL_VERSION_NAME=$(cat<buildinfos/version_name.txt)
fccc685 Initial open-source release
MLstate authored
12 # VERSION_NAME shall be a string of alphanumeric characters or . + ~ (Debian guidelines)
ab0b5b4 Rudy Sicard [feature] version: move to 0.9.0 & S4
OpaOnWindowsNow authored
13 VERSION_NAME=$(tr '[:upper:]' '[:lower:]' <buildinfos/version_name.txt)
fccc685 Initial open-source release
MLstate authored
14 VERSION_BUILD=build
15
16 # the version string will be MAJORNAME+BUILDnnnn with nnnn the build number
17 # (MAJORNAME if BUILD is empty)
18
19 msg () {
20 case "$1" in
21 -n) shift; echo -n "$*";;
22 *) echo "$*";;
23 esac
24 }
25
26 . platform_helper.sh
27
28 MYDIR=$PWD
29
30 OPAGENERAL=$(dirname $0)
31
32 TBZ2=""
33 AUTOINSTALL=""
34 DEB="false"
35 PKG="false"
36 WINPKG="false"
37
93fa005 Frederic Ye [fix] build: package manager path
Aqua-Ye authored
38 PACK_MAN="/Applications/Xcode.app/Contents/Applications/PackageMaker.app" # PackageManager path for OS X
a6a9515 Frederic Ye [fix] make_package: fix for package manager path
Aqua-Ye authored
39
fccc685 Initial open-source release
MLstate authored
40 help() {
495a04a Frederic Ye [enhance] package: changed Mac package name + renamed OPA -> Opa
Aqua-Ye authored
41 echo "Makes an installation package from an installed Opa (installation"
fccc685 Initial open-source release
MLstate authored
42 echo "should be done through install_release.sh)."
43 echo "Options"
44 # echo " -prefix <dir> Prefix where the package should install opa by"
45 # echo " default (default $PREFIX)"
46 echo " -dir <dir> Where to get the installed tree (as specified"
47 echo " to install_release.sh; default $INSTALLDIR)"
48 echo " -make-autoinstall <filename> builds an auto-installing archive (you will need"
49 echo " MakeSelf installed). {} in filename is replaced by"
50 echo " the version string"
51 echo " -make-tbz2 <filename.tar.bz2>"
52 echo " -make-deb Build a debian package"
53 echo " -make-pkg Build a Macintosh .pkg"
54 echo " -make-winpkg Build a pakage for ms-windows (need nsis)"
55 echo
56 }
57
58 while [ $# -gt 0 ]; do
59 case $1 in
60 -make-tbz2)
61 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument"; exit 1; fi
62 shift
63 TBZ2="$1";;
64 -make-autoinstall)
65 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument"; exit 1; fi
66 shift
67 AUTOINSTALL="$1";;
68 -make-deb)
69 DEB=true;;
70 -make-pkg)
71 if [ -z "$OPAGENERAL" ]; then
72 echo "Error: you need to define \$OPAGENERAL to build a mac package"
73 exit 1
74 fi
75 PKG=true;;
76 -make-winpkg)
77 if [ -z "$OPAGENERAL" ]; then
78 echo "Error: you need to define \$OPAGENERAL to build a windows package"
79 exit 1
80 fi
81 WINPKG=true;;
82 # -prefix)
83 # if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument"; exit 1; fi
84 # shift
85 # PREFIX="$1";;
86 -dir)
87 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument"; exit 1; fi
88 shift
89 INSTALLDIR="$1";;
90 -help|--help|-h)
91 help
92 exit 0;;
93 *)
94 echo "Unknown option $1."
95 help
96 exit 1;;
97 esac
98 shift
99 done
100
101 if [ $(id -u) -ne 0 ] && [[ -z "$IS_MAC" ]] || [ -n "${MAKE_PACKAGE_NON_ROOT:-""}" ]; then
102 msg "Error: running as user."
103 msg "This would generate wrong packages, please run within fakeroot."
104 exit 3
105 fi
106
107 if [ ${INSTALLDIR:0:1} != "/" ]; then
108 msg "Error: please specify an absolute dir"
109 exit 1
110 fi
111
112 BUILDNUM=$($INSTALLDIR/lib/opa/bin/opa-bin --version 2>&1 | sed 's/.*build \([0-9]\+\).*/\1/')
113 VERSION_STRING=${VERSION_MAJOR}${VERSION_NAME}$(if [ -n "$VERSION_BUILD" ]; then echo "+$VERSION_BUILD$BUILDNUM"; fi)
114
495a04a Frederic Ye [enhance] package: changed Mac package name + renamed OPA -> Opa
Aqua-Ye authored
115 msg "Making package from installation in $INSTALLDIR, with Opa version $VERSION_STRING."
fccc685 Initial open-source release
MLstate authored
116
117 if [ -n "$TBZ2" ]; then
118 msg "Making $TBZ2 (to be decompressed at the installation prefix)"
119 msg "(after decompression in <prefix> (eg. /usr/local), the user will"
120 msg "need to run <prefix>/share/opa/install/sh --dir <prefix>)"
121 tar -C $INSTALLDIR -cj * -f $MYDIR/$TBZ2
122 fi
123
124 ###################################
125 # auto-extract package generation #
126 ###################################
127
128 if [ -n "$AUTOINSTALL" ]; then
129 AUTOINSTALL=${AUTOINSTALL//\{\}/$VERSION_STRING}
130 msg "Making $AUTOINSTALL"
131 cat >"$INSTALLDIR/install.sh" <<EOF
22b433a Don't assume that bash is in /bin
Frédéric Perrin authored
132 #!/usr/bin/env bash
133
134 set -e
135 set -u
fccc685 Initial open-source release
MLstate authored
136
137 if [ -n "\${1:-}" ]; then
138 echo "Installing in \$1"
139 INSTALL="\$1"
140 else
141 PREFIX=\$HOME/mlstate-opa
142 if [ "\$(id -u)" -eq 0 ]; then PREFIX=/usr/local; fi
143 echo "Please specify install prefix. (default \$PREFIX)"
144 INSTALL=""
145 while [ -z "\$INSTALL" ]; do
146 read INSTALL
147 if [ -z "\$INSTALL" ]; then INSTALL="\$PREFIX"
148 elif [ "\${INSTALL:0:1}" != "/" ]; then
149 echo "Please provide an absolute directory"
150 INSTALL=""
151 else
152 mkdir -p "\$INSTALL" || {
153 echo "Could not create directory \$INSTALL. Please specify another install prefix"
154 INSTALL=""
155 }
156 fi
157 done
158 fi
159
160 echo "Installing, please wait..."
161
162 mkdir -p "\$INSTALL"
163 GLOBIGNORE=install.sh
164 cp -a * "\$INSTALL"
165
166 \$INSTALL/share/opa/install.sh --quiet --dir "\$INSTALL"
167
168 echo
169 echo "Done !"
170 echo "Documentation is in \$INSTALL/share/doc/opa"
171 echo "If you want to uninstall, run \$INSTALL/share/opa/uninstall.sh"
172 EOF
173 chmod a+x "$INSTALLDIR/install.sh"
174
175 cat >"$INSTALLDIR/share/opa/uninstall.sh" <<"EOF"
22b433a Don't assume that bash is in /bin
Frédéric Perrin authored
176 #!/usr/bin/env bash
177
178 set -e
179 set -u
fccc685 Initial open-source release
MLstate authored
180
181 SCRIPT="$0"
182 if [ "${SCRIPT:0:1}" != "/" ]; then
183 SCRIPT=$PWD/$SCRIPT
184 fi
185
186 # Always run from /tmp
187 TMPDIR="${TMPDIR:-/tmp}"
188 if [ $# -eq 0 ] || [ "${SCRIPT:0:${#TMPDIR}}" != "$TMPDIR" ]; then
189 INSTALLDIR=${SCRIPT%/share/opa/*}
190 X=$(mktemp $TMPDIR/uninstall_opa.XXXXX)
191 cp --preserve=mode "$0" "$X"
192 exec "$X" "$INSTALLDIR" "$@"
193 else
194 if [ $# -ne 1 ]; then echo "Error: bad number of arguments"; exit 1; fi
195 INSTALLDIR="$1"
196 trap "rm -f $0" EXIT
197 fi
198
495a04a Frederic Ye [enhance] package: changed Mac package name + renamed OPA -> Opa
Aqua-Ye authored
199 echo -n "Going to remove Opa from $INSTALLDIR. Proceed ? "
fccc685 Initial open-source release
MLstate authored
200 read yesno
201 if [ "${yesno:0:1}" != "y" ]; then exit 0; fi
202
203 "$INSTALLDIR"/share/opa/install.sh --dir "$INSTALLDIR" --uninstall
204
205 P=$PWD; cd "$INSTALLDIR"
206 rm -f \
207 EOF
208 ( cd $INSTALLDIR; find . ! -type d | sed 's/^\(.*\)$/ "\1" \\/' ) >>$INSTALLDIR/share/opa/uninstall.sh
209 echo >>"$INSTALLDIR/share/opa/uninstall.sh"
210 cat >>"$INSTALLDIR/share/opa/uninstall.sh" <<"EOF"
211 cd $P
212
7affb20 Quentin Bourgerie [fix] package: manpage should be uninstalled
BourgerieQuentin authored
213 for DIR in "$INSTALLDIR/share/opa" "$INSTALLDIR/share/man" "$INSTALLDIR/share/doc/opa" "$INSTALLDIR/lib/opa"; do
fccc685 Initial open-source release
MLstate authored
214 R=0
215 find $DIR \( -type d -empty \) -delete || R=$?
216 if [ $R -ne 0 ] || [ -d $DIR ]; then
217 echo "Warning: some files left in $DIR"
218 fi
219 done
220
221 set +e
7affb20 Quentin Bourgerie [fix] package: manpage should be uninstalled
BourgerieQuentin authored
222 rmdir "$INSTALLDIR/share/man" 2>/dev/null
fccc685 Initial open-source release
MLstate authored
223 rmdir "$INSTALLDIR/share/doc" 2>/dev/null
224 rmdir "$INSTALLDIR/share" 2>/dev/null
225 rmdir "$INSTALLDIR/lib" 2>/dev/null
226 rmdir "$INSTALLDIR/bin" 2>/dev/null
227 rmdir "$INSTALLDIR" 2>/dev/null
228
229 echo "Done."
230 EOF
231 chmod a+x "$INSTALLDIR/share/opa/uninstall.sh"
232
233 makeself --bzip2 $INSTALLDIR "$MYDIR/$AUTOINSTALL" "$AUTOINSTALL" ./install.sh
234 msg "Generated $AUTOINSTALL"
235 fi
236
237 #############################
238 # MacOSX package generation #
239 #############################
240 if [ "$PKG" = "true" ]; then
241 OS_VARIANT=`sw_vers -productVersion`
9f59881 Frederic Ye [enhance] package: keep official version name for Mac package
Aqua-Ye authored
242 PKG_NAME="Opa $VERSION_MAJOR $OFFICIAL_VERSION_NAME - Build $BUILDNUM for Mac OS X (64-bit)"
fccc685 Initial open-source release
MLstate authored
243 echo "Making package '$MYDIR/$PKG_NAME.pkg'"
93fa005 Frederic Ye [fix] build: package manager path
Aqua-Ye authored
244 $PACK_MAN/Contents/MacOS/PackageMaker --root $INSTALLDIR --resources $OPAGENERAL/installer/Mac/Resources/ --scripts $OPAGENERAL/installer/Mac/Scripts --info $OPAGENERAL/installer/Mac/Info.plist --id com.mlstate.opa.pkg -o "$MYDIR/$PKG_NAME.pkg" -n $BUILDNUM --domain system --root-volume-only --discard-forks -m --verbose --title "Opa $VERSION_MAJOR $OFFICIAL_VERSION_NAME"
fccc685 Initial open-source release
MLstate authored
245 echo "Creating image '$MYDIR/$PKG_NAME.dmg'"
246 hdiutil create "$MYDIR/$PKG_NAME.dmg" -srcfolder "$MYDIR/$PKG_NAME.pkg"
247 fi
248
249
250 ################################
251 # MsWindows package generation #
252 ################################
253 if [ "$WINPKG" = "true" ]; then
495a04a Frederic Ye [enhance] package: changed Mac package name + renamed OPA -> Opa
Aqua-Ye authored
254 PKG_NAME="Opa $VERSION_MAJOR $VERSION_NAME Build $BUILDNUM"
fccc685 Initial open-source release
MLstate authored
255 rm -rf pkg_ms_windows
256 mkdir -p pkg_ms_windows
257 # Copy
258 # -everyting
259 cp -a $INSTALLDIR/* pkg_ms_windows/
260 # -nsis script
261 cp $OPAGENERAL/ms_windows/opa_pkg/install.nsi pkg_ms_windows
262 # -opa.bat install
263 cat $OPAGENERAL/ms_windows/opa_pkg/opa.bat | grep -v "^REM" | grep -v "^$" > pkg_ms_windows/bin/opa.bat
264 # Some tidying
265 mkdir -p pkg_ms_windows/bin/ocaml
266 mkdir -p pkg_ms_windows/bin/uninstall
267 mv pkg_ms_windows/share/opa/examples pkg_ms_windows/examples
268 mv pkg_ms_windows/bin/opa-bin pkg_ms_windows/bin/runopa.exe
269 # hidding ocaml executable to be oustide of PATH
270 mv pkg_ms_windows/bin/ocamlopt.opt.exe pkg_ms_windows/bin/ocaml/ocamlopt.opt.exe
271 cp $OPAGENERAL/ms_windows/opa_pkg/opa_logo*.ico pkg_ms_windows/bin/uninstall
272 /cygdrive/c/Program\ Files/NSIS/makensis.exe pkg_ms_windows/install.nsi
273 echo The package is in pkg_ms_windows/installer.exe
274 fi
275
276
277
278
279 #############################
280 # Debian package generation #
281 #############################
282
283 if [ "$DEB" = "true" ]; then
432467c Rudy Sicard [fix] debian,package: mail of maintainer is now package.maintainer@opala...
OpaOnWindowsNow authored
284 MAINTAINER="package.maintainer@opalang.org"
fccc685 Initial open-source release
MLstate authored
285 PREFIX=/usr
286 WORKDIR=$(mktemp -d /tmp/mkdeb.XXXXX)
287 cd $WORKDIR
288 DEBROOT=$WORKDIR/debian
289 mkdir -p $DEBROOT$PREFIX
290 mkdir -p $DEBROOT/DEBIAN
291 mkdir _build
292 cp -a $INSTALLDIR/* $DEBROOT$PREFIX
293 find debian -type d | xargs chmod 755
294
295 cat > debian/DEBIAN/control <<EOF
296 Package: opa
297 Version: $VERSION_STRING
298 Section: devel
299 Priority: optional
300 Architecture: $(dpkg --print-architecture)
301 Installed-Size: $(du -s $INSTALLDIR | cut -f1)
302 Pre-Depends: debconf
303 Depends: libc6 (>= 2.3.2), libgdbm3, libssl0.9.8, libssl-dev, zlib1g, zlib1g-dev, libjpeg62, libpng12-0, libgif4
304 Maintainer: $MAINTAINER
305 Description: The unified language for web 2.0 development
495a04a Frederic Ye [enhance] package: changed Mac package name + renamed OPA -> Opa
Aqua-Ye authored
306 Opa is a unified programming language for web development. This self-contained
307 package contains the Opa compiler, that compiles stand-alone web servers
fccc685 Initial open-source release
MLstate authored
308 including AJAX features, database, etc. from single source files.
309 EOF
310
311 # The wrapper scripts are always bound to $PREFIX, pre-generate them...
312 $DEBROOT$PREFIX/share/opa/install.sh --quiet --dir "$DEBROOT$PREFIX" --prefix "$PREFIX"
313 rm $DEBROOT$PREFIX/share/opa/install.sh
314
315 mkdir -p $DEBROOT$PREFIX/share/lintian/overrides
316 cat > $DEBROOT$PREFIX/share/lintian/overrides/opa <<EOF
432467c Rudy Sicard [fix] debian,package: mail of maintainer is now package.maintainer@opala...
OpaOnWindowsNow authored
317 # The package itself is in AGPL & APACHE, but includes other software and lists their licenses
fccc685 Initial open-source release
MLstate authored
318 # in the copyright file
319 opa binary: copyright-should-refer-to-common-license-file-for-lgpl
320 EOF
321
322 dpkg-deb --build debian _build
323 PACKAGE=$(ls _build/*.deb)
324 mv $PACKAGE $MYDIR
325 msg "Generated $(basename "$PACKAGE")"
326 cd $MYDIR
327 rm -rf /tmp/${WORKDIR#/tmp/}
328 fi
329
330 msg 'Done !'
Something went wrong with that request. Please try again.