1#!/bin/sh 2# Make sure we are running in the right directory... 3if test ! -f tools/testosx; then 4 echo "Run this script from the top-level CUPS source directory, e.g.:" 5 echo "" 6 echo " sudo tools/testosx [version]" 7 echo "" 8 exit 1 9fi 10 11if test `whoami` != root; then 12 echo "Run this script with sudo, e.g.:" 13 echo "" 14 echo " sudo tools/testosx [version]" 15 echo "" 16 exit 1 17fi 18 19# Get the current working copy version... 20rev=`svnversion . | awk -F: '{print $NF}' | sed -e '1,$s/[a-zA-Z]*//g'` 21 22if test $# = 0; then 23 version="1.5svn-r$rev" 24else 25 version=$1 26fi 27 28# Setup an install directory... 29user=`whoami` 30topdir=`pwd` 31pkgdir="/tmp/cups.pkg-$user" 32 33echo Building package using temp directory $pkgdir... 34rm -rf $pkgdir 35mkdir -p $pkgdir/Package 36mkdir -p $pkgdir/Resources 37 38# Install resource files into the Resources directory... 39echo Installing resource files... 40cp packaging/LICENSE.rtf $pkgdir/Resources/ReadMe.rtf 41sed -e '1,$s/@CUPS_VERSION@/'$version'/g' \ 42 <packaging/WELCOME.rtf >$pkgdir/Resources/Welcome.rtf 43cp packaging/installer.tif $pkgdir/Resources/background.tif 44 45if test -x /bin/launchctl; then 46 cat >$pkgdir/Resources/preflight <<EOF 47#!/bin/sh 48# Tell launchd to stop cupsd... 49if test "x`whoami`" = xroot; then 50 sudo launchctl unload /System/Library/LaunchDaemons/org.cups.cupsd.plist || exit 0 51 sudo launchctl unload /System/Library/LaunchDaemons/org.cups.cups-lpd.plist || exit 0 52fi 53killall cupsd || exit 0 54EOF 55else 56 cat >$pkgdir/Resources/preflight <<EOF 57#!/bin/sh 58# Stop any running cupsd processes... 59killall cupsd || exit 0 60EOF 61fi 62 63chmod 755 $pkgdir/Resources/preflight 64 65if test -x /bin/launchctl; then 66 cat >$pkgdir/Resources/postflight <<EOF 67#!/bin/sh 68 69# Remove old xinetd config file, we use launchd now... 70rm -f /etc/xinetd.d/cups-lpd 71 72# Tell launchd to reload cupsd... 73if test "x`whoami`" = xroot; then 74 sudo launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist 75 sudo launchctl load /System/Library/LaunchDaemons/org.cups.cupsd-lpd.plist || exit 0 76fi 77EOF 78else 79 cat >$pkgdir/Resources/postflight <<EOF 80#!/bin/sh 81 82# Start cupsd... 83/usr/sbin/cupsd 84EOF 85fi 86 87chmod 755 $pkgdir/Resources/postflight 88 89case `uname -r` in 90 8.* | 9.*) 91 cp packaging/InstallationCheck $pkgdir/Resources 92 chmod 755 $pkgdir/Resources/InstallationCheck 93 ;; 94esac 95 96# Tag the current revision in the plist and web interface files... 97for file in packaging/cups-desc.plist packaging/cups-info.plist \ 98 doc/index.html templates/header.tmpl; do 99 echo Updating $file... 100 sed -e '1,$s/@CUPS_VERSION@/'$version'/g' \ 101 -e '1,$s/@CUPS_REVISION@//g' \ 102 -e '1,$s/@CUPS_RELEASE@/1.5.'$rev'/g' \ 103 <$file.in >$file 104done 105 106# Install CUPS into the Package directory... 107#make INSTALL=$topdir/install-sh BUILDROOT=$pkgdir/Package install 108make BUILDROOT=$pkgdir/Package install || exit 1 109 110# Figure out where PackageMaker is installled... 111if test -d /Developer/Applications/Utilities/PackageMaker.app; then 112 PackageMaker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker 113else 114 PackageMaker=/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker 115fi 116 117# Create the package... 118echo Creating MacOS X package... 119rm -rf cups.pkg 120echo $PackageMaker -build -v -p cups.pkg \ 121 -f $pkgdir/Package \ 122 -r $pkgdir/Resources \ 123 -d packaging/cups-desc.plist \ 124 -i packaging/cups-info.plist 125$PackageMaker -build -v -p cups.pkg \ 126 -f $pkgdir/Package \ 127 -r $pkgdir/Resources \ 128 -d packaging/cups-desc.plist \ 129 -i packaging/cups-info.plist 130 131# Create a disk image... 132echo Creating MacOS X disk image... 133hdiutil create -ov -srcfolder cups.pkg cups-$version.dmg 134 135# Cleanup temp files... 136echo Removing temporary files... 137#rm -rf $pkgdir 138