cuirass.in 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/sh
  2. # -*- scheme -*-
  3. # @configure_input@
  4. #GUILE_LOAD_PATH="@PACKAGE_LOAD_PATH@${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
  5. #GUILE_LOAD_COMPILED_PATH="@PACKAGE_LOAD_COMPILED_PATH@${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
  6. exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@"
  7. !#
  8. ;;;; cuirass -- continuous integration tool
  9. ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
  10. ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
  11. ;;;
  12. ;;; This file is part of Cuirass.
  13. ;;;
  14. ;;; Cuirass is free software: you can redistribute it and/or modify
  15. ;;; it under the terms of the GNU General Public License as published by
  16. ;;; the Free Software Foundation, either version 3 of the License, or
  17. ;;; (at your option) any later version.
  18. ;;;
  19. ;;; Cuirass is distributed in the hope that it will be useful,
  20. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. ;;; GNU General Public License for more details.
  23. ;;;
  24. ;;; You should have received a copy of the GNU General Public License
  25. ;;; along with Cuirass. If not, see <http://www.gnu.org/licenses/>.
  26. (use-modules (cuirass)
  27. (cuirass ui)
  28. (cuirass utils)
  29. (ice-9 getopt-long))
  30. (define (show-help)
  31. (format #t "Usage: ~a [OPTIONS]~%" (%program-name))
  32. (display "Run build jobs from internal database.
  33. --one-shot Evaluate and build jobs only once
  34. --cache-directory=DIR Use DIR for storing repository data
  35. -L --load-path=DIR Prepend DIR to Guix package module search path.
  36. -S --specifications=SPECFILE
  37. Add specifications from SPECFILE to database.
  38. -D --database=DB Use DB to store build results.
  39. -p --port=NUM Port of the HTTP server.
  40. -I, --interval=N Wait N seconds between each poll
  41. --use-substitutes Allow usage of pre-built substitutes
  42. -V, --version Display version
  43. -h, --help Display this help message")
  44. (newline)
  45. (show-package-information))
  46. (define %options
  47. '((one-shot (value #f))
  48. (cache-directory (value #t))
  49. (load-path (single-char #\L) (value #t))
  50. (specifications (single-char #\S) (value #t))
  51. (database (single-char #\D) (value #t))
  52. (port (single-char #\p) (value #t))
  53. (interval (single-char #\I) (value #t))
  54. (use-substitutes (value #f))
  55. (version (single-char #\V) (value #f))
  56. (help (single-char #\h) (value #f))))
  57. ;;;
  58. ;;; Entry point.
  59. ;;;
  60. (define* (main #:optional (args (command-line)))
  61. (let ((opts (getopt-long args %options)))
  62. (parameterize
  63. ((%program-name (car args))
  64. (%package-database (option-ref opts 'database (%package-database)))
  65. (%package-cachedir
  66. (option-ref opts 'cache-directory (%package-cachedir)))
  67. (%guix-package-path
  68. (option-ref opts 'load-path (%guix-package-path)))
  69. (%use-substitutes? (option-ref opts 'use-substitutes #f)))
  70. (cond
  71. ((option-ref opts 'help #f)
  72. (show-help)
  73. (exit 0))
  74. ((option-ref opts 'version #f)
  75. (show-version)
  76. (exit 0))
  77. (else
  78. (let ((one-shot? (option-ref opts 'one-shot #f))
  79. (port (string->number (option-ref opts 'port "8080")))
  80. (interval (string->number (option-ref opts 'interval "10")))
  81. (specfile (option-ref opts 'specifications #f)))
  82. (with-database db
  83. (and specfile
  84. (let ((new-specs (save-module-excursion
  85. (λ ()
  86. (set-current-module (make-user-module))
  87. (primitive-load specfile)))))
  88. (for-each (λ (spec) (db-add-specification db spec))
  89. new-specs)))
  90. (if one-shot?
  91. (process-specs db (db-get-specifications db))
  92. (begin
  93. (call-with-new-thread
  94. (λ ()
  95. (while #t
  96. (process-specs db (db-get-specifications db))
  97. (sleep interval))))
  98. (run-cuirass-server db #:port port))))))))))