Robo System Package Tasks
, (*1)
Collection of tasks for interacting with system package managers., (*2)
Requirements
-
Robo ~0.5 (0.5.0 or higher)
Installation
Add the falc/robo-system-package package to your composer.json:, (*3)
composer require falc/robo-system-package
Add the Falc\Robo\Package\loadTasks trait to your RoboFile:, (*4)
class RoboFile extends \Robo\Tasks
{
use Falc\Robo\Package\loadTasks;
// ...
}
Tasks
Install
Installing a single package:, (*5)
$this->taskPackageInstall()
->packageManager('yum')
->package('package1')
->run();
Installing many packages:, (*6)
$this->taskPackageInstall()
->packageManager('yum')
->packages(['package1', 'package2'])
->run();
Compact form:, (*7)
$this->taskPackageInstall('yum', ['package1', 'package2'])->run();
It allows to specify packages conditionally:, (*8)
$install = $this->taskPackageInstall('yum', ['package1']);
if ($requiresPackage2) {
$install->package('package2');
}
$install->run();
It is possible to specify a pattern:, (*9)
$this->taskPackageInstall()
->packageManager('yum')
->package('package1-*') // Installs all packages starting with "package1-"
->run();
You can combine it with taskSshExec() to install packages in a remote server:, (*10)
$installTask = $this->taskPackageInstall()
->packageManager('yum')
->packages(['package1', 'package2']);
$this->taskSshExec('remote.example.com')
->remoteDir('/home/user')
->printed(false) // Do not display output
->exec($installTask)
->run();
Uninstall
Uninstalling a single package:, (*11)
$this->taskPackageUninstall()
->packageManager('yum')
->package('package1')
->run();
Uninstalling many packages:, (*12)
$this->taskPackageUninstall()
->packageManager('yum')
->packages(['package1', 'package2'])
->run();
Compact form:, (*13)
$this->taskPackageUninstall('yum', ['package1', 'package2'])->run();
It is possible to specify a pattern:, (*14)
$this->taskPackageUninstall()
->packageManager('yum')
->package('package1-*') // Uninstalls all packages starting with "package1-"
->run();
You can combine it with taskSshExec() to uninstall packages from a remote server:, (*15)
$uninstallTask = $this->taskPackageUninstall()
->packageManager('yum')
->packages(['package1', 'package2']);
$this->taskSshExec('remote.example.com')
->remoteDir('/home/user')
->printed(false) // Do not display output
->exec($uninstallTask)
->run();
Update
Updating a single package:, (*16)
$this->taskPackageUpdate()
->packageManager('yum')
->package('package1')
->run();
Updating many packages:, (*17)
$this->taskPackageUpdate()
->packageManager('yum')
->packages(['package1', 'package2'])
->run();
Do not specify any package in order to perform a full update:, (*18)
$this->taskPackageUpdate()
->packageManager('yum')
->run();
Compact form:, (*19)
// Update some packages
$this->taskPackageUpdate('yum', ['package1', 'package2'])->run();
// Update everything
$this->taskPackageUpdate('yum')->run();
It is possible to specify a pattern:, (*20)
$this->taskPackageUpdate()
->packageManager('yum')
->package('package1-*') // Updates all packages starting with "package1-"
->run();
You can combine it with taskSshExec() to update packages in a remote server:, (*21)
$updateTask = $this->taskPackageUpdate()
->packageManager('yum')
->packages(['package1', 'package2']);
$this->taskSshExec('remote.example.com')
->remoteDir('/home/user')
->printed(false) // Do not display output
->exec($updateTask)
->run();
Methods
All the tasks implement these methods:
* packageManager($packageManager): Sets the package manager to use.
* package(): Adds a package to the package list.
* packages(): Adds packages to the package list.
* verbose(): Enables the verbose mode., (*22)
Package managers
Every task requires to set a package manager either in the constructor or using the packageManager($packageManager) method., (*23)
At the moment these are the supported package managers:
* apt
* dnf
* pacman
* yum, (*24)