Configuration System
From RockWiki
Configuration System
Fundamentals
The configuration script ./scripts/Config
generates the files in the config/${config}/
directory:
config
the configuration options
packages
the packages which are build in this configuration
./scripts/Config
defines some special shell functions and contains the main-loop of the configuration program. The structure of the config menus is stored in scripts/config.in
(and other config.in
files included by it). Have a look at scripts/config.in
for more information on which file is including which other files.
Special Commands
Whenever the menu is displayed (i.e. after starting ./scripts/Config
and whenever a change has been made), scripts/config.in
is executed and is using the following special commands to write the 'config
' file and add items to the menu.
comment 'Description' ["Help"]
Add a comment to the config menu (an item without any function). E.g.:
comment '- Architecture, CPU and Optimisation' " Select which CPU optimalization is right for your machine."
<Description>
Title of the item in the config menu (comment text)
<Help>
This is an optional field where you can add a longer comment that will be displayed when you highlight this comment line and hit the Help button
comment_id 'Description' 'ID' ["Help"]
Add a comment to the config menu (an item without any function). E.g.:
comment '- Architecture, CPU and Optimisation' COMMENT_ARCH_CPU_OPT " Select which CPU optimalization is right for your machine."
<Description>
Title of the item in the config menu (comment text)
<ID>
ID which will be used to identify a comment. It is useful when you use config.hlp
files to store help
<Help>
This is an optional field where you can add a longer comment that will be displayed when you highlight this comment line and hit the Help button
bool 'Description' Variable Default ["Help"]
Add a bool (on/off) menu item. E.g.:
bool 'Abort when a package-build fails' ROCKCFG_ABORT_ON_ERROR 1 " When you select this option Build-Target will abort when a packet fails to compile"
<Description>
Title of the item in the config menu
<Variable>
Name of the config variable triggered by this menu item
<Default>
'1' = On, '0' = Off
<Help>
This is an optional field where you can add a longer comment that will be displayed when you highlight this item line and hit the Help button
The variable will be set to '1' or '0'.
text 'Description' Variable Default ["Help"]
Add a text menu item. If the text must fit a special pattern, modify the config variable __before__ calling the text function. E.g.:
ROCKCFG_MAKE_JOBS="`echo $ROCKCFG_MAKE_JOBS | sed 's,[^0-9],,g'`" text 'Number of parallel make jobs (make -j)' ROCKCFG_MAKE_JOBS 1
<Description>
Title of the item in the config menu
<Variable>
Name of the config variable triggered by this menu item
<Default>
Default value
<Help>
This is an optional field where you can add a longer comment that will be displayed when you highlight this item line and hit the Help button
choice Variable Default Value1 'Description1' [ ... ]
Add a multiple-choice menu item. E.g.:
choice ROCKCFG_INTEL_OPT generic \ generic "No special optimisation" \ i386 "Optimised for Intel 386" \ i486 "Optimised for Intel 486" \ i586 "Optimised for Intel Pentium" \ i686 "Optimised for Intel Pentium-Pro" \ k6 "Optimised for AMD K-6" \ k7 "Optimised for AMD Athlon"
<Variable>
Name of the config variable triggered by this menu item
<Default>
Default value
<ValueN>
Value for option N
<DescriptionN>
Title of the item in the config menu if option N is active
const Variable Default
Sets the given variable to the given default value without displaying any menu item.
block_begin
And block_end
A set of menu items which belongs together should be surrounded with block_begin
and block_end
. block_begin
expects a numeric parameter which specifies the number of characters the menu item titles should be shifted to the right. E.g.:
comment '--- Default compiler for building (almost) everything' block_begin 5 choice ROCKCFG_PKG_GCC_DEFAULT_CC gcc2 $list if [ $ROCKCFG_PKG_GCC_DEFAULT_CC = 'gcc2' ] ; then bool 'Use GCC Stack-Smashing Protector' ROCKCFG_PKG_GCC_STACKPRO 0 [ $ROCKCFG_PKG_GCC_STACKPRO = 1 ] && ROCKCFG_ID="$ROCKCFG_ID-stackprotector" else ROCKCFG_ID="$ROCKCFG_ID-$ROCKCFG_PKG_GCC_DEFAULT_CC" fi block_end
expert_begin
And expert_end
Options which should only be displayed if the 'expert mode' is active should be surrounded with expert_begin
and expert_end
.
Special Variables
ROCKCFG_*
All Configuration variables should start with "ROCKCFG_
". Non-core variables have extended prefixes:
Arches: ROCKCFG_ARCH_<Arch-Name>_*
Targets: ROCKCFG_TRG_<Target-Name>_*
Packages: ROCKCFG_PKG_<Pkg-Name>_*
Some variables are handled by ./scripts/Config
in a special way:
ROCKCFG_ID
Is the short-description of the configuration. Important config options should append something to this variable.
ROCKCFG_EXPERT
If set to '0', config items between expert_begin
and expert_end
will not be displayed and the default values for those options will be used.
ROCKCFGSET_*
The ROCKCFGSET_*
variables can be used to preset an option (e.g. in a target). If e.g. ROCKCFGSET_STRIP
is set to 1, ROCKCFG_STRIP
will have the value 1 when you start configuring this target. Note that these options can still be overwritten in scripts/Config
, they are merely different default values.
CFGTEMP_*
This variables can be used for data-exchange between the various config.in
files. Non-core variables have extended prefixes:
Arches: CFGTEMP_ARCH_<Arch-Name>_*
Targets: CFGTEMP_TRG_<Target-Name>_*
Packages: CFGTEMP_PKG_<Pkg-Name>_*
E.g. dynamic creation of a multiple-choice option:
architecture/intel/preconfig.in: CFGTEMP_ARCHLIST="$CFGTEMP_ARCHLIST intel IBM_PCs_and_compatible"
architecture/powerpc/preconfig.in: CFGTEMP_ARCHLIST="$CFGTEMP_ARCHLIST powerpc PowerPC_Workstations"
scripts/config.in: choice ROCKCFG_ARCH $ROCKCFG_ARCH $CFGTEMP_ARCHLIST
config.in
Call-Tree
All config.in
files are executed from scripts/config.in
in the following order:
- architecture/*/preconfig.in * Selecting Architecture * architecture/$ROCKCFG_ARCH/config.in
- target/*/preconfig.in - package/*/*/preconfig.in
* Selecting Target * target/$ROCKCFG_TARGET/config.in
* package/*/*/config.in * Various common build options
- package/*/*/postconfig.in - architecture/$ROCKCFG_ARCH/postconfig.in - target/$ROCKCFG_TARGET/postconfig.in
Only scripts marked with '{*
}' may interact with the user (create menu items). The others may only set and modify various variables.
Creation Of The packages
File
The ./scripts/Config
script creates a 'packages
' file with all packages available for the selected architecture before calling scripts/config.in
. Every config.in
file might now modify this packages
file by creating a packages.new
file and renaming it to packages
. E.g.:
if [ $ROCKCFG_TRG_GENERIC_BUILDSF != 1 ] ; then awk '$4 != "sourceforge" { print }' \ < config/$config.$swpid/packages \ > config/$config.$swpid/packages.new mv config/$config.$swpid/packages.new config/$config.$swpid/packages fi
The packages file is blank-separated and easy to parse with grep
, sed
and awk
. The fields are:
X/O
'X' = packages is active, 'O' = package is not active If you don't want another config.in
to re-activate a package you might also simply remove the line from the file.
Stages
Stage levels as specified in the packages [P]
tag (see next chapter)
Pri.
Priority as specified in the packages [P]
tag (sort-key for the file)
Rep.
Repository name where the package is found
Name
Package Name
Ver.
Package Version
Prefix
Package prefix (with leading '/')
Cat.
Package categories (always lower case, contain at least one /)
Flags
Package flags (always upper case)
Counter
Simply ignore that field
Because of the 'counter
' field, categories and flags are always pre- and postfixed with a ' '. So you can e.g. easy remove all not dietlibc-ready packages with a command like:
grep ' DIETLIBC ' < config/$config.$swpid/packages \ > config/$config.$swpid/packages.new
Read the existing config.in
files for details.