summaryrefslogtreecommitdiff
path: root/ci.scm
blob: e8a1459633f6776f6c256317966a8fd6c0376e12 (plain)
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
;; webid-oidc, implementation of the Solid specification
;; Copyright (C) 2020, 2021  Vivien Kraus

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Affero General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.

;; This program 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 Affero General Public License for more details.

;; You should have received a copy of the GNU Affero General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

(use-modules (vkraus packages webid-oidc))
(use-modules (gnu packages bash))
(use-modules (gnu packages base))
(use-modules (gnu packages tex))
(use-modules (gnu packages code))
(use-modules (gnu packages version-control))
(use-modules (guix build-system gnu))
(use-modules (guix packages))
(use-modules (guix gexp))
(use-modules (guix modules))
(use-modules (guix build utils))
(use-modules (guix store))
(use-modules (ice-9 textual-ports))

(define ref
  (getenv "CI_REF"))

(let ((checked-out-index
       (let ((tmp-dirname (tmpnam))
             (git
              (run-with-store
               (open-connection)
               (package-file git "bin/git")))
             (bash
              (run-with-store
               (open-connection)
               (package-file bash "bin/bash")))
             (tar
              (run-with-store
               (open-connection)
               (package-file tar "bin/tar"))))
         (mkdir tmp-dirname)
         (if ref
             (begin
               (invoke git "archive" ref "-o" (string-append tmp-dirname "/source.tar.gz"))
               (with-directory-excursion
                tmp-dirname
                (invoke tar "xf" (string-append tmp-dirname "/source.tar.gz"))
                (delete-file (string-append tmp-dirname "/source.tar.gz"))))
             (invoke git
                     "checkout-index"
                     (format #f "--prefix=~a/" tmp-dirname)
                     "-a"))
         (invoke bash
                 "-c"
                 (format #f "~a describe ~a --tags --always > ~a/.tarball-version"
                         git (or ref "") tmp-dirname))
         (let ((interned
                (run-with-store
                 (open-connection)
                 (interned-file tmp-dirname "ci-checkout" #:recursive? #t))))
           (delete-file-recursively tmp-dirname)
           interned))))
  (let ((dist-without-maintainer (dist-package webid-oidc-snapshot checked-out-index))
        (version
         (car
          (string-split
           (call-with-input-file (string-append checked-out-index "/.tarball-version")
             get-string-all)
           #\newline))))
    (let ((tar-name (string-append "webid-oidc-" version ".tar.gz")))
      (computed-file
       tar-name
       #~(let ((source
                #$(file-append
                   (package
                    (inherit dist-without-maintainer)
                    (native-inputs
                     (cons* `("indent" ,indent)
                            `("texlive" ,texlive)
                            (package-native-inputs dist-without-maintainer))))
                   "/" tar-name))
               (destination #$output))
           (format (current-error-port) "Symlinking ~a -> ~a...\n" source destination)
           (symlink source destination))))))