24d066
#!/bin/bash
24d066
#
24d066
# Copyright (C) 2010 Red Hat, Inc.
24d066
# Authors:
24d066
# Thomas Woerner <twoerner@redhat.com>
24d066
#
24d066
# This program is free software; you can redistribute it and/or modify
24d066
# it under the terms of the GNU General Public License as published by
24d066
# the Free Software Foundation; either version 2 of the License, or
24d066
# (at your option) any later version.
24d066
#
24d066
# This program is distributed in the hope that it will be useful,
24d066
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24d066
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24d066
# GNU General Public License for more details.
24d066
#
24d066
# You should have received a copy of the GNU General Public License
24d066
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
24d066
#
24d066
24d066
version=$1
24d066
[ -z "$version" ] && { echo "Usage: $0 <version>"; exit 1; }
24d066
24d066
# files to be removed without the main SDL-<version>/ prefix
24d066
declare -a REMOVE
24d066
REMOVE[${#REMOVE[*]}]="symbian.zip"
24d066
24d066
# no changes below this line should be needed
24d066
24d066
orig="SDL-${version}"
24d066
orig_tgz="${orig}.tar.gz"
24d066
repackaged="${orig}_repackaged"
24d066
repackaged_tar="${repackaged}.tar"
24d066
repackaged_tgz="${repackaged_tar}.gz"
24d066
24d066
# pre checks
24d066
[ ! -f "${orig_tgz}" ] && { echo "ERROR: ${orig_tgz} does not exist"; exit 1; }
24d066
[ -f "${repackaged_tgz}" ] && { echo "ERROR: ${repackaged_tgz} already exist"; exit 1; }
24d066
24d066
# repackage
24d066
failure=0
24d066
gzip -dc "${orig_tgz}" > "${repackaged_tar}"
24d066
for file in "${REMOVE[@]}"; do
24d066
    tar -f "${repackaged_tar}" --delete "${orig}/${file}" >> repackage.log
24d066
    [ $? != 0 ] && { echo "ERROR: Could not remove file ${orig}/${file} from archive."; failure=1; } || echo "Removed ${orig}/${file} from archive."
24d066
done
24d066
[ $failure != 0 ] && { echo "See repackage.log for details."; exit 1; }
24d066
gzip -9 -n "${repackaged_tar}"
24d066
24d066
# post checks
24d066
RET=0
24d066
for file in "${REMOVE[@]}"; do
24d066
    found=$(tar -ztvf "${repackaged_tgz}" | grep "${file}")
24d066
    [ -n "$found" ] && { echo "ERROR: file ${file} is still in the repackaged archive."; RET=1; }
24d066
done
24d066
24d066
[ $RET == 0 ] && echo "Sucessfully repackaged ${orig}: ${repackaged_tgz}"
24d066
24d066
exit $RET