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 collapse

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

Parameters:

  • path (Pathname)

    Path to driver update

Raises:

  • NotFound



77
78
79
80
81
82
83
84
85
# File 'src/lib/installation/driver_update.rb', line 77

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)

Returns Path to the instsys path of the driver update.

Returns:

  • (Pathname)

    Path to the instsys path of the driver update.



46
47
48
# File 'src/lib/installation/driver_update.rb', line 46

def instsys_path
  @instsys_path
end

#kindSymbol (readonly)

Returns Kind of driver update (:dud or :archive).

Returns:

  • (Symbol)

    Kind of driver update (:dud or :archive).



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

def kind
  @kind
end

#pathPathname (readonly)

Returns Path to the driver update.

Returns:

  • (Pathname)

    Path to the driver update.



39
40
41
# File 'src/lib/installation/driver_update.rb', line 39

def path
  @path
end

Class Method Details

.find(update_dirs) ⇒ Array<DriverUpdate>

Find driver updates in a given set of directories

Parameters:

  • update_dirs (Array<Pathname>, Pathname)

    Directories to search for driver updates

Returns:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'src/lib/installation/driver_update.rb', line 53

def find(update_dirs)
  dirs = Array(update_dirs)
  log.info("Searching for Driver Updates at #{dirs.map(&:to_s)}")

  # DUD as directories
  duds_globs = dirs.map { |d| d.join("*", "dud.config") }
  duds = Pathname.glob(duds_globs).map(&:dirname)

  # DUD as files (squashfs filesystems)
  archives_globs = dirs.map { |d| d.join("dud_*") }
  archives = Pathname.glob(archives_globs)

  (duds + archives).uniq.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:



95
96
97
98
99
100
101
102
# File 'src/lib/installation/driver_update.rb', line 95

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