Operations | Qt Installer Framework Manual

Qt Installer Framework Manual | Operations

Component Scripting ◦ Tools

# Operations

The operations are prepared by component and controller scripts and performed by the installer.

Note: Operations are performed threaded.

Internally, each operation has a DO step that contains instructions for the installer and an UNDO step that contains instructions for the uninstaller.

## Summary of Operations

The following table summarizes the available operations and their syntax.

Operation | Syntax | Use
--- | --- | ---
Copy | "Copy" `source` `target` | Copies a file from `source` to `target`.
Move | "Move" `source` `target` | Moves a file from `source` to `target`.
SimpleMoveFile | "SimpleMoveFile" `source` `target` | Moves a file from `source` to `target`.
Delete | "Delete" `filename` | Deletes the file specified by `filename`.
Mkdir | "Mkdir" `path` | Creates the directory path `path`.
Rmdir | "Rmdir" `path` | Removes the directory path `path`.
CopyDirectory | "CopyDirectory" `sourcePath` `targetPath` | Copies a directory from `sourcePath` to `targetPath`.
AppendFile | "AppendFile" `filename` `text` | Appends `text` to the file specified by `filename`. `text` is treated as ASCII text.
PrependFile | "PrependFile" `filename` `text` | Prepends `text` to the file specified by `filename`. `text` is treated as ASCII text.
Replace | "Replace" `file` `search` replace | Opens `file` to find `search` string and replaces that with the `replace` string.
LineReplace | "LineReplace" `file` `search` `replace` | Opens `file` to find lines that start with `search` string and replaces that with the `replace` string. Lines are trimmed before the search.

Execute

"Execute" [{`exitcodes`}] `command` [`parameter1` [`parameter...` [`parameter10`]]]

Executes the command specified by `command`. Up to 10 parameters can be passed. If that is not enough, you can use a JavaScript string array.

Optionally, you can pass a comma-separated list of exit codes within curly brackets ({}) as the first argument to specify the exit codes for successful execution. This defaults to "{0}".

Other optional named arguments are: "workingdirectory=<your_working_dir>"; "errormessage=<your_custom_errormessage>"

In addition, a special argument, UNDOEXECUTE, separates the DO step of the operation from the UNDO step.

Example: `component.addOperation("Execute", "touch", "test.txt", "UNDOEXECUTE", "rm", "test.txt")`

CreateShortcut | "CreateShortcut" `filename` `linkname` [`arguments`] | Creates a shortcut from the file specified by `filename` to `linkname`. On Windows, this creates a .lnk file which can have `arguments`. Furthermore, on Windows, `filename` can be an HTTP or FTP URL in which case a URL shortcut is created. On Unix, this creates a symbolic link.

CreateDesktopEntry

"CreateDesktopEntry" `filename "key=value[ key2=value2[ key3=value3]]]"`

Creates a .desktop initialization file, as specified by freedesktop.org.

If `filename` is absolute, the desktop entry is stored there. Otherwise, it is stored in the location specified in `$XDG_DATA_DIRS/applications` or `$XDG_DATA_HOME/applications`, including the default paths for both, as defined by freedesktop.org.

The key-value pairs are written to the file.

The file is set to use UTF-8 encoding.

InstallIcons | "InstallIcons" `directory` `[Vendorprefix]` | Installs the contents of `directory` into a location, as specified by freedesktop.org. That is, into `$XDG_DATA_DIRS/icons`, `/usr/share/icons`, or `$HOME/.icons`. The files are removed from their initial location. Make sure to add this operation after the operation that extracts the files from the archive. If you provide a `Vendorprefix` it replaces all characters up to the first dash (-) in the filename of the icon with this prefix.
Extract | "Extract" `archive` `targetdirectory` | Extracts `archive` to `targetdirectory`.

GlobalConfig

"GlobalConfig" `company` `application` `key` `value`

or

"GlobalConfig" `scope` `company` `application` `key` `value`

or

"GlobalConfig" `filename` `key` `value`

Stores `value` for `key` in a configuration file. The configuration file is specified either by `filename` (using `QSettings::NativeFormat`, which might be the Windows registry) or by `application` and `company` name. Set `scope` to "SystemScope" to create an entry in the system scope.

Note: The operation is using QSettings to store the key value pair. QSettings always treats backslash as a special character and provides no API for reading or writing such entries. Do not use slashes ('/' and '') in section or key names; the backslash character is used to separate sub keys. On windows, '' are converted by QSettings to '/', which makes them identical. Because the backslash character is used by QSettings to separate sub keys, you cannot read or write windows registry entries that contain slashes or backslashes. You should use a native windows API if you need to do so.

EnvironmentVariable | "EnvironmentVariable" `key` `value` [`persistent` [`system`]] | Sets the environment variable `key` to `value`. If `persistent` is set to `true`, the variable is set persistently. This is currently only supported on Windows. If `system` is set to `true`, the persistent variable is set system-wide, not only for the current user.
RegisterFileType | "RegisterFileType" `extension` `command` [`description` [`contentType` [`icon`]]]. | Registers the file type with `extension` to be opened via `command`. Optionally, you can specify `description`, `contentType`, and `icon`. This is currently only supported on Windows.
ConsumeOutput | "ConsumeOutput" `installerKeyName` `executablePath` `processArguments` | Saves the output from running the executable located at `executablePath` with the arguments `processArguments` to the installer key specified by `installerKeyName`. Additional arguments can be passed.
CreateLink | "CreateLink" `linkPath` `targetPath` | Creates a link from the location specified by `linkPath` to the location specified by `targetPath`.
CreateLocalRepository | "CreateLocalRepository" `binaryPath` `repoPath` | Creates a local repository in the directory specified by `repoPath`. For offline installers, stores binary data in the directory specified by `binaryPath`.
FakeStopProcessForUpdate | "FakeStopProcessForUpdate" `processlist` | Matches running processes against the comma-separated entries in `processlist` during uninstallation. If matches are found, shows a messagebox asking the user to stop those processes before continuing.
License | "License" `licenses` | Copies the license files specified by `licenses` to a subfolder called `Licenses` in the target directory. This operation is automatically added for packages declaring `<Licenses>` in their package description file.
MinimumProgress | "MinimumProgress" | Increases the progress value by one.
SelfRestart | "SelfRestart" `core` | Restarts the updater or package manager specified by `core`.
Settings | "Settings" `path` `method` `key` `aValue` | Sets or removes the value `aValue` of `key` in the settings file or registry located at `path`, depending on the value of `method`: `set`, `remove`, `add_array_value`, and `remove_array_value`.

The Extract, License, and MinimumProgress operations are automatically added for matching components that do not overwrite the component::createOperations() method. See also component::autoCreateOperations.

If errors occur, you can test operations manually using the `devtool`. However, variables are not resolved, so you need to use absolute values.

For example, to test copying a file:

      devtool --operation DO,Copy,<source>,<target>

Component Scripting ◦ Tools