Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial support for handling $releasever
- Loading branch information
Showing
3 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) 2015 SUSE LLC, All Rights Reserved. | ||
# | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of version 2 of the GNU General Public License as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE about this file by physical or electronic mail, you may find | ||
# current contact information at www.suse.com. | ||
# ------------------------------------------------------------------------------ | ||
|
||
require "yast" | ||
require "registration/sw_mgmt" | ||
|
||
require "uri" | ||
|
||
module Registration | ||
# this class handles activating the new releasever value in the package management | ||
class Releasever | ||
include Yast::Logger | ||
|
||
# the placeholder used in the URL | ||
RELEASEVER_ID = "$releasever" | ||
|
||
Yast.import "Pkg" | ||
|
||
attr_reader :version | ||
|
||
# constructor | ||
# @param [String] version the new release version value | ||
def initialize(version) | ||
@version = version | ||
end | ||
|
||
# activate the new releasever | ||
def activate | ||
log.info "Setting $releasever to: #{version}" | ||
# export the settings | ||
ENV["ZYPP_REPO_RELEASEVER"] = version | ||
|
||
repos = releasever_repos | ||
return if repos.empty? | ||
|
||
refresh(repos) | ||
# refresh the loaded packages | ||
SwMgmt.sync_pool | ||
end | ||
|
||
private | ||
|
||
# get the repositories which contain "$releasever" directory in the URL | ||
# @return [Array<Fixnum>] the repository list | ||
def releasever_repos | ||
repos = Yast::Pkg.SourceGetCurrent(true) | ||
repos.select do |repo| | ||
data = Pkg.SourceGeneralData(repo) | ||
|
||
url = URI(data["url"]) | ||
url.path.split("/").include?(RELEASEVER_ID) | ||
end | ||
end | ||
|
||
# refresh the requested repositories | ||
# @param [Array<Fixnum>] repos the repositories to refresh | ||
def refresh(repos) | ||
repos.each do |repo| | ||
log.info "Refreshing repository #{repo}" | ||
Yast::Pkg.SourceForceRefreshNow(repo) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters