-
Notifications
You must be signed in to change notification settings - Fork 19
/
scc.rb
102 lines (86 loc) · 3.17 KB
/
scc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# ------------------------------------------------------------------------------
# Copyright (c) 2013 Novell, Inc. 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 Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail, you may find
# current contact information at www.novell.com.
# ------------------------------------------------------------------------------
#
#
# this is just a wrapper for running the SCC client in installed system
require "yast"
require "registration/sw_mgmt"
# HTML escaping
require "cgi/util"
module Yast
unless defined?(SccClient)
class SccClient < Client
include Yast::Logger
Yast.import "CommandLine"
Yast.import "Pkg"
Yast.import "Report"
Yast.import "Wizard"
def main
textdomain "registration"
if WFM.Args.include?("help")
print_help
else
Wizard.CreateDialog
begin
::Registration::SwMgmt.init
WFM.call("inst_scc", WFM.Args)
rescue Registration::SourceRestoreError => e
retry if fix_repositories(e.message)
rescue Registration::PkgAborted => e
# Libzypp init has failed because another application
# has already locked the zypp stack. The user has already
# decided to exit the module. So nothing more has to be
# done here.
log.info "User abort..."
ensure
Wizard.CloseDialog
end
end
end
private
# Print help in command line mode
def print_help
cmdline_description = {
"id" => "scc",
# Command line help text for the repository module, %1 is "SUSEconnect"
"help" => _("Use '%s' instead of this YaST module.") % "SUSEconnect"
}
CommandLine.Run(cmdline_description)
end
# Let the user manually fix the broken repositories
# @return [Boolean] true if the repository manager was successfuly closed,
# false after pressing [Cancel]
def fix_repositories(details)
Report.LongError(
# TRANSLATORS: Error message in RichText format, %s contains the details from libzypp
_("<p>The repository initialization failed. " \
"Disable (or remove) the offending service or repository " \
"in the repository manager.</p><p>Details:</p><p>%s</p>") %
CGI.escapeHTML(details)
)
ret = WFM.call("repositories", WFM.Args)
log.info "repository manager result: #{ret}"
# drop all loaded repos, force complete reloading
Pkg.SourceFinishAll
ret == :next
end
end
end
end
Yast::SccClient.new.main