-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcheck_dist_ver.rb
executable file
·57 lines (51 loc) · 1.42 KB
/
check_dist_ver.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
#!/usr/bin/ruby -Ku
require 'rexml/document'
MAJOR_VERSION = ARGV[0].to_i
MINOR_VERSION = ARGV[1].to_i
TARGET = {
'agent.manifest' => {
:xpath => '/assembly/assemblyIdentity/@version',
:match => "#{MAJOR_VERSION}.#{MINOR_VERSION}.0.0"
},
'askpass.manifest' => {
:xpath => '/assembly/assemblyIdentity/@version',
:match => "#{MAJOR_VERSION}.#{MINOR_VERSION}.0.0"
},
"README.txt" => {
:line => /^\s+\d\d\d\d\/\d\d\/\d\d\s+(\d+\.\d+)\s*$/,
:match => sprintf("%d.%02d", MAJOR_VERSION, MINOR_VERSION)
},
"README-ja.txt" => {
:line => /^\s+\d\d\d\d\/\d\d\/\d\d\s+(\d+\.\d+)\s*$/,
:match => sprintf("%d.%02d", MAJOR_VERSION, MINOR_VERSION)
},
}
have_error = false
TARGET.each{|filename, desc|
if desc[:xpath]
open(filename){|fp|
doc = REXML::Document.new(fp.read)
value = REXML::XPath.first(doc, desc[:xpath]).to_s
if value != desc[:match]
print "error: #{filename}: #{desc[:xpath]} is #{value} (expected #{desc[:match]})\n"
have_error = true
end
}
elsif desc[:line]
open(filename){|fp|
fp.each_line{|line|
if line =~ desc[:line]
value = $1
if value != desc[:match]
print "error: #{filename}: #{desc[:line]} is #{value} (expected #{desc[:match]})\n"
have_error = true
end
break
end
}
}
else
print "error: #{filename}: "
end
}
exit 1 if have_error