Skip to content

Commit

Permalink
activate the repository setup as set in the SCC response (bnc#875839)
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed May 2, 2014
1 parent 960753c commit c49367c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/lib/registration/sw_mgmt.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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<String>] 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<String>] 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

0 comments on commit c49367c

Please sign in to comment.