#!/bin/sh
#
# "$Id: makeipptoolpkg 11214 2013-08-01 22:24:05Z msweet $"
#
#   Make an ipptool package for CUPS.
#
#   Copyright 2007-2013 by Apple Inc.
#   Copyright 1997-2007 by Easy Software Products, all rights reserved.
#
#   These coded instructions, statements, and computer programs are the
#   property of Apple Inc. and are protected by Federal copyright
#   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
#   which should have been included with this file.  If this file is
#   file is missing or damaged, see the license at "http://www.cups.org/".
#

# Make sure we are running in the right directory...
if test ! -f tools/makeipptoolpkg; then
        echo "Run this script from the top-level CUPS source directory, e.g.:"
        echo ""
        echo "    tools/makeipptoolpkg $*"
        echo ""
        exit 1
fi

platform="`uname | awk '{print tolower($1)}'`"
case "x$1" in
	xfedora* | xlsb | xrhel* | xubuntu*)
		platform="linux-$1"
		shift
		;;
esac

if test $# = 0; then
	echo Updating to get snapshot version...
	svn up
	rev=`svn info . | grep Revision | awk '{print $2}'`
	fileversion="`date '+%Y%m%d'`-r$rev"
else
	fileversion=$1
fi

if (svn st | grep -qv '^\?'); then
	echo Local changes remain:
	svn st | grep -v '^\?'
	exit 1
fi

echo Creating package directory...
pkgdir="ipptool-$fileversion"

test -d $pkgdir && rm -r $pkgdir
mkdir $pkgdir || exit 1

echo Copying package files
cp CHANGES-IPPTOOL.txt IPPTOOL.txt LICENSE.txt $pkgdir
cp doc/help/man-ipp*.html $pkgdir
cp test/color.jpg $pkgdir
cp test/create-printer-subscription.test $pkgdir
cp test/document-*.pdf $pkgdir
cp test/document-*.ps $pkgdir
cp test/get-completed-jobs.test test/get-jobs.test $pkgdir
cp test/get-notifications.test $pkgdir
cp test/get-printer-attributes.test $pkgdir
cp test/get-subscriptions.test $pkgdir
cp test/gray.jpg $pkgdir
cp test/ipp-[12].*.test $pkgdir
cp test/ipp-everywhere.test $pkgdir
cp test/ippfind-static $pkgdir/ippfind
cp test/ipptool-static $pkgdir/ipptool
cp test/onepage-*.pdf $pkgdir
cp test/onepage-*.ps $pkgdir
cp test/print-job.test $pkgdir
cp test/print-job-deflate.test $pkgdir
cp test/print-job-gzip.test $pkgdir
cp test/testfile.* $pkgdir
cp test/validate-job.test $pkgdir

if test x$platform = xdarwin; then
	pkgfile="$pkgdir-osx-universal.dmg"
	echo Creating disk image $pkgfile...
	test -f $pkgfile && rm $pkgfile
	hdiutil create -srcfolder $pkgdir $pkgfile
else
	pkgfile="$pkgdir-$platform-`uname -m`.tar.gz"
	echo Creating archive $pkgfile...
	tar czf $pkgfile $pkgdir || exit 1
fi

echo Removing temporary files...
rm -r $pkgdir

echo Done.

#
# End of "$Id: makeipptoolpkg 11214 2013-08-01 22:24:05Z msweet $".
#
