Class: Installation::SelfupdateVerifier

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

Overview

This class does some self-update repository sanity checks to avoid applying a wrong self update repository (specified by user).

Constant Summary collapse

VERIFIED_PACKAGES =

We only check the version of these packages, the reason for a fixed list is that these packages are maintained by us and their version is under our control.

We do not care about the other packages, in theory there might be valid reasons for downgrading them. With these YaST packages we can go back to the previous state but still increase the version number.

We can also check the "too new" packages because the YaST package versions are bound to specific SP release (e.g. 4.1.x in SP1, 4.2.x in SP2). So the major and minor version parts must not be changed during self update.

[
  "autoyast2-installation",
  "yast2",
  "yast2-installation",
  "yast2-packager",
  "yast2-pkg-bindings",
  "yast2-registration",
  "yast2-storage-ng",
  "yast2-update"
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(repositories, instsys_packages) ⇒ SelfupdateVerifier

Constructor

Parameters:

  • repositories (Array<UpdateRepository>)

    the self-update repositories

  • instsys_packages (Array<Y2Packager::Package>)

    the installed packages in the current inst-sys



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'src/lib/installation/selfupdate_verifier.rb', line 49

def initialize(repositories, instsys_packages)
  @instsys_packages = instsys_packages.select do |p|
    VERIFIED_PACKAGES.include?(p.name)
  end

  # the selfupdate repo might provide the same package in several versions,
  # find the latest one

  # group the same packages together
  packages = {}

  repositories.each do |repo|
    repo.packages.each do |p|
      next unless VERIFIED_PACKAGES.include?(p.name)

      if packages[p.name]
        packages[p.name] << p
      else
        packages[p.name] = [p]
      end
    end
  end

  # for each package find the highest version
  @selfupdate_packages = packages.values.map do |pkgs|
    pkgs.max { |a, b| Yast::Pkg.CompareVersions(a.version, b.version) }
  end
end

Instance Method Details

#downgraded_packagesArray<Y2Packager::Resolvable>

check for downgraded packages, e.g. using the SP1 updates in the SP2 installer

Returns:

  • (Array<Y2Packager::Resolvable>)

    List of downgraded packages



81
82
83
84
85
86
87
88
89
# File 'src/lib/installation/selfupdate_verifier.rb', line 81

def downgraded_packages
  packages = filter_self_updates do |inst_sys_pkg, update_pkg|
    # -1 = "update_pkg" is older than "inst_sys_pkg" (0 = the same, 1 = newer)
    Yast::Pkg.CompareVersions(update_pkg.version, inst_sys_pkg.version) == -1
  end

  log.warn("Found downgraded self-update packages: #{packages} ") unless packages.empty?
  packages
end