2017-08-02 14:53:00 +02:00
|
|
|
# Calamares modules
|
|
|
|
|
|
|
|
Calamares modules are plugins that provide features like installer pages,
|
|
|
|
batch jobs, etc. An installer page (visible to the user) is called a "view",
|
|
|
|
while other modules are "jobs".
|
2014-06-11 13:37:10 +02:00
|
|
|
|
2014-08-06 15:50:39 +02:00
|
|
|
Each Calamares module lives in its own directory.
|
|
|
|
|
|
|
|
All modules are installed in `$DESTDIR/lib/calamares/modules`.
|
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
There are two **types** of Calamares module:
|
2017-08-02 14:53:00 +02:00
|
|
|
* viewmodule, for user-visible modules. These may be in C++, or PythonQt.
|
|
|
|
* jobmodule, for not-user-visible modules. These may be done in C++,
|
|
|
|
Python, or as external processes.
|
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
A viewmodule exposes a UI to the user. The PythonQt-based modules
|
|
|
|
are considered experimental (and as of march 2019 may be on the
|
|
|
|
way out again as never-used-much and PythonQt is not packaged
|
|
|
|
on Debian anymore).
|
2014-08-06 15:50:39 +02:00
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
There are three (four) **interfaces** for Calamares modules:
|
2019-03-11 17:10:34 +01:00
|
|
|
* qtplugin (viewmodules, jobmodules),
|
2017-08-02 14:53:00 +02:00
|
|
|
* python (jobmodules only),
|
2019-03-11 17:10:34 +01:00
|
|
|
* pythonqt (viewmodules, jobmodules, optional),
|
2017-08-02 14:53:00 +02:00
|
|
|
* process (jobmodules only).
|
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
## Module directory
|
2017-08-02 14:53:00 +02:00
|
|
|
|
|
|
|
Each Calamares module lives in its own directory. The contents
|
|
|
|
of the directory depend on the interface and type of the module.
|
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
### Module descriptor
|
2014-08-06 15:50:39 +02:00
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
A Calamares module must have a *module descriptor file*, named
|
|
|
|
`module.desc`. For C++ (qtplugin) modules using CMake as a build-
|
|
|
|
system and using the calamares_add_plugin() function -- this is the
|
|
|
|
recommended way to create such modules -- the module descriptor
|
|
|
|
file is optional, since it can be generated by the build system.
|
|
|
|
For other module interfaces, the module descriptor file is required.
|
|
|
|
|
|
|
|
The module descriptor file must be placed in the module's directory.
|
|
|
|
The module descriptor file is a YAML 1.2 document which defines the
|
|
|
|
module's name, type, interface and possibly other properties. The name
|
|
|
|
of the module as defined in `module.desc` must be the same as the name
|
|
|
|
of the module's directory.
|
|
|
|
|
2018-06-15 13:11:17 +02:00
|
|
|
Module descriptors **must** have the following keys:
|
2017-08-08 22:45:09 +02:00
|
|
|
- *name* (an identifier; must be the same as the directory name)
|
|
|
|
- *type* ("job" or "view")
|
|
|
|
- *interface* (see below for the different interfaces; generally we
|
|
|
|
refer to the kinds of modules by their interface)
|
|
|
|
|
2019-03-11 22:04:47 +01:00
|
|
|
Module descriptors for Python and PythonQt modules **must** have the following key:
|
|
|
|
- *script* (the name of the Python script to load, nearly always `main.py`)
|
|
|
|
|
2018-06-15 13:11:17 +02:00
|
|
|
Module descriptors **may** have the following keys:
|
2019-03-11 21:59:00 +01:00
|
|
|
- *requiredModules* (a list of modules which are required for this module
|
2018-06-15 13:11:17 +02:00
|
|
|
to operate properly)
|
|
|
|
- *emergency* (a boolean value, set to true to mark the module
|
|
|
|
as an emergency module)
|
|
|
|
|
2019-03-11 21:59:00 +01:00
|
|
|
### Required Modules
|
|
|
|
|
|
|
|
A module may list zero (if it has no requirements) or more modules
|
|
|
|
by name. As modules are loaded from the global sequence in `settings.conf`,
|
|
|
|
each module is checked that all of the modules it requires are
|
|
|
|
already loaded before it. This ensures that if a module needs
|
|
|
|
another one to fill in globalstorage keys, that happens before
|
|
|
|
it needs those keys.
|
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
### Emergency Modules
|
|
|
|
|
|
|
|
Only C++ modules and job modules may be emergency modules. If, during an
|
|
|
|
*exec* step in the sequence, a module fails, installation as a whole fails
|
|
|
|
and the install is aborted. If there are emergency modules in the **same**
|
|
|
|
exec block, those will be executed before the installation is aborted.
|
|
|
|
Non-emergency modules are not executed.
|
|
|
|
|
|
|
|
If an emergency-module fails while processing emergency-modules for
|
|
|
|
another failed module, that failure is ignored and emergency-module
|
|
|
|
processing continues.
|
|
|
|
|
|
|
|
Use the EMERGENCY keyword in the CMake description of a C++ module
|
|
|
|
to generate a suitable `module.desc`.
|
|
|
|
|
|
|
|
A module that is marked as an emergency module in its module.desc
|
|
|
|
must **also** set the *emergency* key to *true* in its configuration file
|
|
|
|
(see below). If it does not, the module is not considered to be an emergency
|
|
|
|
module after all (this is so that you can have modules that have several
|
|
|
|
instances, only some of which are actually needed for emergencies).
|
|
|
|
|
|
|
|
### Module-specific configuration
|
2017-08-02 14:53:00 +02:00
|
|
|
|
2018-06-15 13:11:17 +02:00
|
|
|
A Calamares module **may** read a module configuration file,
|
2017-08-02 14:53:00 +02:00
|
|
|
named `<modulename>.conf`. If such a file is present in the
|
2019-03-11 17:10:34 +01:00
|
|
|
module's directory, it can be shipped as a *default* configuration file.
|
|
|
|
This only happens if the CMake-time option `INSTALL_CONFIG` is on.
|
|
|
|
|
|
|
|
The sample configuration files may work and may be suitable for
|
|
|
|
your distribution, but no guarantee is given about their stability
|
|
|
|
beyond syntactic correctness.
|
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
The module configuration file, if it exists, is a YAML 1.2 document
|
|
|
|
which contains a YAML map of anything.
|
|
|
|
|
2019-03-11 17:10:34 +01:00
|
|
|
All sample module configuration files are installed in
|
2017-08-02 14:53:00 +02:00
|
|
|
`$DESTDIR/share/calamares/modules` but can be overridden by
|
|
|
|
files with the same name placed manually (or by the packager)
|
|
|
|
in `/etc/calamares/modules`.
|
2014-07-16 17:08:05 +02:00
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
|
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
## C++ modules
|
2014-07-16 17:08:05 +02:00
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
Currently the recommended way to write a module which exposes one or more
|
|
|
|
installer pages (viewmodule) is through a C++ and Qt plugin. Viewmodules must
|
|
|
|
implement `Calamares::ViewStep`. They can also implement `Calamares::Job`
|
|
|
|
to provide jobs.
|
2014-07-16 17:08:05 +02:00
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
To add a Qt plugin module, put it in a subdirectory and make sure it has
|
|
|
|
a `CMakeLists.txt` with a `calamares_add_plugin` call. It will be picked
|
|
|
|
up automatically by our CMake magic. The `module.desc` file is optional.
|
2014-07-16 17:08:05 +02:00
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
|
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
## Python modules
|
2014-07-16 17:08:05 +02:00
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
Modules may use one of the python interfaces, which may be present
|
|
|
|
in a Calamares installation (but also may not be). These modules must have
|
|
|
|
a `module.desc` file. The Python script must implement one or more of the
|
|
|
|
Python interfaces for Calamares -- either the python jobmodule interface,
|
|
|
|
or the experimental pythonqt job- and viewmodule interfaces.
|
2014-07-16 17:08:05 +02:00
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
To add a Python or process jobmodule, put it in a subdirectory and make sure
|
|
|
|
it has a `module.desc`. It will be picked up automatically by our CMake magic.
|
2017-08-08 22:45:09 +02:00
|
|
|
For all kinds of Python jobs, the key *script* must be set to the name of
|
2019-03-11 22:04:47 +01:00
|
|
|
the main python file for the job. This is almost universally `main.py`.
|
2014-08-06 15:50:39 +02:00
|
|
|
|
|
|
|
`CMakeLists.txt` is *not* used for Python and process jobmodules.
|
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
Calamares offers a Python API for module developers, the core Calamares
|
|
|
|
functionality is exposed as `libcalamares.job` for job data,
|
|
|
|
`libcalamares.globalstorage` for shared data and `libcalamares.utils` for
|
|
|
|
generic utility functions. Documentation is inline.
|
|
|
|
|
|
|
|
All code in Python job modules must obey PEP8, the only exception are
|
|
|
|
`libcalamares.globalstorage` keys, which should always be
|
|
|
|
camelCaseWithLowerCaseInitial to match the C++ identifier convention.
|
|
|
|
|
|
|
|
For testing and debugging we provide the `testmodule.py` script which
|
|
|
|
fakes a limited Calamares Python environment for running a single jobmodule.
|
|
|
|
|
|
|
|
### Python Jobmodule
|
|
|
|
|
|
|
|
A Python jobmodule is a Python program which imports libcalamares and has a
|
|
|
|
function `run()` as entry point. The function `run()` must return `None` if
|
|
|
|
everything went well, or a tuple `(str,str)` with an error message and
|
|
|
|
description if something went wrong.
|
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
### Python API
|
|
|
|
|
|
|
|
**TODO:** this needs documentation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## PythonQt modules
|
|
|
|
|
|
|
|
The PythonQt modules are considered experimental and may be removed again
|
|
|
|
due to low uptake. Their documentation is also almost completely lacking.
|
|
|
|
|
2017-08-02 14:53:00 +02:00
|
|
|
### PythonQt Jobmodule
|
|
|
|
|
|
|
|
A PythonQt jobmodule implements the experimental Job interface by defining
|
|
|
|
a subclass of something.
|
|
|
|
|
|
|
|
### PythonQt Viewmodule
|
|
|
|
|
|
|
|
A PythonQt viewmodule implements the experimental View interface by defining
|
|
|
|
a subclass of something.
|
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
### Python API
|
2014-08-06 15:50:39 +02:00
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
**TODO:** this needs documentation
|
2014-07-29 14:40:56 +02:00
|
|
|
|
2018-06-15 13:11:17 +02:00
|
|
|
|
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
## Process jobmodules
|
2018-06-15 13:11:17 +02:00
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
A process jobmodule runs a (single) command. The interface is *process*,
|
|
|
|
while the module type must be *job* or *jobmodule*.
|
2018-06-15 15:32:19 +02:00
|
|
|
|
2019-03-11 21:52:06 +01:00
|
|
|
The module-descriptor key *command* should have a string as value, which is
|
|
|
|
passed to the shell -- remember to quote it properly. It is generally
|
|
|
|
recommended to use a *shellprocess* job module instead (less configuration,
|
|
|
|
easier to have multiple instances).
|