File precheckin_cripple_tarball.sh of Package scummvm

# The following source parts of stk may not be distributed for legal
# reasons (bnc#761623)
# Thus we have to cripple the source tree in a way that it still builds.

# Find source tarball + unpack
tmp="$(mktemp)"
trap 'rm -f $tmp; echo 1>&2 "$0 failed"' EXIT
tarsource="$(echo scummvm-*[0-9].tar.bz2)"
if [ ! -s "$tarsource" ] ; then
  echo "Error: cannot find source tarball"
  exit 1
fi
tarbase="${tarsource%.tar.bz2}"
tardest="$tarbase-crippled.tar.bz2"

rm -rf scummvm-*-crippled.tar.bz2

# Cripple source
echo 1>&2 "Crippling..."

files=$(tar -tf ${tarsource} | fgrep /devtools/create_project/xcode.cpp)

bzip2 -cd ${tarsource} > ${tmp}
tar --delete --file=${tmp} ${files}
bzip2 -c ${tmp} > ${tardest}

echo 1>&2 ""
echo 1>&2 "Successfully crippled tarball. :-("
echo 1>&2 ""

rm -rf $tmp
trap - EXIT
exit 0