diff options
author | 2015-11-06 14:28:37 +0000 | |
---|---|---|
committer | 2015-11-06 16:40:08 +0000 | |
commit | a2c60d0594545ec266b23cf0122d664397b69b77 (patch) | |
tree | 4139165984bff8a0679ab028c0790dcb2f463be0 /tools | |
parent | 619ad608ef1270461aade6608ae5f1371009e4b9 (diff) |
Fix bash completion script location in the Debian package
It was ending up installed as /bazel.
Also, the documented way of telling pkg_tar not to strip off the prefix
didn't work.
--
Change-Id: I593d17690526c614697369cab543aff1ba67de0a
Reviewed-on: https://bazel-review.googlesource.com/#/c/2222/
MOS_MIGRATED_REVID=107229260
Diffstat (limited to 'tools')
-rw-r--r-- | tools/build_defs/pkg/BUILD | 35 | ||||
-rw-r--r-- | tools/build_defs/pkg/README.md | 7 | ||||
-rwxr-xr-x | tools/build_defs/pkg/build_test.sh | 5 | ||||
-rw-r--r-- | tools/build_defs/pkg/pkg.bzl | 8 |
4 files changed, 48 insertions, 7 deletions
diff --git a/tools/build_defs/pkg/BUILD b/tools/build_defs/pkg/BUILD index 22aef61cc7..cc6a7a06b4 100644 --- a/tools/build_defs/pkg/BUILD +++ b/tools/build_defs/pkg/BUILD @@ -80,6 +80,37 @@ genrule( ".bz2", ]] +pkg_tar( + name = "test-tar-strip_prefix-empty", + files = [ + ":etc/nsswitch.conf", + ], + strip_prefix = "", +) + +pkg_tar( + name = "test-tar-strip_prefix-none", + files = [ + ":etc/nsswitch.conf", + ], +) + +pkg_tar( + name = "test-tar-strip_prefix-etc", + files = [ + ":etc/nsswitch.conf", + ], + strip_prefix = "etc", +) + +pkg_tar( + name = "test-tar-strip_prefix-dot", + files = [ + ":etc/nsswitch.conf", + ], + strip_prefix = ".", +) + pkg_deb( name = "test-deb", data = ":test-tar-gz.tar.gz", @@ -105,6 +136,10 @@ sh_test( ":test-tar-.tar", ":test-tar-bz2.tar.bz2", ":test-tar-gz.tar.gz", + ":test-tar-strip_prefix-dot.tar", + ":test-tar-strip_prefix-empty.tar", + ":test-tar-strip_prefix-etc.tar", + ":test-tar-strip_prefix-none.tar", ], deps = [ "//src/test/shell:bashunit", diff --git a/tools/build_defs/pkg/README.md b/tools/build_defs/pkg/README.md index eaa8f804e4..384043d912 100644 --- a/tools/build_defs/pkg/README.md +++ b/tools/build_defs/pkg/README.md @@ -135,10 +135,11 @@ Creates a tar file from a list of inputs. tarball but a prefix path determined by <code>strip_prefix</code> is removed from the directory structure. This path can be absolute from the workspace root if starting with a <code>/</code> or - relative to the rule's directory. A relative path may starts with "./" - (or be ".") but cannot use go up with "..". By default, the + relative to the rule's directory. A relative path may start with "./" + (or be ".") but cannot use ".." to go up level(s). By default, the <code>data_path</code> attribute is unused and all files are supposed to have no - prefix. + prefix. A <code>data_path</code> of "" (the empty string) means the + same as the default. </p> </td> </tr> diff --git a/tools/build_defs/pkg/build_test.sh b/tools/build_defs/pkg/build_test.sh index daa6125447..d0caa2c197 100755 --- a/tools/build_defs/pkg/build_test.sh +++ b/tools/build_defs/pkg/build_test.sh @@ -61,6 +61,11 @@ function test_tar() { check_eq "-rwxr-xr-x" "$(get_tar_permission test-tar-${i:1}.tar$i ./usr/titi)" check_eq "-rw-r--r--" "$(get_tar_permission test-tar-${i:1}.tar$i ./etc/nsswitch.conf)" done; + + check_eq "./nsswitch.conf" "$(get_tar_listing test-tar-strip_prefix-empty.tar)" + check_eq "./nsswitch.conf" "$(get_tar_listing test-tar-strip_prefix-none.tar)" + check_eq "./nsswitch.conf" "$(get_tar_listing test-tar-strip_prefix-empty.tar)" + check_eq "./etc/nsswitch.conf" "$(get_tar_listing test-tar-strip_prefix-dot.tar)" } function test_deb() { diff --git a/tools/build_defs/pkg/pkg.bzl b/tools/build_defs/pkg/pkg.bzl index d8a69644a0..399369cb1a 100644 --- a/tools/build_defs/pkg/pkg.bzl +++ b/tools/build_defs/pkg/pkg.bzl @@ -41,12 +41,12 @@ def _compute_data_path(out, data_path): # There is no way to handle .// correctly (no function that would make # that possible and Skylark is not turing complete) so just consider it # as an absolute path. - if data_path[0:2] == "./": + if len(data_path) >= 2 and data_path[0:2] == "./": data_path = data_path[2:] - if data_path[0] == "/": # Absolute path - return data_path[1:] - elif not data_path or data_path == ".": # Relative to current package + if not data_path or data_path == ".": # Relative to current package return _short_path_dirname(out) + elif data_path[0] == "/": # Absolute path + return data_path[1:] else: # Relative to a sub-directory return _short_path_dirname(out) + "/" + data_path else: |