Skip to content

Commit

Permalink
Support for urls with repo variables (bnc#944505)
Browse files Browse the repository at this point in the history
Conflicts:
	src/clients/repositories.rb
  • Loading branch information
ancorgs authored and lslezak committed Oct 22, 2015
1 parent c2c1103 commit 7d29b8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
24 changes: 17 additions & 7 deletions src/clients/repositories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def getSourceInfo(index, source)
"autorefresh" => Ops.get_boolean(source, "autorefresh", true),
"name" => Ops.get_locale(source, "name", _("Unknown Name")),
"url" => Ops.get_string(generalData, "url", ""),
"raw_url" => Ops.get_string(generalData, "raw_url", ""),
"type" => Ops.get_string(generalData, "type", ""),
"priority" => Ops.get_integer(source, "priority", @default_priority),
"service" => Ops.get_string(source, "service", ""),
Expand Down Expand Up @@ -313,9 +314,12 @@ def fillTable(repo_mode, service_name)
nil
end

def repoInfoRichText(name, raw_url, category)
def repoInfoRichText(name, category, info)
url = info["url"]
raw_url = info["raw_url"]

schema = Builtins.tolower(
Ops.get_string(URL.Parse(raw_url), "scheme", "")
Ops.get_string(URL.Parse(url), "scheme", "")
)
icon_tag = Ops.add(
Ops.add(
Expand All @@ -327,15 +331,20 @@ def repoInfoRichText(name, raw_url, category)
"\">   "
)

url = _("Unknown") if url == ""
raw_url = _("Unknown") if raw_url == ""

url = Builtins.sformat(_("URL: %1"), raw_url)
url_string = Builtins.sformat(_("URL: %1"), url)
if url != raw_url
url_string += "<BR>"
url_string += Builtins.sformat(_("Raw URL: %1"), raw_url)
end

Builtins.sformat(
"<P>%1<B><BIG>%2</BIG></B></P><P>%3<BR>%4</P>",
icon_tag,
name,
url,
url_string,
category
)
end
Expand Down Expand Up @@ -394,7 +403,7 @@ def fillRepoInfo(index, source, repo_mode, service_name)
UI.ChangeWidget(
Id(:repo_info),
:Value,
repoInfoRichText(name, Ops.get_string(info, "url", ""), category)
repoInfoRichText(name, category, info)
)
end

Expand Down Expand Up @@ -1149,7 +1158,8 @@ def SummaryDialog
if input == :replace
if @repository_view
generalData = Pkg.SourceGeneralData(id)
url2 = Ops.get_string(generalData, "url", "")
# use the full URL (incl. the password) when editing it
url2 = Pkg.SourceRawURL(id)
old_url = url2
plaindir = Ops.get_string(generalData, "type", "YaST") == @plaindir_type

Expand Down Expand Up @@ -1312,7 +1322,7 @@ def SummaryDialog
else
service_info = Ops.get(@serviceStatesOut, current, {})
Builtins.y2milestone("Editing service %1...", current)
url2 = Ops.get_string(service_info, "url", "")
url2 = Ops.get_string(service_info, "raw_url", "")
old_url = url2

SourceDialogs.SetRepoName(
Expand Down
8 changes: 5 additions & 3 deletions src/include/packager/repositories_include.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def createSourceImpl(url, plaindir, download, preffered_name, force_alias)
)

if url != ""
expanded_url = Pkg.ExpandedUrl(url)

# for Plaindir repository we have to use SourceCreateType() binding
parsed = URL.Parse(url)
scheme = Ops.get_string(parsed, "scheme", "")
Expand Down Expand Up @@ -94,7 +96,7 @@ def createSourceImpl(url, plaindir, download, preffered_name, force_alias)
)

Progress.NextStage
service_type = Pkg.ServiceProbe(url)
service_type = Pkg.ServiceProbe(expanded_url)
Builtins.y2milestone("Probed service type: %1", service_type)

if service_type != nil && service_type != "NONE"
Expand Down Expand Up @@ -142,7 +144,7 @@ def createSourceImpl(url, plaindir, download, preffered_name, force_alias)
return :ok
end

new_repos = Pkg.RepositoryScan(url)
new_repos = Pkg.RepositoryScan(expanded_url)
Builtins.y2milestone("new_repos: %1", new_repos)

# add at least one product if the scan result is empty (no product info available)
Expand Down Expand Up @@ -208,7 +210,7 @@ def createSourceImpl(url, plaindir, download, preffered_name, force_alias)
# probe repository type (do not probe plaindir repo)
repo_type = plaindir ?
@plaindir_type :
Pkg.RepositoryProbe(url, prod_dir)
Pkg.RepositoryProbe(expanded_url, prod_dir)
Builtins.y2milestone(
"Repository type (%1,%2): %3",
URL.HidePassword(url),
Expand Down

0 comments on commit 7d29b8e

Please sign in to comment.