#!/bin/sh
# Takes a binary file and an ups patch
# Outputs a hexdump diff of the input file and the patched output file
set -e
input="$1"
patch="$2"
if [ -z "$input" ] || [ -z "$patch" ]; then
echo "Usage: $0 "
exit 1
fi
t="$(mktemp -d)"
trap 'rm -rf "$t"' EXIT
xxd "$input" > "$t/input"
mkups apply "$input" "$patch" | xxd > "$t/patched"
diff -u "$t/input" "$t/patched"