goals:

  • build lineageos android distribution
  • for device nexus_5x
  • on ubuntu server
  • using hetzner cloud (~0.30$ pro build)

pull a big cpx server on hetzner cloud (16vcpus|32gb-ram|360gb-ssd)

## using hcloud command
> hcloud server create \
  --name buildbox \
  --image ubuntu-20.04 \
  --location hel1 \
  --type cpx51 \
  --ssh-key 0123456 \
  --start-after-create
...
1m0.552s [===============================] 100.00%
Waiting for server 120XXXXX to have started
...done
Server 120XXXX created
IPv4: w.x.y.z

configure system

## upgrade system
> apt update ; apt upgrade -y

## install recommended software
> apt install tmux htop ranger

## install required software
> apt install python unzip bc bison build-essential \
  ccache curl flex g++-multilib gcc-multilib git gnupg \
  gperf imagemagick lib32ncurses5-dev lib32readline-dev \
  lib32z1-dev liblz4-tool libncurses5 libncurses5-dev \
  libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop \
  pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev

prepare build environment

## create directorys
> mkdir -p ~/bin
> mkdir -p ~/android/lineage

## get repo command
> curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
> chmod a+x ~/bin/repo

## configure git
> git config --global user.email "username@example.com"
> git config --global user.name "User Name"

## enable caching
> export USE_CCACHE=1
> export CCACHE_EXEC=/usr/bin/ccache

## edit ~/.bashrc
ccache -M 50G
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

## reload .profile
> source ~/.profile

get sources

> cd ~/android/lineage

> repo init --depth=1 -u https://github.com/LineageOS/android.git -b lineage-17.1

> git clone https://github.com/Toomoch/android_local_manifests_bullhead .repo/local_manifests -b lineage-17.1

> repo sync --no-tags --no-clone-bundle --force-sync -c -j8

try -j1 --fail-fast if the repo sync fails

build the system

> . build/envsetup.sh

> lunch lineage_bullhead-userdebug

> make -j16 bacon

#### build completed successfully (01:17:23 (hh:mm:ss)) ####

find image in: android/lineage/out/target/product/bullhead

delete server after the job is done

## delete server using hcloud
> hcloud server delete buildbox