Skip to content

Commit

Permalink
Merge pull request #139 from yast/SLE12_raw_url_and_repo_filter
Browse files Browse the repository at this point in the history
Backport raw URL editing and a repo filter to SLE12-GA [do not merge/submit yet]
  • Loading branch information
lslezak committed Nov 11, 2015
2 parents ef755be + 836b822 commit 75e7cbe
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 20 deletions.
13 changes: 13 additions & 0 deletions package/yast2-packager.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
-------------------------------------------------------------------
Tue Oct 6 11:36:25 UTC 2015 - ancor@suse.com

- Repository editor can now manage urls with repo variables like
$arch, $releasever, etc. (bsc#944505)
- 3.1.52.1

-------------------------------------------------------------------
Tue Oct 6 11:13:46 UTC 2015 - jreidinger@suse.com

- Added a filter showing only those repositories not belonging to
any service. (bnc#944504)

-------------------------------------------------------------------
Mon Jan 26 13:06:17 UTC 2015 - jreidinger@suse.com

Expand Down
10 changes: 5 additions & 5 deletions package/yast2-packager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 3.1.52
Version: 3.1.52.1
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand All @@ -34,14 +34,14 @@ BuildRequires: rubygem(rspec)
# HwDetection
BuildRequires: yast2 >= 3.1.19

# "growonly" in Pkg::SetTargetDU()
BuildRequires: yast2-pkg-bindings >= 3.1.19
# Pkg::SourceRawURL() and Pkg:ExpandedUrl()
BuildRequires: yast2-pkg-bindings >= 3.1.20.3

# Newly added RPM
Requires: yast2-country-data >= 2.16.3

# "growonly" in Pkg::SetTargetDU()
Requires: yast2-pkg-bindings >= 3.1.19
# Pkg::SourceRawURL() and Pkg:ExpandedUrl()
Requires: yast2-pkg-bindings >= 3.1.20.3

# Fixed .proc.cmdline agent
Requires: yast2 >= 3.1.89
Expand Down
60 changes: 48 additions & 12 deletions src/clients/repositories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#
module Yast
class RepositoriesClient < Client
NO_SERVICE = :no_service
NO_SERVICE_ITEM = :no_service_item

def main
Yast.import "Pkg"
Yast.import "UI"
Expand Down Expand Up @@ -171,6 +174,7 @@ def PriorityToString(priority)

def ReposFromService(service, input)
input = deep_copy(input)
service = "" if service == NO_SERVICE
Builtins.filter(input) do |repo|
Ops.get_string(repo, "service", "") == service
end
Expand Down Expand Up @@ -259,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 @@ -309,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 @@ -323,15 +331,22 @@ def repoInfoRichText(name, raw_url, category)
"\">&nbsp;&nbsp;&nbsp;"
)

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>"
# TRANSLATORS: Raw URL is the address without expanding repo variables
# e.g. Raw URL = http://something/$arch -> URL = http://something/x86_64
url_string += _("Raw URL: %s") % 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 @@ -390,7 +405,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 @@ -641,10 +656,24 @@ def buildList
@displayed_service == Ops.get_string(srv_state, "alias", "")
)
ret = Builtins.add(ret, t)
end
end

# there is some service, so allow to filter repos without service (bnc#944504)
if ret.size > 2
t = Item(
Id(NO_SERVICE_ITEM),
# TRANSLATORS: Item in selection box that allow user to see only
# repositories not associated with service. Sometimes called also
# third party as they are usually repositories not provided by SUSE
# within product subscription.
_("Only repositories not provided by a service"),
@repository_view &&
@displayed_service == NO_SERVICE
)
ret = Builtins.add(ret, t)
end

deep_copy(ret)
ret
end

def RepoFilterWidget
Expand Down Expand Up @@ -1035,7 +1064,7 @@ def SummaryDialog
exit = true if Popup.YesNoHeadline(headline, msg)
end
elsif input == :key_mgr
exit = true
exit = true
#return `key_mgr;
# start the GPG key manager
#RunGPGKeyMgmt();
Expand All @@ -1058,6 +1087,12 @@ def SummaryDialog
@repository_view = false
# display all services
@displayed_service = ""
elsif current_item == NO_SERVICE_ITEM
update_table_widget = @repository_view
Builtins.y2milestone("Switching to without service view")
@repository_view = true
# display repositories without service
@displayed_service = NO_SERVICE
elsif Ops.is_string?(current_item)
# switch to the selected repository
Builtins.y2milestone("Switching to service %1", current_item)
Expand Down Expand Up @@ -1125,7 +1160,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 @@ -1288,7 +1324,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 Expand Up @@ -1741,7 +1777,7 @@ def KnownURL(url)
generalData = Pkg.SourceGeneralData(src_id)
src_url = Ops.get_string(generalData, "url", "")
ret = true if src_url == url
end
end


Builtins.y2milestone("URL exists: %1", ret)
Expand Down Expand Up @@ -1900,7 +1936,7 @@ def StartInstSource
UI.CloseDialog
ret
end
end
end unless defined? (Yast::RepositoriesClient)
end

Yast::RepositoriesClient.new.main
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 75e7cbe

Please sign in to comment.