;; disfluid, 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 . (use-modules (vkraus packages disfluid)) (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)) (invoke bash "-c" (format #f "~a show -s --format=%cI ~a > ~a/.tarball-release-date" 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 (package (inherit (disfluid-release ;; These are arbitrary, they will be overriden by what’s in checked-out-index #:version "SNAPSHOT" #:release-date "1970-01-01" #:manual-mdate "1970-01-01" #:commit-id "3e63c05b8e809a84490767841d84770f535f2f22" #:hash "0bf55ajdnjgsa7fp30id28z7ic9kcf2gvs6w1r4ba9yiya9h337q")) (source checked-out-index)) 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 "disfluid-" version ".tar.gz"))) (computed-file tar-name #~(let ((source #$(file-append (package (inherit dist-without-maintainer) (native-inputs (cons* `("indent" ,indent) `("texlive" ,(texlive-union (list texlive-tex-texinfo))) (package-native-inputs dist-without-maintainer)))) "/" tar-name)) (destination #$output)) (format (current-error-port) "Symlinking ~a -> ~a...\n" source destination) (symlink source destination))))))