xref: /aosp_15_r20/external/executorch/.ci/docker/common/install_buck.sh (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1#!/bin/bash
2# Copyright (c) Meta Platforms, Inc. and affiliates.
3# All rights reserved.
4#
5# This source code is licensed under the BSD-style license found in the
6# LICENSE file in the root directory of this source tree.
7
8set -ex
9
10install_ubuntu() {
11  apt-get update
12  apt-get install -y zstd
13
14  BUCK2=buck2-x86_64-unknown-linux-gnu.zst
15  wget -q "https://github.com/facebook/buck2/releases/download/${BUCK2_VERSION}/${BUCK2}"
16  zstd -d "${BUCK2}" -o buck2
17
18  chmod +x buck2
19  mv buck2 /usr/bin/
20
21  rm "${BUCK2}"
22  # Cleanup package manager
23  apt-get autoclean && apt-get clean
24  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
25}
26
27# Install base packages depending on the base OS
28ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
29case "$ID" in
30  ubuntu)
31    install_ubuntu
32    ;;
33  *)
34    echo "Unable to determine OS..."
35    exit 1
36    ;;
37esac
38