Class: Yast::Execute

Inherits:
Object
  • Object
show all
Extended by:
I18n
Defined in:
library/system/src/lib/yast2/execute.rb

Overview

A module for executing scripts/programs in a safe way (not prone to shell quoting bugs). It uses Cheetah as the backend, but adds support for chrooting during the installation. It also globally switches the default Cheetah logger to Y2Logger.

Class Method Summary collapse

Class Method Details

.locally(*args) ⇒ Object

Runs without chroot; a failure becomes a popup. Runs a command described by args, disregarding a `chroot(2)` specified by the installation (WFM.scr_root). Shows a popup if the command fails and returns `nil` in such case. It also globally switches the default Cheetah logger to Y2Logger.



79
80
81
# File 'library/system/src/lib/yast2/execute.rb', line 79

def self.locally(*args)
  popup_error { locally!(*args) }
end

.locally!(*args) ⇒ Object

Runs without chroot; a failure becomes an exception. Runs a command described by args, disregarding a `chroot(2)` specified by the installation (WFM.scr_root). It also globally switches the default Cheetah logger to Y2Logger.

Parameters:

Raises:

  • Cheetah::ExecutionFailed if the command fails



90
91
92
# File 'library/system/src/lib/yast2/execute.rb', line 90

def self.locally!(*args)
  Cheetah.run(*args)
end

.on_target(*args) ⇒ Object

Runs with chroot; a failure becomes a popup. Runs a command described by args, in a `chroot(2)` specified by the installation (WFM.scr_root). Shows a popup if the command fails and returns `nil` in such case. It also globally switches the default Cheetah logger to Y2Logger.



48
49
50
# File 'library/system/src/lib/yast2/execute.rb', line 48

def self.on_target(*args)
  popup_error { on_target!(*args) }
end

.on_target!(*args) ⇒ Object

Runs with chroot; a failure becomes an exception. Runs a command described by args, in a `chroot(2)` specified by the installation (WFM.scr_root). It also globally switches the default Cheetah logger to Y2Logger.

Parameters:

Raises:

  • Cheetah::ExecutionFailed if the command fails



59
60
61
62
63
64
65
66
67
68
69
# File 'library/system/src/lib/yast2/execute.rb', line 59

def self.on_target!(*args)
  root = Yast::WFM.scr_root

  if args.last.is_a? ::Hash
    args.last[:chroot] = root
  else
    args.push(chroot: root)
  end

  Cheetah.run(*args)
end