summaryrefslogtreecommitdiff
path: root/tools/testosx
blob: 655853a3b38fa042abcca39620f091d352f9b826 (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
102
103
104
105
106
107
#!/bin/sh
# Make sure we are running in the right directory...
if test ! -f tools/testosx; then
	echo "Run this script from the top-level CUPS source directory, e.g.:"
	echo ""
	echo "    tools/testosx [version]"
	echo ""
	exit 1
fi

# Get the current working copy version...
rev=`svnversion . | awk -F: '{print $NF}' | sed -e '1,$s/[a-zA-Z]*//g'`

if test $# = 0; then
	version="1.2svn-r$rev"
else
	version=$1
fi

# Setup an install directory...
user=`whoami`
topdir=`pwd`
pkgdir="/tmp/cups.pkg-$user"

echo Building package using temp directory $pkgdir...
rm -rf $pkgdir
mkdir -p $pkgdir/Package
mkdir -p $pkgdir/Resources

# Install resource files into the Resources directory...
echo Installing resource files...
cp packaging/LICENSE.rtf $pkgdir/Resources/ReadMe.rtf
sed -e '1,$s/@CUPS_VERSION@/'$version'/g' \
	<packaging/WELCOME.rtf >$pkgdir/Resources/Welcome.rtf
cp packaging/installer.tif $pkgdir/Resources/background.tif

cat >$pkgdir/Resources/preflight <<EOF
#!/bin/sh
# Stop any running cupsd processes...
killall cupsd || exit 0
EOF
chmod 755 $pkgdir/Resources/preflight

if test -x /bin/launchctl; then
	cat >$pkgdir/Resources/postflight <<EOF
#!/bin/sh

# Remove old startup item, we use launchd now...
rm -f /System/Library/StartupItems/PrintingServices/PrintingServices

# Tell launchd to reload cupsd...
launchctl unload /System/Library/LaunchDaemons/org.cups.cupsd.plist || exit 0
launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist
EOF
else
	cat >$pkgdir/Resources/postflight <<EOF
#!/bin/sh

# Start cupsd...
/usr/sbin/cupsd
EOF
fi

chmod 755 $pkgdir/Resources/postflight

# Tag the current revision in the plist and web interface files...
for file in packaging/cups-desc.plist packaging/cups-info.plist \
		doc/index.html doc/ja/index.html templates/header.tmpl; do
	echo Updating $file...
	sed -e '1,$s/@CUPS_VERSION@/'$version'/g' \
		-e '1,$s/@CUPS_REVISION@//g' \
		-e '1,$s/@CUPS_RELEASE@/1.2.'$rev'/g' \
		<$file.in >$file
done

# Install CUPS into the Package directory...
#make INSTALL=$topdir/install-sh BUILDROOT=$pkgdir/Package install
make BUILDROOT=$pkgdir/Package install

# Figure out where PackageMaker is installled...
if test -d /Developer/Applications/Utilities/PackageMaker.app; then
	PackageMaker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
else
	PackageMaker=/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
fi

# Create the package...
echo Creating MacOS X package...
rm -rf cups.pkg
echo $PackageMaker -build -v -p cups.pkg \
	-f $pkgdir/Package \
	-r $pkgdir/Resources \
	-d packaging/cups-desc.plist \
	-i packaging/cups-info.plist
$PackageMaker -build -v -p cups.pkg \
	-f $pkgdir/Package \
	-r $pkgdir/Resources \
	-d packaging/cups-desc.plist \
	-i packaging/cups-info.plist

# Create a disk image...
echo Creating MacOS X disk image...
hdiutil create -ov -srcfolder cups.pkg cups-$version.dmg

# Cleanup temp files...
echo Removing temporary files...
rm -rf $pkgdir