diff options
Diffstat (limited to 'recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch')
-rw-r--r-- | recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch | 82 |
1 files changed, 21 insertions, 61 deletions
diff --git a/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch b/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch index 605756a..86aba40 100644 --- a/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch +++ b/recipes-devtools/bazel/files/0001-HttpDownloader-save-download-tarball-to-distdir.patch @@ -1,71 +1,31 @@ -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 +From 28acb4a213938bcb7e55ef3859699091c1f434c0 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia <hongxu.jia@eng.windriver.com> +Date: Thu, 1 Dec 2022 19:32:33 +0800 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> +Signed-off-by: Hongxu Jia <hongxu.jia@eng.windriver.com> --- - .../repository/downloader/HttpDownloader.java | 50 ++++++++++++++-------- - 1 file changed, 32 insertions(+), 18 deletions(-) + .../bazel/repository/downloader/DownloadManager.java | 12 ++++++++++++ + 1 file changed, 12 insertions(+) -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")); +diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java +index bf65090..ee30dde 100755 +--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java ++++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java +@@ -213,6 +213,7 @@ public class DownloadManager { } 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 (String name : candidateFileNames) { + boolean match = false; ++ name += "_"+cacheKey; + Path candidate = dir.getRelative(name); + try { + eventHandler.post( +@@ -280,6 +281,17 @@ public class DownloadManager { + repositoryCache.put(destination, KeyType.SHA256, canonicalId); } + for (Path dir : distdir) { @@ -73,7 +33,7 @@ index 18d10d2..cf71ac4 100755 + FileSystemUtils.createDirectoryAndParents(dir); + + if (dir.isDirectory()) { -+ Path dl_mirror = dir.getRelative(destination.getBaseName()+"_"+sha256); ++ Path dl_mirror = dir.getRelative(destination.getBaseName()+"_"+checksum.get().toString()); + if (!dl_mirror.exists()) + FileSystemUtils.copyFile(destination, dl_mirror); + } @@ -83,5 +43,5 @@ index 18d10d2..cf71ac4 100755 } -- -2.8.1 +2.27.0 |