/RoboSystemPackage

Robo tasks related to system package management

Primary LanguagePHPMIT LicenseMIT

Robo System Package Tasks

License Build Status Coverage Status Quality Score

Collection of tasks for interacting with system package managers.

Requirements

  • Robo ~0.5 (0.5.0 or higher)

Installation

Add the falc/robo-system-package package to your composer.json:

composer require falc/robo-system-package

Add the Falc\Robo\Package\loadTasks trait to your RoboFile:

class RoboFile extends \Robo\Tasks
{
    use Falc\Robo\Package\loadTasks;

    // ...
}

Tasks

Install

Installing a single package:

$this->taskPackageInstall()
    ->packageManager('yum')
    ->package('package1')
    ->run();

Installing many packages:

$this->taskPackageInstall()
    ->packageManager('yum')
    ->packages(['package1', 'package2'])
    ->run();

Compact form:

$this->taskPackageInstall('yum', ['package1', 'package2'])->run();

It allows to specify packages conditionally:

$install = $this->taskPackageInstall('yum', ['package1']);

if ($requiresPackage2) {
    $install->package('package2');
}

$install->run();

It is possible to specify a pattern:

$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:

$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:

$this->taskPackageUninstall()
    ->packageManager('yum')
    ->package('package1')
    ->run();

Uninstalling many packages:

$this->taskPackageUninstall()
    ->packageManager('yum')
    ->packages(['package1', 'package2'])
    ->run();

Compact form:

$this->taskPackageUninstall('yum', ['package1', 'package2'])->run();

It is possible to specify a pattern:

$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:

$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:

$this->taskPackageUpdate()
    ->packageManager('yum')
    ->package('package1')
    ->run();

Updating many packages:

$this->taskPackageUpdate()
    ->packageManager('yum')
    ->packages(['package1', 'package2'])
    ->run();

Do not specify any package in order to perform a full update:

$this->taskPackageUpdate()
    ->packageManager('yum')
    ->run();

Compact form:

// Update some packages
$this->taskPackageUpdate('yum', ['package1', 'package2'])->run();

// Update everything
$this->taskPackageUpdate('yum')->run();

It is possible to specify a pattern:

$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:

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

Package managers

Every task requires to set a package manager either in the constructor or using the packageManager($packageManager) method.

At the moment these are the supported package managers: