/ scripts / bootstrap.sh
bootstrap.sh
 1  #!/usr/bin/env bash
 2  set -euxo pipefail
 3  
 4  FLAG_FILE="/var/lib/bootstrap.done"
 5  
 6  # If bootstrap already executed once, exit cleanly
 7  if [[ -f "$FLAG_FILE" ]]; then
 8    echo "Bootstrap already completed — skipping."
 9    exit 0
10  fi
11  
12  # Install all the required packages
13  
14  sudo apt-get update && sudo apt-get upgrade -y
15  sudo apt-get install build-essential gcc-multilib g++-multilib bc bison flex schedtool zip unzip lz4 lzop \
16    squashfs-tools libssl-dev libelf-dev libdw-dev zlib1g-dev libxml2 libxml2-utils lib32z1-dev lib32readline-dev \
17    libsdl1.2-dev xsltproc imagemagick pngcrush protobuf-compiler python3-protobuf git git-lfs gnupg repo ccache curl \
18    rsync python3 python-is-python3 openjdk-17-jdk tree
19  
20  # Install latest platform tools from google
21  sudo wget -O /opt/platform-tools.zip https://dl.google.com/android/repository/platform-tools-latest-linux.zip
22  sudo unzip -d /opt/platform-tools /opt/platform-tools.zip
23  sudo chown -R root:root /opt/platform-tools
24  sudo rm /opt/platform-tools.zip
25  
26  # Add platform-tools to path
27  echo 'export PATH="/opt/platform-tools:$PATH"' | sudo tee /etc/profile.d/platform-tools.sh
28  
29  # This part is from the lineageos wiki. Thanks!
30  # Source: https://wiki.lineageos.org/devices/kenzo/build/#install-the-build-packages
31  wget https://archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2_amd64.deb &&
32    sudo dpkg -i libtinfo5_6.3-2_amd64.deb && rm -f libtinfo5_6.3-2_amd64.deb
33  wget https://archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libncurses5_6.3-2_amd64.deb &&
34    sudo dpkg -i libncurses5_6.3-2_amd64.deb && rm -f libncurses5_6.3-2_amd64.deb
35  
36  # Make dirs for building
37  mkdir -p $HOME/bin
38  mkdir -p $HOME/android/lineage
39  
40  # Install repo command from google
41  curl https://storage.googleapis.com/git-repo-downloads/repo >$HOME/bin/repo
42  chmod a+x $HOME/bin/repo
43  
44  # Configure git
45  git config --global user.email "builder@porff.pn"
46  git config --global user.name "builder"
47  git config --global trailer.changeid.key "Change-Id"
48  
49  # Install git lfs
50  git lfs install
51  
52  # Add ccache to bashrc
53  echo "export USE_CCACHE=1" >>$HOME/.bashrc
54  echo "export CCACHE_EXEC=/usr/bin/ccache" >>$HOME/.bashrc
55  
56  # Set ccache size to 50GB and enable compression
57  ccache -M 50G
58  ccache -o compression=true
59  
60  # Configure Jack the java toolchain for building lineageos
61  echo "export ANDROID_JACK_VM_ARGS='-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G'" >>$HOME/.bashrc
62  
63  sudo touch "$FLAG_FILE"