diff --git a/src/lib/registration/sw_mgmt.rb b/src/lib/registration/sw_mgmt.rb index 30f835711..dc7959569 100644 --- a/src/lib/registration/sw_mgmt.rb +++ b/src/lib/registration/sw_mgmt.rb @@ -176,6 +176,10 @@ def self.add_services(product_services, credentials) raise ::Registration::ServiceError.new(N_("Refreshing service '%s' failed."), source.name) end end + + # activate the requested repository setup + repos_enable(product_services.map(&:enabled).flatten) + repos_disable_autorefresh(product_services.map(&:norefresh).flatten) ensure Pkg.SourceSaveAll end @@ -223,6 +227,41 @@ def self.set_repos_state(repos, enabled) end end + # convert repository alias to repository ID + # @param repo_alias [String] alias + # @return [Fixnum,nil] Repository ID or nil when not found + def self.find_repository(repo_alias) + Pkg.SourceGetCurrent(false).find do |repo| + Pkg.SourceGeneralData(repo)["alias"] == repo_alias + end + end + + # Disable specified repositories + # @param repo_aliases [Array] list of repository aliases + def self.repos_enable(repo_aliases) + repo_aliases.each do |repo_alias| + repo = find_repository(repo_alias) + + if repo + log.info "Enabling repository #{repo_alias}" + Pkg.SourceSetEnabled(repo, true) + end + end + end + + # Disable autorefresh for specified repositories + # @param repo_aliases [Array] list of repository aliases + def self.repos_disable_autorefresh(repo_aliases) + repo_aliases.each do |repo_alias| + repo = find_repository(repo_alias) + + if repo + log.info "Disabling autorefresh for #{repo_alias} repository" + Pkg.SourceSetAutorefresh(repo, false) + end + end + end + end end