#!/bin/bash
# $Id: makedist,v 1.6 2005/01/16 21:55:40 Tux Exp $

# Copyright (C) 2003-2005 Olivier Borowski
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

# Goal :
#	clean & bzip2
# Params :
#	$1 = ARCHNAME (ex: )
#	$2 = ORIGDIR (ex: )

ARCHNAME=$1
ORIGDIR=$2
if [ -z "$ARCHNAME" ] || [ -z "$ORIGDIR" ] ; then
	exit 1
fi

cd $ORIGDIR
./autogen.sh

TMPDIR2=`mktemp -d /tmp/eagle-usb.XXXXXXXXXX` || exit 1
cd $TMPDIR2

# Copy
rm -Rf $ARCHNAME
mkdir -p $ARCHNAME
cp -R $ORIGDIR/* $ARCHNAME

# Clean
rm -f $ARCHNAME/eagle-usb.kateproject
#fixme. Must we remove files used to construct packages ?
find $TMPDIR2/$ARCHNAME -iname "CVS" -type d -exec rm -Rf '{}' ';' -prune
find $TMPDIR2/$ARCHNAME -name "*~" -exec rm -f '{}' ';' 
find $TMPDIR2/$ARCHNAME -name "*.old" -exec rm -f '{}' ';'

# Tar & Bzip2
tar cfj $ARCHNAME.tar.bz2 $ARCHNAME
rm -Rf $ARCHNAME
cd $ORIGDIR
mkdir -p ../eagle-usb.dist
mv $TMPDIR2/$ARCHNAME.tar.bz2 ../eagle-usb.dist
rm -Rf $TMPDIR2

#***************************************************************************
# $Log: makedist,v $
# Revision 1.6  2005/01/16 21:55:40  Tux
# - add license header
#
# Revision 1.5  2004/11/09 13:54:10  mcoolive
# - simplifications and add comments
#
# Revision 1.4  2004/10/31 17:15:11  mcoolive
# - some simplifications
#
# Revision 1.3  2004/05/11 19:40:29  Tux
# - security fix
#
#***************************************************************************/
