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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
def run_repoman(docker_image, num_of_packages)
packages = []
Package.order { [category, lower(name), version] }.each do |package|
target = ''
target = package[:r19_target] unless package[:r19_target] == 'nil'
target = package[:r20_target] unless package[:r20_target] == 'nil'
target = package[:r21_target] unless package[:r21_target] == 'nil'
target = package[:r22_target] unless package[:r22_target] == 'nil'
next if target.empty?
next_target = ''
next_target = 'ruby20' if target == 'ruby19'
next_target = 'ruby21' if target == 'ruby20'
next_target = 'ruby22' if target == 'ruby21'
next if next_target.empty?
category = package[:category]
name = package[:name]
version = package[:version]
revision = package[:revision] == 'r0' ? '' : "-#{package[:revision]}"
packages << "#{category} #{name} #{version}#{revision} #{target} #{next_target}"
end
if num_of_packages == :all
packages = packages
else
packages = packages.sample(num_of_packages)
end
packages = packages.uniq
packages.each do |package|
package = "'" + package + "'"
end
packages = packages.unshift('/ruby-tinderbox/repoman.sh')
docker_container = docker_image.run(packages)
docker_container.wait(36_000)
tar = Tempfile.new('tar')
File.open(tar, 'w') do |file|
docker_container.copy('/ruby-tinderbox/repo-logs') do |chunk|
file.write(chunk)
puts chunk
end
end
Archive::Tar::Minitar.unpack(tar, File.dirname(File.expand_path(File.dirname(__FILE__))))
tar.close
tar.unlink
docker_container.delete
update_timestamp = Time.now.to_i
portage_timestamp = File.read('/usr/portage/metadata/timestamp.x').split.first
Repoman.dataset.update(update_timestamp: update_timestamp)
Repoman.dataset.update(portage_timestamp: portage_timestamp)
end
def update_repoman
Dir.glob('repo-logs/*/*/*') do |repoman|
repoman_array = repoman.split('/')
package_id = "#{repoman_array[1]}/#{repoman_array[2]}"
time = repoman_array[3]
current_log = File.read("#{repoman}/current.txt") if File.exist?("#{repoman}/current.txt")
next_log = File.read("#{repoman}/next.txt") if File.exist?("#{repoman}/next.txt")
current_result = 'unknown'
if current_log.include?('If everyone were like you, I\'d be out of business!')
current_result = 'passed'
elsif current_log.include?('You\'re only giving me a partial QA payment?')
current_result = 'partial'
elsif current_log.include?('Make your QA payment on time and you\'ll never see the likes of me.')
current_result = 'failed'
end
next_result = 'unknown'
if next_log.include?('If everyone were like you, I\'d be out of business!')
next_result = 'passed'
elsif next_log.include?('You\'re only giving me a partial QA payment?')
next_result = 'partial'
elsif next_log.include?('Make your QA payment on time and you\'ll never see the likes of me.')
next_result = 'failed'
end
Repoman.find_or_create(
package_id: package_id,
time: time,
current_result: current_result,
current_log: current_log,
next_result: next_result,
next_log: next_log
)
end
Package.order { [category, lower(name), version] }.each do |package|
target = ''
target = package[:r19_target] unless package[:r19_target] == 'nil'
target = package[:r20_target] unless package[:r20_target] == 'nil'
target = package[:r21_target] unless package[:r21_target] == 'nil'
target = package[:r22_target] unless package[:r22_target] == 'nil'
if target.empty?
Repoman.where(package_id: package[:identifier]).delete
next
end
next_target = ''
next_target = 'ruby20' if target == 'ruby19'
next_target = 'ruby21' if target == 'ruby20'
next_target = 'ruby22' if target == 'ruby21'
if next_target.empty?
Repoman.where(package_id: package[:identifier]).delete
next
end
end
end
def clear_repoman
Repoman.map(&:delete)
end
|