job: Add load-path field to <job-spec>.

pull/3/head
Mathieu Lirzin 2016-07-02 01:51:56 +02:00
parent b185505db0
commit 94f910355c
4 changed files with 36 additions and 24 deletions

View File

@ -72,15 +72,22 @@ DIR if required."
commit
(string-append "origin/" branch)))))))))
(define (set-load-path! cachedir spec)
"Set %LOAD-PATH to match what is specified in SPEC."
(let* ((name (job-spec-name spec))
(path (job-spec-load-path spec))
(dir (string-join (list cachedir name path) "/")))
(format #t "prepending ~s to the load path~%" dir)
(set! %load-path (cons dir %load-path))))
(define (evaluate store db cachedir spec)
"Evaluate and build package derivations. Return a list a jobs."
(save-module-excursion
(lambda ()
(set-current-module %user-module)
(let ((dir (string-append cachedir "/" (job-spec-name spec))))
(format #t "prepending ~s to the load path~%" dir)
(set! %load-path (cons dir %load-path)))
(primitive-load (job-spec-file spec))))
;; Handle both relative and absolute file names for SPEC-FILE.
(with-directory-excursion cachedir
(primitive-load (job-spec-file spec)))))
(let* ((proc (module-ref %user-module (job-spec-proc spec)))
(jobs (proc store (job-spec-arguments spec))))
(map (λ (job)
@ -140,16 +147,20 @@ DIR if required."
(for-each
(λ (spec)
(fetch-repository cachedir spec)
(let ((store ((guix-variable 'store 'open-connection))))
(dynamic-wind
(const #t)
(lambda ()
(let ((jobs (evaluate store db cachedir spec))
(set-build-options
(guix-variable 'store 'set-build-options)))
(set-build-options store #:use-substitutes? #f)
(build-packages store db jobs)))
(lambda ()
((guix-variable 'store 'close-connection) store)))))
(let ((old-path %load-path))
(and (job-spec-load-path spec)
(set-load-path! cachedir spec))
(let ((store ((guix-variable 'store 'open-connection))))
(dynamic-wind
(const #t)
(lambda ()
(let ((jobs (evaluate store db cachedir spec))
(set-build-options
(guix-variable 'store 'set-build-options)))
(set-build-options store #:use-substitutes? #f)
(build-packages store db jobs)))
(lambda ()
((guix-variable 'store 'close-connection) store)
(set! %load-path old-path))))))
specs)
(sleep (string->number interval))))))))))

View File

@ -22,6 +22,7 @@ abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd`"
GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/src${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_PATH="$abs_top_builddir/src:$abs_top_srcdir/src${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
PATH="$abs_top_builddir/bin:$PATH"
export PATH
@ -29,10 +30,4 @@ export PATH
CUIRASS_CACHEDIR="$abs_top_builddir/cache"
export CUIRASS_CACHEDIR
# Append Guix cloned repository to Guile load paths.
guixdir="$CUIRASS_CACHEDIR/guix"
GUILE_LOAD_COMPILED_PATH="$guixdir:$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_PATH="$guixdir:$GUILE_LOAD_PATH"
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
exec "$@"

View File

@ -32,6 +32,7 @@
job-spec?
job-spec-name
job-spec-url
job-spec-load-path
job-spec-branch
job-spec-commit
job-spec-tag
@ -58,10 +59,11 @@
metadata)))))
(define-record-type <job-spec>
(%make-job-spec name url branch commit file proc arguments)
(%make-job-spec name url load-path branch commit file proc arguments)
job-spec?
(name job-spec-name) ;string
(url job-spec-url) ;string
(load-path job-spec-load-path) ;string
(branch job-spec-branch) ;string
(commit job-spec-commit) ;string
(tag job-spec-tag) ;string
@ -69,6 +71,7 @@
(proc job-spec-proc) ;symbol
(arguments job-spec-arguments)) ;alist
(define* (make-job-spec #:key name url commit tag file proc arguments
(define* (make-job-spec #:key name url load-path
commit tag file proc arguments
(branch "master"))
(%make-job-spec name url branch tag file proc arguments))
(%make-job-spec name url load-path branch tag file proc arguments))

View File

@ -27,6 +27,7 @@
(list (make-job-spec
#:name "guix"
#:url "git://git.savannah.gnu.org/guix.git"
#:load-path "."
#:branch "master"
#:file (local-file "gnu-system.scm")
#:proc 'hydra-jobs
@ -34,6 +35,7 @@
(make-job-spec
#:name "guix"
#:url "git://git.savannah.gnu.org/guix.git"
#:load-path "."
#:branch "core-updates"
#:file (local-file "gnu-system.scm")
#:proc 'hydra-jobs
@ -41,6 +43,7 @@
(make-job-spec
#:name "guix"
#:url "git://git.savannah.gnu.org/guix.git"
#:load-path "."
#:tag "v0.9.0"
#:file (local-file "gnu-system.scm")
#:proc 'hydra-jobs