diff options
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorValue.java | 4 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/bazel/repository/TarFunction.java | 36 |
2 files changed, 39 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorValue.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorValue.java index 02df7137ec..924a8791c4 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorValue.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorValue.java @@ -55,6 +55,8 @@ public class DecompressorValue implements SkyValue { String baseName = archivePath.getBaseName(); if (baseName.endsWith(".zip") || baseName.endsWith(".jar") || baseName.endsWith(".war")) { return ZipDecompressor.INSTANCE; + } else if (baseName.endsWith(".tar")) { + return TarFunction.INSTANCE; } else if (baseName.endsWith(".tar.gz") || baseName.endsWith(".tgz")) { return TarGzFunction.INSTANCE; } else if (baseName.endsWith(".tar.xz")) { @@ -64,7 +66,7 @@ public class DecompressorValue implements SkyValue { } else { throw new RepositoryFunctionException( new EvalException(null, String.format( - "Expected a file with a .zip, .jar, .war, .tar.gz, .tgz, .tar.xz, or .tar.bz2 " + "Expected a file with a .zip, .jar, .war, .tar, .tar.gz, .tgz, .tar.xz, or .tar.bz2 " + "suffix (got %s)", archivePath)), Transience.PERSISTENT); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/TarFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/TarFunction.java new file mode 100644 index 0000000000..e67f1ec1e1 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/TarFunction.java @@ -0,0 +1,36 @@ +// Copyright 2015 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.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 plain .tar file. */ +public class TarFunction extends CompressedTarFunction { + public static final Decompressor INSTANCE = new TarFunction(); + private static final int BUFFER_SIZE = 32 * 1024; + + private TarFunction() {} + + @Override + protected InputStream getDecompressorStream(DecompressorDescriptor descriptor) + throws IOException { + return new BufferedInputStream( + new FileInputStream(descriptor.archivePath().getPathFile()), BUFFER_SIZE); + } +} |