[PATCH 0/2] Add support for Git Large File Storage (LFS).

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Maxim Cournoyer
Severity
normal
M
M
Maxim Cournoyer wrote on 12 Oct 2023 04:49
(address . guix-patches@gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
cover.1697078526.git.maxim.cournoyer@gmail.com
While updating orcus to its latest version (0.19.0), I stumbled on a test a
failure, which ended up being caused by the lack of test files in the
repository checkout. These files are stored using the LFS extension in the
repo; when not using LFS, empty text stubs with some metadata are left in
their place.

I've opted to keep the dependency on git-lfs optional for now for the daemon.
The git in-band downloader will only add the git-lfs dependency when the
git-reference object has its lfs? field set to true.

Maxim Cournoyer (2):
gnu: git-lfs: Patch /bin/sh references.
git-download: Add support for Git Large File Storage (LFS).

configure.ac | 10 ++++++
doc/guix.texi | 9 +++++
gnu/packages/version-control.scm | 5 +++
guix/build/git.scm | 18 +++++++---
guix/config.scm.in | 4 +++
guix/git-download.scm | 58 ++++++++++++++++++++-----------
guix/scripts/perform-download.scm | 3 ++
guix/self.scm | 10 +++++-
8 files changed, 92 insertions(+), 25 deletions(-)


base-commit: d6d706a58b8159748d3a46fa97cae18850487c8a
--
2.41.0
M
M
Maxim Cournoyer wrote on 12 Oct 2023 05:02
[PATCH 1/2] gnu: git-lfs: Patch /bin/sh references.
(address . 66475@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
2343e018a06ef7e1ce7d9d7cc2e6d30c76027277.1697078865.git.maxim.cournoyer@gmail.com
* gnu/packages/version-control.scm (git-lfs)
[arguments]: Add patch-/bin/sh phase.

Change-Id: I2d455e683e4f6e30cd32f5b1fdaccac71616826c
---
gnu/packages/version-control.scm | 5 +++++
1 file changed, 5 insertions(+)

Toggle diff (18 lines)
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index d9c53af71c..04b52f2a85 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -3175,6 +3175,11 @@ (define-public git-lfs
#:install-source? #f
#:phases
#~(modify-phases %standard-phases
+ (add-after 'unpack 'patch-/bin/sh
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "src/github.com/git-lfs/git-lfs/lfs/hook.go"
+ (("/bin/sh")
+ (search-input-file inputs "bin/sh")))))
(add-after 'unpack 'fix-embed-x-net
(lambda _
(delete-file-recursively "src/golang.org/x/net/publicsuffix/data")
--
2.41.0
M
M
Maxim Cournoyer wrote on 12 Oct 2023 05:02
[PATCH 2/2] git-download: Add support for Git Large File Storage (LFS).
(address . 66475@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
58269ccea06b016c38d3bea8678608c8cccce1ca.1697078865.git.maxim.cournoyer@gmail.com
* guix/git-download.scm (<git-reference>) [lfs?]: New field.
(git-fetch/in-band): New #:git-lfs argument.
<inputs>: Remove labels. Conditionally add git-lfs.
<build>: Read "git lfs?" environment
variable and pass its value to the #:lfs? argument of git-fetch-with-fallback.
Use INPUTS directly; update comment.
<gexp->derivation>: Add "git lfs?" to #:env-vars.
(git-fetch/built-in): Add "lfs?" to #:env-vars.
* guix/build/git.scm (git-fetch) [lfs?]: New argument, doc and setup code.
(git-fetch-with-fallback) [lfs?]: New argument. Pass it to git-fetch.
* guix/scripts/perform-download.scm (perform-git-download): Honor the 'lfs?'
environment variable.
* doc/guix.texi (origin Reference) <git-reference>: Document the new 'lfs?'
field.
(Requirements): Mention the optional 'git-lfs' dependency.
* configure.ac: Add a check for the 'git-lfs' command.
* guix/config.scm.in (%git-lfs): New variable.
* guix/self.scm (%packages): Add git-lfs.
(compiled-guix): Add git-lfs to guix-config.
(make-config.scm): New #:git-lfs argument.

Change-Id: I5b233b8642a7bdb8737b9d9b740e7254a89ccb25
---
configure.ac | 10 ++++++
doc/guix.texi | 9 +++++
guix/build/git.scm | 18 +++++++---
guix/config.scm.in | 4 +++
guix/git-download.scm | 58 ++++++++++++++++++++-----------
guix/scripts/perform-download.scm | 3 ++
guix/self.scm | 10 +++++-
7 files changed, 87 insertions(+), 25 deletions(-)

Toggle diff (347 lines)
diff --git a/configure.ac b/configure.ac
index d817f620cf..5342c0f80e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -208,6 +208,16 @@ if test "x$GIT" = "x"; then
fi
AC_SUBST([GIT])
+dnl Git Large File Storage is an optional dependency for the
+dnl "builtin:git-download" derivation builder.
+AC_PATH_PROG([GIT_LFS], [git-lfs])
+if test "x$GIT_LFS" = "x"; then
+ AC_MSG_WARN([Git Large File Storage (git-lfs) is missing;
+ The builtin:git-download derivation builder of the Guix daemon will
+ not be able to use it.])
+fi
+AC_SUBST([GIT_LFS])
+
LIBGCRYPT_LIBDIR="no"
LIBGCRYPT_PREFIX="no"
diff --git a/doc/guix.texi b/doc/guix.texi
index dc16ec1d15..89faaa7b90 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -1020,6 +1020,11 @@ Requirements
The following dependencies are optional:
@itemize
+@item
+The daemon will be able to fetch from Git repositories using the
+@uref{https://git-lfs.com/, Git Large File Storage} extension when the
+@command{git-lfs} command is available.
+
@item
@c Note: We need at least 0.13.0 for #:nodelay.
Support for build offloading (@pxref{Daemon Offload Setup}) and
@@ -8499,6 +8504,10 @@ origin Reference
@command{git describe} style identifier such as
@code{v1.0.1-10-g58d7909c97}.
+@item @code{lfs?} (default: @code{#f})
+This Boolean indicates whether to fetch Git large file storage (LFS)
+files.
+
@item @code{recursive?} (default: @code{#f})
This Boolean indicates whether to recursively fetch Git sub-modules.
@end table
diff --git a/guix/build/git.scm b/guix/build/git.scm
index 0ff263c81b..82c31fabf1 100644
--- a/guix/build/git.scm
+++ b/guix/build/git.scm
@@ -33,10 +33,13 @@ (define-module (guix build git)
;;; Code:
(define* (git-fetch url commit directory
- #:key (git-command "git") recursive?)
+ #:key (git-command "git")
+ lfs? recursive?)
"Fetch COMMIT from URL into DIRECTORY. COMMIT must be a valid Git commit
-identifier. When RECURSIVE? is true, all the sub-modules of URL are fetched,
-recursively. Return #t on success, #f otherwise."
+identifier. When LFS? is true, configure Git to also fetch Large File
+Storage (LFS) files; it assumes that the @code{git-lfs} extension is available
+in the environment. When RECURSIVE? is true, all the sub-modules of URL are
+fetched, recursively. Return #t on success, #f otherwise."
;; Disable TLS certificate verification. The hash of the checkout is known
;; in advance anyway.
@@ -57,6 +60,11 @@ (define* (git-fetch url commit directory
(with-directory-excursion directory
(invoke git-command "init" "--initial-branch=main")
(invoke git-command "remote" "add" "origin" url)
+
+ (when lfs?
+ (setenv "HOME" "/tmp")
+ (invoke git-command "lfs" "install"))
+
(if (zero? (system* git-command "fetch" "--depth" "1" "origin" commit))
(invoke git-command "checkout" "FETCH_HEAD")
(begin
@@ -81,11 +89,13 @@ (define* (git-fetch url commit directory
(define* (git-fetch-with-fallback url commit directory
- #:key (git-command "git") recursive?)
+ #:key (git-command "git")
+ lfs? recursive?)
"Like 'git-fetch', fetch COMMIT from URL into DIRECTORY, but fall back to
alternative methods when fetching from URL fails: attempt to download a nar,
and if that also fails, download from the Software Heritage archive."
(or (git-fetch url commit directory
+ #:lfs? lfs?
#:recursive? recursive?
#:git-command git-command)
(download-nar directory)
diff --git a/guix/config.scm.in b/guix/config.scm.in
index 62e15dd713..4997a1740e 100644
--- a/guix/config.scm.in
+++ b/guix/config.scm.in
@@ -36,6 +36,7 @@ (define-module (guix config)
%system
%git
+ %git-lfs
%gzip
%bzip2
%xz))
@@ -113,6 +114,9 @@ (define %system
(define %git
"@GIT@")
+(define %git-lfs
+ "@GIT_LFS@")
+
(define %gzip
"@GZIP@")
diff --git a/guix/git-download.scm b/guix/git-download.scm
index 5d5d73dc6b..6feeea6428 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -51,6 +51,7 @@ (define-module (guix git-download)
git-reference?
git-reference-url
git-reference-commit
+ git-reference-lfs?
git-reference-recursive?
git-fetch
@@ -71,7 +72,9 @@ (define-record-type* <git-reference>
git-reference?
(url git-reference-url)
(commit git-reference-commit)
- (recursive? git-reference-recursive? ; whether to recurse into sub-modules
+ (lfs? git-reference-lfs? ;whether to fetch LFS files
+ (default #f))
+ (recursive? git-reference-recursive? ;whether to recurse into sub-modules
(default #f)))
(define (git-package)
@@ -79,11 +82,17 @@ (define (git-package)
(let ((distro (resolve-interface '(gnu packages version-control))))
(module-ref distro 'git-minimal)))
+(define (git-lfs-package)
+ "Return the default 'git-lfs' package."
+ (let ((distro (resolve-interface '(gnu packages version-control))))
+ (module-ref distro 'git-lfs)))
+
(define* (git-fetch/in-band ref hash-algo hash
#:optional name
#:key (system (%current-system))
(guile (default-guile))
- (git (git-package)))
+ (git (git-package))
+ (git-lfs (git-lfs-package)))
"Return a fixed-output derivation that performs a Git checkout of REF, using
GIT and GUILE (thus, said derivation depends on GIT and GUILE).
@@ -91,18 +100,22 @@ (define* (git-fetch/in-band ref hash-algo hash
It will be removed when versions of guix-daemon implementing
\"builtin:git-download\" will be sufficiently widespread."
(define inputs
- `(("git" ,(or git (git-package)))
-
- ;; When doing 'git clone --recursive', we need sed, grep, etc. to be
- ;; available so that 'git submodule' works.
+ `(,(or git (git-package))
+ ,@(if (git-reference-lfs? ref)
+ (list (or git-lfs (git-lfs-package)))
+ '())
,@(if (git-reference-recursive? ref)
- (standard-packages)
+ ;; TODO: remove (standard-packages) after
+ ;; 48e528a26f9c019eeaccf5e3de3126aa02c98d3b is merged into master;
+ ;; currently when doing 'git clone --recursive', we need sed, grep,
+ ;; etc. to be available so that 'git submodule' works.
+ (map second (standard-packages))
;; The 'swh-download' procedure requires tar and gzip.
- `(("gzip" ,(module-ref (resolve-interface '(gnu packages compression))
- 'gzip))
- ("tar" ,(module-ref (resolve-interface '(gnu packages base))
- 'tar))))))
+ (list (module-ref (resolve-interface '(gnu packages compression))
+ 'gzip)
+ (module-ref (resolve-interface '(gnu packages base))
+ 'tar)))))
(define guile-json
(module-ref (resolve-interface '(gnu packages guile)) 'guile-json-4))
@@ -126,7 +139,7 @@ (define* (git-fetch/in-band ref hash-algo hash
(define build
(with-imported-modules modules
- (with-extensions (list guile-json gnutls ;for (guix swh)
+ (with-extensions (list guile-json gnutls ;for (guix swh)
guile-lzlib)
#~(begin
(use-modules (guix build git)
@@ -134,6 +147,9 @@ (define* (git-fetch/in-band ref hash-algo hash
#:select (set-path-environment-variable))
(ice-9 match))
+ (define lfs?
+ (call-with-input-string (getenv "git lfs?") read))
+
(define recursive?
(call-with-input-string (getenv "git recursive?") read))
@@ -144,18 +160,17 @@ (define* (git-fetch/in-band ref hash-algo hash
#+(file-append glibc-locales "/lib/locale"))
(setlocale LC_ALL "en_US.utf8")
- ;; The 'git submodule' commands expects Coreutils, sed,
- ;; grep, etc. to be in $PATH.
- (set-path-environment-variable "PATH" '("bin")
- (match '#+inputs
- (((names dirs outputs ...) ...)
- dirs)))
+ ;; The 'git submodule' commands expects Coreutils, sed, grep,
+ ;; etc. to be in $PATH. This also ensures that git extensions are
+ ;; found.
+ (set-path-environment-variable "PATH" '("bin") '#+inputs)
(setvbuf (current-output-port) 'line)
(setvbuf (current-error-port) 'line)
(git-fetch-with-fallback (getenv "git url") (getenv "git commit")
#$output
+ #:lfs? lfs?
#:recursive? recursive?
#:git-command "git")))))
@@ -175,13 +190,15 @@ (define* (git-fetch/in-band ref hash-algo hash
(git-reference-url ref))))
("git commit" . ,(git-reference-commit ref))
("git recursive?" . ,(object->string
- (git-reference-recursive? ref))))
+ (git-reference-recursive? ref)))
+ ("git lfs?" . ,(object->string
+ (git-reference-lfs? ref))))
#:leaked-env-vars '("http_proxy" "https_proxy"
"LC_ALL" "LC_MESSAGES" "LANG"
"COLUMNS")
#:system system
- #:local-build? #t ;don't offload repo cloning
+ #:local-build? #t ;don't offload repo cloning
#:hash-algo hash-algo
#:hash hash
#:recursive? #t
@@ -209,6 +226,7 @@ (define* (git-fetch/built-in ref hash-algo hash
(_
(git-reference-url ref)))))
("commit" . ,(git-reference-commit ref))
+ ("lfs?" . ,(object->string (git-reference-lfs? ref)))
("recursive?" . ,(object->string
(git-reference-recursive? ref))))
#:leaked-env-vars '("http_proxy" "https_proxy"
diff --git a/guix/scripts/perform-download.scm b/guix/scripts/perform-download.scm
index 9aa0e61e9d..37904941d1 100644
--- a/guix/scripts/perform-download.scm
+++ b/guix/scripts/perform-download.scm
@@ -96,6 +96,7 @@ (define* (perform-git-download drv output
'bmRepair' builds."
(derivation-let drv ((url "url")
(commit "commit")
+ (lfs? "lfs?")
(recursive? "recursive?"))
(unless url
(leave (G_ "~a: missing Git URL~%") (derivation-file-name drv)))
@@ -103,6 +104,7 @@ (define* (perform-git-download drv output
(leave (G_ "~a: missing Git commit~%") (derivation-file-name drv)))
(let* ((url (call-with-input-string url read))
+ (lfs? (and lfs? (call-with-input-string lfs? read)))
(recursive? (and recursive?
(call-with-input-string recursive? read)))
(drv-output (assoc-ref (derivation-outputs drv) "out"))
@@ -115,6 +117,7 @@ (define* (perform-git-download drv output
(setenv "PATH" "/run/current-system/profile/bin:/bin:/usr/bin")
(git-fetch-with-fallback url commit output
+ #:lfs? lfs?
#:recursive? recursive?
#:git-command %git))))
diff --git a/guix/self.scm b/guix/self.scm
index a1f235659d..96021be6f6 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -69,6 +69,7 @@ (define %packages
("gzip" . ,(ref 'compression 'gzip))
("bzip2" . ,(ref 'compression 'bzip2))
("xz" . ,(ref 'compression 'xz))
+ ("git-lfs" . ,(ref 'version-control 'git-lfs))
("git-minimal" . ,(ref 'version-control 'git-minimal))
("po4a" . ,(ref 'gettext 'po4a))
("gettext-minimal" . ,(ref 'gettext 'gettext-minimal))
@@ -830,6 +831,9 @@ (define* (compiled-guix source #:key
(define git
(specification->package "git-minimal"))
+ (define git-lfs
+ (specification->package "git-lfs"))
+
(define dependencies
(append-map transitive-package-dependencies
(list guile-gcrypt guile-gnutls guile-git guile-avahi
@@ -1004,6 +1008,7 @@ (define* (compiled-guix source #:key
#:bzip2 bzip2
#:xz xz
#:git git
+ #:git-lfs git-lfs
#:package-name
%guix-package-name
#:package-version
@@ -1109,7 +1114,7 @@ (define %default-config-variables
(%storedir . "/gnu/store")
(%sysconfdir . "/etc")))
-(define* (make-config.scm #:key gzip xz bzip2 git
+(define* (make-config.scm #:key gzip xz bzip2 git git-lfs
(package-name "GNU Guix")
(package-version "0")
(channel-metadata #f)
@@ -1140,6 +1145,7 @@ (define* (make-config.scm #:key gzip xz bzip2 git
%store-database-directory
%config-directory
%git
+ %git-lfs
%gzip
%bzip2
%xz))
@@ -1184,6 +1190,8 @@ (define* (make-config.scm #:key gzip xz bzip2 git
(define %git
#+(and git (file-append git "/bin/git")))
+ (define %git-lfs
+ #+(and git-lfs (file-append git-lfs "/bin/git-lfs")))
(define %gzip
#+(and gzip (file-append gzip "/bin/gzip")))
(define %bzip2
--
2.41.0
M
M
Maxim Cournoyer wrote on 16 Oct 2023 23:28
Re: [bug#66475] [PATCH 1/2] gnu: git-lfs: Patch /bin/sh references.
(address . 66475@debbugs.gnu.org)
87y1g2uui9.fsf@gmail.com
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (25 lines)
> * gnu/packages/version-control.scm (git-lfs)
> [arguments]: Add patch-/bin/sh phase.
>
> Change-Id: I2d455e683e4f6e30cd32f5b1fdaccac71616826c
> ---
> gnu/packages/version-control.scm | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
> index d9c53af71c..04b52f2a85 100644
> --- a/gnu/packages/version-control.scm
> +++ b/gnu/packages/version-control.scm
> @@ -3175,6 +3175,11 @@ (define-public git-lfs
> #:install-source? #f
> #:phases
> #~(modify-phases %standard-phases
> + (add-after 'unpack 'patch-/bin/sh
> + (lambda* (#:key inputs #:allow-other-keys)
> + (substitute* "src/github.com/git-lfs/git-lfs/lfs/hook.go"
> + (("/bin/sh")
> + (search-input-file inputs "bin/sh")))))
> (add-after 'unpack 'fix-embed-x-net
> (lambda _
> (delete-file-recursively "src/golang.org/x/net/publicsuffix/data")

That one has been merged with commit
b6a070d2a3c059c1a574dc4048fb8f942e008799.

--
Thanks,
Maxim
M
M
Maxim Cournoyer wrote on 31 Oct 2023 21:25
[PATCH v2 1/4] git-download: Add support for Git Large File Storage (LFS).
(address . 66475@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
e3c1dbbfe236e1fb6b96f941f37a22473f652c44.1698783917.git.maxim.cournoyer@gmail.com
* guix/build/git.scm (git-fetch) [lfs?]: New argument, doc and setup code.
(git-fetch-with-fallback) [lfs?]: New argument. Pass it to git-fetch.
* guix/git-download.scm (git-lfs-package): New procedure.
(git-fetch/in-band*): New procedure, made of the logic of git-fetch/in-band,
with new git-lfs specifics, with the following changes:
New #:git-lfs argument.
<inputs>: Remove labels. Conditionally add git-lfs.
<build>: Read "git lfs?" environment
variable and pass its value to the #:lfs? argument of git-fetch-with-fallback.
Use INPUTS directly; update comment.
<gexp->derivation>: Add "git lfs?" to #:env-vars.
(git-fetch/in-band): Express in terms of git-fetch/in-band*.
(git-fetch/lfs): New procedure.
* doc/guix.texi (origin Reference): Document it.

Change-Id: I5b233b8642a7bdb8737b9d9b740e7254a89ccb25
---

Changes in v2:
- Do not add lfs? to <git-reference>; instead add a git-fetch/lfs procedure.

doc/guix.texi | 7 ++++
guix/build/git.scm | 19 +++++++--
guix/git-download.scm | 97 ++++++++++++++++++++++++++++++-------------
3 files changed, 91 insertions(+), 32 deletions(-)

Toggle diff (248 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index b90078be06..0076e27939 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8375,6 +8375,13 @@ origin Reference
the file name, or a generic name if @code{#f}.
@end deffn
+@deffn {Procedure} git-fetch/lfs ref hash-algo hash
+This is a variant of the @code{git-fetch} procedure that supports the
+Git @acronym{LFS, Large File Storage} extension. This may be useful to
+pull some binary test data to run the test suite of a package, for
+example.
+@end deffn
+
@deftp {Data Type} git-reference
This data type represents a Git reference for @code{git-fetch} to
retrieve.
diff --git a/guix/build/git.scm b/guix/build/git.scm
index 0ff263c81b..867cade2c4 100644
--- a/guix/build/git.scm
+++ b/guix/build/git.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2016, 2019, 2023 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -33,10 +34,13 @@ (define-module (guix build git)
;;; Code:
(define* (git-fetch url commit directory
- #:key (git-command "git") recursive?)
+ #:key (git-command "git")
+ lfs? recursive?)
"Fetch COMMIT from URL into DIRECTORY. COMMIT must be a valid Git commit
-identifier. When RECURSIVE? is true, all the sub-modules of URL are fetched,
-recursively. Return #t on success, #f otherwise."
+identifier. When LFS? is true, configure Git to also fetch Large File
+Storage (LFS) files; it assumes that the @code{git-lfs} extension is available
+in the environment. When RECURSIVE? is true, all the sub-modules of URL are
+fetched, recursively. Return #t on success, #f otherwise."
;; Disable TLS certificate verification. The hash of the checkout is known
;; in advance anyway.
@@ -57,6 +61,11 @@ (define* (git-fetch url commit directory
(with-directory-excursion directory
(invoke git-command "init" "--initial-branch=main")
(invoke git-command "remote" "add" "origin" url)
+
+ (when lfs?
+ (setenv "HOME" "/tmp")
+ (invoke git-command "lfs" "install"))
+
(if (zero? (system* git-command "fetch" "--depth" "1" "origin" commit))
(invoke git-command "checkout" "FETCH_HEAD")
(begin
@@ -81,11 +90,13 @@ (define* (git-fetch url commit directory
(define* (git-fetch-with-fallback url commit directory
- #:key (git-command "git") recursive?)
+ #:key (git-command "git")
+ lfs? recursive?)
"Like 'git-fetch', fetch COMMIT from URL into DIRECTORY, but fall back to
alternative methods when fetching from URL fails: attempt to download a nar,
and if that also fails, download from the Software Heritage archive."
(or (git-fetch url commit directory
+ #:lfs? lfs?
#:recursive? recursive?
#:git-command git-command)
(download-nar directory)
diff --git a/guix/git-download.scm b/guix/git-download.scm
index 5d5d73dc6b..3de6ae970d 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
;;; Copyright © 2020 Jakub K?dzio?ka <kuba@kadziolka.net>
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -54,6 +55,7 @@ (define-module (guix git-download)
git-reference-recursive?
git-fetch
+ git-fetch/lfs
git-version
git-file-name
git-predicate))
@@ -79,30 +81,36 @@ (define (git-package)
(let ((distro (resolve-interface '(gnu packages version-control))))
(module-ref distro 'git-minimal)))
-(define* (git-fetch/in-band ref hash-algo hash
- #:optional name
- #:key (system (%current-system))
- (guile (default-guile))
- (git (git-package)))
- "Return a fixed-output derivation that performs a Git checkout of REF, using
-GIT and GUILE (thus, said derivation depends on GIT and GUILE).
+(define (git-lfs-package)
+ "Return the default 'git-lfs' package."
+ (let ((distro (resolve-interface '(gnu packages version-control))))
+ (module-ref distro 'git-lfs)))
-This method is deprecated in favor of the \"builtin:git-download\" builder.
-It will be removed when versions of guix-daemon implementing
-\"builtin:git-download\" will be sufficiently widespread."
+(define* (git-fetch/in-band* ref hash-algo hash
+ #:optional name
+ #:key (system (%current-system))
+ (guile (default-guile))
+ (git (git-package))
+ git-lfs)
+ "Shared implementation code for git-fetch/in-band & friends. Refer to their
+respective documentation."
(define inputs
- `(("git" ,(or git (git-package)))
-
- ;; When doing 'git clone --recursive', we need sed, grep, etc. to be
- ;; available so that 'git submodule' works.
+ `(,(or git (git-package))
+ ,@(if git-lfs
+ (list git-lfs)
+ '())
,@(if (git-reference-recursive? ref)
- (standard-packages)
+ ;; TODO: remove (standard-packages) after
+ ;; 48e528a26f9c019eeaccf5e3de3126aa02c98d3b is merged into master;
+ ;; currently when doing 'git clone --recursive', we need sed, grep,
+ ;; etc. to be available so that 'git submodule' works.
+ (map second (standard-packages))
;; The 'swh-download' procedure requires tar and gzip.
- `(("gzip" ,(module-ref (resolve-interface '(gnu packages compression))
- 'gzip))
- ("tar" ,(module-ref (resolve-interface '(gnu packages base))
- 'tar))))))
+ (list (module-ref (resolve-interface '(gnu packages compression))
+ 'gzip)
+ (module-ref (resolve-interface '(gnu packages base))
+ 'tar)))))
(define guile-json
(module-ref (resolve-interface '(gnu packages guile)) 'guile-json-4))
@@ -126,7 +134,7 @@ (define* (git-fetch/in-band ref hash-algo hash
(define build
(with-imported-modules modules
- (with-extensions (list guile-json gnutls ;for (guix swh)
+ (with-extensions (list guile-json gnutls ;for (guix swh)
guile-lzlib)
#~(begin
(use-modules (guix build git)
@@ -134,6 +142,9 @@ (define* (git-fetch/in-band ref hash-algo hash
#:select (set-path-environment-variable))
(ice-9 match))
+ (define lfs?
+ (call-with-input-string (getenv "git lfs?") read))
+
(define recursive?
(call-with-input-string (getenv "git recursive?") read))
@@ -144,18 +155,17 @@ (define* (git-fetch/in-band ref hash-algo hash
#+(file-append glibc-locales "/lib/locale"))
(setlocale LC_ALL "en_US.utf8")
- ;; The 'git submodule' commands expects Coreutils, sed,
- ;; grep, etc. to be in $PATH.
- (set-path-environment-variable "PATH" '("bin")
- (match '#+inputs
- (((names dirs outputs ...) ...)
- dirs)))
+ ;; The 'git submodule' commands expects Coreutils, sed, grep,
+ ;; etc. to be in $PATH. This also ensures that git extensions are
+ ;; found.
+ (set-path-environment-variable "PATH" '("bin") '#+inputs)
(setvbuf (current-output-port) 'line)
(setvbuf (current-error-port) 'line)
(git-fetch-with-fallback (getenv "git url") (getenv "git commit")
#$output
+ #:lfs? lfs?
#:recursive? recursive?
#:git-command "git")))))
@@ -175,18 +185,49 @@ (define* (git-fetch/in-band ref hash-algo hash
(git-reference-url ref))))
("git commit" . ,(git-reference-commit ref))
("git recursive?" . ,(object->string
- (git-reference-recursive? ref))))
+ (git-reference-recursive? ref)))
+ ("git lfs?" . ,(if git-lfs "#t" "#f")))
#:leaked-env-vars '("http_proxy" "https_proxy"
"LC_ALL" "LC_MESSAGES" "LANG"
"COLUMNS")
#:system system
- #:local-build? #t ;don't offload repo cloning
+ #:local-build? #t ;don't offload repo cloning
#:hash-algo hash-algo
#:hash hash
#:recursive? #t
#:guile-for-build guile)))
+(define* (git-fetch/in-band ref hash-algo hash
+ #:optional name
+ #:key (system (%current-system))
+ (guile (default-guile))
+ (git (git-package)))
+ "Return a fixed-output derivation that performs a Git checkout of REF, using
+GIT and GUILE (thus, said derivation depends on GIT and GUILE).
+
+This method is deprecated in favor of the \"builtin:git-download\" builder.
+It will be removed when versions of guix-daemon implementing
+\"builtin:git-download\" will be sufficiently widespread."
+ (git-fetch/in-band* ref hash-algo hash name
+ #:system system
+ #:guile guile
+ #:git git))
+
+(define* (git-fetch/lfs ref hash-algo hash
+ #:optional name
+ #:key (system (%current-system))
+ (guile (default-guile))
+ (git (git-package))
+ (git-lfs (git-lfs-package)))
+ "Like git-fetch/in-band, but with support for the Git Large File
+Storage (LFS) extension."
+ (git-fetch/in-band* ref hash-algo hash name
+ #:system system
+ #:guile guile
+ #:git git
+ #:git-lfs git-lfs))
+
(define* (git-fetch/built-in ref hash-algo hash
#:optional name
#:key (system (%current-system)))

base-commit: d96a9c7473a6d07747f59eeda7d4085173c25383
--
2.41.0
M
M
Maxim Cournoyer wrote on 31 Oct 2023 21:25
[PATCH v2 2/4] gnu: mdds: Update to 2.1.1.
(address . 66475@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
058de06b044c549d06571bc3d1fcd97b175e5532.1698783917.git.maxim.cournoyer@gmail.com
* gnu/packages/boost.scm (mdds): Update to 2.1.1.
[source]: Fetch from git.
[native-inputs]: New field.

Change-Id: I4e71d5c360f4b7305cffd7008e2bbbfcaad2f897
---

(no changes since v1)

gnu/packages/boost.scm | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

Toggle diff (49 lines)
diff --git a/gnu/packages/boost.scm b/gnu/packages/boost.scm
index 98dccf7f16..71999709ed 100644
--- a/gnu/packages/boost.scm
+++ b/gnu/packages/boost.scm
@@ -8,7 +8,7 @@
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2018, 2019, 2021 Ricardo Wurmus <rekado@elephly.net>
-;;; Copyright © 2018, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2018, 2020, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019, 2020 Giacomo Leidi <goodoldpaul@autistici.org>
@@ -44,6 +44,7 @@ (define-module (gnu packages boost)
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
#:use-module (gnu packages)
+ #:use-module (gnu packages autotools)
#:use-module (gnu packages compression)
#:use-module (gnu packages icu4c)
#:use-module (gnu packages llvm)
@@ -445,15 +446,18 @@ (define-public boost-mpi
(define-public mdds
(package
(name "mdds")
- (version "2.0.3")
+ (version "2.1.1")
(source (origin
- (method url-fetch)
- (uri (string-append "https://kohei.us/files/mdds/src/mdds-"
- version ".tar.xz"))
- (sha256
- (base32
- "1r68kxqppmhfg0dhz54d0hqzs5882cqrv1x6wpg7lak6gyyws0bc"))))
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://gitlab.com/mdds/mdds")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0866020brc1kmiryh7dmhjamnywlsd56ks649hy87283k0p7d3bb"))))
(build-system gnu-build-system)
+ (native-inputs (list autoconf automake))
(propagated-inputs
(list boost)) ; inclusion of header files
(home-page "https://gitlab.com/mdds/mdds")
--
2.41.0
M
M
Maxim Cournoyer wrote on 31 Oct 2023 21:25
[PATCH v2 3/4] gnu: ixion: Update to 0.19.0.
(address . 66475@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
0988de7c26094f29e1dc25d3ddc6493f2d56f19e.1698783917.git.maxim.cournoyer@gmail.com
* gnu/packages/libreoffice.scm (ixion): Update to 0.19.0.
[source]: Use git.
[native-inputs]: Add autoconf, automake and libtool.

Change-Id: I245457d7c99b6adfb895dc46276f8008ff13d0cd
---

(no changes since v1)

gnu/packages/libreoffice.scm | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

Toggle diff (47 lines)
diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index 71131ca1f3..e38095fb1e 100644
--- a/gnu/packages/libreoffice.scm
+++ b/gnu/packages/libreoffice.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2019 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2020 Marcin Karpezo <sirmacik@wioo.waw.pl>
;;; Copyright © 2023 Nicolas Graves <ngraves@ngraves.fr>
+;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -92,20 +93,19 @@ (define-module (gnu packages libreoffice)
(define-public ixion
(package
(name "ixion")
- (version "0.17.0")
- (source
- (origin
- (method url-fetch)
- (uri (string-append "http://kohei.us/files/ixion/src/libixion-"
- version ".tar.xz"))
- (sha256
- (base32
- "07hhqkvns4da8xv990gr1smqz1zf40m531lg95nphfrz48wp3jak"))))
+ (version "0.19.0")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://gitlab.com/ixion/ixion")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0nycbs3765wkaw9ff7aflm56ayxkn15dlfl5pbbb9b5i2rcv3dq6"))))
(build-system gnu-build-system)
- (native-inputs
- (list pkg-config))
- (inputs
- (list mdds python spdlog))
+ (native-inputs (list autoconf automake libtool pkg-config))
+ (inputs (list mdds python spdlog))
(home-page "https://gitlab.com/ixion/ixion")
(synopsis "General purpose formula parser and interpreter")
(description "Ixion is a library for calculating the results of formula
--
2.41.0
M
M
Maxim Cournoyer wrote on 31 Oct 2023 21:25
[PATCH v2 4/4] gnu: orcus: Update to 0.19.0.
(address . 66475@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
59a3d5e428c780a7d863cd5e53b64addc5122169.1698783917.git.maxim.cournoyer@gmail.com
* gnu/packages/libreoffice.scm (orcus): Update to 0.19.0.
[source]: Use git-fetch/lfs.
[arguments]: Use gexps.
[native-inputs]: Add autoconf, automake and libtool.

Change-Id: I76efbc57ca4acf8ffd5154a72e49b4aedd071a76
---

(no changes since v1)

gnu/packages/libreoffice.scm | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)

Toggle diff (44 lines)
diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index e38095fb1e..572077a0ee 100644
--- a/gnu/packages/libreoffice.scm
+++ b/gnu/packages/libreoffice.scm
@@ -117,22 +117,22 @@ (define-public ixion
(define-public orcus
(package
(name "orcus")
- (version "0.17.2")
- (source
- (origin
- (method url-fetch)
- (uri (string-append "http://kohei.us/files/orcus/src/lib"
- "orcus-" version ".tar.xz"))
- (sha256
- (base32
- "1as04qb74jnlnwy4wh5jwaw2nnzgn2s3230ymvh3kx1w9r0rsl1h"))))
+ (version "0.19.0")
+ (source (origin
+ ;; The test suite requires data files store with Git Large
+ ;; File Storage.
+ (method git-fetch/lfs)
+ (uri (git-reference
+ (url "https://gitlab.com/orcus/orcus")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "02prj6kgph56fkr89k8wlqarrmx65cq92863i4rrny5sqr8c2llr"))))
(build-system gnu-build-system)
- (arguments
- `(#:configure-flags '("--disable-static")))
- (native-inputs
- (list pkg-config))
- (inputs
- (list ixion mdds python zlib))
+ (arguments (list #:configure-flags #~(list "--disable-static")))
+ (native-inputs (list autoconf automake libtool pkg-config))
+ (inputs (list ixion mdds python zlib))
(home-page "https://gitlab.com/orcus/orcus")
(synopsis "File import filter library for spreadsheet documents")
(description "Orcus is a library that provides a collection of standalone
--
2.41.0
M
M
Maxim Cournoyer wrote on 31 Oct 2023 21:30
Re: [bug#66475 (was 66436)] [PATCH 2/2] git-download: Add support for Git Large File Storage (LFS).
874ji6pmb4.fsf_-_@gmail.com
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

Toggle quote (29 lines)
> Hi,
>
> Simon Tournier <zimon.toutoune@gmail.com> writes:
>
>> Hi,
>>
>> I reorder Ludo’s answers for clarity.
>>
>> On Sat, 14 Oct 2023 at 19:12, Ludovic Courtès <ludo@gnu.org> wrote:
>>
>>> Also, it is crucial for the “builtin:git-download” semantics to be the
>>> same across all installations and to be very stable.
>>
>> I agree and that’s one strong argument for me.
>>
>>> Overall, I feel like LFS support, if needed, should be “on the side”,
>>> with a custom ‘git-fetch/lfs’ or something along these lines (just like
>>> we have ‘url-fetch/tarbomb’).
>>
>> I agree with this direction. Most of the fetching methods should not be
>> implemented with “builtin“ but the converse, git-fetch/lfs.
>>
>> ( Even, I think the current git-fetch using out-of-band builtin
>> recently introduced should be a ’git-fetch/bootstrap’ method, and
>> git-fetch using in-band should be the default method. )
>
> Thanks for tipping in, I'll look into adding a whole new 'git-fetch/lfs'
> procedure.

Done, see v2. The 'orcus' package makes use of it -- its test suite is
broken without it.

--
Thanks,
Maxim
L
L
Ludovic Courtès wrote on 5 Nov 2023 15:49
Re: [bug#66475] [PATCH v2 1/4] git-download: Add support for Git Large File Storage (LFS).
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87jzqw1cio.fsf@gnu.org
Hi Maxim,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (21 lines)
> * guix/build/git.scm (git-fetch) [lfs?]: New argument, doc and setup code.
> (git-fetch-with-fallback) [lfs?]: New argument. Pass it to git-fetch.
> * guix/git-download.scm (git-lfs-package): New procedure.
> (git-fetch/in-band*): New procedure, made of the logic of git-fetch/in-band,
> with new git-lfs specifics, with the following changes:
> New #:git-lfs argument.
> <inputs>: Remove labels. Conditionally add git-lfs.
> <build>: Read "git lfs?" environment
> variable and pass its value to the #:lfs? argument of git-fetch-with-fallback.
> Use INPUTS directly; update comment.
> <gexp->derivation>: Add "git lfs?" to #:env-vars.
> (git-fetch/in-band): Express in terms of git-fetch/in-band*.
> (git-fetch/lfs): New procedure.
> * doc/guix.texi (origin Reference): Document it.
>
> Change-Id: I5b233b8642a7bdb8737b9d9b740e7254a89ccb25
> ---
>
> Changes in v2:
> - Do not add lfs? to <git-reference>; instead add a git-fetch/lfs procedure.

I haven’t tested it but it looks great to me, thank you!

Ludo’.
M
M
Maxim Cournoyer wrote on 7 Nov 2023 17:17
(name . Ludovic Courtès)(address . ludo@gnu.org)
87a5rpk05t.fsf@gmail.com
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (27 lines)
> Hi Maxim,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> * guix/build/git.scm (git-fetch) [lfs?]: New argument, doc and setup code.
>> (git-fetch-with-fallback) [lfs?]: New argument. Pass it to git-fetch.
>> * guix/git-download.scm (git-lfs-package): New procedure.
>> (git-fetch/in-band*): New procedure, made of the logic of git-fetch/in-band,
>> with new git-lfs specifics, with the following changes:
>> New #:git-lfs argument.
>> <inputs>: Remove labels. Conditionally add git-lfs.
>> <build>: Read "git lfs?" environment
>> variable and pass its value to the #:lfs? argument of git-fetch-with-fallback.
>> Use INPUTS directly; update comment.
>> <gexp->derivation>: Add "git lfs?" to #:env-vars.
>> (git-fetch/in-band): Express in terms of git-fetch/in-band*.
>> (git-fetch/lfs): New procedure.
>> * doc/guix.texi (origin Reference): Document it.
>>
>> Change-Id: I5b233b8642a7bdb8737b9d9b740e7254a89ccb25
>> ---
>>
>> Changes in v2:
>> - Do not add lfs? to <git-reference>; instead add a git-fetch/lfs procedure.
>
> I haven’t tested it but it looks great to me, thank you!

Thanks for taking the time to review it! I'll push it shortly.

--
Thanks,
Maxim
Closed
?