New feature : boolean variables and expressions

Stéphane Peter megastep at
Wed Mar 29 19:20:49 EST 2006

I have just committed a big patch I have been working on for the past  
couple of days. This new features allows the creation of user-defined  
boolean variables from within installer files, which can be  
referenced with a simple evaluation language to create complex  
conditional expressions.

Basically this allows for very fine-grained control over what files  
get installed. My main motivation for this at first was to have an  
easy way to automatically install GTK 1.x or 2.x binaries. This  
system is advanced enough to make the previous "arch", glibc, etc.  
filters obsolete.

I'll just post here the relevant entry from README.xml :

The BOOL element :

This element allows the user to create some complex expressions to  
guide the
installer. This element allows the user to define boolean conditions,  
the values of
which are defined by arbritrary scripts. These booleans can then be  
used as part
of expressions used by other elements, like FILE or BINARY below, to  
define conditions.

This element must be a direct child of the root INSTALL element.  
Booleans are global
to a particular instance of the installer. Additionally, the  
installer itself defines
a set of standard booleans, as described below.

Booleans are intended to replace the previous filtering mechanisms,  
using "arch", "libc"
and so on attributes, while providing additional flexibility.

Booleans are case sensitive.

The BOOL element takes one mandatory attribute :

   name      The symbolic name for the boolean (variable name). May  
be up to 30 characters
             long, and must start with an alphanumerical character.  
May not contain blank

Additionally, one of the following attributes must be used :

   script    The command to be run to determine the value of the  
boolean. In the UNIX
             tradition, it should return 0 for a TRUE value.

   envvar    The name of an environment variable to query for the  
value of the boolean.
             The value must be a non-zero number to map to be TRUE.  
If the variable is not
             set in the environment, the boolean will likewise be set  

It also recognizes two optional attributes :

   later     If set to "yes", the script will be executed at the time  
that the condition
             referencing it is evaluated. The default is to run the  
script once immediately
             upon initialization to gather the static value.

   if        Additionally make this boolean dependent on another  
boolean expression. This
             expression can reference any previously defined boolean.  
See below for more details
             about the syntax. If this expression evaluates to FALSE,  
then the script won't be
             run, or the environment queried, and the value will also  
be set to FALSE.

Standard booleans defined by the installer :
- Standard 'true' and 'false' booleans.
- 'is-root' is TRUE if the installer is running as root.
- 'reinstalling' is TRUE if the product is already installed.
- 'bzip2' is TRUE if Bzip2 decompression is available in the installer.
- One boolean corresponding to the selected user interface: gtk1,  
gtk2, carbon, dialog, console
- One boolean for the CPU architecture: x86, ppc, sparc, alpha, etc
- One boolean for the detected libc version: libc5, glibc-2.1, etc.
- One boolean for the distribution / OS name : redhat, suse, aix,  
sco, etc.
- A boolean for the OS name as returned by uname.
- Two booleans representing the detection distribution version (not  
always meaningful) :
    distro-major-<number> and distro-minor-<number>.
= Booleans for the detected locale setting and its encoding, e.g.  
en_US, ISO-8859-1, etc.
- On Linux, 'selinux' indicates whether SELinux is available and  
- If RPM support was compiled in, 'rpm-support' is set. If RPM 3.x,  
then 'rpm3-support' is
   also set to TRUE.

For example, on a Redhat Linux 7.3 sytem, the following bools would  
be defined to TRUE :
Linux, x86, redhat, distro-major-7, distro-minor-3

About Boolean Expressions :

Many elements support the 'if' or 'condition' attribute to reference  
complex expressions
using the Setup boolean variables. The expressions have to follow the  
following syntax:

expression := [!]<operator>(<expression1>,<expression2>) |
               [!]<boolean name>

Supported operators are : + (logical "and"), | (logical "or"), and ^  
(logical "exclusive or").
Any expression can be negated by a ! prefix.
An undefined boolean is the same as a false boolean.

Some examples :

Match Fedora on PowerPC system:
Match one of SuSE, Redhat 9 or Fedora, on all but Intel:

Stéphane Peter
megastep at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Lokisetup mailing list