#!/bin/sh
set -e -u -x
if test $# -ne 2
then echo "repack_devzone <archive> <extension>"
exit 1
fi
arch=$1
ext=$2
if test `basename $arch .zip`.zip == $arch
then echo "zippie"
unzip -x $arch
arch=`basename $arch .zip`
fi
if test `basename $arch .tar`.tar != $arch
then echo "no TAR!"
exit 1
fi
tar xf $arch
base=`basename $arch .tar`
if test ! -d $base
then echo "No unpacked basename!"
exit 1
fi
mv $base $base-$ext
tar cf $base-$ext.tar $base-$ext
echo " rm -r $base-$ext $arch $1"
echo " mv $base-$ext.tar $HOME/.openttd/newgrf"