Class: Y2Packager::KnownRepositories

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

Overview

Track the known repositories from which the system packages (drivers) have been installed (or suggested to the user).

Constant Summary collapse

STATUS_FILE =
"/var/lib/YaST2/system_packages_repos.yaml".freeze

Instance Method Summary collapse

Constructor Details

#initializeKnownRepositories

Constructor


26
27
28
29
# File 'src/lib/y2packager/known_repositories.rb', line 26

def initialize
  Yast.import "Pkg"
  Yast.import "Installation"
end

Instance Method Details

#new_repositoriesArray<String>

Return new (unknown) repositories


56
57
58
59
60
61
62
63
# File 'src/lib/y2packager/known_repositories.rb', line 56

def new_repositories
  log.info "current repositories: #{current_repositories.inspect}"
  log.info "known repositories: #{repositories.inspect}"

  new_repos = current_repositories - repositories
  log.info "New repositories: #{new_repos.inspect}"
  new_repos
end

#repositoriesObject


31
32
33
# File 'src/lib/y2packager/known_repositories.rb', line 31

def repositories
  @repositories ||= read_repositories
end

#updateObject


43
44
45
46
47
48
49
# File 'src/lib/y2packager/known_repositories.rb', line 43

def update
  # add the current repositories
  repositories.concat(current_repositories)
  # remove duplicates and sort them
  repositories.uniq!
  repositories.sort!
end

#writeObject


35
36
37
38
39
40
41
# File 'src/lib/y2packager/known_repositories.rb', line 35

def write
  log.info("Writing known repositories #{repositories.inspect} to #{status_file}")

  # accessible only for the root user, the repository URLs should not contain
  # any passwords but rather be safe than sorry
  File.write(status_file, repositories.to_yaml, open_args: ["w", 0o600])
end