Skip to content

Build instructions ESR 91

Vlad G. edited this page Sep 3, 2024 · 8 revisions

Building ESR 91 requires quite a few special steps compared to the latest official release (ESR 78). This page provides detailed step-by-step instructions for how to build ESR 91.

I've tested these instructions on a clean install of Ubuntu 22.04, but systems, distributions and configurations differ, so if you hit trouble following these instructions please either edit these pages or create an issue.

Check also https://www.flypig.co.uk/?page=list?&list_id=904&list=gecko which provides more details.

Step 1: Install the Sailfish SDK

You'll need a recent Sailfish SDK with a suitable target to build the packages. See the Sailfish OS docs site for installation instructions.

Testing of ESR 91 was done using Sailfish SDK 3.1.0 and the aarch64 4.5.0.18 build target.

Step 2: Configure your SDK

I've cloned my target using the following command. This step isn't necessary but if you do this it'll make it easier to follow the later commands.

sfdk tools target clone SailfishOS-4.5.0.18-aarch64 SailfishOS-devel-aarch64

You'll want the SDK to install the packages you build as part of the build process, so you should configure a unified output directory. You can set this to any empty folder, it doesn't have to be this one.

mkdir ~/RPMS
sfdk config --global --push output-prefix ~/RPMS

It's also convenient to lock the target in so it can be omitted from future commands.

sfdk config --global --push target SailfishOS-devel-aarch64

Step 3: Increase swap memory

You'll need at least 48 GiB of memory to successfully build gecko. My system has 32 GiB of RAM installed, so I've added an extra 16 GiB of swap.

Check instructions for your distribution to find out how to add swap memory.

Step 4: Configure the build engine

For building aarch64 packages the build engine still needs to be able to handle x86 compilation (because the build system builds part of itself). You'll therefore need to install a few packages into your build engine (note: not the build target).

sfdk engine exec
sudo zypper -n install clang-libs llvm-libs gcc-c++
exit

Depending on whether you're running an aarch64 or an i486 build you may also need to apply, or remove, a semaphore fix.

Step 5: Get the code

You need code from a number of repositories. I'll update these once the code has moved into the official repos.

git clone -b master --recurse-submodules https://github.com/sailfishos/rust-cbindgen.git
git clone -b master https://github.com/sailfishos/nspr.git
git clone -b sailfishos-esr91 --recurse-submodules --depth 256 https://github.com/llewelld/gecko-dev.git
git clone -b sailfishos-esr91 https://github.com/llewelld/qtmozembed.git
git clone -b sailfishos-esr91 https://github.com/llewelld/embedlite-components.git
git clone -b sailfishos-esr91 https://github.com/llewelld/sailfish-browser.git
git clone -b sailfishos-esr91 https://github.com/llewelld/sailfish-components-webview.git
git clone -b master https://github.com/sailfishos/mapplauncherd-booster-browser

Step 6: Build the pre-requisites

Building the rust-cbindgen code is straightforward.

$ cd rust-cbindgen
$ sfdk build -d -p
$ cd ..

Building NSPR is more convoluted because it's structured as a "dummy" project which OBS understands. You have to restructure the project into something the SDK can understand before building it. The following commands can be used to do this. Note that these commands will commit changes to your local repository that you might want to remove afterwards.

cd nspr
mkdir rpm
mv *.patch *.spec *.changes rpm
sed -i -e 's/"@${SOURCE_DATE_EPOCH}"/"${SOURCE_DATE_EPOCH}"/g' rpm/nspr.spec 
tar -xvf nspr-4.35.tar.gz --strip-components=1
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
git add -u .
git add nspr rpm
git commit -m "temp"
sfdk build -d -p
cd ..

In the above commands the -p parameter tells sfdk to run the prepare step. You only need to do this on the first build; on subsequent builds you should omit this parameter.

You need a patched version of gcc for the build to complete successfully. You can install this into your target using the following commands.

sfdk engine exec
sb2 -R -m sdk-install -t SailfishOS-devel-aarch64.default
zypper ar -f https://repo.sailfishos.org/obs/home:/flypig:/gecko-esr91/sailfish_latest_aarch64 gecko-esr91
zypper --no-gpg-checks -n ref --repo gecko-esr91
zypper ref
zypper -n install gmp mpc
zypper -n install --force --repo gecko-esr91 cpp gcc gcc libstdc++ libgomp libstdc++
zypper rr gecko-esr91
exit
exit

Step 7: Build!

You're now ready to build gecko. Note that this is likely to take a long time (like, 8 hours long). Be prepared to leave it building (and I recommend running it in a screen or tmux session).

cd gecko-dev/
sfdk -c no-fix-version build -d -p --with git_workaround
cd ..

The -c no-fix-version flag ensures the correct version number is used for the package. The -d flag builds extra debug packages. The -p flag tells the build engine to run the prepare step. You should omit this flag on subsequent builds (the patches can only be applied once). Finally the --with git_workaround flag will rename the .git folder to .git-disabled. If the build doesn't complete for whatever reason you'll need to rename the folder back again manually.

Step 8: Clean up

If the build fails it's worth running it again as there seems to be some inconsistency, especially when it comes to installing the requirements.

If you do find you have to install local packages manually, you can do something along the following lines.

sfdk engine exec
sb2 -R -m sdk-install -t SailfishOS-devel-aarch64.default
rpm -U --oldpackage ~/RPM/cbindgen-0.*.rpm nspr-4.*.rpm nspr-devel-4.*.rpm
exit
exit

Step 8: Build the post-requisites

These are the packages that need gecko in order to build. These are also necessary in order to install the full set of packages on your device.

cd qtmozembed/
sfdk -c no-fix-version build -d -p
cd ..

cd embedlite-components/
sfdk build -d -p
cd ..

cd sailfish-browser
sfdk build -d -p
cd ..

cd sailfish-components-webview
sfdk build -d -p
cd ..

cd mapplauncherd-booster-browser
sfdk build -d -p
cd ..

Step 9: Install the results on your device

You'll need to scp the following packages over to your device and install them. These can all be found in the ~/RPMS output folder.

  1. embedlite-components
  2. mapplauncherd-booster-browser
  3. nspr
  4. qtmozembed-qt5
  5. sailfish-browser
  6. sailfish-browser-settings
  7. xulrunner-qt5
  8. xulrunner-qt5-misc
  9. sailfish-components-webview-*

If you want to perform debugging, you should also install the following:

  1. embedlite-components-qt5-debuginfo
  2. embedlite-components-qt5-debugsource
  3. qtmozembed-qt5-debuginfo
  4. qtmozembed-qt5-debugsource
  5. sailfish-browser-debuginfo
  6. sailfish-browser-debugsource
  7. xulrunner-qt5-debuginfo
  8. xulrunner-qt5-debugsource

That's it! If you run into trouble please edit the steps or submit an issue.