prettyprint/zipdiff | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
New commits: commit f2713985b034438ab9ae52dbd09d4bd0186cc039 Author: Miklos Vajna <[email protected]> Date: Fri Jul 18 14:18:01 2014 +0200 prettyprint: add zipdiff script Change-Id: I5222798d326a21dd2f4170df3880cf1af4deca9d diff --git a/prettyprint/zipdiff b/prettyprint/zipdiff new file mode 100755 index 0000000..b1a39dc --- /dev/null +++ b/prettyprint/zipdiff @@ -0,0 +1,64 @@ +#!/bin/bash +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +# For ODF, there is flat ODF, but for other XML-based zipped formats, you have +# to unpack the archive and compare each file manually. +# +# This script tries to automate that: you can diff archive contents as well XML +# contents as well. + +# Allow symlinking to ~/bin while still finding formatxml next to us in the original location. +mydir=$(dirname $0) +[ -h $0 ] && mydir=$(dirname $(readlink $0)) + +unpack() +{ + mkdir $1 + cd $1 + unzip -q $2 + if [ -z "$filesOnly" ]; then + for i in $(find . -name "*.xml" -o -name "*.rels") + do + $mydir/formatxml "$i" > "$i-new" + mv -f "$i-new" "$i" + done + fi + cd .. +} + +filesOnly= +if [ "$1" = "-f" ]; then + shift + filesOnly=t +fi + +if [ -z "$1" -o -z "$2" ]; then + echo "usage: zipdiff [-f] onefile otherfile" + echo + echo "-f diff only the list of files, not their contents" + exit 1 +fi + +a=$(realpath $1) +b=$(realpath $2) +workdir=$(mktemp -d) +cd $workdir +unpack a $a +unpack b $b + +if [ -n "$filesOnly" ]; then + find a -mindepth 1 |sed 's|^a/||' |sort > a-list + find b -mindepth 1 |sed 's|^b/||' |sort > b-list + diff -u a-list b-list +else + diff -Nur a b +fi +rm -rf $workdir + +# vim:set shiftwidth=4 softtabstop=4 expandtab: _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
