Skip to content

Commit

Permalink
Merge 69a7505 into 70d6da0
Browse files Browse the repository at this point in the history
  • Loading branch information
wfeldt committed Oct 25, 2022
2 parents 70d6da0 + 69a7505 commit b593df4
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/modules/AddOnProduct.rb
Expand Up @@ -5,6 +5,8 @@
require "packager/product_patterns"
require "y2packager/resolvable"
require "y2packager/repository"
require "uri"
require "yast2/rel_url"

# Yast namespace
module Yast
Expand Down Expand Up @@ -388,12 +390,15 @@ def GetBaseProductURL
end

# Returns an absolute URL from base + relative url.
# Relative URL needs to start with 'reulrl://' othewise
# it is not considered being relative and it's returned
# as it is (just the relative_url parameter).
#
# Relative URL needs to start with 'reulrl://' or 'repo:/', otherwise it
# is not considered being relative and it's returned as it is (just the
# relative_url parameter).
#
# 'repo' URLs are resolved relative to the installation medium, not base_url.
#
# @param [String] base_url
# @param [String] url URL relative to the base
# @param [String] url URL relative to base_url resp. installation medium
#
# @example
# AddOnProduct::GetAbsoluteURL (
Expand All @@ -404,7 +409,27 @@ def GetBaseProductURL
# "username:password@ftp://www.example.org/dir/",
# "relurl://./Product_CD1/"
# ) -> "username:password@ftp://www.example.org/dir/Product_CD1/"
# AddOnProduct::GetAbsoluteURL (
# "username:password@ftp://www.example.org/dir/",
# "repo:/Product_CD1/"
# ) -> "username:password@ftp://www.example.org/dir/Product_CD1/"
def GetAbsoluteURL(base_url, url)
url_parsed = URI(url)

if url_parsed.scheme == "repo"
base_url = InstURL.installInf2Url("")
if base_url.empty?
log.error "no ZyppRepoURL in /etc/install.inf"
else
rel_url = "relurl:" + url_parsed.path
url = Yast2::RelURL.from_installation_repository(rel_url).absolute_url.to_s
log.info("base url + relative path: #{URL.HidePassword(base_url)} + #{url_parsed.path}")
log.info("absolute url: #{URL.HidePassword(url)}")
end

return url
end

if !Builtins.regexpmatch(url, "^relurl://")
Builtins.y2debug("Not a relative URL: %1", URL.HidePassword(url))
return url
Expand Down

0 comments on commit b593df4

Please sign in to comment.