Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ikem-krueger/b0c6229b30bbc2ca33742ab1d4561077 to your computer and use it in GitHub Desktop.
Save ikem-krueger/b0c6229b30bbc2ca33742ab1d4561077 to your computer and use it in GitHub Desktop.

Build LineageOS 16.0 for the Samsung Galaxy S5

This how to is based on the official build instructions.

Wherever I refer to "host" it means on the Linux PC native shell, "client" it means in the Qemu virtual machine.

Requirements

  • Debian/Ubuntu or similar Linux distro host system
  • Qemu installed on the host
  • 170GB disk space (maybe you could get away with less if you disable ccache)
  • >8G of RAM (replace -m 8192 below with a smaller number if you don't have this much)
  • Ability to use copy and paste :-D

Creating Qemu Ubuntu 18.04

  1. Create the virtual disk drive (starts off small in size, and grows as the build proceeds):
qemu-img create -f qcow2 ubuntu18.04.qcow2 170G
  1. Download Ubuntu:
wget http://releases.ubuntu.com/18.04/ubuntu-18.04.3-desktop-amd64.iso
  1. Install Ubuntu in the virtual machine (enter "s5build" as the username and choose a very simple password):
qemu-system-x86_64 -enable-kvm -m 8192 -cdrom ubuntu-18.04.3-desktop-amd64.iso -boot d ubuntu18.04.qcow2
  1. Run the newly-created Ubuntu 18.04 virtual machine (this command can be changed/optimised as you wish):
qemu-system-x86_64 -enable-kvm -m 8192 -vga std -daemonize -cpu host -smp cpus=2 -net  user,hostfwd=tcp::10022-:22 -net nic ubuntu18.04.qcow2
  1. Log in to the Ubuntu virtual machine. Run a "terminal" (Ctrl-Alt-T) and install an SSH server with:
sudo apt-get install dropbear
  1. Reboot Ubuntu using the Ubuntu GUI in Qemu.

  2. SSH into the virtual machine by running this on your host:

ssh s5build@localhost -p10022

Set Up and Build Android

Most of these commands will be run directly following the above ssh command. i.e. while logged into the virtual machine with a console.

  1. Download adb/fastboot:
wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip unzip platform-tools-latest-linux.zip -d ~
  1. Add adb and fastboot to the PATH. Open ~/.profile and add the following:
# add Android SDK platform tools to path
if [ -d "$HOME/platform-tools" ] ; then
  PATH="$HOME/platform-tools:$PATH"
fi
  1. Install programs necessary for the build:
apt-get install repo bc bison build-essential ccache curl flex g++-multilib  gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev  lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev  libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync  schedtool squashfs-tools xsltproc zip zlib1g-dev
  1. Set up the build folders:
mkdir -p ~/bin mkdir -p ~/android/lineage
  1. Set up git:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
  1. Get repo (don't use Ubuntu's one as it is out of date):
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo
  1. Source the profile for changes:
source ~/.profile
  1. Perform initial setup of the build for Galaxy S5:
cd ~/android/lineage
repo init -u https://github.com/LineageOS/android.git -b lineage-16.0 
repo sync 
source build/envsetup.sh 
breakfast klte
  1. Use "themuppets" - a Github project containing the proprietary blobs which cannot be built. Edit .repo/local_manifests/roomservice.xml and add this line in the nested section:
<project name="TheMuppets/proprietary_vendor_samsung" path="vendor/samsung" depth="1" />
  1. Sync again and build:
repo sync
export USE_CCACHE=1
ccache -M 50G
brunch klte
  1. Get the image off the Ubuntu virtual machine. On the host:
scp  -P 10022  s5build@localhost:/home/s5build/android/lineage/out/target/product/klte/lineage-16.0-<<DATE  OF BUILD - REFER TO THE OUTPUT TEXT OF THE BUILD  PROCESS>>-UNOFFICIAL-klte.zip.

BACK UP YOUR DATA WITH TWRP BEFORE DOING ANY FLASHING!!!

  1. For flashing the zip, the LineageOS official instructions are pretty good, but for me doing an upgrade of the same major version of LineageOS, I do adb sideload <<ZIP FILE>> and then restore the data partition using TWRP afterwards.

  2. For doing another, say a few days later that uses the very latest nightly source tree, simply do source build/envsetup.sh and repeat the steps from 10. down. :-)

Source

Original by u/klteman. Edit by ikem-krueger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment