Compile LineageOS 15.1 for Oneplus 3 on Fedora

LineageOS in Android Oreo flavor is finally here, I guess it is time to update the guide I wrote a while back.
Most of the stuff is exactly the same, for the sake of simplicity this guide will be pretty much a copy and paste of the old one with just some bits changed here and there.

Required packages on Fedora are (rpmfusion repo must be previously installed):

$ sudo dnf install screen java-1.8.0-openjdk-devel git schedtool ncurses-devel ncurses-libs ncurses-compat-libs ImageMagick-devel libstdc++-devel bison gnupg lzma

For some reason the compilation process stores some temporary files in /tmp which, in Fedora, is mounted on a tmpfs ramdisk.
In case the ramdisk runs out of space for some retarded reason the build process instead of halting will go on like nothing happens and produce borked binaries as output.
To keep /tmp mounted on HDD run:

systemctl mask tmp.mount

Download the SDK (sdk-tools-linux) and extract the files, if building on an headless machine just get the command line tools:

$ mkdir android-sdk-linux
$ mv
$ cd android-sdk-linux
$ unzip
$ vi ~/.bash_profile
export ANDROID_HOME=/home/user/android-sdk-linux
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
$ source .bash_profile

Download the latest version of “Android SDK Tools”, “Android SDK Platform-tools”, “Android SDK Build-tools” and “SDK Plattform Android”:

### list available downloads
$ sdkmanager --list
$ sdkmanager "platform-tools" "tools"

Get repo utility and create a directory where Android’s source code will be downloaded.
Screen utility might come in handy since the download will likely take some time (it is around 60 GB).

$ sudo curl > /usr/bin/repo
$ sudo chmod a+x /usd/bin/repo
$ mkdir -p ~/android/system
$ cd android/system
### replace cm-14.1 with the desired branch
$ repo init -u git:// -b lineageos-15.1
$ repo sync -j16

Now it is time to download the source code needed to compile for a specific device, which is a Oneplus 3 in my case.
Before actually compiling it is a good idea to run “make clobber” to clean the system from all the temp files created the previous time Android was compiled.
While this should not be necessary and makes the compilation procedure much longer it should ensure that everything is recompiled correctly every time even if some binary blobs have changed:

$ make clobber
$ source build/
$ breakfast oneplus3

Double check that all the needed repository are actually present in roomservice.xml file:

<?xml version="1.0" encoding="UTF-8"?>
  <project name="LineageOS/android_device_oneplus_oneplus3" path="device/oneplus/oneplus3" remote="github" revision="lineage-15.1" />
  <project name="LineageOS/android_device_oppo_common" path="device/oppo/common" remote="github" revision="lineage-15.1" />
  <project name="LineageOS/android_kernel_oneplus_msm8996" path="kernel/oneplus/msm8996" remote="github" revision="lineage-15.1" />
  <project name="LineageOS/android_packages_resources_devicesettings" path="packages/resources/devicesettings" remote="github" revision="lineage-15.1" />
  <project name="LineageOS/android_device_qcom_common" path="device/qcom/common" remote="github" revision="lineage-15.1" />
  <project name="LineageOS/android_external_sony_boringssl-compat" path="external/sony/boringssl-compat" remote="github" revision="lineage-15.1" />
  <project name="LineageOS/android_external_stlport" path="external/stlport" remote="github" revision="lineage-15.1" />
  <project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus" remote="github" revision="lineage-15.1" />

Google’s Android compilation guide suggest the user to enable gcc ccache, I prefer to keep it disabled because it can cause corrupted output (it already happened more than once to me).
Set jack server’s allocated memory (-Xmx flag) to as much RAM you can spare for it:

$ repo sync
#$ export USE_CCACHE=1
#$ prebuilts/misc/linux-x86/ccache/ccache -M 50G
$ export ANDROID_JACK_VM_ARGS="-Xmx8192m -Dfile.encoding=UTF-8 -XX:+TieredCompilation"
#set this environmental variable to include su binaries
$ export WITH_SU=true
$ brunch oneplus3

The compiled binaries can be found in ~/android/system/out/target/product/oneplus3/, it will all be compressed in an archive named “lineage-version-date-UNOFFICIAL-oneplus3” that can then be flashed from recovery.
This LineageOS build procedure can be extended to any other device, the only thing that needs to be adjusted are the repositories present in roomservice.xml file.

.:. How to install
The correct procedure to install this ROM on Oneplus 3 is comprised of the following steps:
1. Download and install the latest release of TWRP recovery from here:
2. Power off the phone and boot into recovery.
3. Upgrade the baseband firmware to the latest version, the best and safest way to get those is by extracting them directly from Oneplus own ROM.
4. Flash LineageOS 15.1

