1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
From e31a37bc9cb53de5085e885b190652f994209cf6 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Tue, 23 Apr 2019 05:21:40 -0400
Subject: [PATCH] HttpDownloader: save download tarball to distdir
It is helpful for collecting tarball url which supports offline build.
Upstream-Status: Inappropriate [oe specific]
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
.../repository/downloader/HttpDownloader.java | 50 ++++++++++++++--------
1 file changed, 32 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java
index 18d10d2..cf71ac4 100755
--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java
@@ -204,26 +204,29 @@ public class HttpDownloader {
eventHandler.handle(Event.warn("distdir " + dir + " is not a directory"));
} else {
boolean match = false;
- Path candidate = dir.getRelative(destination.getBaseName());
- try {
- match = RepositoryCache.getChecksum(KeyType.SHA256, candidate).equals(sha256);
- } catch (IOException e) {
- // Not finding anything in a distdir is a normal case, so handle it absolutely
- // quietly. In fact, it is not uncommon to specify a whole list of dist dirs,
- // with the asumption that only one will contain an entry.
- }
- if (match) {
- if (isCachingByProvidedSha256) {
- try {
- repositoryCache.put(sha256, candidate, KeyType.SHA256);
- } catch (IOException e) {
- eventHandler.handle(
- Event.warn("Failed to copy " + candidate + " to repository cache: " + e));
+ String[] basenames = {destination.getBaseName(), destination.getBaseName()+"_"+sha256};
+ for (String basename: basenames) {
+ Path candidate = dir.getRelative(basename);
+ try {
+ match = RepositoryCache.getChecksum(KeyType.SHA256, candidate).equals(sha256);
+ } catch (IOException e) {
+ // Not finding anything in a distdir is a normal case, so handle it absolutely
+ // quietly. In fact, it is not uncommon to specify a whole list of dist dirs,
+ // with the asumption that only one will contain an entry.
+ }
+ if (match) {
+ if (isCachingByProvidedSha256) {
+ try {
+ repositoryCache.put(sha256, candidate, KeyType.SHA256);
+ } catch (IOException e) {
+ eventHandler.handle(
+ Event.warn("Failed to copy " + candidate + " to repository cache: " + e));
+ }
}
+ FileSystemUtils.createDirectoryAndParents(destination.getParentDirectory());
+ FileSystemUtils.copyFile(candidate, destination);
+ return destination;
}
- FileSystemUtils.createDirectoryAndParents(destination.getParentDirectory());
- FileSystemUtils.copyFile(candidate, destination);
- return destination;
}
}
}
@@ -264,6 +267,17 @@ public class HttpDownloader {
eventHandler.handle(Event.info("SHA256 (" + urls.get(0) + ") = " + newSha256));
}
+ for (Path dir : distdir) {
+ if (!dir.exists())
+ FileSystemUtils.createDirectoryAndParents(dir);
+
+ if (dir.isDirectory()) {
+ Path dl_mirror = dir.getRelative(destination.getBaseName()+"_"+sha256);
+ if (!dl_mirror.exists())
+ FileSystemUtils.copyFile(destination, dl_mirror);
+ }
+ }
+
return destination;
}
--
2.8.1
|