calamares/src/modules
Adriaan de Groot 4ae484dbca [netinstall] Initial work for configurable sidebar label
- Now that multiple netinstall pages may be supported, it's annoying
  that they all have the same name. Copy the approach from other
  modules (e.g. notesQML) of having the sidebar and other labels
  configured in the config file.
2020-02-18 17:46:56 +01:00
..
bootloader [bootloader] Fix sb-shim mode to write grub.cfg into the ESP 2019-05-12 16:11:35 +02:00
contextualprocess CMake: give yamlcpp a proper imported target 2020-02-17 14:55:12 +01:00
displaymanager [displaymanager] Treat openSUSE sysconfig like anything else 2019-10-07 17:04:10 +02:00
dracut [dracut] [fstab] Translate module names and error messages 2019-04-19 17:08:53 +02:00
dracutlukscfg [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
dummycpp [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
dummyprocess [dummyprocess] Add some delay in the dummy 2019-06-17 15:53:02 +02:00
dummypython [modules] Minor documentation work on modules a-g 2018-06-26 05:47:23 -04:00
dummypythonqt i18n: [dummypythonqt] Automatic merge of Transifex translations 2020-02-04 22:19:48 +01:00
finished [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
fsresizer CMake: give yamlcpp a proper imported target 2020-02-17 14:55:12 +01:00
fstab [fstab] Tighten up the *efiMountOptions* documentation 2019-08-02 09:27:54 +02:00
grubcfg [grubcfg] HOTFIX typo in function call 2019-11-30 21:46:45 +01:00
hostinfo CMake: give yamlcpp a proper imported target 2020-02-17 14:55:12 +01:00
hwclock Modules: set noconfig:true on Python modules 2020-01-24 23:10:41 +01:00
initcpio CMake: give yamlcpp a proper imported target 2020-02-17 14:55:12 +01:00
initcpiocfg Merge pull request #1291 from calamares/initcpiocfg-usr 2020-01-06 14:41:24 +01:00
initramfs Merge branch 'better-hostname' 2020-02-17 17:10:21 +01:00
initramfscfg Modules: set noconfig:true on Python modules 2020-01-24 23:10:41 +01:00
interactiveterminal [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
keyboard [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
license [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
locale CMake: give yamlcpp a proper imported target 2020-02-17 14:55:12 +01:00
localecfg Modules: set noconfig:true on Python modules 2020-01-24 23:10:41 +01:00
luksbootkeyfile [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
luksopenswaphookcfg Modules: Improve error reporting 2019-04-28 14:34:39 -04:00
machineid Merge branch 'better-hostname' 2020-02-17 17:10:21 +01:00
mount [mount] Add docstrings to methods 2019-08-19 06:31:37 -04:00
netinstall [netinstall] Initial work for configurable sidebar label 2020-02-18 17:46:56 +01:00
networkcfg Modules: set noconfig:true on Python modules 2020-01-24 23:10:41 +01:00
notesqml [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
oemid [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
openrcdmcryptcfg Modules: Improve error reporting 2019-04-28 14:43:39 -04:00
packagechooser CMake: Allow extra libraries in calamares_add_test 2020-02-17 14:36:52 +01:00
packages [packages] Log unfamiliar package operations 2020-02-18 12:02:16 +01:00
partition CMake: Allow extra libraries in calamares_add_test 2020-02-17 14:36:52 +01:00
plasmalnf [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
plymouthcfg [modules] Enable translations on some Python modules 2019-02-14 15:30:48 +01:00
preservefiles [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
rawfs Modules: Improve error reporting 2019-04-28 14:43:39 -04:00
removeuser [modules] Enable translations on some Python modules 2019-02-14 15:30:48 +01:00
services-openrc [services-*] Fix translations 2019-02-18 06:27:36 -05:00
services-systemd [services-*] Fix translations 2019-02-18 06:27:36 -05:00
shellprocess CMake: give yamlcpp a proper imported target 2020-02-17 14:55:12 +01:00
summary [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
tracking [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
umount [umount]: Fix default srcLog in umount.conf 2019-05-06 15:01:30 +02:00
unpackfs [unpackfs] Improve progress reporting 2020-01-20 19:39:05 +01:00
users [users] Document new knobs 2020-02-18 10:38:31 +01:00
webview [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
welcome [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
welcomeq [libcalamares] Merge PluginDllMacro.h into DllMacro.h 2020-02-17 11:37:35 +01:00
CMakeLists.txt CMake: chase introduction of IMPORTED yamlcpp 2020-02-17 15:01:05 +01:00
globalStorage.yaml Consistency: calamares_main ==> run; global_storage => globalStorage 2014-07-25 16:46:12 +02:00
README.md Docs: describe *noconfig* module option 2020-01-21 18:31:13 +01:00
test_conf.cpp [libcalamares] Rename YamlUtils.h 2019-04-29 06:14:21 -04:00
testmodule.py Documentation: change http links to GitHub to https 2017-12-20 08:39:09 -05:00
testpythonrun.sh Tests: add script for running multiple Python-module tests 2019-01-25 06:42:26 -05: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".

Each Calamares module lives in its own directory.

All modules are installed in $DESTDIR/lib/calamares/modules.

There are two types of Calamares module:

  • 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.

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).

There are three (four) interfaces for Calamares modules:

  • qtplugin (viewmodules, jobmodules),
  • python (jobmodules only),
  • pythonqt (viewmodules, jobmodules, optional),
  • process (jobmodules only).

Module directory

Each Calamares module lives in its own directory. The contents of the directory depend on the interface and type of the module.

Module descriptor

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.

Module descriptors must have the following keys:

  • 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)

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)

Module descriptors may have the following keys:

  • emergency (a boolean value, set to true to mark the module as an emergency module)
  • noconfig (a boolean value, set to true to state that the module has no configuration file; defaults to false)
  • requiredModules (a list of modules which are required for this module to operate properly)

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.

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

A Calamares module may read a module configuration file, named <modulename>.conf. If such a file is present in the module's directory, it can be shipped as a default configuration file. This only happens if the CMake-time option INSTALL_CONFIG is on.

Modules that have noconfig set to true will not attempt to read a configuration file, and will not warn that one is missing; conversely if noconfig is set to false (or is missing, since the default value is false) if there is no configuration file, a warning is printed during Calamares start-up.

The sample configuration files may work and may be suitable for your distribution, but no guarantee is given about their stability beyond syntactic correctness.

The module configuration file, if it exists, is a YAML 1.2 document which contains a YAML map of anything.

All sample module configuration files are installed in $DESTDIR/share/calamares/modules but can be overridden by files with the same name placed manually (or by the packager) in /etc/calamares/modules.

C++ modules

Type: viewmodule, jobmodule Interface: qtplugin

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.

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 not recommended: nearly all cases can be described in CMake.

Python modules

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.

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. For all kinds of Python jobs, the key script must be set to the name of the main python file for the job. This is almost universally main.py.

CMakeLists.txt is not used for Python and process jobmodules.

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

Type: jobmodule Interface: python

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.

Python API

TODO: this needs documentation

PythonQt modules

Type: viewmodule, jobmodule Interface: pythonqt

The PythonQt modules are considered experimental and may be removed again due to low uptake. Their documentation is also almost completely lacking.

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.

Python API

TODO: this needs documentation

Process jobmodules

Type: jobmodule Interface: process

A process jobmodule runs a (single) command. The interface is process, while the module type must be job or jobmodule.

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).