aboutsummaryrefslogtreecommitdiff
path: root/forge
diff options
context:
space:
mode:
authorArun Isaac2022-02-09 23:53:31 +0530
committerArun Isaac2022-02-09 23:58:33 +0530
commit8bc27ffef8f6636aeb2ef9f58b2fe205d812ce7a (patch)
treed047fa26bffa50f2882f2ccb70582cbf7c435c3f /forge
parent9075f01fa32c9ecae021393b870a23413000f9c4 (diff)
downloadguix-forge-8bc27ffef8f6636aeb2ef9f58b2fe205d812ce7a.tar.gz
guix-forge-8bc27ffef8f6636aeb2ef9f58b2fe205d812ce7a.tar.lz
guix-forge-8bc27ffef8f6636aeb2ef9f58b2fe205d812ce7a.zip
forge: Implement our own git downloader.
Implement our own git downloader independent of that provided by Guix. This is required for better control of the output, and to later print the current git commit. * forge/build/git.scm: Do not import (guix build git). Import (rnrs exceptions). (download-git-to-store): Do not accept #:git-command argument. Expect git and nss-certs to be in the environment. Do not call git-fetch from (guix build git). * forge/forge.scm: Import nss-certs from (gnu packages certs). (gexp-producer->job-script): Run in environment with the git-minimal and nss-certs packages. Do not pass #:git-command to latest-git-checkout.
Diffstat (limited to 'forge')
-rw-r--r--forge/build/git.scm23
-rw-r--r--forge/forge.scm57
2 files changed, 43 insertions, 37 deletions
diff --git a/forge/build/git.scm b/forge/build/git.scm
index e699822..2e3dc41 100644
--- a/forge/build/git.scm
+++ b/forge/build/git.scm
@@ -18,7 +18,7 @@
;;; <https://www.gnu.org/licenses/>.
(define-module (forge build git)
- #:use-module ((guix build git) #:prefix guix-build:)
+ #:use-module (rnrs exceptions)
#:use-module (guix build utils)
#:use-module (guix store)
#:use-module (guix utils)
@@ -34,16 +34,21 @@
;;; Code:
-(define* (download-git-to-store store name url commit #:key (git-command "git"))
- "Download COMMIT from git repository from URL to STORE under NAME
-and return store path."
+(define (download-git-to-store store name url branch)
+ "Download BRANCH of git repository from URL to STORE under NAME and
+return store path. git and certificates should be in the environment."
(call-with-temporary-directory
(lambda (directory)
- (unless (with-output-to-port (current-error-port)
- (lambda ()
- (guix-build:git-fetch url commit directory
- #:git-command git-command)))
- (error "Error fetching git repository" url commit))
+ (with-directory-excursion directory
+ (guard (condition ((invoke-error? condition)
+ (format (current-error-port)
+ "git-fetch: '~a~{ ~a~}' failed with exit code ~a~%"
+ (invoke-error-program condition)
+ (invoke-error-arguments condition)
+ (invoke-error-exit-status condition))
+ (exit #f)))
+ (invoke "git" "clone" "--quiet" "--depth" "1" "--branch" branch url "."))
+ (delete-file-recursively ".git"))
(add-to-store store name #t "sha256" directory))))
(define latest-git-checkout
diff --git a/forge/forge.scm b/forge/forge.scm
index 11a1e92..d3bb879 100644
--- a/forge/forge.scm
+++ b/forge/forge.scm
@@ -22,6 +22,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
+ #:use-module ((gnu packages certs) #:select (nss-certs))
#:use-module (gnu packages ci)
#:use-module ((gnu packages gnupg) #:select (guile-gcrypt))
#:use-module ((gnu packages guile) #:select (guile-3.0 guile-zlib))
@@ -198,35 +199,35 @@ derivation to run."
(guix profiles))
#:select? import-module?)
(with-extensions (list guile-gcrypt guile-zlib)
- #~(begin
- (use-modules (forge build git)
- (guix derivations)
- (guix gexp)
- (guix monads)
- (guix store)
- (rnrs exceptions))
+ (with-packages (list git-minimal nss-certs)
+ #~(begin
+ (use-modules (forge build git)
+ (guix derivations)
+ (guix gexp)
+ (guix monads)
+ (guix store)
+ (rnrs exceptions))
- (parameterize ((%daemon-socket-uri #$guix-daemon-uri))
- (with-store store
- (guard (condition ((store-protocol-error? condition)
- (exit #f)))
- (format (current-error-port)
- "Built ~a successfully~%"
- (run-with-store store
- (mlet* %store-monad ((git-checkout (latest-git-checkout #$git-checkout-name
- #$git-repository
- #$git-branch
- #:git-command #$(file-append git-minimal "/bin/git")))
- (tests-drv (gexp->derivation #$derivation-name
- (#$gexp-producer git-checkout)
- #:guile-for-build (read-derivation-from-file
- #$(raw-derivation-file
- (with-store store
- (package-derivation store guile-3.0))))
- #:substitutable? #f)))
- (mbegin %store-monad
- (built-derivations (list tests-drv))
- (return (derivation->output-path tests-drv)))))))))))))
+ (parameterize ((%daemon-socket-uri #$guix-daemon-uri))
+ (with-store store
+ (guard (condition ((store-protocol-error? condition)
+ (exit #f)))
+ (format (current-error-port)
+ "Built ~a successfully~%"
+ (run-with-store store
+ (mlet* %store-monad ((git-checkout (latest-git-checkout #$git-checkout-name
+ #$git-repository
+ #$git-branch))
+ (tests-drv (gexp->derivation #$derivation-name
+ (#$gexp-producer git-checkout)
+ #:guile-for-build (read-derivation-from-file
+ #$(raw-derivation-file
+ (with-store store
+ (package-derivation store guile-3.0))))
+ #:substitutable? #f)))
+ (mbegin %store-monad
+ (built-derivations (list tests-drv))
+ (return (derivation->output-path tests-drv))))))))))))))
(define forge-service-type
(service-type