This guide is focused on building the ROM under a Linux host environment.
In general follow one of the many build instructions found at the LineageOS wiki. For example the instructions for the Google Nexus 5 aka hammerhead. Here is a short summing up.
To successfully build LineageOS, you’ll need
sudo apt-get install 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
For Ubuntu versions older than 16.04 (xenial), you’ll need
sudo apt-get install libwxgtk2.8-dev
For Ubuntu versions older than 20.04 (focal), you’ll also need
sudo apt-get install libwxgtk3.0-dev
Only if you haven’t previously installed adb and fastboot
wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
unzip platform-tools-latest-linux.zip -d ~
Update your PATH variable for your environment
gedit ~/.profile
Add the following
# add Android SDK platform tools to path
if [ -d "$HOME/platform-tools" ] ; then
PATH="$HOME/platform-tools:$PATH"
fi
Then update your environment
source ~/.profile
Download the binary and make it executable
mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Update your PATH variable for your environment
gedit ~/.profile
Add the following
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Then update your environment
source ~/.profile
If you want to include GAPPS in the build you need git-lfs otherwise the apk's can't be downloaded.
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
repo requires you to identify yourself to sync Android
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
Update your build environment
gedit ~/.bashrc
Add the following
export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
export CCACHE_COMPRESS=1
Create the project folder and download the source code
mkdir -p ~/android/lineage
cd ~/android/lineage
repo init -u https://github.com/LineageOS/android.git -b lineage-17.1
Now let's add this very device repo to the local_manifest
gedit cd ~/android/lineage/.repo/local_manifests/roomservice.xml
Add the following
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remove-project name="LineageOS/android_packages_apps_FMRadio"/>
<project name="Meetoul/android_device_Unihertz_Jelly2" path="device/Unihertz/Jelly2" remote="github" revision="master" />
<project name="Meetoul/android_device_Unihertz_Jelly2_TEE" path="device/Unihertz/Jelly2_TEE" remote="github" revision="master" />
</manifest>
If you want to build with GAPPS included add the following to the manifest-tag
<remote name="opengapps" fetch="https://github.com/opengapps/" />
<remote name="opengapps-gitlab" fetch="https://gitlab.opengapps.org/opengapps/" />
<project path="vendor/opengapps/build" name="aosp_build" revision="master" remote="opengapps" />
<project path="vendor/opengapps/sources/all" name="all" clone-depth="1" revision="master" remote="opengapps-gitlab" />
<!-- arm64 depends on arm -->
<project path="vendor/opengapps/sources/arm" name="arm" clone-depth="1" revision="master" remote="opengapps-gitlab" />
<project path="vendor/opengapps/sources/arm64" name="arm64" clone-depth="1" revision="master" remote="opengapps-gitlab" />
<project path="vendor/opengapps/sources/x86" name="x86" clone-depth="1" revision="master" remote="opengapps-gitlab" />
<project path="vendor/opengapps/sources/x86_64" name="x86_64" clone-depth="1" revision="master" remote="opengapps-gitlab" />
If you want to build with Magisk included add the following to the manifest-tag
<project name="ADeadTrousers/android_vendor_magisk" path="vendor/magisk" remote="github" revision="master" />
To finish everything up sync the repo
cd ~/android/lineage
repo sync --force-sync
If you included GAPPS you also need to sync git-lfs
cd vendor/opengapps/sources
for d in ./*/ ; do (cd "$d" && git lfs pull); done
If you don't want to include GAPPS at all or want to change the apps to be installed
gedit ~/android/lineage/device/Unihertz/Jelly2/gapps_prop.mk
Documentation of the possible settings
First follow the instructions to extract and mount the stock rom files
Then extract all the files we need
# For the Jelly2 TEE use
~/android/lineage/device/Unihertz/Jelly2_TEE/extract-files.sh ~/unihertz/extracted
If you were able to root your device this is just a small step. Plug in your device and do the follwing
# For the Jelly2 TEE use
~/android/lineage/device/Unihertz/Jelly2_TEE/extract-files.sh
Prepare the build
cd ~/android/lineage
source build/envsetup.sh
# For the Jelly2 TEE use
breakfast Jelly2_TEE
Do the actual build
cd ~/android/lineage
ccache -M 50G
croot
# For the Jelly2 TEE use
brunch Jelly2_TEE
Make sure everything is up-to-date
cd ~/android/lineage
repo sync --force-sync
If you changed the settings of TWRP and GAPPS sadly you need to redo them now.
Also don't forget to sync git-lfs if you included GAPPS
cd vendor/opengapps/sources
for d in ./*/ ; do (cd "$d" && git lfs pull); done