bzr-download.scm 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (guix bzr-download)
  19. #:use-module (guix gexp)
  20. #:use-module (guix modules) ;for 'source-module-closure'
  21. #:use-module (guix monads)
  22. #:use-module (guix packages)
  23. #:use-module (guix records)
  24. #:use-module (guix store)
  25. #:export (bzr-reference
  26. bzr-reference?
  27. bzr-reference-url
  28. bzr-reference-revision
  29. bzr-fetch))
  30. ;;; Commentary:
  31. ;;;
  32. ;;; An <origin> method that fetches a specific revision from a Bazaar
  33. ;;; repository. The repository URL and revision identifier are specified with
  34. ;;; a <bzr-reference> object.
  35. ;;;
  36. ;;; Code:
  37. (define-record-type* <bzr-reference>
  38. bzr-reference make-bzr-reference
  39. bzr-reference?
  40. (url bzr-reference-url)
  41. (revision bzr-reference-revision))
  42. (define (bzr-package)
  43. "Return the default Bazaar package."
  44. (let ((distro (resolve-interface '(gnu packages version-control))))
  45. (module-ref distro 'breezy)))
  46. (define* (bzr-fetch ref hash-algo hash
  47. #:optional name
  48. #:key (system (%current-system)) (guile (default-guile))
  49. (bzr (bzr-package)))
  50. "Return a fixed-output derivation that fetches REF, a <bzr-reference>
  51. object. The output is expected to have recursive hash HASH of type
  52. HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
  53. (define build
  54. (with-imported-modules (source-module-closure
  55. '((guix build bzr)))
  56. #~(begin
  57. (use-modules (guix build bzr))
  58. (bzr-fetch
  59. (getenv "bzr url") (getenv "bzr reference") #$output
  60. #:bzr-command (string-append #+bzr "/bin/brz")))))
  61. (mlet %store-monad ((guile (package->derivation guile system)))
  62. (gexp->derivation (or name "bzr-branch") build
  63. ;; Use environment variables and a fixed script name so
  64. ;; there's only one script in store for all the
  65. ;; downloads.
  66. #:script-name "bzr-download"
  67. #:env-vars
  68. `(("bzr url" . ,(bzr-reference-url ref))
  69. ("bzr reference" . ,(bzr-reference-revision ref)))
  70. #:leaked-env-vars '("http_proxy" "https_proxy"
  71. "LC_ALL" "LC_MESSAGES" "LANG"
  72. "COLUMNS")
  73. #:system system
  74. #:local-build? #t ;don't offload repo branching
  75. #:hash-algo hash-algo
  76. #:hash hash
  77. #:recursive? #t
  78. #:guile-for-build guile)))
  79. ;;; bzr-download.scm ends here