When sb2 runs it needs to know where to get header files and libraries and what architecture and cross-compiler to use. This is called a 'target'. SB2 can be configured to run against multiple named targets.

Setup a new target for sb2

Target Preparation

A target is a rootfs that contains development files like headers, libraries and possibly programs. Notably it does *not* need to contain compilers, linkers etc.

If zypper fails with "Cant open /var/run/zypp.pid in mode w" you can fix it with:

cd /srv/mer/targets/<target_name>/var
rm run && mkdir run

Compile the simple C program

Again run:

sb2 -t mer-target-armv7hl gcc ~/src/hello.c -o ~/src/hello

This time:

~/src/hello.c:1:19: fatal error: stdio.h: No such file or directory

This is because the target has no development header files in it.

We need to be at the target root (this is bug #239) and then we can install some basic header files:
Note the important use of the "-m sdk-install" and the "-R". The -m tells sb2 to use a mapping mode that permit the updating of the target and -R tells sb2 to run as fake root.

SB2 Detailed setup information

The sb2-init options mean:

-d : make this the default target
-L : linker options
-C : compiler options
-c : which qemu to use
-m : which mapping to use by default
-n : don't build libtool
-N : don't do localisation for the target
-t : the location of the build tools
mer-target-armv7hl : The name of the target
/opt/cross/bin/armv7hl-meego-linux-gnueabi-gcc : the cross-compiler to use

Alternate targets

Creating an SB2 Target for any (non-x86) Mer OBS package (draft)

osc provides the ability to do a "local build" where it creates a chroot within the SDK suitable for building a package.

When SB2 is enabled on the OBS (as it is in the MeeGo public OBS) then it also creates a suitable SB2 'target'.

So checkout the package from OBS, start a local build, setup the SB2 target:

osc co PROJECT PACKAGE
cd PROJECT/PACKAGE

determine which repository/architecture to build for

osc repos

Then run a build

osc build --chroot-only REPO ARCH

Note the build root from the above command or use this to find it:

osc chroot

Check the directory of the osc chroot and use the ./target/ directory in there for your SB2 target:

Initialize scratchbox2

Note: If you installed the mer-target-armv7hl target earlier, that will be your default target. If you, however, like the nemo-n950 to be your default target, add the -d switch to the command line above.

Notes

some messages about "cannot find 'ld'" and "no gcc" are expected.

running sb2-init again with the same name will just change the values for that name - make sure each target is named uniquely.

# Save the target magic.mgc file (just in case) and use the one from the MerSDK
mv /parentroot/srv/mer/targets/nemo-i486-vm-wayland_SB2/usr/share/misc/magic.mgc /parentroot/srv/mer/targets/nemo-i486-vm-wayland_SB2/usr/share/misc/magic.mgc.orig
cp /usr/share/misc/magic.mgc /parentroot/srv/mer/targets/nemo-i486-vm-wayland_SB2/usr/share/misc/magic.mgc

Plasma Active

Plasma Active can run on various devices, such as Nexus 7, the Flying Squirrel (in previous iteration - Vivaldi) and so on.

Setup target

Extract the PlasmaActive rootfs as a target and set file permissions (in this example we are taking a Nexus 7 tablet, where PA uses armv7hl build. For other targets and potential armv7l versions, adjust the instructions below accordingly: