aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2016-06-10 17:28:08 +0000
committerGravatar Yue Gan <yueg@google.com>2016-06-13 08:10:24 +0000
commit1219345c4c2dff6c59dc7619d158ecfb08c434f6 (patch)
tree016b38577a72ea97304c2da639a0c0c6df51793a /src
parente7e2301079cd71d12bc97f8b908c2c6746579984 (diff)
Support absolute paths for zip files
This resolves them relative to the repository root directory (the same way .tar.gz paths do). -- MOS_MIGRATED_REVID=124573519
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressor.java4
-rwxr-xr-xsrc/test/shell/bazel/external_integration_test.sh16
2 files changed, 7 insertions, 13 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressor.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressor.java
index 80da40333a..be3553584b 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressor.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressor.java
@@ -133,8 +133,8 @@ public class ZipDecompressor implements Decompressor {
+ reader.getFilename() + " has a symlink to " + target);
}
if (target.isAbsolute()) {
- throw new IOException("Zip entries cannot be symlinks to absolute paths: "
- + reader.getFilename() + " has a symlink to " + target);
+ target = target.relativeTo(PathFragment.ROOT_DIR);
+ target = destinationDirectory.getRelative(target).asFragment();
}
outputPath.createSymbolicLink(target);
} else {
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh
index 223a0cb57d..8a620eda33 100755
--- a/src/test/shell/bazel/external_integration_test.sh
+++ b/src/test/shell/bazel/external_integration_test.sh
@@ -83,8 +83,6 @@ function http_archive_helper() {
zipper=$1
local write_workspace
[[ $# -gt 1 ]] && [[ "$2" = "nowrite" ]] && write_workspace=1 || write_workspace=0
- local do_symlink
- [[ $# -gt 1 ]] && [[ "$2" = "do_symlink" ]] && do_symlink=1 || do_symlink=0
if [[ $write_workspace -eq 0 ]]; then
# Create a zipped-up repository HTTP response.
@@ -107,9 +105,7 @@ echo $what_does_the_fox_say
EOF
chmod +x fox/male
ln -s male fox/male_relative
- if [[ $do_symlink = 1 ]]; then
- ln -s /fox/male fox/male_absolute
- fi
+ ln -s /fox/male fox/male_absolute
# Add some padding to the .zip to test that Bazel's download logic can
# handle breaking a response into chunks.
dd if=/dev/zero of=fox/padding bs=1024 count=10240 >& $TEST_log
@@ -151,9 +147,7 @@ fi
base_external_path=bazel-out/../external/endangered/fox
assert_files_same ${base_external_path}/male ${base_external_path}/male_relative
- if [[ $do_symlink = 1 ]]; then
- assert_files_same ${base_external_path}/male ${base_external_path}/male_absolute
- fi
+ assert_files_same ${base_external_path}/male ${base_external_path}/male_absolute
}
function assert_files_same() {
@@ -187,13 +181,13 @@ EOF
}
function test_http_archive_tgz() {
- http_archive_helper tar_gz_up "do_symlink"
+ http_archive_helper tar_gz_up
bazel shutdown
- http_archive_helper tar_gz_up "do_symlink"
+ http_archive_helper tar_gz_up
}
function test_http_archive_tar_xz() {
- http_archive_helper tar_xz_up "do_symlink"
+ http_archive_helper tar_xz_up
}
function test_http_archive_no_server() {