aboutsummaryrefslogtreecommitdiffstats
path: root/release/makemacpkg.in
blob: 4465be0d343e924d28dad58731f7610c75383c3f (plain)
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
#!/bin/sh

set -u
set -e
trap onexit INT
trap onexit TERM
trap onexit EXIT

TMPDIR=

onexit()
{
	if [ ! "$TMPDIR" = "" ]; then
		sudo rm -rf $TMPDIR
	fi
}

usage()
{
	echo "$0 [universal [32-bit build dir]]"
	exit 1
}

UNIVERSAL=0

PACKAGE_NAME=TigerVNC
VERSION=@VERSION@
BUILD=@BUILD@
SRCDIR=@srcdir@
BUILDDIR32=@srcdir@/osxx86
if [ $# -gt 0 ]; then
	if [ "$1" = "universal" ]; then
		UNIVERSAL=1
		if [ $# -gt 1 ]; then BUILDDIR32=$2; fi
	fi
fi
PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker

if [ -f $PACKAGE_NAME.dmg ]; then
	rm -f $PACKAGE_NAME.dmg
fi

umask 022
TMPDIR=`mktemp -d /tmp/$PACKAGE_NAME-build.XXXXXX`
PKGROOT=$TMPDIR/pkg/Package_Root
mkdir -p $PKGROOT/opt/$PACKAGE_NAME/bin
mkdir -p $PKGROOT/opt/$PACKAGE_NAME/man/man1

install -m 755 unix/vncviewer/vncviewer $PKGROOT/opt/$PACKAGE_NAME/bin/

if [ $UNIVERSAL = 1 ]; then
	if [ ! -d $BUILDDIR32 ]; then
		echo ERROR: 32-bit build directory $BUILDDIR32 does not exist
		exit 1
	fi
	if [ ! -f $BUILDDIR32/Makefile ]; then
		echo ERROR: 32-bit build directory $BUILDDIR32 is not configured
		exit 1
	fi
	pushd $BUILDDIR32
	make
	popd
	lipo -create -arch i386 $BUILDDIR32/unix/vncviewer/vncviewer -arch x86_64 \
		$PKGROOT/opt/$PACKAGE_NAME/bin/vncviewer \
		-output $PKGROOT/opt/$PACKAGE_NAME/bin/vncviewer
fi

mkdir -p $PKGROOT/Library/Documentation/$PACKAGE_NAME
chmod 1775 $PKGROOT/Library
chmod 775 $PKGROOT/Library/Documentation 
mkdir -p $TMPDIR/pkg/Resources 

(cat $SRCDIR/release/Description.plist.tmpl | sed s/{__VERSION}/$VERSION/g \
	| sed s/{__APPNAME}/$PACKAGE_NAME/g \
	> $TMPDIR/pkg/Description.plist) 
(cat $SRCDIR/release/Info.plist.tmpl | sed s/{__VERSION}/$VERSION/g	\
	| sed s/{__BUILD}/$BUILD/g > $TMPDIR/pkg/Info.plist) 
(cat $SRCDIR/release/uninstall.sh.tmpl \
	| sed s/{__APPNAME}/$PACKAGE_NAME/g \
	> $PKGROOT/opt/$PACKAGE_NAME/bin/uninstall) 
chmod 755 $PKGROOT/opt/$PACKAGE_NAME/bin/uninstall

install -m 644 $SRCDIR/unix/vncviewer/vncviewer.man $PKGROOT/opt/$PACKAGE_NAME/man/man1/vncviewer.1
install -m 644 $SRCDIR/LICENCE.txt $PKGROOT/Library/Documentation/$PACKAGE_NAME/

sudo chown -R root:admin $PKGROOT 
cp $SRCDIR/release/License.rtf $SRCDIR/release/Welcome.rtf $SRCDIR/release/ReadMe.rtf $TMPDIR/pkg/Resources/ 

mkdir $TMPDIR/dmg
$PACKAGEMAKER -build -v -p $TMPDIR/dmg/$PACKAGE_NAME.pkg \
	-f $PKGROOT -r $TMPDIR/pkg/Resources \
	-i $TMPDIR/pkg/Info.plist -d $TMPDIR/pkg/Description.plist 
install -m 644 $SRCDIR/release/uninstall.applescript $TMPDIR 
sudo osacompile -t APPL -o "$TMPDIR/dmg/Uninstall.app" $TMPDIR/uninstall.applescript 
sudo chown -R $USER "$TMPDIR/dmg/Uninstall.app" 
hdiutil create -fs HFS+ -volname $PACKAGE_NAME-$VERSION \
	-srcfolder "$TMPDIR/dmg" \
	$TMPDIR/$PACKAGE_NAME-$VERSION.dmg 
cp $TMPDIR/$PACKAGE_NAME-$VERSION.dmg . 

exit