bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65924: [PATCH core-updates 3/3] gnu: git-minimal: Add coreutils and


From: Maxim Cournoyer
Subject: bug#65924: [PATCH core-updates 3/3] gnu: git-minimal: Add coreutils and sed to PATH.
Date: Sat, 7 Oct 2023 23:18:51 -0400

Fixes <https://issues.guix.gnu.org/65924>.

* gnu/packages/version-control.scm (git-minimal)
[arguments] <imported-modules>: New field.
<modules>: Augment with (ice-9 match), (ice-9 textual-ports) and (guix
search-paths).
<phases>: Add patch-commands phase.
[inputs]: Add coreutils-minimal and sed.
---
 gnu/packages/version-control.scm | 57 ++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index bc647d1538..b0997db5da 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -82,6 +82,7 @@ (define-module (gnu packages version-control)
   #:use-module (guix build-system python)
   #:use-module (guix build-system qt)
   #:use-module (guix build-system trivial)
+  #:use-module (guix modules)
   #:use-module (gnu packages apr)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages documentation)
@@ -245,9 +246,14 @@ (define-public git-minimal
     (build-system gnu-build-system)
     (arguments
      (list
-      #:modules `((srfi srfi-1)
+      #:imported-modules `(,@%gnu-build-system-modules
+                           ,@(source-module-closure '((guix search-paths))))
+      #:modules `((ice-9 match)
+                  (ice-9 textual-ports)
+                  (srfi srfi-1)
                   (srfi srfi-26)
                   ((guix build gnu-build-system) #:prefix gnu:)
+                  (guix search-paths)
                   ,@%gnu-build-system-modules)
       ;; Make sure the full bash does not end up in the final closure.
       #:disallowed-references (list bash perl)
@@ -311,6 +317,51 @@ (define-public git-minimal
                                            inputs "bin/curl-config"))
                                  ":" (getenv "PATH"))))))
                  #~())
+          (add-after 'unpack 'patch-commands
+            (lambda* (#:key inputs #:allow-other-keys)
+              (define (prepend-string-to-file text file)
+                "Prepend TEXT to FILE."
+                (let ((content (call-with-input-file file
+                                 (cut get-string-all <>))))
+                  (call-with-output-file file
+                    (lambda (port)
+                      (display text port)
+                      (display content port)))))
+
+              (define PATH-variable-definition
+                (let ((value
+                       (match (evaluate-search-paths
+                               (list $PATH)
+                               (list #$(this-package-input "coreutils-minimal")
+                                     #$(this-package-input "sed")))
+                         (((spec . value))
+                          value))))
+                  (string-append
+                   (search-path-definition $PATH value
+                                           #:kind 'prefix) "\n\n")))
+
+              ;; Ensure that coreutils (for basename) and sed are on PATH
+              ;; for any script that sources the 'git-sh-setup.sh' file.
+              (prepend-string-to-file PATH-variable-definition
+                                      "git-sh-setup.sh")
+
+              ;; Avoid depending on util-linux; it's only used to detect
+              ;; whether the system is MinGW, which we can detect at build
+              ;; time.
+              (substitute* "git-sh-setup.sh"
+                (("\\$\\(uname -s)")
+                 (if #$(target-mingw?)
+                     "MINGW"
+                     "GNU")))           ;matched against '*'
+
+              ;; git-submodule sources 'git-sh-setup.sh', but not before
+              ;; invoking the basename and sed commands... patch them to their
+              ;; absolute location.
+              (substitute* "git-submodule.sh"
+                (("\\$\\(basename")
+                 (string-append "$(" (search-input-file inputs 
"bin/basename")))
+                (("sed -e")
+                 (string-append (search-input-file inputs "bin/sed") " -e")))))
           (add-after 'configure 'patch-makefiles
             (lambda _
               (substitute* "Makefile"
@@ -414,10 +465,12 @@ (define-public git-minimal
            gettext-minimal
            perl))
     (inputs
-     (list curl                         ;for HTTP(S) access
+     (list coreutils-minimal
+           curl                         ;for HTTP(S) access
            expat                        ;for 'git push' over HTTP(S)
            openssl
            perl
+           sed
            zlib))
     (native-search-paths
      ;; For HTTPS access, Git needs a single-file certificate bundle, specified
-- 
2.41.0






reply via email to

[Prev in Thread] Current Thread [Next in Thread]