Class: Installation::DriverUpdate

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
src/lib/installation/driver_update.rb

Overview

Represents a driver update.

This class will handle driver updates which are applied yet. The main purpose is to re-apply them after the installer's self-update has been performed.

At this point, two kinds of driver updates are considered:

  • Driver Update Disks (DUD): a directory containing different subdirectories, one of them called inst-sys.
  • Packages: are stored in a squashed filesystem which is mounted in /mounts directory.

Defined Under Namespace

Classes: CouldNotBeApplied, NotFound, PreScriptFailed

Constant Summary

APPLY_CMD =

Command to apply the DUD disk to inst-sys

"/sbin/adddir %<source>s /".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ DriverUpdate

Constructor

Raises:

  • NotFound



71
72
73
74
75
76
77
78
79
# File 'src/lib/installation/driver_update.rb', line 71

def initialize(path)
  @path = path
  if !path.exist?
    log.error("Driver Update not found at #{path}")
    raise NotFound
  end
  @kind = path.file? ? :archive : :dud
  @instsys_path = send("#{@kind}_instsys_path")
end

Instance Attribute Details

#instsys_pathPathname (readonly)



48
49
50
# File 'src/lib/installation/driver_update.rb', line 48

def instsys_path
  @instsys_path
end

#kindSymbol (readonly)



44
45
46
# File 'src/lib/installation/driver_update.rb', line 44

def kind
  @kind
end

#pathPathname (readonly)



41
42
43
# File 'src/lib/installation/driver_update.rb', line 41

def path
  @path
end

Class Method Details

.find(update_dirs) ⇒ Array<DriverUpdate>

Find driver updates in a given set of directories



55
56
57
58
59
60
61
62
63
# File 'src/lib/installation/driver_update.rb', line 55

def find(update_dirs)
  dirs = Array(update_dirs)
  log.info("Searching for Driver Updates at #{dirs.map(&:to_s)}")
  globs = dirs.map { |d| d.join("dud_*") }
  Pathname.glob(globs).map do |path|
    log.info("Found a Driver Update at #{path}")
    new(path)
  end
end

Instance Method Details

#applyObject

Add files/directories to the inst-sys

Raises:

  • CouldNotBeApplied

See Also:



89
90
91
92
93
94
95
# File 'src/lib/installation/driver_update.rb', line 89

def apply
  return false if instsys_path.nil? || !instsys_path.exist?
  cmd = format(APPLY_CMD, source: instsys_path)
  out = Yast::SCR.Execute(Yast::Path.new(".target.bash_output"), cmd)
  log.info("Applying update at #{path} (#{cmd}): #{out}")
  raise CouldNotBeApplied unless out["exit"].zero?
end