blob: cc6a7a06b4215a535f3df2ba3a5a10672210b1db [file] [log] [blame]
Damien Martin-Guillerez80245bc2015-10-09 14:10:42 +00001licenses(["notice"]) # Apache 2.0
2
3filegroup(
4 name = "srcs",
5 srcs = glob(["**"]),
6 visibility = ["//tools:__pkg__"],
7)
8
9# Used by pkg_deb
10py_library(
11 name = "archive",
12 srcs = ["archive.py"],
13 visibility = [
14 "//tools/build_defs/docker:__subpackages__",
15 ],
16)
17
18filegroup(
19 name = "archive_testdata",
20 srcs = glob(["testdata/**"]),
21)
22
23py_test(
24 name = "archive_test",
25 srcs = [
26 "archive_test.py",
27 "testenv.py",
28 ],
29 data = [":archive_testdata"],
30 deps = [":archive"],
31)
32
33py_binary(
34 name = "build_tar",
35 srcs = ["build_tar.py"],
36 visibility = ["//visibility:public"],
37 deps = [
Lukacs Berkie517abe2015-10-13 12:22:56 +000038 "@bazel_tools//third_party/py/gflags",
Damien Martin-Guillerez80245bc2015-10-09 14:10:42 +000039 ":archive",
Damien Martin-Guillerez80245bc2015-10-09 14:10:42 +000040 ],
41)
42
43py_binary(
44 name = "make_deb",
45 srcs = ["make_deb.py"],
46 visibility = ["//visibility:public"],
47 deps = [
Lukacs Berkie517abe2015-10-13 12:22:56 +000048 "@bazel_tools//third_party/py/gflags",
Damien Martin-Guillerez80245bc2015-10-09 14:10:42 +000049 ":archive",
Damien Martin-Guillerez80245bc2015-10-09 14:10:42 +000050 ],
51)
52
53# tests
54load("/tools/build_defs/pkg/pkg", "pkg_deb", "pkg_tar")
55
56genrule(
57 name = "generate_files",
58 outs = [
59 "etc/nsswitch.conf",
60 "usr/titi",
61 ],
62 cmd = "for i in $(OUTS); do echo 1 >$$i; done",
63)
64
65[pkg_tar(
66 name = "test-tar-%s" % ext[1:],
67 extension = "tar%s" % ext,
68 files = [
69 ":etc/nsswitch.conf",
70 ":usr/titi",
71 ],
72 mode = "0644",
73 modes = {"usr/titi": "0755"},
74 package_dir = "/",
75 strip_prefix = ".",
76 symlinks = {"usr/bin/java": "/path/to/bin/java"},
77) for ext in [
78 "",
79 ".gz",
80 ".bz2",
81]]
82
Brian Silvermana2c60d02015-11-06 14:28:37 +000083pkg_tar(
84 name = "test-tar-strip_prefix-empty",
85 files = [
86 ":etc/nsswitch.conf",
87 ],
88 strip_prefix = "",
89)
90
91pkg_tar(
92 name = "test-tar-strip_prefix-none",
93 files = [
94 ":etc/nsswitch.conf",
95 ],
96)
97
98pkg_tar(
99 name = "test-tar-strip_prefix-etc",
100 files = [
101 ":etc/nsswitch.conf",
102 ],
103 strip_prefix = "etc",
104)
105
106pkg_tar(
107 name = "test-tar-strip_prefix-dot",
108 files = [
109 ":etc/nsswitch.conf",
110 ],
111 strip_prefix = ".",
112)
113
Damien Martin-Guillerez80245bc2015-10-09 14:10:42 +0000114pkg_deb(
115 name = "test-deb",
116 data = ":test-tar-gz.tar.gz",
117 depends = [
118 "dep1",
119 "dep2",
120 ],
121 description = "toto",
122 maintainer = "someone@somewhere.com",
123 package = "titi",
124 version = "test",
125)
126
127sh_test(
128 name = "build_test",
129 size = "medium",
130 srcs = [
131 "build_test.sh",
132 ],
133 data = [
134 "testenv.sh",
135 ":test-deb.deb",
136 ":test-tar-.tar",
137 ":test-tar-bz2.tar.bz2",
138 ":test-tar-gz.tar.gz",
Brian Silvermana2c60d02015-11-06 14:28:37 +0000139 ":test-tar-strip_prefix-dot.tar",
140 ":test-tar-strip_prefix-empty.tar",
141 ":test-tar-strip_prefix-etc.tar",
142 ":test-tar-strip_prefix-none.tar",
Damien Martin-Guillerez80245bc2015-10-09 14:10:42 +0000143 ],
144 deps = [
145 "//src/test/shell:bashunit",
146 ],
147)