]> rtime.felk.cvut.cz Git - novaboot.git/blob - README.md
Move --scons documentation to the correct section
[novaboot.git] / README.md
1 # NAME
2
3 novaboot - A tool for booting various operating systems on various hardware or in qemu
4
5 # SYNOPSIS
6
7 __novaboot__ \[ options \] \[--\] script...
8
9 __./script__ \[ options \]
10
11 __novaboot__ --help
12
13 # DESCRIPTION
14
15 This program makes it easier to boot NOVA or other operating system
16 (OS) in different environments. It reads a so called novaboot script
17 and uses it either to boot the OS in an emulator (e.g. in qemu) or to
18 generate the configuration for a specific bootloader and optionally to
19 copy the necessary binaries and other needed files to proper
20 locations, perhaps on a remote server. In case the system is actually
21 booted, its serial output is redirected to standard output if that is
22 possible.
23
24 A typical way of using novaboot is to make the novaboot script
25 executable and set its first line to _\#!/usr/bin/env novaboot_. Then,
26 booting a particular OS configuration becomes the same as executing a
27 local program - the novaboot script.
28
29 With `novaboot` you can:
30
31 1. Run an OS in Qemu. This is the default action when no other action is
32 specified by command line switches. Thus running `novaboot ./script`
33 (or `./script` as described above) will run Qemu and make it boot the
34 configuration specified in the _script_.
35 2. Create a bootloader configuration file (currently supported
36 bootloaders are GRUB, GRUB2 and Pulsar) and copy it with all other
37 files needed for booting to another, perhaps remote, location.
38
39         ./script --server --iprelay=192.168.1.2
40
41     This command copies files to a TFTP server specified in the
42     configuration file and uses TCP/IP-controlled relay to reset the test
43     box and receive its serial output.
44
45 3. Run DHCP and TFTP server on developer's machine to PXE-boot NOVA from
46 it. E.g.
47
48         ./script --dhcp-tftp
49
50     When a PXE-bootable machine is connected via Ethernet to developer's
51     machine, it will boot the configuration described in _script_.
52
53 4. Create bootable ISO images. E.g.
54
55         novaboot --iso -- script1 script2
56
57     The created ISO image will have GRUB bootloader installed on it and
58     the boot menu will allow selecting between _script1_ and _script2_
59     configurations.
60
61 # PHASES AND OPTIONS
62
63 Novaboot perform its work in several phases. Each phase can be
64 influenced by several options, certain phases can be skipped. The list
65 of phases with the corresponding options follows.
66
67 ## Configuration reading phase
68
69 After starting, novaboot reads configuration files. By default, it
70 searches for files named `.novaboot` starting from the directory of
71 the novaboot script (or working directory, see bellow) and continuing
72 upwards up to the root directory. The configuration files are read in
73 order from the root directory downwards with latter files overriding
74 settings from the former ones.
75
76 In certain cases, the location of the novaboot script cannot be
77 determined in this early phase. This happens either when the script is
78 read from the standard input or when novaboot is invoked explicitly
79 and options precede the script name, as in the example ["4."](#4.) above.
80 In this case the current working directory is used as a starting point
81 for configuration file search.
82
83 - \-c, --config=<filename>
84
85     Use the specified configuration file instead of the default one(s).
86
87 ## Command line processing phase
88
89 - \--dump-config
90
91     Dump the current configuration to stdout end exits. Useful as an
92     initial template for a configuration file.
93
94 - \-h, --help
95
96     Print short (__\-h__) or long (__\--help__) help.
97
98 - \-t, --target=<target>
99
100     This option serves as a user configurable shortcut for other novaboot
101     options. The effect of this option is the same as the options stored
102     in the `%targets` configuration variable under key _target_. See
103     also ["CONFIGURATION FILE"](#CONFIGURATION FILE).
104
105 ## Script preprocessing phase
106
107 This phases allows to modify the parsed novaboot script before it is
108 used in the later phases.
109
110 - \-a, --append=<parameters>
111
112     Appends a string to the first "filename" line in the novaboot script.
113     This can be used to append parameters to the kernel's or root task's
114     command line.
115
116 - \-b, --bender
117
118     Use `bender` chainloader. Bender scans the PCI bus for PCI serial
119     ports and stores the information about them in the BIOS data area for
120     use by the kernel.
121
122 - \--dump
123
124     Prints the content of the novaboot script after removing comments and
125     evaluating all _\--scriptmod_ expressions. Exit after reading (and
126     dumping) the script.
127
128 - \--scriptmod=_perl expression_
129
130     When novaboot script is read, _perl expression_ is executed for every
131     line (in $\_ variable). For example, `novaboot
132     --scriptmod=s/sigma0/omega6/g` replaces every occurrence of _sigma0_
133     in the script with _omega6_.
134
135     When this option is present, it overrides _$script\_modifier_ variable
136     from the configuration file, which has the same effect. If this option
137     is given multiple times all expressions are evaluated in the command
138     line order.
139
140 - \--strip-rom
141
142     Strip _rom://_ prefix from command lines and generated config files.
143     The _rom://_ prefix is used by NUL. For NRE, it has to be stripped.
144
145 ## File generation phase
146
147 In this phase, files needed for booting are generated in a so called
148 _build directory_ (see TODO). In most cases configuration for a
149 bootloader is generated automatically by novaboot. It is also possible
150 to generate other files using _heredoc_ or _"<"_ syntax in novaboot
151 scripts. Finally, binaries can be generated in this phases by running
152 `scons` or `make`.
153
154 - \--build-dir=<directory>
155
156     Overrides the default build directory location.
157
158     The default build directory location is determined as follows:
159
160     If there is a configuration file, the value specified in the
161     _$builddir_ variable is used. Otherwise, if the current working
162     directory is inside git work tree and there is `build` directory at
163     the top of that tree, it is used. Otherwise, if directory
164     `~/nul/build` exists, it is used. Otherwise, it is the directory that
165     contains the first processed novaboot script.
166
167 - \-g, --grub\[=_filename_\]
168
169     Generates grub bootloader menu file. If the _filename_ is not
170     specified, `menu.lst` is used. The _filename_ is relative to the
171     build directory (see __\--build-dir__).
172
173 - \--grub-preamble=_prefix_
174
175     Specifies the _preable_ that is at the beginning of the generated
176     GRUB or GRUB2 config files. This is useful for specifying GRUB's
177     timeout.
178
179 - \--grub-prefix=_prefix_
180
181     Specifies _prefix_ that is put in front of every file name in GRUB's
182     `menu.lst`. The default value is the absolute path to the build directory.
183
184     If the _prefix_ contains string $NAME, it will be replaced with the
185     name of the novaboot script (see also __\--name__).
186
187 - \--grub2\[=_filename_\]
188
189     Generate GRUB2 menuentry in _filename_. If _filename_ is not
190     specified `grub.cfg` is used. The content of the menuentry can be
191     customized with __\--grub-preable__, __\--grub2-prolog__ or
192     __\--grub\_prefix__ options.
193
194     In order to use the the generated menuentry on your development
195     machine that uses GRUB2, append the following snippet to
196     `/etc/grub.d/40\_custom` file and regenerate your grub configuration,
197     i.e. run update-grub on Debian/Ubuntu.
198
199         if [ -f /path/to/nul/build/grub.cfg ]; then
200           source /path/to/nul/build/grub.cfg
201         fi
202
203 - \--grub2-prolog=_prolog_
204
205     Specifies text _preable_ that is put at the begiging of the entry
206     GRUB2 entry.
207
208 - \--name=_string_
209
210     Use the name _string_ instead of the name of the novaboot script.
211     This name is used for things like a title of grub menu or for the
212     server directory where the boot files are copied to.
213
214 - \--no-file-gen
215
216     Do not generate files on the fly (i.e. "<" syntax) except for the
217     files generated via "<<WORD" syntax.
218
219 - \-p, --pulsar\[=mac\]
220
221     Generates pulsar bootloader configuration file named `config-_mac_`
222     The _mac_ string is typically a MAC address and defaults to
223     _novaboot_.
224
225 - \--scons\[=scons command\]
226
227     Runs _scons_ to build files that are not generated by novaboot
228     itself.
229
230 ## Target connection check
231
232 If supported by the target, the connection to it is made and it is
233 checked whether the target is not occupied by another novaboot
234 user/instance.
235
236 ## File deployment phase
237
238 In some setups, it is necessary to copy the files needed for booting
239 to a particular location, e.g. to a TFTP boot server or to the
240 `/boot` partition.
241
242 - \-d, --dhcp-tftp
243
244     Turns your workstation into a DHCP and TFTP server so that NOVA
245     can be booted via PXE BIOS on a test machine directly connected by
246     a plain Ethernet cable to your workstation.
247
248     The DHCP and TFTP servers require root privileges and `novaboot`
249     uses `sudo` command to obtain those. You can put the following to
250     _/etc/sudoers_ to allow running the necessary commands without
251     asking for password.
252
253         Cmnd_Alias NOVABOOT = /bin/ip a add 10.23.23.1/24 dev eth0, /bin/ip l set dev eth0 up, /usr/sbin/dhcpd -d -cf dhcpd.conf -lf dhcpd.leases -pf dhcpd.pid, /usr/sbin/in.tftpd --foreground --secure -v -v -v *, /usr/bin/touch dhcpd.leases
254         your_login ALL=NOPASSWD: NOVABOOT
255
256 - \-i, --iso\[=filename\]
257
258     Generates the ISO image that boots NOVA system via GRUB. If no filename
259     is given, the image is stored under _NAME_.iso, where _NAME_ is the name
260     of the novaboot script (see also __\--name__).
261
262 - \--server\[=\[\[user@\]server:\]path\]
263
264     Copy all files needed for booting to another location (implies __\-g__
265     unless __\--grub2__ is given). The files will be copied (by __rsync__
266     tool) to the directory _path_. If the _path_ contains string $NAME,
267     it will be replaced with the name of the novaboot script (see also
268     __\--name__).
269
270 - \--concat
271
272     If __\--server__ is used and its value ends with $NAME, then after
273     copying the files, a new bootloader configuration file (e.g. menu.lst)
274     is created at _path-wo-name_, i.e. the path specified by __\--server__
275     with $NAME part removed. The content of the file is created by
276     concatenating all files of the same name from all subdirectories of
277     _path-wo-name_ found on the "server".
278
279 - \--rsync-flags=_flags_
280
281     Specifies which _flags_ are appended to `rsync` command line when
282     copying files as a result of _\--server_ option.
283
284 ## Target power-on and reset phase
285
286 - \--iprelay=_addr\[:port\]_
287
288     Use IP relay to reset the machine and to get the serial output. The IP
289     address of the relay is given by _addr_ parameter.
290
291     Note: This option is expected to work with HWG-ER02a IP relays.
292
293 - \--on, --off
294
295     Switch on/off the target machine. Currently works only with
296     __\--iprelay__.
297
298 - \-Q, --qemu=_qemu-binary_
299
300     The name of qemu binary to use. The default is 'qemu'.
301
302 - \--qemu-append=_flags_
303
304     Append _flags_ to the default qemu flags (QEMU\_FLAGS variable or
305     `-cpu coreduo -smp 2`).
306
307 - \-q, --qemu-flags=_flags_
308
309     Replace the default qemu flags (QEMU\_FLAGS variable or `-cpu coreduo
310     -smp 2`) with _flags_ specified here.
311
312 ## Interaction with the bootloader on the target
313
314 See __\--serial__. There will be new options soon.
315
316 ## Target's output reception phase
317
318 - \-s, --serial\[=device\]
319
320     Use serial line to control GRUB bootloader and to see the output
321     serial output of the machine. The default value is `/dev/ttyUSB0`.
322
323 See also __\--iprelay__.
324
325 ## Termination phase
326
327 Daemons that were spwned (`dhcpd` and `tftpd`) are killed here.
328
329 # NOVABOOT SCRIPT SYNTAX
330
331 The syntax tries to mimic POSIX shell syntax. The syntax is defined with the following rules.
332
333 Lines starting with "\#" are ignored.
334
335 Lines that end with "\\" are concatenated with the following line after
336 removal of the final "\\" and leading whitespace of the following line.
337
338 Lines in the form _VARIABLE=..._ (i.e. matching '^\[A-Z\_\]+=' regular
339 expression) assign values to internal variables. See VARIABLES
340 section.
341
342 Otherwise, the first word on the line represents the filename
343 (relative to the build directory (see __\--build-dir__) of the module to
344 load and the remaining words are passed as the command line
345 parameters.
346
347 When the line ends with "<<WORD" then the subsequent lines until the
348 line containing only WORD are copied literally to the file named on
349 that line.
350
351 When the line ends with "< CMD" the command CMD is executed with
352 `/bin/sh` and its standard output is stored in the file named on that
353 line. The SRCDIR variable in CMD's environment is set to the absolute
354 path of the directory containing the interpreted novaboot script.
355
356 Example:
357   \#!/usr/bin/env novaboot
358   WVDESC=Example program
359   bin/apps/sigma0.nul S0\_DEFAULT script\_start:1,1 \\
360     verbose hostkeyb:0,0x60,1,12,2
361   bin/apps/hello.nul
362   hello.nulconfig <<EOF
363   sigma0::mem:16 name::/s0/log name::/s0/timer name::/s0/fs/rom ||
364   rom://bin/apps/hello.nul
365   EOF
366
367 This example will load three modules: sigma0.nul, hello.nul and
368 hello.nulconfig. sigma0 gets some command line parameters and
369 hello.nulconfig file is generated on the fly from the lines between
370 <<EOF and EOF.
371
372 ## VARIABLES
373
374 The following variables are interpreted in the novaboot script:
375
376 - WVDESC
377
378     Description of the wvtest-compliant program.
379
380 - WVTEST\_TIMEOUT
381
382     The timeout in seconds for WvTest harness. If no complete line appears
383     in the test output within the time specified here, the test fails. It
384     is necessary to specify this for long running tests that produce no
385     intermediate output.
386
387 - QEMU
388
389     Use a specific qemu binary (can be overriden with __\-Q__) and flags
390     when booting this script under qemu. If QEMU\_FLAGS variable is also
391     specified flags specified in QEMU variable are replaced by those in
392     QEMU\_FLAGS.
393
394 - QEMU\_FLAGS
395
396     Use specific qemu flags (can be overriden with __\-q__).
397
398 - HYPERVISOR\_PARAMS
399
400     Parameters passed to hypervisor. The default value is "serial", unless
401     overriden in configuration file.
402
403 - KERNEL
404
405     The kernel to use instead of NOVA hypervisor specified in the
406     configuration file. The value should contain the name of the kernel
407     image as well as its command line parameters. If this variable is
408     defined and non-empty, the variable HYPERVISOR\_PARAMS is not used.
409
410 # CONFIGURATION FILE
411
412 Novaboot can read its configuration from a file. Configuration file
413 was necessary in early days of novaboot. Nowadays, an attempt is made
414 to not use the configuration file because it makes certain novaboot
415 scripts unusable on systems without (or with different) configuration
416 file. The only recommended use of the configuration file is to specify
417 custom\_options (see bellow).
418
419 If you decide to use the configuration file, it is looked up, by
420 default, in files named `.novaboot` as described in ["Configuration reading phase"](#Configuration reading phase). Alternatively, its location can be specified with the
421 __\-c__ switch or with the NOVABOOT\_CONFIG environment variable. The
422 configuration file has perl syntax and should set values of certain
423 Perl variables. The current configuration can be dumped with the
424 __\--dump-config__ switch. Some configuration variables can be overriden
425 by environment variables (see below) or by command line switches.
426
427 Documentation of some configuration variables follows:
428
429 - @chainloaders
430
431     Custom chainloaders to load before hypervisor and files specified in
432     novaboot script. E.g. ('bin/boot/bender promisc', 'bin/boot/zapp').
433
434 - %targets
435
436     Hash of shortcuts to be used with the __\--target__ option. If the hash
437     contains, for instance, the following pair of values
438
439         'mybox' => '--server=boot:/tftproot --serial=/dev/ttyUSB0 --grub',
440
441     then the following two commands are equivalent:
442
443         ./script --server=boot:/tftproot --serial=/dev/ttyUSB0 --grub
444         ./script -t mybox
445
446 # ENVIRONMENT VARIABLES
447
448 Some options can be specified not only via config file or command line
449 but also through environment variables. Environment variables override
450 the values from configuration file and command line parameters
451 override the environment variables.
452
453 - NOVABOOT\_CONFIG
454
455     Name of the novaboot configuration file to use instead of the default
456     one(s).
457
458 - NOVABOOT\_BENDER
459
460     Defining this variable has the same meaning as __\--bender__ option.
461
462 # AUTHORS
463
464 Michal Sojka <sojka@os.inf.tu-dresden.de>