#!/bin/sh # # check-patch [-v] # # Check a patch for updates in its parent set -e if [ "$1" = "-v" ]; then VERBOSE="echo" shift else VERBOSE=":" fi if [ "$#" -ne 1 ]; then echo "Usage: check-patch [-v] " exit 1 fi PATCHDIR="$(dirname "$1")" PATCHNAME="$(basename "$1")" PARENTNAME="$(grep "^## Parent-Name:" $PATCHDIR/$PATCHNAME | cut -d: -f2- | xargs)" PARENTVERSION="$(grep "^## Parent-Version:" $PATCHDIR/$PATCHNAME | cut -d: -f2- | xargs)" PARENTMD5="$(grep "^## Parent-MD5:" $PATCHDIR/$PATCHNAME | cut -d: -f2- | xargs)" NOWMD5="$(md5sum "$PATCHDIR/$PARENTNAME" | cut -b-32)" if ! [ "$PARENTMD5" = "$NOWMD5" ]; then echo "$PATCHDIR/$PATCHNAME needs updating" echo " Parent-Name: $PARENTNAME" echo " Parent-Version: $PARENTVERSION" echo " Parent-MD5: $PARENTMD5" echo " MD5 is now: $NOWMD5" exit 1 fi $VERBOSE "$PATCHDIR/$PATCHNAME is current"