Subject: [bug#69661] [PATCH] gnu: Add redo-apenwarr

From: Massimo Zaniboni <[email-masked]>
Date: Sat, 9 Mar 2024 01:00:28 +0100

Change-Id: Ied142a7dc3e9baf9babdeff046f350e647a7a5cc
---
  gnu/packages/build-tools.scm | 110 +++++++++++++++++++++++++++++++++++
  1 file changed, 110 insertions(+)

diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 15d88de..54de681 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -15,6 +15,7 @@
  ;;; Copyright © 2021 qblade <[email-masked]>
  ;;; Copyright © 2021, 2023 Maxim Cournoyer <[email-masked]>
  ;;; Copyright © 2022, 2023 Juliana Sims <[email-masked]>
+;;; Copyright © 2024 Massimo Zaniboni <[email-masked]>
  ;;;
  ;;; This file is part of GNU Guix.
  ;;;
@@ -457,6 +458,115 @@ (define-public premake5
  scripted definition of a software project and outputs @file{Makefile}s or
  other lower-level build files.")))

+(define-public redo-apenwarr
+  (package
+    (name "redo-apenwarr")
+    (version "0.42d")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/apenwarr/redo")
+             (commit (string-append "redo-" version))))
+       (sha256
+        (base32 "0z78fmkb85k9hnpvh0pgi8cahljjgnr6j7mb614cykvpa3xsyl0p"))))
+
+    (build-system gnu-build-system)
+    (arguments
+     `(#:test-target "test"
+       #:parallel-build? #f
+       #:parallel-tests? #f
+       #:make-flags (list (string-append "PREFIX="
+                                         (assoc-ref %outputs "out"))
+                          "DESTDIR=/")
+       #:phases (modify-phases %standard-phases
+                  (delete 'configure)
+                  (add-before 'build 'patch-shell-scripts
+                    (lambda* (#:key inputs outputs #:allow-other-keys)
+
+                      (patch-shebang "minimal/do")
+
+                      ;; In Guix build phase there is no anymore a Git 
repo,
+                      ;; hence the Git tool cannot be anymore called.
+                      ;; So the content of the file is manually generated.
+                      (let* ((repo-version "0.42d")
+                             (repo-commit
+                              "7f00abc36be15f398fa3ecf9f4e5283509c34a00")
+                             (repo-date "2021-07-27 20:48:36 -0700")
+                             (repo-head (format #f
+                                         "(HEAD -> main, tag: redo-~a)"
+                                         repo-version)))
+
+                        (substitute* '("redo/version/gitvars.pre")
+                          (("\\$Format:%H\\$")
+                           repo-commit)
+                          (("\\$Format:%d\\$")
+                           repo-head)
+                          (("\\$Format:%ci\\$")
+                           repo-date)))
+
+                      ;; Redo scripts can inject shebangs headers to 
generated scripts.
+                      (substitute* '("bin/default.do"
+                                     "t/203-make/whichmake.do"
+                                     "redo/py.do"
+                                     "redoconf/link.od"
+                                     "redoconf/run.od"
+                                     "redoconf/link-shlib.od"
+                                     "redoconf/_compile.od"
+                                     "redoconf/compile.od"
+                                     "minimal/do")
+                        (("#!/bin/sh")
+                         (format #f "#!~a"
+                                 (which "sh"))))
+
+                      ;; Use `pwd' on the store.
+                      (substitute* '("t/all.do" "t/105-sympath/all.do"
+                                     "t/110-compile/hello.o.do" 
"minimal/do"
+                                     "minimal/do.test" "do")
+                        (("/bin/pwd")
+                         (which "pwd"))
+                        (("/bin/ls")
+                         (which "ls")))
+
+                      ;; Use `perl' on the store.
+                      (substitute* '("t/200-shell/nonshelltest.do")
+                        (("/usr/bin/env perl")
+                         (format #f "~a"
+                                 (which "perl"))))
+
+                      ;; Use `gcc' compiler, because Guix has no 
default `cc' compiler.
+                      (substitute* '("docs/cookbook/hello/hello.do"
+                                     "t/110-compile/LD.do"
+                                     "t/110-compile/CC.do"
+                                     "t/110-compile/yellow.o.do"
+                                     "t/111-example/CC.do"
+                                     "t/111-example/hello.do")
+                        (("^([ \t]*)cc " dummy starting-spaces)
+                         (string-append starting-spaces "gcc ")))
+
+                      (substitute* '("t/110-compile/all.do"
+                                     "t/111-example/all.do")
+                        ((" type cc ")
+                         " type gcc "))
+
+                      (substitute* '("docs/cookbook/c/flagtest.o.od")
+                        (("^CC=\"\\$CC\"")
+                         "CC=\"gcc\"")))))))
+
+    (inputs (list python-wrapper python-markdown python-beautifulsoup4))
+
+    (native-inputs
+     ;; Used for the tests.
+     (list which perl git gcc))
+
+    (synopsis
+     "Build tool where dependencies are part of the building instructions")
+    (description
+     "Redo-apenwarr is a build tool where each artifact is produced by 
a shell
+script having optional annotations for specifying its dependencies.")
+    (home-page "https://github.com/apenwarr/redo")
+    (license license:asl2.0)))
+
  (define-public scons
    (package
      (name "scons")

base-commit: d79c88e8809d2079452fd276bf4d17eb16636ff9
-- 
2.41.0