blob: d89d5cb3f91c0d2fc775742c6f74e2155954c9bb [file] [log] [blame]
DRCee229f42010-04-12 00:25:14 +00001#!/bin/sh
2
3set -u
4set -e
5trap onexit INT
6trap onexit TERM
7trap onexit EXIT
8
9TMPDIR=
10
11onexit()
12{
13 if [ ! "$TMPDIR" = "" ]; then
14 sudo rm -rf $TMPDIR
15 fi
16}
17
18usage()
19{
DRC2b0b1942011-02-09 03:10:44 +000020 echo "$0 [universal [32-bit build dir]]"
DRCee229f42010-04-12 00:25:14 +000021 exit 1
22}
23
24UNIVERSAL=0
25
DRC069cdcc2011-02-09 08:08:14 +000026PACKAGE_NAME=TigerVNC
DRC2b0b1942011-02-09 03:10:44 +000027VERSION=@VERSION@
28BUILD=@BUILD@
29SRCDIR=@srcdir@
30BUILDDIR32=@srcdir@/osxx86
31if [ $# -gt 0 ]; then
32 if [ "$1" = "universal" ]; then
33 UNIVERSAL=1
34 if [ $# -gt 1 ]; then BUILDDIR32=$2; fi
35 fi
DRCee229f42010-04-12 00:25:14 +000036fi
37PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
38
39if [ -f $PACKAGE_NAME.dmg ]; then
40 rm -f $PACKAGE_NAME.dmg
41fi
42
43umask 022
44TMPDIR=`mktemp -d /tmp/$PACKAGE_NAME-build.XXXXXX`
45PKGROOT=$TMPDIR/pkg/Package_Root
DRCee229f42010-04-12 00:25:14 +000046mkdir -p $PKGROOT/opt/$PACKAGE_NAME/bin
DRC6452add2010-07-08 07:12:38 +000047mkdir -p $PKGROOT/opt/$PACKAGE_NAME/man/man1
DRCee229f42010-04-12 00:25:14 +000048
49install -m 755 unix/vncviewer/vncviewer $PKGROOT/opt/$PACKAGE_NAME/bin/
50
51if [ $UNIVERSAL = 1 ]; then
DRC2b0b1942011-02-09 03:10:44 +000052 if [ ! -d $BUILDDIR32 ]; then
53 echo ERROR: 32-bit build directory $BUILDDIR32 does not exist
54 exit 1
DRCee229f42010-04-12 00:25:14 +000055 fi
DRC2b0b1942011-02-09 03:10:44 +000056 if [ ! -f $BUILDDIR32/Makefile ]; then
57 echo ERROR: 32-bit build directory $BUILDDIR32 is not configured
58 exit 1
59 fi
60 pushd $BUILDDIR32
DRCee229f42010-04-12 00:25:14 +000061 make
62 popd
DRC2b0b1942011-02-09 03:10:44 +000063 lipo -create -arch i386 $BUILDDIR32/unix/vncviewer/vncviewer -arch x86_64 \
DRCee229f42010-04-12 00:25:14 +000064 $PKGROOT/opt/$PACKAGE_NAME/bin/vncviewer \
65 -output $PKGROOT/opt/$PACKAGE_NAME/bin/vncviewer
66fi
67
68mkdir -p $PKGROOT/Library/Documentation/$PACKAGE_NAME
69chmod 1775 $PKGROOT/Library
70chmod 775 $PKGROOT/Library/Documentation
71mkdir -p $TMPDIR/pkg/Resources
72
73(cat $SRCDIR/release/Description.plist.tmpl | sed s/{__VERSION}/$VERSION/g \
74 | sed s/{__APPNAME}/$PACKAGE_NAME/g \
75 > $TMPDIR/pkg/Description.plist)
76(cat $SRCDIR/release/Info.plist.tmpl | sed s/{__VERSION}/$VERSION/g \
77 | sed s/{__BUILD}/$BUILD/g > $TMPDIR/pkg/Info.plist)
78(cat $SRCDIR/release/uninstall.sh.tmpl \
79 | sed s/{__APPNAME}/$PACKAGE_NAME/g \
80 > $PKGROOT/opt/$PACKAGE_NAME/bin/uninstall)
81chmod 755 $PKGROOT/opt/$PACKAGE_NAME/bin/uninstall
82
DRC6452add2010-07-08 07:12:38 +000083install -m 644 $SRCDIR/unix/vncviewer/vncviewer.man $PKGROOT/opt/$PACKAGE_NAME/man/man1/vncviewer.1
DRCee229f42010-04-12 00:25:14 +000084install -m 644 $SRCDIR/LICENCE.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/
85
86sudo chown -R root:admin $PKGROOT
87cp $SRCDIR/release/License.rtf $SRCDIR/release/Welcome.rtf $SRCDIR/release/ReadMe.rtf $TMPDIR/pkg/Resources/
88
89mkdir $TMPDIR/dmg
90$PACKAGEMAKER -build -v -p $TMPDIR/dmg/$PACKAGE_NAME.pkg \
91 -f $PKGROOT -r $TMPDIR/pkg/Resources \
92 -i $TMPDIR/pkg/Info.plist -d $TMPDIR/pkg/Description.plist
93install -m 644 $SRCDIR/release/uninstall.applescript $TMPDIR
94sudo osacompile -t APPL -o "$TMPDIR/dmg/Uninstall.app" $TMPDIR/uninstall.applescript
95sudo chown -R $USER "$TMPDIR/dmg/Uninstall.app"
96hdiutil create -fs HFS+ -volname $PACKAGE_NAME-$VERSION \
97 -srcfolder "$TMPDIR/dmg" \
98 $TMPDIR/$PACKAGE_NAME.dmg
99cp $TMPDIR/$PACKAGE_NAME.dmg .
100
101exit