gems-status 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/exists_in_upstream.rb +2 -1
- data/lib/gem_simple.rb +3 -3
- data/lib/gems_composite_command.rb +25 -7
- data/lib/gems_status.rb +4 -1
- data/lib/gems_status_metadata.rb +1 -1
- data/lib/lockfile_gems.rb +8 -8
- data/lib/not_native_gem_checker.rb +1 -1
- data/lib/obs_gems.rb +17 -16
- data/lib/ruby_gems_gems.rb +1 -1
- data/lib/ruby_gems_gems_gem_simple.rb +2 -2
- data/lib/utils.rb +9 -8
- data/lib/view_results.rb +36 -12
- data/test/test-obs_gems.rb +1 -1
- metadata +4 -4
data/lib/exists_in_upstream.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'open-uri'
|
3
3
|
require 'gem_checker'
|
4
|
+
require 'utils'
|
4
5
|
|
5
6
|
class ExistsInUpstream < GemChecker
|
6
7
|
def ExistsInUpstream.check?(gem)
|
7
|
-
|
8
|
+
Utils::log_debug("Looking for #{gem.name}")
|
8
9
|
result = nil
|
9
10
|
gem_uri = "#{gem.gems_url}/#{gem.name}-#{gem.version}.gem"
|
10
11
|
begin
|
data/lib/gem_simple.rb
CHANGED
@@ -12,7 +12,7 @@ class GemSimple
|
|
12
12
|
#TODO: write a test for this
|
13
13
|
def depends?(gem)
|
14
14
|
if !@dependencies
|
15
|
-
Utils::log_error("
|
15
|
+
Utils::log_error(@name, "trying to get depends on a gem that has no info on dependencies #{@name} depends #{gem.name}")
|
16
16
|
return false
|
17
17
|
end
|
18
18
|
@dependencies.each do |dep|
|
@@ -24,7 +24,7 @@ class GemSimple
|
|
24
24
|
#TODO: write a test for this
|
25
25
|
def merge_deps(gem)
|
26
26
|
if !@dependencies || !gem.dependencies
|
27
|
-
Utils::log_error("
|
27
|
+
Utils::log_error(@name, "trying to merge depends on a gem that has no info on dependencies #{@name} merge #{gem.name}")
|
28
28
|
return false
|
29
29
|
end
|
30
30
|
changes = false
|
@@ -32,7 +32,7 @@ class GemSimple
|
|
32
32
|
if !@dependencies.include?(dep)
|
33
33
|
changes = true
|
34
34
|
@dependencies << dep
|
35
|
-
Utils::log_debug("
|
35
|
+
Utils::log_debug("adding #{dep} to dependencies")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
return changes
|
@@ -9,6 +9,8 @@ class GemsCompositeCommand < GemsCommand
|
|
9
9
|
def initialize(target)
|
10
10
|
@commands = []
|
11
11
|
@checkers = []
|
12
|
+
@checker_results = {}
|
13
|
+
@comments = {}
|
12
14
|
@results = {}
|
13
15
|
@target = target
|
14
16
|
end
|
@@ -33,6 +35,11 @@ class GemsCompositeCommand < GemsCommand
|
|
33
35
|
@commands.each do |command|
|
34
36
|
@results[command.ident] = command.result
|
35
37
|
end
|
38
|
+
@checkers.each do |check_class|
|
39
|
+
@results[@target].sort.each do |k, gem|
|
40
|
+
@checker_results[gem.name] = check_class::description + gem.name unless check_class::check?(gem)
|
41
|
+
end
|
42
|
+
end
|
36
43
|
end
|
37
44
|
|
38
45
|
def common_key?(k)
|
@@ -69,6 +76,10 @@ class GemsCompositeCommand < GemsCommand
|
|
69
76
|
return true
|
70
77
|
end
|
71
78
|
|
79
|
+
def add_comments(comments)
|
80
|
+
@comments = comments
|
81
|
+
end
|
82
|
+
|
72
83
|
def are_there_results?
|
73
84
|
if !@results or @results.empty?
|
74
85
|
return false
|
@@ -92,19 +103,26 @@ class GemsCompositeCommand < GemsCommand
|
|
92
103
|
end
|
93
104
|
@results[@target].sort.each do |k,v|
|
94
105
|
if !common_key?(k) then
|
95
|
-
Utils::log_error "
|
106
|
+
Utils::log_error(k, "#{k} in #{@target} but not found in all the sources!")
|
96
107
|
next
|
97
108
|
end
|
98
109
|
if equal_gems?(k) then
|
99
110
|
next
|
100
111
|
end
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
112
|
+
if @checker_results[k]
|
113
|
+
checker_results = @checker_results[k]
|
114
|
+
else
|
115
|
+
checker_results = nil
|
116
|
+
end
|
117
|
+
if @comments[k]
|
118
|
+
comments = @comments[k]
|
119
|
+
else
|
120
|
+
comments = nil
|
106
121
|
end
|
122
|
+
ViewResults::print_results(k, @results, @target, checker_results, comments)
|
123
|
+
@checker_results.delete(k)
|
124
|
+
@comments.delete(k)
|
107
125
|
end
|
108
|
-
ViewResults::print_tail
|
126
|
+
ViewResults::print_tail(@checker_results, @comments)
|
109
127
|
end
|
110
128
|
end
|
data/lib/gems_status.rb
CHANGED
@@ -21,7 +21,7 @@ class GemStatus
|
|
21
21
|
begin
|
22
22
|
@conf = YAML::load(File::open(conf_file))
|
23
23
|
rescue
|
24
|
-
Utils::log_error "
|
24
|
+
Utils::log_error("?", "There was a problem opening #{conf_file}")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -36,6 +36,9 @@ class GemStatus
|
|
36
36
|
gems_composite_command.add_checker(eval(c["classname"]))
|
37
37
|
end
|
38
38
|
end
|
39
|
+
if @conf["comments"]
|
40
|
+
gems_composite_command.add_comments(@conf["comments"])
|
41
|
+
end
|
39
42
|
gems_composite_command.execute
|
40
43
|
gems_composite_command.print
|
41
44
|
end
|
data/lib/gems_status_metadata.rb
CHANGED
data/lib/lockfile_gems.rb
CHANGED
@@ -23,13 +23,13 @@ class LockfileGems < GemsCommand
|
|
23
23
|
begin
|
24
24
|
data = File.open(filename).read
|
25
25
|
rescue
|
26
|
-
Utils::log_error "
|
26
|
+
Utils::log_error("?", "There was a problem opening file #{filename} ")
|
27
27
|
end
|
28
28
|
return data
|
29
29
|
end
|
30
30
|
|
31
31
|
def update_gem_dependencies(gem)
|
32
|
-
Utils::log_debug("
|
32
|
+
Utils::log_debug("updating dependencies for #{gem.name}")
|
33
33
|
changes = false
|
34
34
|
@result.each do |k, gem2|
|
35
35
|
if gem.depends?(gem2)
|
@@ -49,10 +49,10 @@ class LockfileGems < GemsCommand
|
|
49
49
|
|
50
50
|
def execute
|
51
51
|
@filenames.each do |filename|
|
52
|
-
Utils::log_debug "
|
52
|
+
Utils::log_debug "reading #{filename}"
|
53
53
|
file_data = get_data(File::dirname(filename), File::basename(filename))
|
54
54
|
if file_data.empty?
|
55
|
-
Utils::log_error "
|
55
|
+
Utils::log_error("?", "file empty #{filename}")
|
56
56
|
next
|
57
57
|
end
|
58
58
|
lockfile = Bundler::LockfileParser.new(file_data)
|
@@ -60,13 +60,13 @@ class LockfileGems < GemsCommand
|
|
60
60
|
name = spec.name
|
61
61
|
version = Gem::Version.create(spec.version)
|
62
62
|
if @result[name] && @result[name].version != version
|
63
|
-
Utils::log_error "
|
64
|
-
|
63
|
+
Utils::log_error(name, "
|
64
|
+
Same gem with different versions:
|
65
65
|
#{name} - #{version} - #{filename}\n
|
66
|
-
#{name} - #{@result[name].version} - #{@result[name].origin} "
|
66
|
+
#{name} - #{@result[name].version} - #{@result[name].origin} ")
|
67
67
|
end
|
68
68
|
dependencies = spec.dependencies
|
69
|
-
Utils::log_debug "
|
69
|
+
Utils::log_debug "dependencies for #{name} #{dependencies}"
|
70
70
|
@result[name] = RubyGemsGems_GemSimple.new(name, version , '', filename,
|
71
71
|
@gems_url, dependencies)
|
72
72
|
end
|
@@ -17,7 +17,7 @@ class NotNativeGemChecker < GemChecker
|
|
17
17
|
#io.close if io && !io.closed?
|
18
18
|
#or is a bug on rubygems???
|
19
19
|
rescue => e
|
20
|
-
Utils::log_error "
|
20
|
+
Utils::log_error(gem.name, "There was a problem opening #{gem_uri} #{e.class} #{e.message}")
|
21
21
|
end
|
22
22
|
return false unless result
|
23
23
|
return result.spec.extensions.empty?
|
data/lib/obs_gems.rb
CHANGED
@@ -7,6 +7,7 @@ require "gems_command"
|
|
7
7
|
require "utils"
|
8
8
|
|
9
9
|
class OBSGems < GemsCommand
|
10
|
+
FILES_TO_IGNORE = /(\w(\.gem|\.spec|\.changes|\.rpmlintrc|-rpm-lintrc|-rpmlintrc))|README.SuSE/
|
10
11
|
def initialize(conf)
|
11
12
|
Utils::check_parameters('OBSGems', conf, ["id", "username", "password", "url", "obs_repo"])
|
12
13
|
@result = {}
|
@@ -20,34 +21,34 @@ class OBSGems < GemsCommand
|
|
20
21
|
|
21
22
|
def parse_link(linkinfo)
|
22
23
|
if linkinfo.length > 1 then
|
23
|
-
Utils::log_error "
|
24
|
+
Utils::log_error("?", "There is more than one linkinfo element")
|
24
25
|
return
|
25
26
|
end
|
26
27
|
if !linkinfo[0]["project"] then
|
27
|
-
Utils::log_error "
|
28
|
+
Utils::log_error("?", "Project element does not exists in linkinfo")
|
28
29
|
return
|
29
30
|
end
|
30
31
|
if !linkinfo[0]["package"] then
|
31
|
-
Utils::log_error "
|
32
|
+
Utils::log_error("?", "Package element does not exists in linkinfo")
|
32
33
|
return
|
33
34
|
end
|
34
35
|
repo = linkinfo[0]["project"]
|
35
36
|
package = linkinfo[0]["package"]
|
36
37
|
if linkinfo[0]["rev"] then
|
37
38
|
rev = linkinfo[0]["rev"]
|
38
|
-
Utils::log_debug "
|
39
|
+
Utils::log_debug "Revision in link: #{rev}."
|
39
40
|
package = package + "?rev=" + rev
|
40
41
|
end
|
41
|
-
Utils::log_debug "
|
42
|
+
Utils::log_debug "follow link to project: #{repo} package: #{package}"
|
42
43
|
parse_rpm_data(repo, package)
|
43
44
|
end
|
44
45
|
|
45
|
-
def get_data(url)
|
46
|
+
def get_data(package, url)
|
46
47
|
data = ""
|
47
48
|
begin
|
48
49
|
data = open(url, :http_basic_authentication => [@username, @password]).read
|
49
50
|
rescue
|
50
|
-
Utils::log_error "
|
51
|
+
Utils::log_error(package.sub("rubygem-",""), "There was a problem opening #{url} ")
|
51
52
|
end
|
52
53
|
return data
|
53
54
|
end
|
@@ -55,28 +56,28 @@ class OBSGems < GemsCommand
|
|
55
56
|
def parse_rpm_data(project, package)
|
56
57
|
url = @obs_url + "/" + project
|
57
58
|
rpm_url = url + "/" + package
|
58
|
-
response = get_data(rpm_url)
|
59
|
+
response = get_data(package, rpm_url)
|
59
60
|
if response.empty? then
|
60
61
|
return
|
61
62
|
end
|
62
63
|
data = XmlSimple.xml_in(response)
|
63
64
|
if data["linkinfo"] then
|
64
|
-
Utils::log_debug "
|
65
|
+
Utils::log_debug "#{data["name"]} is a link."
|
65
66
|
if data["entry"].length != 1
|
66
|
-
msg = ""
|
67
|
-
data["entry"].each {|e| msg << e["name"]}
|
68
|
-
Utils::log_error "
|
67
|
+
msg = " "
|
68
|
+
data["entry"].each {|e| msg << " " << e["name"]}
|
69
|
+
Utils::log_error(package.sub("rubygem-",""), "when parsing the link for #{project} : #{package}. There are more entries than expected. That may be a patched link and the result may not be correct:" + msg)
|
69
70
|
end
|
70
71
|
parse_link(data["linkinfo"])
|
71
72
|
return
|
72
73
|
end
|
73
74
|
if !data["entry"] then
|
74
|
-
Utils::log_error "
|
75
|
+
Utils::log_error(package.sub("rubygem-",""), "something went wrong retrieving info from #{project} : #{package}")
|
75
76
|
return
|
76
77
|
end
|
77
78
|
data["entry"].each do |entry|
|
78
|
-
if !(entry["name"] =~
|
79
|
-
Utils::log_error "
|
79
|
+
if !(entry["name"] =~ OBSGems::FILES_TO_IGNORE)
|
80
|
+
Utils::log_error(package.sub("rubygem-",""), "when parsing data for #{project} : #{package}. Entry not expected. That may be a patched rpm and the result may not be correct. #{entry["name"]} ")
|
80
81
|
end
|
81
82
|
if entry["name"].end_with?(".gem") then
|
82
83
|
name = gem_name(entry['name'])
|
@@ -91,7 +92,7 @@ class OBSGems < GemsCommand
|
|
91
92
|
|
92
93
|
def execute
|
93
94
|
url = @obs_url + "/" + @repo
|
94
|
-
response = get_data(url)
|
95
|
+
response = get_data("?", url)
|
95
96
|
if response.empty? then
|
96
97
|
return
|
97
98
|
end
|
data/lib/ruby_gems_gems.rb
CHANGED
@@ -26,7 +26,7 @@ class RubyGemsGems < GemsCommand
|
|
26
26
|
gz = Zlib::GzipReader.new(source)
|
27
27
|
return gz.read
|
28
28
|
rescue
|
29
|
-
Utils::log_error "
|
29
|
+
Utils::log_error "?", "There was a problem opening #{specs_url} "
|
30
30
|
end
|
31
31
|
return ""
|
32
32
|
end
|
@@ -11,13 +11,13 @@ class RubyGemsGems_GemSimple < GemSimple
|
|
11
11
|
return @md5
|
12
12
|
end
|
13
13
|
gem_uri = "#{@gems_url}/#{@name}-#{@version}.gem"
|
14
|
-
Utils::log_debug "
|
14
|
+
Utils::log_debug "download and md5 for #{@name} from #{gem_uri}"
|
15
15
|
begin
|
16
16
|
source = open(gem_uri)
|
17
17
|
@md5 = Digest::MD5.hexdigest(source.read)
|
18
18
|
return @md5
|
19
19
|
rescue
|
20
|
-
Utils::log_error "
|
20
|
+
Utils::log_error(@name, "There was a problem opening #{gem_uri}")
|
21
21
|
end
|
22
22
|
return nil
|
23
23
|
end
|
data/lib/utils.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Utils
|
2
2
|
attr_accessor :errors
|
3
|
-
@@errors =
|
3
|
+
@@errors = {}
|
4
4
|
|
5
5
|
def Utils.errors
|
6
6
|
return @@errors
|
@@ -8,25 +8,26 @@ class Utils
|
|
8
8
|
|
9
9
|
def Utils.check_parameters(classname, conf, parameters)
|
10
10
|
if !conf['classname'] then
|
11
|
-
raise "
|
11
|
+
raise "trying to initialize #{classname} when parameter classname does not exists"
|
12
12
|
end
|
13
13
|
if conf['classname'] != classname then
|
14
|
-
raise "
|
14
|
+
raise "trying to initialize #{classname} when parameter classname is #{conf['classname']}"
|
15
15
|
end
|
16
16
|
parameters.each do |p|
|
17
17
|
if !conf[p] then
|
18
|
-
raise "
|
18
|
+
raise "parameter #{p} not found for #{classname}"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def Utils.log_error(msg)
|
24
|
-
@@errors
|
25
|
-
|
23
|
+
def Utils.log_error(name, msg)
|
24
|
+
@@errors[name] = "\n" unless @@errors[name]
|
25
|
+
@@errors[name] << msg << "\n"
|
26
|
+
$stderr.puts "ERROR: #{msg}"
|
26
27
|
end
|
27
28
|
|
28
29
|
def Utils.log_debug(msg)
|
29
|
-
$stderr.puts msg
|
30
|
+
$stderr.puts "DEBUG: #{msg}"
|
30
31
|
end
|
31
32
|
|
32
33
|
end
|
data/lib/view_results.rb
CHANGED
@@ -39,9 +39,9 @@ class ViewResults
|
|
39
39
|
</li>
|
40
40
|
</ol>
|
41
41
|
<p>
|
42
|
-
After the comparison there are some checks that have been performed.
|
42
|
+
After the comparison there are some checks that have been performed, errors related and comments. Look those results as they imply there is some kind of work to do
|
43
43
|
</p>
|
44
|
-
<p> At the end there are the errors. Look them carefully.
|
44
|
+
<p> At the end there are the errors, checks and comments that do not apply to any of the gems. Look them carefully.
|
45
45
|
</p>
|
46
46
|
<p>
|
47
47
|
You should run gems-status periodically until the lists of errors, patched, outdated and checks are gone.
|
@@ -49,7 +49,7 @@ class ViewResults
|
|
49
49
|
"
|
50
50
|
end
|
51
51
|
|
52
|
-
def ViewResults.
|
52
|
+
def ViewResults.print_results(k, results, target, checker_results, comments)
|
53
53
|
puts "<p>"
|
54
54
|
puts "<table width='100%' class='table_results'>"
|
55
55
|
version = results[target][k].version
|
@@ -91,16 +91,20 @@ class ViewResults
|
|
91
91
|
version = result[k].version
|
92
92
|
md5 = result[k].md5
|
93
93
|
end
|
94
|
-
puts "<tr><td width='50%'><span class='#{name_color}'>#{k}</span></td><td width='10%'>version</td><td width='40%'>md5</td></tr>"
|
94
|
+
puts "<tr><td width='50%'><span class='#{name_color}'>#{k.upcase}</span></td><td width='10%'>version</td><td width='40%'>md5</td></tr>"
|
95
95
|
puts html_string
|
96
96
|
puts "</table>"
|
97
97
|
puts "</p>"
|
98
|
+
puts "<p> <span class='check'>checks:"
|
99
|
+
puts "<br/>#{checker_results}</span>" if checker_results
|
100
|
+
puts "</p><p><span class='errors'>errors: "
|
101
|
+
puts "<br/>#{Utils::errors[k]}</span>" if Utils::errors[k]
|
102
|
+
Utils.errors.delete(k)
|
103
|
+
puts "</p><p><span class='comment'>comments: "
|
104
|
+
puts "<br/>#{comments}</span>" if comments
|
105
|
+
puts "</p>"
|
98
106
|
end
|
99
107
|
|
100
|
-
def ViewResults.print_check(description, name_gem)
|
101
|
-
puts "<span class='check'> #{description} #{name_gem}</span><br/>"
|
102
|
-
end
|
103
|
-
|
104
108
|
def ViewResults.print_head
|
105
109
|
puts "<html>
|
106
110
|
<head>
|
@@ -145,11 +149,23 @@ class ViewResults
|
|
145
149
|
color: #aaaaaa;
|
146
150
|
font-size: 60%;
|
147
151
|
}
|
152
|
+
.errors
|
153
|
+
{
|
154
|
+
color: #ff0000;
|
155
|
+
font-size: 80%;
|
156
|
+
font-style: italic;
|
157
|
+
}
|
148
158
|
.check
|
149
159
|
{
|
160
|
+
color: #a0a0a0;
|
161
|
+
font-size: 80%;
|
150
162
|
font-style: italic;
|
151
|
-
|
163
|
+
}
|
164
|
+
.comment
|
165
|
+
{
|
166
|
+
color: #a0a0a0;
|
152
167
|
font-size: 80%;
|
168
|
+
font-style: italic;
|
153
169
|
}
|
154
170
|
.table_results
|
155
171
|
{
|
@@ -160,9 +176,17 @@ class ViewResults
|
|
160
176
|
<body>"
|
161
177
|
end
|
162
178
|
|
163
|
-
def ViewResults.
|
164
|
-
puts "<
|
165
|
-
|
179
|
+
def ViewResults.print_hash(desc, data, style)
|
180
|
+
puts "<p>"
|
181
|
+
puts "<h2>#{desc}: #{data.length}</h2>"
|
182
|
+
data.each {|k,v| puts "<span class='#{style}'>#{k.upcase} : #{v}</span><br/>"}
|
183
|
+
puts "</p>"
|
184
|
+
end
|
185
|
+
|
186
|
+
def ViewResults.print_tail(checker_results, comments)
|
187
|
+
self.print_hash("checks", checker_results, "check")
|
188
|
+
self.print_hash("comments", comments, "comment")
|
189
|
+
self.print_hash("errors", Utils::errors, "errors")
|
166
190
|
date = Time.now.strftime('%F0')
|
167
191
|
puts "<p class='footer'>run by <a href=\"https://github.com/jordimassaguerpla/gems-status\">gems-status</a> - #{date} - version: #{GemsStatusMetadata::VERSION}</p>
|
168
192
|
</body>
|
data/test/test-obs_gems.rb
CHANGED
@@ -4,7 +4,7 @@ require 'obs_gems'
|
|
4
4
|
|
5
5
|
class OBSGemsTest < OBSGems
|
6
6
|
attr_accessor :result
|
7
|
-
def get_data(url)
|
7
|
+
def get_data(package, url)
|
8
8
|
return '<directory name="rubygem-test" rev="3" vrev="3" srcmd5="85dff037c5d450f68e3724af3624c6b4">
|
9
9
|
<entry name="rubygem-test.changes" md5="410f50267b43b7dba33b54cb3f588ecb" size="284" mtime="1276279120" />
|
10
10
|
<entry name="rubygem-test.spec" md5="6a519f6a782a6f3cb151feef1ab69aaa" size="1827" mtime="1276279120" />
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gems-status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 7
|
10
|
+
version: 0.2.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jordi Massaguer Pla
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-02-
|
18
|
+
date: 2012-02-10 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: xml-simple
|