hg.scm 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
  4. ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
  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 hg)
  22. #:use-module (guix build utils)
  23. #:use-module (srfi srfi-34)
  24. #:use-module (ice-9 format)
  25. #:export (hg-fetch))
  26. ;;; Commentary:
  27. ;;;
  28. ;;; This is the build-side support code of (guix hg-download). It allows a
  29. ;;; Mercurial repository to be cloned and checked out at a specific changeset
  30. ;;; identifier.
  31. ;;;
  32. ;;; Code:
  33. (define* (hg-fetch url changeset directory
  34. #:key (hg-command "hg"))
  35. "Fetch CHANGESET from URL into DIRECTORY. CHANGESET must be a valid
  36. Mercurial changeset identifier. Return #t on success, #f otherwise."
  37. (mkdir-p directory)
  38. (guard (c ((invoke-error? c)
  39. (report-invoke-error c)
  40. (delete-file-recursively directory)
  41. #f))
  42. (with-directory-excursion directory
  43. (invoke hg-command
  44. "clone" url
  45. "--rev" changeset
  46. ;; Disable TLS certificate verification. The hash of
  47. ;; the checkout is known in advance anyway.
  48. "--insecure"
  49. directory)
  50. ;; The contents of '.hg' vary as a function of the current
  51. ;; status of the Mercurial repo. Since we want a fixed
  52. ;; output, this directory needs to be taken out.
  53. ;; Since the '.hg' file is also in sub-modules, we have to
  54. ;; search for it in all sub-directories.
  55. (for-each delete-file-recursively
  56. (find-files directory "^\\.hg$" #:directories? #t))
  57. #t)))
  58. ;;; hg.scm ends here