unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 43bc46673b1bfbda6c23dfe152334a99ac02c05e 4219 bytes (raw)
name: guix/git-download.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix 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.
;;;
;;; GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guix git-download)
  #:use-module (guix gexp)
  #:use-module (guix store)
  #:use-module (guix monads)
  #:use-module (guix records)
  #:use-module (guix packages)
  #:autoload   (guix build-system gnu) (standard-packages)
  #:use-module (ice-9 match)
  #:export (git-reference
            git-reference?
            git-reference-url
            git-reference-commit
            git-reference-tag
            git-reference-recursive?

            git-fetch))

;;; Commentary:
;;;
;;; An <origin> method that fetches a specific commit from a Git repository.
;;; The repository URL and commit hash are specified with a <git-reference>
;;; object.
;;;
;;; Code:

(define-record-type* <git-reference>
  git-reference make-git-reference
  git-reference?
  (url        git-reference-url)
  (commit     git-reference-commit (default #f))
  (tag        git-reference-tag (default #f))
  (recursive? git-reference-recursive?   ; whether to recurse into sub-modules
              (default #f)))

(define (git-package)
  "Return the default Git package."
  (let ((distro (resolve-interface '(gnu packages version-control))))
    (module-ref distro 'git)))

(define* (git-fetch ref hash-algo hash
                    #:optional name
                    #:key (system (%current-system)) (guile (default-guile))
                    (git (git-package)))
  "Return a fixed-output derivation that fetches REF, a <git-reference>
object.  The output is expected to have recursive hash HASH of type
HASH-ALGO (a symbol).  Use NAME as the file name, or a generic name if #f."
  (define inputs
    ;; When doing 'git clone --recursive', we need sed, grep, etc. to be
    ;; available so that 'git submodule' works.
    (if (git-reference-recursive? ref)
        (standard-packages)
        '()))

  (define build
    #~(begin
        (use-modules (guix build git)
                     (guix build utils)
                     (ice-9 match))

        ;; The 'git submodule' commands expects Coreutils, sed,
        ;; grep, etc. to be in $PATH.
        (set-path-environment-variable "PATH" '("bin")
                                       (match '#+inputs
                                         (((names dirs) ...)
                                          dirs)))

        (git-fetch '#$(git-reference-url ref)
                   (or '#$(git-reference-commit ref)
                       '#$(git-reference-tag ref))
                   #$output
                   ;; FIXME: Pass #:tag when fixed daemons are widely
                   ;; deployed.
                   ;; #:tag '#$(git-reference-tag ref)
                   #:recursive? '#$(git-reference-recursive? ref)
                   #:git-command (string-append #+git "/bin/git"))))

  (mlet %store-monad ((guile (package->derivation guile system)))
    (gexp->derivation (or name "git-checkout") build
                      #:system system
                      ;; FIXME: See <https://bugs.gnu.org/18747>.
                      ;; Uncomment when fixed daemons are widely deployed.
                      ;;#:local-build? #t
                      #:hash-algo hash-algo
                      #:hash hash
                      #:recursive? #t
                      #:modules '((guix build git)
                                  (guix build utils))
                      #:guile-for-build guile
                      #:local-build? #t)))

;;; git-download.scm ends here

debug log:

solving 43bc466 ...
found 43bc466 in https://yhetil.org/guix-devel/1439893537.140975.4854@rusty/ ||
	https://yhetil.org/guix-devel/1439892848.733703.3774@rusty/ ||
	https://yhetil.org/guix-devel/1439893929.575691.5108@rusty/ ||
	https://yhetil.org/guix-devel/95cd06d0b1639449fffa2ded823e54d0f26afbb6.1440062095.git.wingo@pobox.com/
found 0f2218c in https://git.savannah.gnu.org/cgit/guix.git
preparing index
index prepared:
100644 0f2218c13e06dfb540140d23670a72071a9f1641	guix/git-download.scm

applying [1/1] https://yhetil.org/guix-devel/1439893537.140975.4854@rusty/
diff --git a/guix/git-download.scm b/guix/git-download.scm
index 0f2218c..43bc466 100644

Checking patch guix/git-download.scm...
Applied patch guix/git-download.scm cleanly.

skipping https://yhetil.org/guix-devel/1439892848.733703.3774@rusty/ for 43bc466
skipping https://yhetil.org/guix-devel/1439893929.575691.5108@rusty/ for 43bc466
skipping https://yhetil.org/guix-devel/95cd06d0b1639449fffa2ded823e54d0f26afbb6.1440062095.git.wingo@pobox.com/ for 43bc466
index at:
100644 43bc46673b1bfbda6c23dfe152334a99ac02c05e	guix/git-download.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).