Skip to content

Ubuntu 22.04LTS へ Bazel をインストールする

Ubuntu 22.04LTS へ Bazel をインストールする手順をメモしておきます。

鍵の追加

gnupg を使い、/usr/local/share/keyrings 配下へ鍵を追加します。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
mkdir -p /usr/local/share/keyrings/
curl \
  -L https://bazel.build/bazel-release.pub.gpg \
  -o /tmp/bazel-release.pub.gpg
gpg \
  --no-default-keyring \
  --keyring /tmp/temp-keyring.gpg \
  --import /tmp/bazel-release.pub.gpg
gpg \
  --no-default-keyring \
  --keyring /tmp/temp-keyring.gpg \
  --export \
  --output /usr/local/share/keyrings/bazel-release.pub.gpg
rm -f /tmp/bazel-release.pub.gpg /tmp/temp-keyring.gpg

リポジトリの追加

リポジトリを追加します。

1
2
3
cat << 'EOF' > /etc/apt/sources.list.d/bazel.list
deb [arch=amd64 signed-by=/usr/local/share/keyrings/bazel-release.pub.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8
EOF

インストール

apt データベースを更新します。

1
apt update

現時点ではバージョン 5.1.1 がインストールされるようです。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# apt info bazel
Package: bazel
Version: 5.1.1
Built-Using: bazel
Priority: optional
Section: contrib/devel
Maintainer: The Bazel Authors <bazel-dev@googlegroups.com>
Installed-Size: unknown
Depends: g++, zlib1g-dev, unzip
Suggests: google-jdk | java8-sdk-headless | java8-jdk | java8-sdk |
 oracle-java8-installer, bash-completion
Homepage: https://bazel.build
Download-Size: 48.5 MB
APT-Sources: https://storage.googleapis.com/bazel-apt stable/jdk1.8 amd64 Packages
Description: Bazel is a tool that automates software builds and tests.
 Supported build tasks include running compilers and linkers to produce
 executable programs and libraries, and assembling deployable packages
 for Android, iOS and other target environments. Bazel is similar to
 other tools like Make, Ant, Gradle, Buck, Pants and Maven.

N: There are 30 additional records. Please use the '-a' switch to see them.

インストールします。

1
apt -y install bazel