Ensure that hexpatch emits an error if we are configured to use a patch and dont have it

pull/140/head
Hamish Coleman 5 years ago
parent 68726da759
commit 55e0f0d0a3

@ -198,7 +198,7 @@ patch_disable_keyboard:
# Generate a working file with any known patches applied
%.img: %.img.orig
@cp --reflink=auto $< $@
./scripts/hexpatch.pl --rm_on_fail --report $@.report $@ $(addprefix $@.d/,$(PATCHES-y))
./scripts/hexpatch.pl --rm_on_fail --fail_on_missing --report $@.report $@ $(addprefix $@.d/,$(PATCHES-y))
# using both __DIR and __FL2 is a hack to get around needing to quote the
# DOS path separator. It feels like there should be a better way if I put

@ -5,6 +5,9 @@ use strict;
# Apply a diff of two hexdumps as a binary patch
#
# Copyright (C) 2016-2019 Hamish Coleman
#
# TODO
# - make parameter parsing more sane
use IO::File;
@ -20,7 +23,7 @@ sub usage() {
print("patching the right file\n");
print("\n");
print("Usage:\n");
print(" hexpatch.pl [--rm_on_fail] [--report file] binaryfile patchfile [patchfile...]\n");
print(" hexpatch.pl [--rm_on_fail] [--fail_on_missing] [--report file] binaryfile patchfile [patchfile...]\n");
print("\n");
exit(1);
}
@ -219,6 +222,12 @@ sub main() {
shift @ARGV;
}
my $fail_on_missing;
if (defined($ARGV[0]) && $ARGV[0] eq "--fail_on_missing") {
$fail_on_missing=1;
shift @ARGV;
}
my $reportfile;
if (defined($ARGV[0]) && $ARGV[0] eq "--report") {
shift @ARGV;
@ -244,7 +253,7 @@ sub main() {
while ($ARGV[0]) {
my $patchfile = shift @ARGV;
if (!-e $patchfile) {
if (!$fail_on_missing && !-e $patchfile) {
warn("Patchfile $patchfile not present, skipping\n");
next;
}

Loading…
Cancel
Save