Firejail and symlink pointing outside of home directory

I normally move /home/user/Downloads off /home/user to a secondary mechanical drive and then symlink it back to /home/user.
Firejail for security reasons does not allow whitelisting directories residing outside of the home directory, the simplest solution I found is mount Download directory using mount –bind.

sudo mount --bind /mnt/data/Downloads/ /home/user/Downloads

To make the change permanent edit fstab:

/mnt/data/Downloads     /home/user/Downloads   none    bind

Free Suunto Ambit3 from the botnet

Suunto makes some solid sport-watches, problem is that the management software is comprised of a closed source synchronization program (compatible with Windows and OSX only) and some cancerous cloud web interface accessible directly from their website.
Even putting aside my personal aversion for closed source software, it is clear that this approach is retarded because an internet connection is required to be able to download any kind of data from the watch.
What if I don’t have any signal? What if I don’t want to upload my data to Suunto’s servers?
Luckily some good lads reverse engineered the communication protocol used by the watch to “speak” with the PC synchronization client, and even more, they also wrote an open source Linux compatible tool that can be used to download data from the watch.
This tool is called: Openambit
The version included in Fedora 27 repositories is not up to date and does not support the Ambit3 Run I own, luckily the github version does.

.:. Compile Openambit from source
First of all install some libraries that are required in order to successfully compile Openambit:

$ dnf install qt5-qtbase-devel qt5-linguist systemd-devel

Clone Openambit’s official git repository:

$ git clone

Run the commands one by one in a terminal or run the following script to automagically compile and install openambit.


# git repo:
# deps: qt5-qtbase-devel qt5-linguist systemd-devel


# compile #
git pull
rm -rf build && mkdir build && cd build
if [ $DEBUG -eq "1" ]
   cmake -DUSE_QT5=1 ..
time make -j$CORE_N

# install #
sudo rm -rf $INSTALL_DIR && sudo mkdir $INSTALL_DIR
sudo cp -r $SRC_DIR/build/src/* $INSTALL_DIR
sudo cp -r $SRC_DIR/tools/ $INSTALL_DIR
sudo chmod 755 $INSTALL_DIR/
if [ $FIRST_INSTALL -eq "1" ]
   sudo ln -s $INSTALL_DIR/openambit/openambit /usr/sbin/openambit
   sudo cp $SRC_DIR/src/libambit/libambit.rules /etc/udev/rules.d/
   sudo ln -s $INSTALL_DIR/ /usr/sbin/
   sudo cp $SRC_DIR/icon.png $INSTALL_DIR

.:. Compile GoldenCheetah from source
GoldenCheetah is not present in Fedora 27 repositories, installing it from source is the best option.
First of all, let’s add some required packages and clone the official git repository:

$ dnf install bison flex byacc qt5-qtbase-devel qt5-qtserialport-devel qt5-qtmultimedia-devel qt5-qtwebkit-devel qt5-qtcharts-devel qt5-qtsvg-devel qt5-qtconnectivity-devel openssl-devel
$ git clone

The following script atomatically compile and install the program:


# git repo:
# deps: bison flex byacc qt5-qtbase-devel qt5-qtserialport-devel qt5-qtmultimedia-devel qt5-qtwebkit-devel qt5-qtcharts-devel qt5-qtsvg-devel qt5-qtconnectivity-devel openssl-devel


cp qwt/ qwt/qwtconfig.pri
MAKE_LEX = flex
QMAKE_YACC = bison
QMAKE_LRELEASE = /usr/bin/lrelease-qt5" > src/gcconfig.pri
make clean
qmake -recursive
time make -j$CORE_N

if [ $FIRST_INSTALL -eq 1 ]
   sudo mkdir $INSTALL_DIR
sudo cp $SRC_DIR/src/GoldenCheetah $INSTALL_DIR
sudo cp $SRC_DIR/src/Resources/images/gc.png $INSTALL_DIR
if [ $FIRST_INSTALL -eq 1 ]
   sudo ln -s $INSTALL_DIR/GoldenCheetah /usb/sbin/GoldenCheetah

.:. Converting Openambit logfiles to TCX format
Openambit logs are XML files but they are not recognized by GoldenCheetah so it is impossible to load them.
Openambit include a Python script to convert the logs to standard GPX files, unfortunately GPX does not store any kind of addition data other than GPU coordinates.
I could not find any existing program/script capable of converting Openambit logs into TCX files, so I wrote one.
The script can be found on my github, hopefully it will also be accepted into openambit official repo: