forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support decompressing zstd tar archives for repository rules.
This is mostly a rebase of bazelbuild#11968 with a few tweaks of my own. Fixes bazelbuild#10342. Co-authored-by: Grzegorz Lukasik <glukasik@nuro.ai> RELNOTES[new]: `repository_ctx.extract`, and thus `http_archive`, can now decompress zstandard-compressed archives. Closes bazelbuild#15026. PiperOrigin-RevId: 436146779
- Loading branch information
1 parent
a421288
commit 00d74ff
Showing
8 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/google/devtools/build/lib/bazel/repository/TarZstFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2022 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.bazel.repository; | ||
|
||
import com.github.luben.zstd.ZstdInputStreamNoFinalizer; | ||
import com.google.devtools.build.lib.bazel.repository.DecompressorValue.Decompressor; | ||
import java.io.BufferedInputStream; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
/** Creates a repository by unarchiving a zstandard-compressed .tar file. */ | ||
final class TarZstFunction extends CompressedTarFunction { | ||
static final Decompressor INSTANCE = new TarZstFunction(); | ||
private static final int BUFFER_SIZE = 32 * 1024; | ||
|
||
private TarZstFunction() {} | ||
|
||
@Override | ||
protected InputStream getDecompressorStream(DecompressorDescriptor descriptor) | ||
throws IOException { | ||
return new ZstdInputStreamNoFinalizer( | ||
new BufferedInputStream( | ||
new FileInputStream(descriptor.archivePath().getPathFile()), BUFFER_SIZE)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.