class SyncWrap::Arch

Arch Linux distro, partial implementation for pacman.

Public Instance Methods

dist_if_installed?( pkg, opts = {}, &block ) click to toggle source

Wrap block in a sudo bash conditional testing if the single specified pkg is installed.

# File lib/syncwrap/components/arch.rb, line 77
def dist_if_installed?( pkg, opts = {}, &block )
  sudo_if( "pacman -Q #{pkg} >/dev/null 2>&1", opts, &block )
end
dist_if_not_installed?( pkgs, chk = true, opts = {}, &block ) click to toggle source

If chk is true, then wrap block in a sudo bash conditional testing if any specified pkgs are not installed. Otherwise just yield to block.

# File lib/syncwrap/components/arch.rb, line 67
def dist_if_not_installed?( pkgs, chk = true, opts = {}, &block )
  if chk
    sudo_if( "! pacman -Q #{pkgs.join ' '} >/dev/null 2>&1", opts, &block )
  else
    block.call
  end
end
dist_install( *pkgs ) click to toggle source

Install the specified package names. A trailing hash is interpreted as options, see below.

Options

:check_install

Short-circuit if all packages already installed. Thus no upgrades will be performed. (Default: true)

Options are also passed to the sudo calls.

# File lib/syncwrap/components/arch.rb, line 42
def dist_install( *pkgs )
  opts = pkgs.last.is_a?( Hash ) && pkgs.pop || {}
  pkgs.flatten!
  chk = opts[ :check_install ]
  chk = check_install? if chk.nil?
  dist_if_not_installed?( pkgs, chk != false, opts ) do
    sudo( "pacman -S --noconfirm #{pkgs.join ' '}", opts )
  end
end
dist_uninstall( *pkgs ) click to toggle source

Uninstall the specified package names. A trailing hash is interpreted as options and passed to the sudo calls.

# File lib/syncwrap/components/arch.rb, line 54
def dist_uninstall( *pkgs )
  opts = pkgs.last.is_a?( Hash ) && pkgs.pop || {}
  pkgs.flatten!
  pkgs.each do |pkg|
    dist_if_installed?( pkg, opts ) do
      sudo( "pacman -R --noconfirm #{pkg}", opts )
    end
  end
end
systemd?() click to toggle source
# File lib/syncwrap/components/arch.rb, line 28
def systemd?
  true
end