aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/packages/debian/BUILD
blob: 157b469b53891b7138b6757cc3f2d60e14bbcc42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
filegroup(
    name = "srcs",
    srcs = glob(["**"]),
    visibility = ["//scripts:__subpackages__"],
)

load("//tools/build_defs/pkg:pkg.bzl", "pkg_tar", "pkg_deb")

pkg_tar(
    name = "bazel-bin",
    srcs = [
        "//scripts/packages:without-jdk/bazel",
        "//scripts/packages:without-jdk/bazel-real",
    ],
    mode = "0755",
    package_dir = "/usr/bin",
    strip_prefix = "/scripts/packages/without-jdk",
)

pkg_tar(
    name = "bazel-rc",
    srcs = ["//scripts/packages:bazel.bazelrc"],
    mode = "0644",
    package_dir = "/etc",
    strip_prefix = "/scripts/packages",
)

genrule(
    name = "rename-bazel-completion",
    srcs = ["//scripts:bash_completion"],
    outs = ["etc/bash_completion.d/bazel"],
    cmd = "cp $< $@",
)

pkg_tar(
    name = "bazel-completion",
    srcs = [":etc/bash_completion.d/bazel"],
    mode = "0644",
    strip_prefix = ".",
)

pkg_tar(
    name = "debian-data",
    extension = "tar.gz",
    deps = [
        ":bazel-bin",
        ":bazel-completion",
        ":bazel-rc",
    ],
)

genrule(
    name = "debian_version",
    srcs = ["//scripts/packages:version.txt"],
    outs = [
        "version.txt",
    ],
    cmd =
        "cat $(location //scripts/packages:version.txt) " +
        # Debian package manager does not order our rcs correctly, insert a tilde
        # Non RC version number are not matched by the regex, example translations:
        # 0.1.2         0.1.2
        # 0.1.2rc2      0.1.2~rc2
        # 0.1.2rc2-jdk7 0.1.2~rc2-jdk7
        " | sed -E 's/^([0-9\\.]+)([^0-9\\.].*)$$/\\1~\\2/'" +
        " > $@\n",
)

pkg_deb(
    name = "bazel-debian",
    architecture = "amd64",
    built_using = "bazel (HEAD)",
    data = ":debian-data",
    depends = [
        "google-jdk | java8-jdk | java8-sdk | oracle-java8-installer",
        "g++",
        "zlib1g-dev",
        "bash-completion",
    ],
    description_file = "description",
    homepage = "http://bazel.build",
    maintainer = "The Bazel Authors <bazel-dev@googlegroups.com>",
    package = "bazel",
    version_file = ":version.txt",
    visibility = ["//scripts/packages:__pkg__"],
)

filegroup(
    name = "debian-files",
    srcs = [
        "compat",
        "control",
        "copyright",
        "rules",
    ],
)

genrule(
    name = "generate-changelog-file",
    srcs = [
        "generate_changelog.py",
        "//:bazel-srcs",  # Force a rebuild on source change
    ],
    outs = ["changelog"],
    cmd = "python2.7 $(location generate_changelog.py) bazel-out/volatile-status.txt $(location changelog)",
    stamp = 1,
)

genrule(
    name = "bazel-debian-src",
    srcs = [
        "//:bazel-srcs",
        ":debian-files",
        ":changelog",
    ],
    outs = [
        "bazel.dsc",
        "bazel.tar.gz",
    ],
    cmd = """
        mkdir -p bazel/debian
        tar -xf $(location //:bazel-srcs) -C ./bazel
        for f in $(locations :debian-files); do
          cp $$f ./bazel/debian/
        done
        cp $(location :changelog) ./bazel/debian
        dpkg-source -b ./bazel
        cp ./bazel_*.dsc $(location bazel.dsc)
        cp ./bazel_*.tar.gz $(location bazel.tar.gz)
        """,
    visibility = ["//scripts/packages:__pkg__"],
)