[sfdk] Build for all architectures in one command

Now with a third architecture to support this becomes even more relevant; please let me build for all of them in one go. There are quite a few steps to doing this manually, so i think it deserves a packaged “proper solution”.

Keep up the good work!

3 Likes

Surely there must be a better way than this (not counting less hardcoded stuff)?
If not, it would be great if there was.

#! /bin/bash
SFDK='/home/attah/SailfishOS/bin/sfdk'
SFOS_VERSION="4.1.0.24"
for ARCH in armv7hl i486 aarch64 
do
	git clean -fdxq
	$SFDK config target="SailfishOS-${SFOS_VERSION=}-${ARCH}"
	$SFDK build
	cp RPMS/*rpm ~/🐊
done

1 Like

You can do more conveniently utilizing shadow builds and a shared output directory.

Use of a shared output directory has a number of advantages, especially when used through the output-prefix configuration option combined with the task option. It’s not just a plain destination for resulting RPM files – check “Working On Multiple Packages” in sfdk --help-all (SDK 3.7) for overview and consider enabling these globally:

sfdk config --global output-prefix=$HOME/RPMS
sfdk config --global task

So, one effect of this configuration is that RPMs will always end in a subtree of $HOME/RPMS, denoted by the current task and target. The default task selection (see the help) can be overriden on command line as the other options just for the purpose of doing a release build, which can be done easily with:

for target in SailfishOS-4.3.0.12-{i486,armv7hl,aarch64}; do
    mkdir -p "$PWD.$target" \
        && sfdk -C "$PWD.$target" -c target="$target" -c task=release build "$PWD"
done

Executed from withing the source directory, the source directory was left untouched. A dedicated build directory (located next to the source directory) was used for each target and all are preserved for investigation in case of troubles. The resulting RPMs can be found under $HOME/RPMS/release:

find ~/RPMS/release

And more can be done with this configuration.

Another effect is that existing RPMs in the shared output directory are considered when looking for build time dependencies. This removes the need to install resulting RPMs of the required packages under the build target manually when you work on packages with dependencies in between. All you need is to build your packages in the correct order:

# With package directories under the current working directory
for package in packageA packageB; do
    for target in SailfishOS-4.3.0.12-{i486,armv7hl,aarch64}; do
        mkdir -p "$package.$target" \
            && sfdk -C "$package.$target" -c target="$target" -c task=release build "$PWD/$package"
    done
done

Here packageB depends on packageA at build time. The dependency was handled automatically thanks to the use of a shared output directory.

3 Likes

Tried this right now - seems to work well, but for whatever reason it plain refused until the output dir was moved to be under ~/repos. I have a vague recollection of setting this as some sort of root way back when, but no idea really. Any chance there could be human-friendly error messages for that?

Very messy in the long run… i’ll see if i can throw that on /tmp.

Not very nice with a deep output structure (for copying to harbour), will look at tweaking that too.

100% that these are minor things, but i was after convenience, after all.