#!/bin/sh set -e INPUT="$1" OUTPUT="$2" # check input arguments if [ "$#" != 2 -o -z "$INPUT" -o -z "$OUTPUT" ]; then echo "USAGE: $0 INPUT OUTPUT" >&2 exit 1 fi # input must be a file [ -f "$INPUT" ] tempdir=$(mktemp -d) unzip -q "$INPUT" -d "$tempdir" # fixup the file xsltproc -o "$tempdir/content.xml.tmp" "$(dirname "$0")/strip-frames.xsl" "$tempdir/content.xml" mv -f "$tempdir/content.xml.tmp" "$tempdir/content.xml" # build the output ( cd "$tempdir" zip -q -r - mimetype . ) > "$OUTPUT" # cleanup rm "$tempdir" -rf