diff options
| author | Maxim Cournoyer <maxim@guixotic.coop> | 2026-02-24 11:17:42 +0900 |
|---|---|---|
| committer | Maxim Cournoyer <maxim@guixotic.coop> | 2026-02-26 09:59:20 +0900 |
| commit | e122291204edd294a03692127206bec2fe427225 (patch) | |
| tree | 85d36911460fde03917a88f6d91bd7a3fd45ccc2 | |
| parent | 14a4a2b8ed856a3681729fef9ccf91d07d4c2e16 (diff) | |
build: Patch the git-lfs hooks shebangs in `git-fetch'.
This reverts commit b6a070d2a3c059c1a574dc4048fb8f942e008799, which patched
git-lfs so its hooks would refer to a 'sh' from the store, but this reference
was at risk of going stale since the hooks are installed and preserved outside
the store. The shebangs are now patched in the `git-fetch' procedure
directly.
* guix/scripts/perform-download.scm (perform-git-download): Expand comment.
* guix/git-download.scm (bash-package): New variable.
(git-fetch/in-band*): Add #:bash argument.
(git-fetch-builder): Add it to `inputs', so that it gets added to PATH.
* guix/build/git.scm (git-fetch): Substitute /bin/bash in the post-checkout
git-lfs hook shebang.
Fixes: https://codeberg.org/guix/guix/issues/5616
Reported-by: Simon Josefsson <simon@josefsson.org>
Change-Id: Ife81737705bef5d0a1edad307ed77a479af4609e
| -rw-r--r-- | gnu/packages/version-control.scm | 5 | ||||
| -rw-r--r-- | guix/build/git.scm | 8 | ||||
| -rw-r--r-- | guix/git-download.scm | 13 | ||||
| -rw-r--r-- | guix/scripts/perform-download.scm | 4 |
4 files changed, 20 insertions, 10 deletions
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm index b54e296bcc3..f5db84f16c3 100644 --- a/gnu/packages/version-control.scm +++ b/gnu/packages/version-control.scm | |||
| @@ -3953,11 +3953,6 @@ matching.") | |||
| 3953 | #:test-flags #~(list "-skip" "TestHistoryRewriterUpdatesRefs") | 3953 | #:test-flags #~(list "-skip" "TestHistoryRewriterUpdatesRefs") |
| 3954 | #:phases | 3954 | #:phases |
| 3955 | #~(modify-phases %standard-phases | 3955 | #~(modify-phases %standard-phases |
| 3956 | (add-after 'unpack 'patch-/bin/sh | ||
| 3957 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 3958 | (substitute* "src/github.com/git-lfs/git-lfs/v3/lfs/hook.go" | ||
| 3959 | (("/bin/sh") | ||
| 3960 | (search-input-file inputs "bin/sh"))))) | ||
| 3961 | ;; Only build the man pages if ruby-asciidoctor is available. | 3956 | ;; Only build the man pages if ruby-asciidoctor is available. |
| 3962 | #$@(if (this-package-native-input "ruby-asciidoctor") | 3957 | #$@(if (this-package-native-input "ruby-asciidoctor") |
| 3963 | #~((add-before 'build 'man-gen | 3958 | #~((add-before 'build 'man-gen |
diff --git a/guix/build/git.scm b/guix/build/git.scm index 07478373750..98077fe8be3 100644 --- a/guix/build/git.scm +++ b/guix/build/git.scm | |||
| @@ -73,7 +73,13 @@ fetched, recursively. Return #t on success, #f otherwise." | |||
| 73 | 73 | ||
| 74 | (when lfs? | 74 | (when lfs? |
| 75 | (setenv "HOME" "/tmp") | 75 | (setenv "HOME" "/tmp") |
| 76 | (invoke git-command "lfs" "install")) | 76 | (invoke git-command "lfs" "install") |
| 77 | ;; Substitute the git-lfs hooks shebangs. These can't be patched | ||
| 78 | ;; in-package because the hooks are installed and the commands | ||
| 79 | ;; referenced in their shebangs could become stale. | ||
| 80 | (substitute* ".git/hooks/post-checkout" | ||
| 81 | (("^#!/bin/sh") | ||
| 82 | (string-append "#!" (which "sh"))))) | ||
| 77 | 83 | ||
| 78 | (if (zero? (system* git-command "fetch" "--depth" "1" "--" "origin" commit)) | 84 | (if (zero? (system* git-command "fetch" "--depth" "1" "--" "origin" commit)) |
| 79 | (invoke git-command "checkout" "FETCH_HEAD") | 85 | (invoke git-command "checkout" "FETCH_HEAD") |
diff --git a/guix/git-download.scm b/guix/git-download.scm index 6d96e63f009..609382eba11 100644 --- a/guix/git-download.scm +++ b/guix/git-download.scm | |||
| @@ -77,6 +77,11 @@ | |||
| 77 | (recursive? git-reference-recursive? ; whether to recurse into sub-modules | 77 | (recursive? git-reference-recursive? ; whether to recurse into sub-modules |
| 78 | (default #f))) | 78 | (default #f))) |
| 79 | 79 | ||
| 80 | (define (bash-package) | ||
| 81 | "Return the default Bash package." | ||
| 82 | (let ((distro (resolve-interface '(gnu packages bash)))) | ||
| 83 | (module-ref distro 'bash-minimal))) | ||
| 84 | |||
| 80 | (define (git-package) | 85 | (define (git-package) |
| 81 | "Return the default Git package." | 86 | "Return the default Git package." |
| 82 | (let ((distro (resolve-interface '(gnu packages version-control)))) | 87 | (let ((distro (resolve-interface '(gnu packages version-control)))) |
| @@ -87,9 +92,10 @@ | |||
| 87 | (let ((distro (resolve-interface '(gnu packages version-control)))) | 92 | (let ((distro (resolve-interface '(gnu packages version-control)))) |
| 88 | (module-ref distro 'git-lfs))) | 93 | (module-ref distro 'git-lfs))) |
| 89 | 94 | ||
| 90 | (define (git-fetch-builder git git-lfs git-ref-recursive? hash-algo) | 95 | (define (git-fetch-builder bash git git-lfs git-ref-recursive? hash-algo) |
| 91 | (define inputs | 96 | (define inputs |
| 92 | `(,(or git (git-package)) | 97 | `(,(or bash (bash-package)) |
| 98 | ,(or git (git-package)) | ||
| 93 | ,@(if git-lfs | 99 | ,@(if git-lfs |
| 94 | (list git-lfs) | 100 | (list git-lfs) |
| 95 | '()) | 101 | '()) |
| @@ -163,6 +169,7 @@ | |||
| 163 | (define* (git-fetch/in-band* ref hash-algo hash | 169 | (define* (git-fetch/in-band* ref hash-algo hash |
| 164 | #:optional name | 170 | #:optional name |
| 165 | #:key (system (%current-system)) | 171 | #:key (system (%current-system)) |
| 172 | (bash (bash-package)) | ||
| 166 | (guile (default-guile)) | 173 | (guile (default-guile)) |
| 167 | (git (git-package)) | 174 | (git (git-package)) |
| 168 | git-lfs) | 175 | git-lfs) |
| @@ -177,7 +184,7 @@ respective documentation." | |||
| 177 | ;; | 184 | ;; |
| 178 | ;; Don't pass package specific data in to the following | 185 | ;; Don't pass package specific data in to the following |
| 179 | ;; procedure, use #:env-vars below instead. | 186 | ;; procedure, use #:env-vars below instead. |
| 180 | (git-fetch-builder git git-lfs | 187 | (git-fetch-builder bash git git-lfs |
| 181 | (git-reference-recursive? ref) | 188 | (git-reference-recursive? ref) |
| 182 | hash-algo) | 189 | hash-algo) |
| 183 | #:script-name "git-download" | 190 | #:script-name "git-download" |
diff --git a/guix/scripts/perform-download.scm b/guix/scripts/perform-download.scm index 86ac68284af..4c1034beaf7 100644 --- a/guix/scripts/perform-download.scm +++ b/guix/scripts/perform-download.scm | |||
| @@ -216,7 +216,9 @@ Note: OUTPUT may differ from the 'out' value of DRV, notably for 'bmCheck' or | |||
| 216 | ;; Commands such as 'git submodule' expect Coreutils and sed (among | 216 | ;; Commands such as 'git submodule' expect Coreutils and sed (among |
| 217 | ;; others) to be in $PATH. The 'git' package in Guix should address it | 217 | ;; others) to be in $PATH. The 'git' package in Guix should address it |
| 218 | ;; with wrappers but packages on other distros such as Debian may rely | 218 | ;; with wrappers but packages on other distros such as Debian may rely |
| 219 | ;; on ambient authority, hence the PATH value below. | 219 | ;; on ambient authority, hence the PATH value below. The ambient 'sh' |
| 220 | ;; command is also used to patch the Git LFS hooks, which uses | ||
| 221 | ;; '/bin/sh'. | ||
| 220 | (setenv "PATH" "/run/current-system/profile/bin:/bin:/usr/bin") | 222 | (setenv "PATH" "/run/current-system/profile/bin:/bin:/usr/bin") |
| 221 | 223 | ||
| 222 | (parameterize ((%download-methods | 224 | (parameterize ((%download-methods |
