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.
- 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
- 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
- Download Ubuntu:
wget http://releases.ubuntu.com/18.04/ubuntu-18.04.3-desktop-amd64.iso
- 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
- 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
- Log in to the Ubuntu virtual machine. Run a "terminal" (Ctrl-Alt-T) and install an SSH server with:
sudo apt-get install dropbear
-
Reboot Ubuntu using the Ubuntu GUI in Qemu.
-
SSH into the virtual machine by running this on your host:
ssh s5build@localhost -p10022
Most of these commands will be run directly following the above ssh command. i.e. while logged into the virtual machine with a console.
- Download adb/fastboot:
wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip unzip platform-tools-latest-linux.zip -d ~
- 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
- 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
- Set up the build folders:
mkdir -p ~/bin mkdir -p ~/android/lineage
- Set up git:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
- 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
- Source the profile for changes:
source ~/.profile
- 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
- 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" />
- Sync again and build:
repo sync
export USE_CCACHE=1
ccache -M 50G
brunch klte
- 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!!!
-
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. -
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. :-)
Original by u/klteman. Edit by ikem-krueger.