From 27e598f3fa2748c81a2d6b14e765d8a96c4e2459 Mon Sep 17 00:00:00 2001 From: Yehoshua Pesach Wallach Date: Wed, 27 Apr 2022 18:25:03 +0300 Subject: [PATCH] fontgen: assume plain .patch for single string patch --- src/displayapp/fonts/fonts.json | 2 +- src/displayapp/fonts/generate.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/displayapp/fonts/fonts.json b/src/displayapp/fonts/fonts.json index 48f9865a..1216472b 100644 --- a/src/displayapp/fonts/fonts.json +++ b/src/displayapp/fonts/fonts.json @@ -12,7 +12,7 @@ ], "bpp": 1, "size": 20, - "patches": [["patch", "{file}", "{file}_zero.patch"]] + "patches": ["{file}_zero.patch"] }, "jetbrains_mono_42": { "sources": [ diff --git a/src/displayapp/fonts/generate.py b/src/displayapp/fonts/generate.py index 4509ecc1..801566b4 100755 --- a/src/displayapp/fonts/generate.py +++ b/src/displayapp/fonts/generate.py @@ -66,11 +66,18 @@ def main(): subprocess.check_call(line) if patches: for patch in patches: - try: patch = patch.format(name=name, file=name+'.c') + try: + # Try and patch, if given a string + patch = patch.format(name=name, file=name+'.c') + subprocess.check_call(['/usr/bin/patch', name+'.c', patch]) + continue except: pass - try: patch = [arg.format(name=name, file=name+'.c') for arg in patch] - except: pass - subprocess.check_call(patch) + try: + # otherwise, assume a "advanced" patch, which is a list of strings. + patch = [arg.format(name=name, file=name+'.c') for arg in patch] + subprocess.check_call(patch) + except Exception as e: + sys.exit('Failed to patch using "{patch}"\n{err}'.format(patch=patch,err=e))