From f1d444ff6b9c2078d52594b1bcba8398bfcd3d66 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Sat, 30 Mar 2019 22:14:11 -0400
Subject: [PATCH] patch-tool: Apply cabal file patches

---
 scripts/patch-tool | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/scripts/patch-tool b/scripts/patch-tool
index 4757f8e9..3ef49e30 100755
--- a/scripts/patch-tool
+++ b/scripts/patch-tool
@@ -39,12 +39,24 @@ add_pkg_dirs() {
 
 patch_pkg() {
     local pkg=$(basename $1 .patch)
+    local pkg_dir=packages/$pkg
     local patch=$patches_dir/$pkg.patch
-    if [ ! -e "$patch" ]; then
-        echo "No patches for $pkg; skipping patching." return
-    else
-        local pkg_dir=packages/$pkg
+    local cabal=$patches_dir/$pkg.cabal
+
+    local patched=
+    if [ -f "$patch" ]; then
+        echo "Applied patch $patch to $pkg"
         git -C $pkg_dir apply $patch
+        patched=1
+    fi
+
+    if [ -f "$cabal" ]; then
+        echo "Updated cabal file of $pkg with $cabal"
+        cp "$cabal" $pkg_dir/*.cabal
+        patched=1
+    fi
+
+    if [ -n "$patched" ]; then
         git -C $pkg_dir commit -q -a -m "head.hackage.org patch"
     fi
 }
-- 
GitLab