Subject: [PATCH] gnu: Add goawk.
From: [email-masked]
To: [email-masked]
Cc: Ashish SHUKLA <[email-masked]>
Date: Mon, 12 Aug 2024 18:38:00 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

From: Ashish SHUKLA <[email-masked]>

* gnu/packages/gawk.scm (goawk): New variable.

Change-Id: Ib611f1ea55b6a4e115f82e08054ea8d04ec57329
---
 gnu/packages/gawk.scm | 47 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/gawk.scm b/gnu/packages/gawk.scm
index 16a4ca5b0a..f407da9d94 100644
--- a/gnu/packages/gawk.scm
+++ b/gnu/packages/gawk.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2018, 2022 Efraim Flashner <[email-masked]>
 ;;; Copyright © 2021, 2022 Marius Bakke <[email-masked]>
 ;;; Copyright © 2022 Paul A. Patience <[email-masked]>
+;;; Copyright © 2024 Ashish SHUKLA <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -34,7 +35,8 @@ (define-module (gnu packages gawk)
   #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix build-system copy)
-  #:use-module (guix build-system gnu))
+  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system go))
 
 (define-public gawk
   (package
@@ -236,3 +238,46 @@ (define-public cppawk-egawk
        (delete "gawk-mpfr")
        (prepend egawk-next)))
     (synopsis "cppawk that calls Enhanced GNU Awk by default")))
+
+(define-public goawk
+  (package
+    (name "goawk")
+    (version "1.27.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/benhoyt/goawk")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "003idgqj1g41y4sja9gzbds95fl3ba0l20wfgh7hp4kiivgls7r8"))))
+    (build-system go-build-system)
+    (native-inputs (list gawk bash-minimal))
+    (arguments
+     (list
+      #:import-path "github.com/benhoyt/goawk"
+      #:phases
+      '(modify-phases %standard-phases
+	 (add-after 'unpack 'patch-bin-sh
+	   (lambda* (#:key inputs import-path #:allow-other-keys)
+	     (for-each (lambda (f)
+			 (substitute* (string-append "src/" import-path "/"  f)
+			   (("/bin/sh")
+			    (string-append (assoc-ref inputs "bash-minimal") "/bin/sh"))
+			   (("TestCommandLine") ;; failing test case
+			    "SkipCommandLine")))
+		       (list "goawk_test.go" "interp/interp.go"))))
+	 (replace 'check
+	   (lambda* (#:key inputs import-path #:allow-other-keys)
+	     (let ((test-output (string-append "src/" import-path "/testdata/output")))
+	       (chmod test-output #o755)
+	       (for-each (lambda (f)
+			   (chmod f #o644))
+			 (find-files test-output))
+	       (invoke "go" "test" import-path
+		       "-awk" (string-append (assoc-ref inputs "gawk") "/bin/gawk"))))))))
+    (home-page "https://github.com/benhoyt/goawk")
+    (synopsis "GoAWK: an AWK interpreter with CSV support")
+    (description "Package goawk is an implementation of AWK with CSV support.")
+    (license license:expat)))

base-commit: 2b7e2f44169c3da710534a614b4a0a313a7d272a
-- 
2.46.0