Skip to content
Go to file
1 contributor

Users who have contributed to this file

137 lines (105 sloc) 5.07 KB

Initial building guide

Table of Contents

Starting from ground zero

When starting out, the ideal situation would be creating another user just for building to keep the environment consistent:


sudo useradd porter -s /bin/bash -m -G wheel -c "SFOS Builder"
sudo passwd porter
su - porter

To make the host environment suitable for building you'll need the following changes made:

  1. Append these lines to your ~/.bashrc
  2. Create a ~/.hadk.env with the following content
  3. Create a ~/.mersdkubu.profile with the following content
  4. Create a ~/.mersdk.profile with the following content
  5. Get the repo command:

mkdir ~/bin
curl > ~/bin/repo
chmod +x ~/bin/repo

Setup the Platform SDK

Here's where the magic magic happens in terms of building Sailfish OS itself. To set it up we need to create some initial directories for the SUSE based Platform SDK chroot and extract it:


exec bash
sudo mkdir -p $PLATFORM_SDK_ROOT/{targets,toolings,sdks/sfossdk}
sudo ln -s $PLATFORM_SDK_ROOT/sdks/sfossdk/$PLATFORM_SDK_ROOT/sdks/ubuntu/ $PLATFORM_SDK_ROOT/sdks/ubuntu
cd && curl -k -O
sudo tar --numeric-owner -p -xjf Jolla-latest-SailfishOS_Platform_SDK_Chroot-i486.tar.bz2 -C $PLATFORM_SDK_ROOT/sdks/sfossdk
mkdir -p $ANDROID_ROOT

After entering the Platform SDK you get to choose your first target device! I chose cheeseburger as that's the only device I own:

Which hybris-16.0 device would you like to build for?

  1. cheeseburger (OnePlus 5)
  2. dumpling     (OnePlus 5T)

Choice: (1/2) 1
Cloning droid HAL & configs for cheeseburger... done!

Env setup for cheeseburger

When gaining control of the prompt we need to fetch the HADK Android tools for utils such as mkbootimg:


sudo zypper ref -f
sudo zypper --non-interactive in bc pigz atruncate android-tools-hadk

NOTE: Repository errors for adaptation0 can be safely ignored here and in the future.

Adding SFOS build target

In the Platform SDK we use Scratchbox to build packages for the target device architecture. Releases for the SDK targets can be found here if another version is desired. To build against the latest public release e.g. at the time of writing, the following command should be run:


sed -i '1iexport RELEASE=""' ~/.hadk.env
source ~/.hadk.env
cd && sdk-manage target install $VENDOR-$DEVICE-$PORT_ARCH$RELEASE-Sailfish_SDK_Target-$PORT_ARCH.tar.7z --tooling SailfishOS-$RELEASE --tooling-url$RELEASE-Sailfish_SDK_Tooling-i486.tar.7z

NOTE: You can add an entry for another device model by simply choosing it when entering Platform SDK again and installing another target!

To verify that the install(s) have succeeded, executing sdk-assistant list should yield something like this:

PLATFORM_SDK $ sdk-assistant list


Next we'll pull down & extract the Ubuntu 14.04 chroot environment where LineageOS HAL parts shall be built:


cd && curl -O$TARBALL
sudo mkdir -p $UBUNTU_CHROOT
sudo tar --numeric-owner -xjf $TARBALL -C $UBUNTU_CHROOT
sudo sed "s/\tlocalhost/\t$(</parentroot/etc/hostname)/g" -i $UBUNTU_CHROOT/etc/hosts

When pulling down large amounts of source code it is a good idea to configure git as to not limit our available resources and cause other issues:


git config --global "Your Name"
git config --global ""

Cleaning up

Once you can enter both PLATFORM_SDK and HA_BUILD environments, you can safely delete the leftover chroot filesystem archives from your home directory:

HA_BUILD $ cd && rm Jolla-latest-SailfishOS_Platform_SDK_Chroot-i486.tar.bz2 ubuntu-*-android-rootfs.tar.bz2

Initializing local repo

When everything is ready to go we can finally init the local source repository:


repo init -u git:// -b hybris-16.0 --depth 1
git clone -b hybris-16.0 .repo/local_manifests/

Now that the repo is initialized you can start syncing the local repository as per the regular porting guide.

You can’t perform that action at this time.