File arnold-repack-free of Package arnold

#!/bin/bash

REMOVE_DIRS=( arnold/src/win arnold/unzip32.dll )

set -o errexit

CMDNAME=${0##*/}
SOURCEDIR=${0%$CMDNAME}

BASENAME=${1%.zip}

cd "$SOURCEDIR" >/dev/null

if ! test -f "$BASENAME.zip" ; then
    exit 0
fi

if test -f "$BASENAME-free.tar.bz2" ; then
    if test "$BASENAME.zip" -ot "$BASENAME-free.tar.bz2" ; then
	if test $CMDNAME -ot "$BASENAME-free.tar.bz2" ; then
	    exit 0
	fi
    fi
fi

mkdir "$BASENAME-repack-tmp"
cd "$BASENAME-repack-tmp"

unzip -qq "$OLDPWD/$BASENAME.zip"
for DIR in "${REMOVE_DIRS[@]}" ; do
    rm -r "$DIR"
done
rm -f "$OLDPWD/$BASENAME-free.tar.bz2"
tar -jcf "$OLDPWD/$BASENAME-free.tar.bz2" *

cd -
rm -rf "$BASENAME-repack-tmp"
openSUSE Build Service is sponsored by