#!/bin/sh

# Copyright (C) 2009 Simon Josefsson <simon@josefsson.org>
# Copyright (C) 2008 Enrico Tassi <gareuselesinge@debian.org>
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA

PROJECT=$1
VERSION=$2
FILE=$PROJECT-$VERSION.zip

if ! test -f $FILE; then
  echo Usage: $0 VERSION
  echo The file $PROJECT-$VERSION.zip must exist.
  exit 1
fi

DEBIAN_REVISION=-1
TMP=tmp

rm -rf $TMP
mkdir $TMP
cp $FILE $TMP/
cd $TMP/
unzip $FILE
chmod a+x bin/*
rm $FILE
echo "Section: libs" > control
echo "Priority: optional" >> control
echo "Standards-Version: 3.8.0" >> control
echo "" >> control
echo "Package: mingw32-$PROJECT" >> control
echo "Version: $VERSION$DEBIAN_REVISION" >> control
echo "Maintainer: ${DEBFULLNAME:-'foo'} <${DEBEMAIL:-'foo <foo@foo>'}>" >> control
echo "Architecture: all" >> control
echo "Files:" >> control
for F in `find . -type f | grep -v ^./control$ | sed s/..//`; do
	echo "	$F /usr/i586-mingw32msvc/$F" >> control
done
echo "Description: $PROJECT library for mingw32" >> control
echo " This package includes both dlls and .h files" >> control
equivs-build control
mv mingw32-${PROJECT}_${VERSION}${DEBIAN_REVISION}_all.deb ..
cd ..
rm -rf $TMP/
