#!/bin/sh
#
# "$Id: makeipptoolpkg 10143 2011-12-02 20:11:30Z mike $"
#
#   Make an ipptool package for CUPS.
#
#   Copyright 2007-2011 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

uname="`uname | awk '{print tolower($1)}'`"
if test "x$1" = xlsb; then
	shift
	uname="linux-lsb"
fi

if test $# = 0; then
	echo Updating to get snapshot version...
	svn up
	rev=`svnversion . | sed -e '1,$s/[a-zA-Z]//g'`
	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-ipptool*.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-printer-attributes.test $pkgdir
cp test/gray.jpg $pkgdir
cp test/ipp-[12].*.test $pkgdir
cp test/ipptool-static $pkgdir/ipptool
cp test/onepage-*.pdf $pkgdir
cp test/onepage-*.ps $pkgdir
cp test/testfile.* $pkgdir

if test `uname` = Darwin; then
	pkgfile="$pkgdir-macosx-universal.dmg"
	echo Creating disk image $pkgfile...
	test -f $pkgfile && rm $pkgfile
	hdiutil create -srcfolder $pkgdir $pkgfile
	#sudo chown `whoami` $pkgfile
else
	pkgfile="$pkgdir-$uname-`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 10143 2011-12-02 20:11:30Z mike $".
#
