From 55e0f0d0a366c4573026b977453caffaeb688e11 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Fri, 23 Aug 2019 23:14:11 +0200 Subject: [PATCH] Ensure that hexpatch emits an error if we are configured to use a patch and dont have it --- Makefile | 2 +- scripts/hexpatch.pl | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 172a781..47101cd 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/scripts/hexpatch.pl b/scripts/hexpatch.pl index 960432b..f82783d 100755 --- a/scripts/hexpatch.pl +++ b/scripts/hexpatch.pl @@ -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; }