Class: Y2Packager::OriginalRepositorySetup

Inherits:
Object
  • Object
show all
Includes:
Singleton, Yast::Logger
Defined in:
library/packages/src/lib/y2packager/original_repository_setup.rb

Overview

This class remembers the current repository setup. This is useful during upgrade when we need to know which repositories/services were already present in the original system and which are the new repositories used for migration.

Since:

  • 4.2.60

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOriginalRepositorySetup

constructor, initialize the stored lists to empty lists

Since:

  • 4.2.60


35
36
37
38
# File 'library/packages/src/lib/y2packager/original_repository_setup.rb', line 35

def initialize
  @repositories = []
  @services = []
end

Instance Attribute Details

#repositoriesObject (readonly)

Since:

  • 4.2.60


32
33
34
# File 'library/packages/src/lib/y2packager/original_repository_setup.rb', line 32

def repositories
  @repositories
end

#servicesObject (readonly)

Since:

  • 4.2.60


32
33
34
# File 'library/packages/src/lib/y2packager/original_repository_setup.rb', line 32

def services
  @services
end

Instance Method Details

#read(installation_repositories = []) ⇒ Object

Read and store the current repository/service setup.

Parameters:

Since:

  • 4.2.60


42
43
44
45
46
47
48
# File 'library/packages/src/lib/y2packager/original_repository_setup.rb', line 42

def read(installation_repositories = [])
  # skip the installation repositories, we need to keep them
  aliases = installation_repositories.map(&:repo_alias)
  @repositories = Repository.all.reject { |r| aliases.include?(r.repo_alias) }
  @services = Service.all
  log.info("Found #{repositories.size} repositories and #{services.size} services")
end

#repository?(repository_alias) ⇒ Boolean

Is the repository present in the stored list?

Parameters:

  • service_alias (String)

    Alias of the service

Returns:

  • (Boolean)

Since:

  • 4.2.60


60
61
62
# File 'library/packages/src/lib/y2packager/original_repository_setup.rb', line 60

def repository?(repository_alias)
  repositories.any? { |r| r.alias == repository_alias }
end

#service?(service_alias) ⇒ Boolean

Is the service present in the stored list?

Parameters:

  • service_alias (String)

    Alias of the service

Returns:

  • (Boolean)

Since:

  • 4.2.60


53
54
55
# File 'library/packages/src/lib/y2packager/original_repository_setup.rb', line 53

def service?(service_alias)
  services.any? { |s| s.alias == service_alias }
end