mb2

mb2 does rpm builds inside a qemu environement. Typically invoked by sb2. ((???)

Executes a subset of build commands in the context of an rpmbuild. Typically called from QtCreator to perform qmake/make phases of a project. Note that any other build steps in the .spec file will also be run.

The mb2 tool is developed at the sailfishos Github organization under sailfishos/sdk-setup.

mb2 is part of the Sailfish SDK suite and resides at /usr/bin/mb2 in the SDK chroot.

Command Synopsis

usage: mb2 [-t <target>] [-s <specfile>] [-d <device>] [-o <outputdir>] [-p <projectdir>]
           [-f <folder>] [-i] [-P] [-x[=<tag>] | -X] [-c[=<args>]]
           build [-p] [-d] [-j <n>] [<args>] | qmake [<args>] | make [<args>] | ssh <args>
           install [<args>] | installdeps <args> | rpm [<args>] | deploy <args>
           prep | apply [-R] | run <args>
       mb2 --version

Usage

Executes a subset of build commands in the context of an rpmbuild. Typically called from QtCreator to perform qmake/make phases of a project.

Note that any other build steps in the .spec file will also be run. <specfile> will be looked for in the current rpm/ dir. If there is more than one it must be provided.

CWD is used as a base dir for installroot/ and RPMS/ to allow for shadowbuilds.

mb2 is aware of spectacle and will update the spec file if there is an obvious yaml file which is newer.

If a file exists with .changes extension, otherwise matching the spec file name, the effect will be the same as having a %changelog section in the spec file. If a file with .changes.run extension is found instead, this file will be executed and its output treated as the actual changelog.

Operations

mb2 qmake [<args>]runs qmake in the ‘build’ phase

Note that this also verifies target build dependencies are up to date

: can use -s -t -p -n

mb2 make [<args>]run make in the ‘build’ phase

: can use -s -t -p

mb2 deploy –zypper|–pkcon|–rsync|–sdk
: runs the install or rpm-creation phase and then

copies/installs the relevant files to the device

: can use -s -t -p -d -i -f -x -X -c

mb2 run|ssh [<args>]runs a command (on device if –device given);

intended for running gdb and a gdb server

: can use -s -t -p -d

mb2 install [<args>]runs the ‘install’ phase to install to $buildroot

: can use -s -t -p

mb2 installdeps [<args>]refresh the zypper cache of the given target and

if required installs build-dependencies

: can use -s -t -p

mb2 rpm [<args>]runs the install & rpm-creation phases

: can use -s -t -p -i -x -X -c

mb2 apply [-R]applies all patches defined in spec from rpm directory

: to the source tree, or if detected, submodule : source tree : -R reverse apply patches (patch -R) : can use -m

Option Arguments

-i | –increment : increment release number in spec file -t | –target : specify the sb2 target to use -d | –device : specify the device -o | –outputdir : where to place produced RPM files. Defaults to ./RPMS directory.

With this option existing files in the output directory are preserved

-p | –projectdir : when running shadow build/deploy from another dir -s | –specfile : if the specfile is not in rpm/*.spec and cannot be found using -p -f | –shared-folder : the folder where QtCreator shares devices.xml and ssh keys

this option is useful if deploy option is used outside of virtual machine

-P | –pedantic : do extra checks -x[=<tag>] | –fix-version[=<tag>]

: this option is implied when used inside a Git working

tree (use -X to override). Within Application SDK it is only implied if the version recorded in the spec file is exactly “0”. Use the latest tag from the current git branch as package version or the given <tag>. If the current HEAD, index or working tree differs from the tree denoted by the tag, a suffix composed from the current branch name, time stamp and a commit SHA1 will be added to the package version. If git-state is not clean a git-stash will be created and its SHA1 will be used instead of HEAD.

-X | –no-fix-version

: override –fix-version option.

-n | –no-deps : don’t update target dependencies -c[=<args>] | –git-change-log[=<args>]

: include change log generated from Git history with

‘git-change-log’ command, forwarding any <args>. This option is not intended for regular use - create a script file named after the spec file but with ‘.changes.run’ extension to instruct mb2 to generate changelog with ‘git-change-log <args>’ instead.

-m | –submodule : use specified directory as submodule when applying patches