flypig.co.uk

List items

Items from the current list are shown below.

Gecko

19 Oct 2023 : Day 64 #
When we hit Day 50 I made a point about it being a milestone. We live in such a decimalised world. Well I'm more of a binary person myself, so Day 26 is a much more exciting event!

As I explained yesterday, over the last couple of days I've been figuring out the exact steps needed to build gecko from start to finish.

Today I'm going to share the results in the most basic form: as a sequence of commands with very little explanation.

So that I know the correct commands I'm firing up a cloud server instance to test out the build steps from a completely clean start. I'm going to build this on an r6a.xlarge server from AWS with 23 GiB of RAM, 4 CPUs, 128 GiB of SSD persistent storage and running Ubuntu 22.04. That means it's also going to be headless, so I'll have to do everything at the command line.

I'm using a cloud server so that it's a completely clean install. If it works here, it should work on any x86 machine with Ubuntu 22.04 installed.

Today I'm just going to literally run through all of the commands needed. Tomorrow I'll write all this up with some better explanations alongside.
# Login to fresh AWS Ubuntu 22.04 instance
$ sudo apt upgrade
$ sudo reboot
# Reboot and log straight back in

# Install and configure docker
# See https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04
$ sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
  sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
$ echo "deb [arch=$(dpkg --print-architecture)" \
  "signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]" \
  "https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt update
$ apt-cache policy docker-ce
$ sudo apt install -y docker-ce
$ sudo usermod -aG docker ${USER}
# Restart the shell

# Install SDK pre-requisites
$ sudo apt install -y libxcb-glx0 libx11-xcb1 libxcb-icccm4 libxcb-image0 \
  libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-sync1 \
  libxcb-xfixes0 libxcb-xinerama0 libxcb-xkb1 libsm6 libxkbcommon-x11-0 \
  libwayland-egl1 libegl1 libxcomposite1 libfontconfig1 libwayland-cursor0 \
  libharfbuzz0b libgl1 openssl 
# See https://forum.sailfishos.org/t/installing-sailfish-sdk-on-ubuntu-22-04/14121
$ wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb
$ sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb

# Download the SDK
$ mkdir -p Programs/sailfish-sdk
$ cd ~/Programs/sailfish-sdk
$ wget https://releases.sailfishos.org/sdk/installers/3.10.4/SailfishSDK-3.10.4-linux64-online.run
$ chmod +x SailfishSDK-3.10.4-linux64-online.run

# Headless install of the SDK
$ QT_QPA_PLATFORM=minimal ./SailfishSDK-3.10.4-linux64-online.run --verbose \
  non-interactive=1 accept-licenses=1 build-engine-type=docker

$ echo "alias sfdk=/home/ubuntu/SailfishOS/bin/sfdk" >> ~/.bashrc 
$ alias sfdk=/home/ubuntu/SailfishOS/bin/sfdk

# Check that things are looking okay
$ sfdk --version
SDK_RELEASE=3.10.4
SDK_RELEASE_CYCLE=Stable
SDK_CONFIG_DIR=SailfishSDK
SDK_VENDOR="Jolla"

$ sfdk tools target list
sfdk: [I] Starting the build engine…
SailfishOS-4.5.0.18-aarch64  sdk-provided,latest
SailfishOS-4.5.0.18-armv7hl  sdk-provided,latest
SailfishOS-4.5.0.18-i486     sdk-provided,latest

# Clone the latest target
$ sfdk tools target clone SailfishOS-4.5.0.18-aarch64 SailfishOS-devel-aarch64

# Configure a unified folder for our packages to be output to
$ mkdir ~/RPMS
$ sfdk config --global --push output-prefix ~/RPMS
$ sfdk config --global --push target SailfishOS-devel-aarch64

# Configure 16 GiB of swap memory
$ sudo dd if=/dev/zero of=/swapfile bs=16384 count=1048576
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ echo 'swapfile swap swap defaults 0 0' | sudo tee -a /etc/fstab

# Clone all the repositories
$ cd ~/Documents
# First the pre-requisites
$ 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
# Second the post-requisites
$ 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 master https://github.com/sailfishos/mapplauncherd-booster-browser

# Build the pre-requisites
$ cd rust-cbindgen
$ sfdk build -d -p
$ cd ..

# Building NSPR is messy, but can be done
$ 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 ..

# Install the patched version of gcc
$ 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 -n install gmp mpc
$ zypper -n install --force --repo gecko-esr91 cpp gcc gcc libstdc++ libgomp libstdc++
$ zypper rr gecko-esr91
$ exit

# Install some requirements into the build engine (not the target!)
$ sudo zypper -n install clang-libs llvm-libs gcc-c++
$ exit

# Build gecko (this takes many hours)
$ cd gecko-dev/
$ sfdk -c no-fix-version build -d -p --with git_workaround
$ cd ..

# Build the post-requisites
$ 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 mapplauncherd-booster-browser
$ sfdk build -d -p
$ cd ..

# Let's see what we got!
$ ls ~/RPMS/SailfishOS-devel-aarch64/
cbindgen-0.19.0+git1-0.aarch64.rpm
embedlite-components-qt5-1.23.1+sailfishos.esr91.20231008210351.b410bec-1.aarch64.rpm
embedlite-components-qt5-debuginfo-1.23.1+sailfishos.esr91.20231008210351.b410bec-1.aarch64.rpm
embedlite-components-qt5-debugsource-1.23.1+sailfishos.esr91.20231008210351.b410bec-1.aarch64.rpm
mapplauncherd-booster-browser-0.2.1-1.aarch64.rpm
mapplauncherd-booster-browser-debuginfo-0.2.1-1.aarch64.rpm
mapplauncherd-booster-browser-debugsource-0.2.1-1.aarch64.rpm
nspr-4.35.0+git1+master.20231016112133.ae5e6ed-1.aarch64.rpm
nspr-debuginfo-4.35.0+git1+master.20231016112133.ae5e6ed-1.aarch64.rpm
nspr-debugsource-4.35.0+git1+master.20231016112133.ae5e6ed-1.aarch64.rpm
nspr-devel-4.35.0+git1+master.20231016112133.ae5e6ed-1.aarch64.rpm
qtmozembed-qt5-1.53.9-1.aarch64.rpm
qtmozembed-qt5-debuginfo-1.53.9-1.aarch64.rpm
qtmozembed-qt5-debugsource-1.53.9-1.aarch64.rpm
qtmozembed-qt5-devel-1.53.9-1.aarch64.rpm
qtmozembed-qt5-tests-1.53.9-1.aarch64.rpm
rust-cbindgen-debuginfo-0.19.0+git1-0.aarch64.rpm
rust-cbindgen-debugsource-0.19.0+git1-0.aarch64.rpm
sailfish-browser-1.18.14+sailfishos.esr91.20231003080304.8563696b-1.aarch64.rpm
sailfish-browser-debuginfo-1.18.14+sailfishos.esr91.20231003080304.8563696b-1.aarch64.rpm
sailfish-browser-debugsource-1.18.14+sailfishos.esr91.20231003080304.8563696b-1.aarch64.rpm
sailfish-browser-settings-1.18.14+sailfishos.esr91.20231003080304.8563696b-1.aarch64.rpm
sailfish-browser-tests-1.18.14+sailfishos.esr91.20231003080304.8563696b-1.aarch64.rpm
sailfish-browser-ts-devel-1.18.14+sailfishos.esr91.20231003080304.8563696b-1.aarch64.rpm
xulrunner-qt5-91.9.1-1.aarch64.rpm
xulrunner-qt5-debuginfo-91.9.1-1.aarch64.rpm
xulrunner-qt5-debugsource-91.9.1-1.aarch64.rpm
xulrunner-qt5-devel-91.9.1-1.aarch64.rpm
xulrunner-qt5-misc-91.9.1-1.aarch64.rpm
It took a bit of back-and-forth, but ultimately that all seemed to work, so I'm confident that these steps should work on a clean Ubuntu system. Tomorrow I'll need to write the steps up properly with a bit of helpful context.

Don't forget, if you'd like to read more about all this gecko stuff, do take a look at my full Gecko Dev Diary.

Comments

Uncover Disqus comments