android-repo.scm 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014, 2016, 2019 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (guix build android-repo)
  20. #:use-module (guix build utils)
  21. #:use-module (srfi srfi-34)
  22. #:use-module (ice-9 format)
  23. #:export (android-repo-fetch))
  24. ;;; Commentary:
  25. ;;;
  26. ;;; This is the build-side support code of (guix android-repo-download).
  27. ;;; It allows a multirepository managed by the git-repo tool to be cloned and
  28. ;;; checked out at a specific revision.
  29. ;;;
  30. ;;; Code:
  31. (define* (android-repo-fetch manifest-url manifest-revision directory
  32. #:key (git-repo-command "git-repo"))
  33. "Fetch packages according to the manifest at MANIFEST-URL with
  34. MANIFEST-REVISION. MANIFEST-REVISION must be either a revision
  35. or a branch. Return #t on success, #f otherwise."
  36. ;; Disable TLS certificate verification. The hash of the checkout is known
  37. ;; in advance anyway.
  38. (setenv "GIT_SSL_NO_VERIFY" "true")
  39. (mkdir-p directory)
  40. (guard (c ((invoke-error? c)
  41. (format (current-error-port)
  42. "android-repo-fetch: '~a~{ ~a~}' failed with exit code ~a~%"
  43. (invoke-error-program c)
  44. (invoke-error-arguments c)
  45. (or (invoke-error-exit-status c) ;XXX: not quite accurate
  46. (invoke-error-stop-signal c)
  47. (invoke-error-term-signal c)))
  48. (delete-file-recursively directory)
  49. #f))
  50. (with-directory-excursion directory
  51. (invoke git-repo-command "init" "-u" manifest-url "-b" manifest-revision
  52. "--depth=1")
  53. (invoke git-repo-command "sync" "-c" "--fail-fast" "-v" "-j"
  54. (number->string (parallel-job-count)))
  55. ;; Delete vendor/**/.git, system/**/.git, toolchain/**/.git,
  56. ;; .repo/**/.git etc since they contain timestamps.
  57. (for-each delete-file-recursively
  58. (find-files "." "^\\.git$" #:directories? #t))
  59. ;; Delete git state directories since they contain timestamps.
  60. (for-each delete-file-recursively
  61. (find-files ".repo" "^.*\\.git$" #:directories? #t))
  62. ;; This file contains timestamps.
  63. (delete-file ".repo/.repo_fetchtimes.json")
  64. #t)))
  65. ;;; android-repo.scm ends here