forked from kpricorn/snmpdumper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
90 lines (76 loc) · 2.12 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
require 'rubygems'
require 'rake'
PACKAGE_NAME = "snmpdumper"
PACKAGE_VERSION = "0.0.4"
DEPENDENCIES = [
["snmp", "1.0.2" ],
["builder", "2.1.2"]
]
SOURCE_FILES = FileList.new do |fl|
[ "bin", "lib", "test" ].each do |dir|
fl.include "#{dir}/**/*"
end
fl.include "Rakefile"
end
PACKAGE_FILES = FileList.new do |fl|
fl.include "README"
fl.include "LICENSE"
fl.include SOURCE_FILES
end
desc "Default task"
task :default => [ :package ]
desc "Clean generated files"
task :clean do
rm_rf "pkg"
end
package_name = "#{PACKAGE_NAME}-#{PACKAGE_VERSION}"
package_dir = "pkg"
package_dir_path = "#{package_dir}/#{package_name}"
gem_file = "#{package_name}.gem"
task :gem => "#{package_dir}/#{gem_file}"
desc "Build all packages"
task :package => [ :gem ]
directory package_dir
file package_dir_path do
mkdir_p package_dir_path rescue nil
PACKAGE_FILES.each do |fn|
f = File.join( package_dir_path, fn )
if File.directory?( fn )
mkdir_p f unless File.exist?( f )
else
dir = File.dirname( f )
mkdir_p dir unless File.exist?( dir )
rm_f f
safe_ln fn, f
end
end
end
file "#{package_dir}/#{gem_file}" => SOURCE_FILES + [ package_dir ] do
spec = Gem::Specification.new do |s|
s.name = PACKAGE_NAME
s.version = PACKAGE_VERSION
s.platform = Gem::Platform::RUBY
s.date = Time.now
s.summary = "Dumps SNMP walk output in different format."
s.description = "Dump snmp walks in various formats"
s.require_paths = [ 'lib' ]
s.bindir = 'bin'
s.executables << 'snmpdumper'
s.files = %w[README LICENSE]
[ 'lib/**/*', 'test/*' ].each do |dir|
s.files += Dir.glob( dir ).delete_if { |item| item =~ /^\./ }
end
s.author = "Sebastian de Castelberg"
s.email = '[email protected]'
s.homepage = 'http://github.com/sdecastelberg/snmpdumper'
DEPENDENCIES.each {|dep| s.add_dependency dep[0], dep[1] }
end
Gem::Builder.new(spec).build
mv gem_file, "#{package_dir}/#{gem_file}"
end
task :install => :package do
`gem install #{package_dir_path}.gem`
end
task :uninstall do
`gem uninstall #{PACKAGE_NAME} -v #{PACKAGE_VERSION}`
end