unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob ee2b15d6c15cbbbcc127cb31a2e805439f215b76 4263 bytes (raw)
name: guix/build/chicken-build-system.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
 
(define-module (guix build chicken-build-system)
  #:use-module ((guix build gnu-build-system) #:prefix gnu:)
  #:use-module (guix build union)
  #:use-module (guix build utils)
  #:use-module (ice-9 match)
  #:use-module (ice-9 ftw)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (rnrs io ports)
  #:use-module (rnrs bytevectors)
  #:export (%standard-phases
            chicken-build))

;; CHICKEN_EGG_CACHE is where sources are fetched and binaries are built
;; CHICKEN_INSTALL_REPOSITORY is where dependencies are looked up
;; its first component is also where new eggs are installed.

;; TODO: deduplicate with go-build-system.scm ?
;; TODO: the binary version should be defined in one of the relevant modules
;; instead of being hardcoded everywhere. Tried to do that but got undefined
;; variable errors.

(define (chicken-package? name)
  (string-prefix? "chicken-" name))

(define* (setup-chicken-environment #:key inputs outputs #:allow-other-keys)
  (setenv "CHICKEN_INSTALL_REPOSITORY"
          (string-concatenate
           ;; see TODO item about binary version above
           (append (list (assoc-ref outputs "out") "/var/lib/chicken/11/")
                   (let ((oldenv (getenv "CHICKEN_INSTALL_REPOSITORY")))
                     (if oldenv
                         (list  ":" oldenv)
                         '())))))
  (setenv "CHICKEN_EGG_CACHE" (getcwd))
  #t)

;; This is copied from go-build-system.scm so it could probably be simplified.
;; I used it because the source of the egg needs to be unpacked into a directory
;; that is named after the egg and I knew that the go build system does that.
(define* (unpack #:key source egg-name unpack-path #:allow-other-keys)
  "Relative to $CHICKEN_EGG_CACHE, unpack SOURCE in UNPACK-PATH, or EGG-NAME
when UNPACK-PATH is unset.  If the SOURCE archive has a single top level
directory, it is stripped so that the sources appear directly under UNPACK-PATH.
When SOURCE is a directory, copy its content into UNPACK-PATH instead of
unpacking."
  (define (unpack-maybe-strip source dest)
    (let* ((scratch-dir (string-append (or (getenv "TMPDIR") "/tmp")
                                       "/scratch-dir"))
           (out (mkdir-p scratch-dir)))
      (with-directory-excursion scratch-dir
        (if (string-suffix? ".zip" source)
            (invoke "unzip" source)
            (invoke "tar" "-xvf" source))
        (let ((top-level-files (remove (lambda (x)
                                         (member x '("." "..")))
                                       (scandir "."))))
          (match top-level-files
            ((top-level-file)
             (when (file-is-directory? top-level-file)
               (copy-recursively top-level-file dest #:keep-mtime? #t)))
            (_
             (copy-recursively "." dest #:keep-mtime? #t)))))
      (delete-file-recursively scratch-dir)))

  (when (string-null? egg-name)
    (display "WARNING: The egg name is unset.\n"))
  (when (string-null? unpack-path)
    (set! unpack-path egg-name))
  (let ((dest (string-append (getenv "CHICKEN_EGG_CACHE") "/" unpack-path)))
    (mkdir-p dest)
    (if (file-is-directory? source)
        (copy-recursively source dest #:keep-mtime? #t)
        (unpack-maybe-strip source dest)))
  #t)

(define* (build #:key egg-name #:allow-other-keys)
  "Build the Chicken egg named by EGG-NAME"
  (invoke "chicken-install" "-cached" "-no-install" egg-name))

(define* (install #:key egg-name outputs #:allow-other-keys)
  "Install the already built egg named by EGG-NAME"
  (invoke "chicken-install" "-cached" egg-name))

;; TODO how do we run tests???

;; TODO remove references

(define %standard-phases
  (modify-phases gnu:%standard-phases
    (replace 'unpack unpack)
    (delete 'bootstrap)
    (delete 'configure)
    (delete 'patch-generated-file-shebangs)
    (add-before 'unpack 'setup-chicken-environment setup-chicken-environment)
    (replace 'build build)
    (delete 'check)
    (replace 'install install)))

(define* (chicken-build #:key inputs (phases %standard-phases)
                       #:allow-other-keys #:rest args)
  "Build the given Chicken package, applying all of PHASES in order."
  (apply gnu:gnu-build #:inputs inputs #:phases phases args))

debug log:

solving ee2b15d6c1 ...
found ee2b15d6c1 in https://yhetil.org/guix-patches/20201013105220.7606ee5a@riseup.net/

applying [1/1] https://yhetil.org/guix-patches/20201013105220.7606ee5a@riseup.net/
diff --git a/guix/build/chicken-build-system.scm b/guix/build/chicken-build-system.scm
new file mode 100644
index 0000000000..ee2b15d6c1

Checking patch guix/build/chicken-build-system.scm...
Applied patch guix/build/chicken-build-system.scm cleanly.

index at:
100644 ee2b15d6c15cbbbcc127cb31a2e805439f215b76	guix/build/chicken-build-system.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).