Skip to content

Commit

Permalink
Fix bash completion script location in the Debian package
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bsilver8192 authored and fweikert committed Nov 6, 2015
1 parent 619ad60 commit a2c60d0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
1 change: 1 addition & 0 deletions scripts/packages/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pkg_tar(
name = "bazel-completion",
files = [":etc/bash_completion.d/bazel"],
mode = "0644",
strip_prefix = ".",
)

pkg_tar(
Expand Down
35 changes: 35 additions & 0 deletions tools/build_defs/pkg/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions tools/build_defs/pkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 5 additions & 0 deletions tools/build_defs/pkg/build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions tools/build_defs/pkg/pkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a2c60d0

Please sign in to comment.