summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-02-08 15:01:19 +0530
committerArun Isaac2022-02-08 15:01:19 +0530
commit2d52e570a86096366cd09700be21d29c1fc42655 (patch)
tree37397116459903a70a9b47846ba15a1ea5f82886
parent093fd09396b3f079101eaa219818c0a43344cd3a (diff)
downloadguix-forge-2d52e570a86096366cd09700be21d29c1fc42655.tar.gz
guix-forge-2d52e570a86096366cd09700be21d29c1fc42655.tar.lz
guix-forge-2d52e570a86096366cd09700be21d29c1fc42655.zip
forge: Provide build-side code to download git repositories.
* forge/build/git.scm: New file.
-rw-r--r--forge/build/git.scm50
1 files changed, 50 insertions, 0 deletions
diff --git a/forge/build/git.scm b/forge/build/git.scm
new file mode 100644
index 0000000..e699822
--- /dev/null
+++ b/forge/build/git.scm
@@ -0,0 +1,50 @@
+;;; guix-forge --- Guix software forge meta-service
+;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of guix-forge.
+;;;
+;;; guix-forge is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published
+;;; by the Free Software Foundation, either version 3 of the License,
+;;; or (at your option) any later version.
+;;;
+;;; guix-forge is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with guix-forge. If not, see
+;;; <https://www.gnu.org/licenses/>.
+
+(define-module (forge build git)
+ #:use-module ((guix build git) #:prefix guix-build:)
+ #:use-module (guix build utils)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:export (download-git-to-store
+ latest-git-checkout))
+
+;;;
+;;; Commentary:
+;;;
+;;; This module provides build-side code to download a git repository
+;;; to the store.
+;;;
+
+;;; 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."
+ (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))
+ (add-to-store store name #t "sha256" directory))))
+
+(define latest-git-checkout
+ (store-lift download-git-to-store))