/
Rakefile
160 lines (143 loc) · 3.85 KB
/
Rakefile
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
require 'rubygems'
require 'bundler'
require 'bundler/setup'
require 'veewee'
Bundler::GemHelper.install_tasks
<<<<<<< HEAD
desc 'Default: run tests'
task :default => :test
=======
#Setup some base variables to use
veewee_dir = "."
lib_dir = File.expand_path(File.join(veewee_dir, "lib"))
box_dir = File.expand_path(File.join(veewee_dir, "boxes"))
vbox_dir = File.expand_path(File.join(veewee_dir, "tmp"))
tmp_dir = File.expand_path(File.join(veewee_dir, "tmp"))
iso_dir = File.expand_path(File.join(veewee_dir, "iso"))
definition_dir = File.expand_path(File.join(veewee_dir, "definitions"))
template_dir = File.expand_path(File.join(veewee_dir, "templates"))
>>>>>>> master
require 'rake/testtask'
Bundler::GemHelper.install_tasks
<<<<<<< HEAD
desc 'Tests not requiring an real box'
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = 'test/**/*_test.rb'
end
desc 'Tests requiring an real box'
Rake::TestTask.new do |t|
t.name="realtest"
t.libs << "test"
t.libs << "."
t.pattern = 'test/**/*_realtest.rb'
end
desc 'Verify ISO'
task :iso, [:box_name] do |t,args|
require 'net/http'
#if args.to_hash.size!=1
#puts "needs one arguments: rake iso [\"yourname\"]"
#exit
#end
Dir.glob("templates/*").each do |name|
definition_name=File.basename(name)
puts name
definition=Veewee::Environment.new(:cwd => ".",:definition_dir => "templates").definitions[definition_name]
next if definition.nil? || definition.iso_src.nil? || definition.iso_src==""
begin
url=definition.iso_src
found=false
response = nil
while found==false
uri=URI.parse(url)
Net::HTTP.start(uri.host,uri.port) {|http|
response = http.head(uri.path)
}
unless response['location'].nil?
#puts "Redirecting to "+response['location']
url=response['location']
else
found=true
end
end
length=response['content-length']
if length.to_i < 10000
puts definition.iso_src
p response['content-type']
puts uri.host,uri.port, uri.path,response.code
end
rescue Exception => ex
puts "Error"+ex.to_s+definition.iso_src
end
end
=======
#Load Veewee::Session libraries
Dir.glob(File.join(lib_dir, '**','*.rb')).each { |f| require f }
#Initialize
Veewee::Session.setenv({
:veewee_dir => veewee_dir,
:definition_dir => definition_dir,
:template_dir => template_dir,
:iso_dir => iso_dir,
:box_dir => box_dir,
:tmp_dir => tmp_dir
})
desc 'Default: list templates'
task :default => [:templates]
desc 'List templates'
task :templates do
Veewee::Session.list_templates
end
desc 'Define box'
task :define, [:boxname,:template_name] do |t,args|
if args.to_hash.size!=2
puts "needs two arguments: rake define['boxname','template_name']"
exit
end
Veewee::Session.define(args.boxname,args.template_name)
end
desc 'Undefine box'
task :undefine, [:boxname] do |t,args|
if args.to_hash.size!=1
puts "needs one arguments: rake undefine[\"yourname\"]"
exit
end
Veewee::Session.undefine(args.boxname)
end
desc 'List Definitions'
task :definitions do
Veewee::Session.list_definitions
end
desc 'Build box'
task :build, [:boxname] do |t,args|
if args.to_hash.size!=1
puts "needs one arguments: rake build['boxname']"
exit
end
Veewee::Session.build(args.boxname)
end
desc 'List boxes'
task :boxes do
Veewee::Session.list_boxes
end
desc 'Export box'
task :export, [:boxname] do |t,args|
if args.to_hash.size!=1
puts "needs one arguments: rake export['boxname']"
exit
end
Veewee::Session.export_box(args.boxname)
end
desc 'Remove box'
task :remove_box, [:boxname] do |t,args|
Veewee::Session.remove_box(args.boxname)
end
desc 'List ostypes available'
task :list_ostypes do |t,args|
Veewee::Session.list_ostypes
end
desc 'Clean all unfinished builds'
task :clean do
Veewee::Session.clean
>>>>>>> master
end