1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
.TH sb2 1 "1 April 2012" "2.2" "sb2 man page"
.SH NAME
sb2 \- crosscompiling environment
.SH SYNOPSIS
.B sb2
[options] [command] [arguments] [...]
.SH DESCRIPTION
.B sb2
runs command in a scratchbox2 session. If no command is given, an interactive shell is started.
.PP
Scratchbox2 is typically used to create a
.I transparent cross-compiling environment
for developing programs and compiling software packages for e.g. embedded devices.
.PP
The environment created by
.B sb2
has essential differences to the host OS environment:
.PP
First, a virtual file system view is presented to the applications.
In practise that means that the file names (paths) which an application
uses may be modified before the OS does its operations;
applications observe a different file system that what the real file system is. For example,
common directories like /bin, /usr/lib and /lib can be changed to point to target-specific directories,
which contain files for a different CPU architecture than what the host has.
.PP
Second, scratchbox2 makes execution of foreign binaries completely transparent.
Target's binaries can be executed on the host just as if they were host's binaries;
scratchbox2 will start a
.I CPU transparency method
automatically whenever needed (Qemu is typically used for this).
.PP
The result is that the development machine appears as a virtual target system to
the software development tools, and complex tools (like GNU Autotools)
can be used directly.
.PP
Scratchbox2 works by intercepting library calls of dynamically linked binaries.
It uses a flexible and highly configurable rule engine, when deciding when, what, and how to
modify parameters of the intercepted calls; this is completely
transparent to the users and applications.
Scratchbox2 2 does not need any special privileges or kernel-level services;
it is completely based on features that are available for all ordinary users.
.PP
Configuration data is stored to a
.I target
(see sb2-init(1) for details about creating a target).
The target contains defaults for all settings that are needed when a session is
created.
.PP
A new session is created every time when the
.B sb2
command is used (unless one of the persistent session control options is present -
see options -S,-J and -D below).
.SH OPTIONS
.TP
\-c
When creating a session, also create a private copy of the target root filesystem (rootstrap).
Modifications done to the copy will be thrown away when the session is destroyed.
Note that the copy operation can be really slow, depending on the size of the file system,
but if the copy goes to a ramdisk, overall performance may much be better (see also option -W).
.TP
\-C DIR
When creating a session, create copy of DIR and use it as the
target root filesystem (rootstrap). Note that this can be really slow. See also option -c.
.TP
\-d
Use debug mode: same as
.B -L debug
.TP
\-D FILE
Delete a persistent session associated with FILE.
Warning: this does not check if the session is still in use!
(see also -S and -J)
.TP
\-e
Same as
.B -m emulate:
Use emulation mode, avoid executing any host binaries except qemu.
See
.B mapping modes
below.
.TP
\-f args
additional fakeroot arguments (see option -R)
.TP
\-g
Create a new session with setsid(); useful when executing commands in the background
(i.e. creates a system session and a new process group, and detaches from the
controlling terminal. See setsid(2) for more info)
.TP
\-G file
Append process group number to a file.
.TP
\-h
Print help.
.TP
\-J FILE
Join a persistent session associated with FILE (see also -D and -S)
.TP
\-L LEVEL
Enable logging. Following values for LEVEL are available (in order
of increasing level of details): error, warning, notice, info, debug, noise, noise2.
The default is
.I warning.
Logs can be post-processed with
.I sb2-logz,
a tool which produces summaries and visualizes various things that were logged.
.TP
\-m MODE
Use one of the pre-defined mapping modes. See
.B mapping modes
below.
.TP
\-M FILE
Read mapping rules from FILE.
.TP
\-O OPTIONS
Set options for the selected mapping mode. OPTIONS is a mode-specific string.
.TP
\-Q BUGLIST
Emulate bugs of scratchbox 1 (BUGLIST consists of letters: 'x' enables exec permission checking bug emulation).
.TP
\-r
Disable creating reverse mapping rules: functions like getcwd() and realpath() will always return the real path.
.TP
\-R
"superuser mode":
Execute commands in fakeroot environment (see fakeroot(1) for details).
Depending on the selected mapping mode,
this may also disables some mode-specific features, like simulated write protection
of the target filesystem.
.TP
\-s DIRECTORY
Use redirection rules from the DIRECTORY given in argument.
.TP
\-S FILE
Create a persistent session: Write session information to FILE
(see also -D and -J)
.TP
\-t TARGET
Define TARGET to use. Use
.I sb2-config -d TARGET
to set a default.
.TP
\-T DIRECTORY
Use DIRECTORY as tools_root (override the value which was specified to sb2-init when the target specification was created).
.TP
\-u
Disable automatic configuration upgrade.
.TP
\-v
Display version number.
.TP
\-W DIR
Use DIR as the session directory when creating the session (The default is to
create the session in /tmp). DIR must be an absolute path and must not exist.
Note that long pathnames may cause trouble with socket operations, so try to
keep DIR as short as possible.
.SH EXAMPLES
.TP
sb2 ./configure
.TP
sb2 make
.TP
sb2 -eR make install
.TP
sb2 -R -m emulate make install
.SH MAPPING MODES
Scratchbox2 contains several ready-made rulesets, called
.I mapping modes,
for different purposes. This manual page presents only the
basics of each. Full details can be found from the
rulesets themselves.
.PP
There are three development-oriented modes, that are intended for
cross-compilation:
.PP
"simple" makes only the very basic modifications to the file environment:
For example,
.I /usr/include
refers to /usr/include in the target root file system, not to the real
/usr/include of the host (and the same applies to /lib, /usr/lib,
and many other directories).
Typical toolchain commands, i.e. commands that are used to
create binary programs (like
.I gcc, as
and
.I ld)
refer to tools that were supplied with the the cross-compiler which was configured with
.I sb2-init
(also when used with full pathname: /usr/bin/gcc, /usr/bin/as, etc)
.PP
The "simple" mode usually takes other tools directly from the host OS.
This approach means that simple tools work fine, and well-behaving
OSS projects can be compiled with the "simple" mode. The drawback is that
there are some cases, where such a simple approach fails.
.PP
The other two development modes, "accel" and "devel" have more complete
support for different tools, but these are not necessarily as easy to
set up as the "simple" mode is.
Both "accel" and "devel" are intended to be used with a separate
"tools root" directory,
consisting of host-compatible binaries of the same programs that
exist in the target file system as foreign binaries (e.g. target root can contain
arm binaries, whereas tools root has x86 binaries of the exactly versions
of the same programs). This is configured with the -t option of sb2-init(1).
.PP
In addition to the development-oriented modes, scratchbox2 also has an "emulate"
mode, which sets up an environment without development tools: It maps as many paths
to the target root as possible. It can be used for
installing programs to the target filesystem and testing them.
.PP
"tools" mode is very much like "emulate", except that there most
things are mapped to tools root.
.PP
"nomap" mode is a special mapping mode, which is mostly useful only
for debugging purposes: It does not apply any file system related mappings,
but otherwise scratchbox2 functions are fully operational.
.SH FILES
.P
.I $HOME/.scratchbox2/*
.P
.I $HOME/sb2_logs
.P
.I /usr/share/scratchbox2/*
.SH SEE ALSO
.BR sb2-init (1),
.BR sb2-config (1),
.BR sb2-show (1),
.BR sb2-logz (1),
.BR sb2-session (1),
.BR fakeroot (1),
.BR qemu (1)
.SH BUGS
No known bugs at this time.
.SH AUTHORS
.nf
Lauri T. Aarnio, Riku Voipio
.fi
|