-
Notifications
You must be signed in to change notification settings - Fork 104
/
addUpdateSiteVersion
executable file
·72 lines (52 loc) · 1.52 KB
/
addUpdateSiteVersion
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
#!/usr/bin/env ruby
require 'rexml/document'
include REXML
require 'fileutils'
include FileUtils
if ARGV.size < 1
puts "Usage: addUpdateSiteVersion versionNumber [directory] [test]"
puts "Use 'ide' to update production otherwise we default to 'beta/ide'"
puts "specifying 'test' does not actually perform the upload"
exit 0
end
def add_version(file_name, version, clear = true)
file = File.new(file_name)
doc = Document.new(file)
children = doc.root.elements["children"]
if children.to_s.include?(version)
puts "File #{file_name} already contains version #{version}"
exit 0
end
# always clear!
if clear
children.elements.delete_all("*")
end
children.add_text(" ")
ne = children.add_element("child").add_attribute("location", version)
children.add_text("\n")
formatter = REXML::Formatters::Pretty.new()
io = File.open(file_name, "w")
formatter.write(doc, io)
io.close
puts("Added version #{version} to #{file_name}")
end
version = ARGV[0]
path = "beta/ide"
if ARGV.size > 1
path = ARGV[1]
end
test = false
if ARGV.size > 2
test = true
end
location = "repo.fusesource.com:/www/repo.fusesource.com/" + path
puts "Adding version #{version} to Eclipse Update XML files at #{location}"
tmpDir = "target"
mkdir_p(tmpDir)
system("scp #{location}/*.xml #{tmpDir}")
add_version("#{tmpDir}/compositeArtifacts.xml", version)
add_version("#{tmpDir}/compositeContent.xml", version)
if not test
puts "Copying modified files to repo..."
system("scp #{tmpDir}/*.xml #{location}")
end