Commit | Line | Data |
---|---|---|
3feb8464 DM |
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 | ||
20 | (define-module (guix build android-repo) | |
21 | #:use-module (guix build utils) | |
22 | #:use-module (srfi srfi-34) | |
23 | #:use-module (ice-9 format) | |
24 | #:export (android-repo-fetch)) | |
25 | ||
26 | ;;; Commentary: | |
27 | ;;; | |
28 | ;;; This is the build-side support code of (guix android-repo-download). | |
29 | ;;; It allows a multirepository managed by the git-repo tool to be cloned and | |
30 | ;;; checked out at a specific revision. | |
31 | ;;; | |
32 | ;;; Code: | |
33 | ||
34 | (define* (android-repo-fetch manifest-url manifest-revision directory | |
35 | #:key (git-repo-command "git-repo")) | |
36 | "Fetch packages according to the manifest at MANIFEST-URL with | |
37 | MANIFEST-REVISION. MANIFEST-REVISION must be either a revision | |
38 | or a branch. Return #t on success, #f otherwise." | |
39 | ||
40 | ;; Disable TLS certificate verification. The hash of the checkout is known | |
41 | ;; in advance anyway. | |
42 | (setenv "GIT_SSL_NO_VERIFY" "true") | |
43 | ||
44 | (mkdir-p directory) | |
45 | ||
46 | (guard (c ((invoke-error? c) | |
47 | (format (current-error-port) | |
48 | "android-repo-fetch: '~a~{ ~a~}' failed with exit code ~a~%" | |
49 | (invoke-error-program c) | |
50 | (invoke-error-arguments c) | |
51 | (or (invoke-error-exit-status c) ;XXX: not quite accurate | |
52 | (invoke-error-stop-signal c) | |
53 | (invoke-error-term-signal c))) | |
54 | (delete-file-recursively directory) | |
55 | #f)) | |
56 | (with-directory-excursion directory | |
57 | (invoke git-repo-command "init" "-u" manifest-url "-b" manifest-revision | |
58 | "--depth=1") | |
4ff0fed7 DM |
59 | (invoke git-repo-command "sync" "-c" "--fail-fast" "-v" "-j" |
60 | (number->string (parallel-job-count))) | |
3feb8464 DM |
61 | |
62 | ;; Delete vendor/**/.git, system/**/.git, toolchain/**/.git, | |
63 | ;; .repo/**/.git etc since they contain timestamps. | |
64 | (for-each delete-file-recursively | |
65 | (find-files "." "^\\.git$" #:directories? #t)) | |
66 | ||
67 | ;; Delete git state directories since they contain timestamps. | |
68 | (for-each delete-file-recursively | |
69 | (find-files ".repo" "^.*\\.git$" #:directories? #t)) | |
70 | ||
71 | ;; This file contains timestamps. | |
72 | (delete-file ".repo/.repo_fetchtimes.json") | |
73 | #t))) | |
74 | ||
75 | ;;; android-repo.scm ends here |