Skip to content

Instantly share code, notes, and snippets.

@digitalLumberjack
Created January 26, 2025 23:04
Show Gist options
  • Select an option

  • Save digitalLumberjack/d4904edcdaf89f0304ed0af0f9f63f55 to your computer and use it in GitHub Desktop.

Select an option

Save digitalLumberjack/d4904edcdaf89f0304ed0af0f9f63f55 to your computer and use it in GitHub Desktop.
linux-patch.sh
#!/bin/bash
which xdelta3 > /dev/null || { echo "please install xdelta3 (sudo apt install xdelta)" && exit 1 ; }
function printhelp {
echo "linux-patch.sh : usage: linux-patch.sh IMG PATCH DEST_DIR"
echo "linux-patch.sh : example: linux-patch.sh 'Vagrant_Story_60_Hz.xdelta' 'Patch/Vagrant Story (France).bin' Patched/"
}
[ "${1}" == "--help" ] && printhelp && exit 0
[ "${#}" != "3" ] && printhelp && exit 1
sha1sumOriginal="6c65136683018c0746569c990956bf05555e335b"
sha1sumPateched="cc94b35eedd4831c6cdf77c43598125d189b611c"
sha1sum "$1" | grep "${sha1sumOriginal}" || { echo "Image checksum not valid (${1})." && exit 2 ; }
echo "Patching file"
xdelta3 -f -d -s "$1" "$2" "$3/$(basename "$1")" || { echo "Patch Error" && exit 3 ; }
sha1sum "$3/$(basename "$1")" | grep "${sha1sumPatched}" && echo "Patch OK : $3/$(basename "$1")" && exit 0
echo "Patch checksum failed" && exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment