svn.scm 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in>
  4. ;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
  5. ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (guix build svn)
  22. #:use-module (guix build utils)
  23. #:use-module (srfi srfi-34)
  24. #:use-module (ice-9 format)
  25. #:export (svn-fetch))
  26. ;;; Commentary:
  27. ;;;
  28. ;;; This is the build-side support code of (guix svn-download). It allows a
  29. ;;; Subversion repository to be cloned and checked out at a specific revision.
  30. ;;;
  31. ;;; Code:
  32. (define* (svn-fetch url revision directory
  33. #:key (svn-command "svn")
  34. (recursive? #t)
  35. (user-name #f)
  36. (password #f))
  37. "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a
  38. valid Subversion revision. Return #t on success, #f otherwise."
  39. (guard (c ((invoke-error? c)
  40. (format (current-error-port)
  41. "svn-fetch: '~a~{ ~a~}' failed with exit code ~a~%"
  42. (invoke-error-program c)
  43. (invoke-error-arguments c)
  44. (or (invoke-error-exit-status c)
  45. (invoke-error-stop-signal c)
  46. (invoke-error-term-signal c)))
  47. #f))
  48. (apply invoke svn-command
  49. "export" "--non-interactive"
  50. ;; Trust the server certificate. This is OK as we
  51. ;; verify the checksum later. This can be removed when
  52. ;; ca-certificates package is added.
  53. "--trust-server-cert" "-r" (number->string revision)
  54. `(,@(if (and user-name password)
  55. (list (string-append "--username=" user-name)
  56. (string-append "--password=" password))
  57. '())
  58. ,@(if recursive?
  59. '()
  60. (list "--ignore-externals"))
  61. ,url ,directory))
  62. #t))
  63. ;;; svn.scm ends here