-
Notifications
You must be signed in to change notification settings - Fork 14
/
Rakefile
136 lines (120 loc) · 3.51 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
# -*- ruby -*-
# Rakefile: build ruby auges bindings
#
# Copyright (C) 2008 Red Hat, Inc.
#
# Distributed under the GNU Lesser General Public License v2.1 or later.
# See COPYING for details
#
# Bryan Kearney <[email protected]>
require 'rake/clean'
require 'rdoc/task'
require 'rake/testtask'
require 'rubygems/package_task'
PKG_NAME='ruby-augeas'
GEM_NAME=PKG_NAME # we'd like 'augeas' but that makes RPM fail
PKG_VERSION='0.6.0'
EXT_CONF='ext/augeas/extconf.rb'
MAKEFILE="ext/augeas/Makefile"
AUGEAS_MODULE="ext/augeas/_augeas.so"
SPEC_FILE="ruby-augeas.spec"
AUGEAS_SRC=AUGEAS_MODULE.gsub(/.so$/, ".c")
#
# Building the actual bits
#
CLEAN.include [ "**/*~",
"ext/**/*.o", AUGEAS_MODULE,
"ext/**/depend" ]
CLOBBER.include [ "config.save",
"ext/**/mkmf.log",
MAKEFILE ]
file MAKEFILE => EXT_CONF do |t|
Dir::chdir(File::dirname(EXT_CONF)) do
unless sh "ruby #{File::basename(EXT_CONF)}"
$stderr.puts "Failed to run extconf"
break
end
end
end
file AUGEAS_MODULE => [ MAKEFILE, AUGEAS_SRC ] do |t|
Dir::chdir(File::dirname(EXT_CONF)) do
unless sh "make"
$stderr.puts "make failed"
break
end
end
end
desc "Build the native library"
task :build => AUGEAS_MODULE
#
# Testing
#
Rake::TestTask.new(:test) do |t|
t.test_files = FileList['tests/tc_*.rb']
t.libs = [ 'lib', 'ext/augeas' ]
end
task :test => :build
#
# Generate the documentation
#
RDoc::Task.new do |rd|
rd.main = "README.md"
rd.rdoc_dir = "doc/site/api"
rd.rdoc_files.include("README.md", "ext/**/*.[ch]","lib/**/*.rb")
end
#
# Packaging
#
PKG_FILES = FileList[
"Rakefile", "COPYING","README.md", "NEWS",
"ext/**/*.[ch]", "lib/**/*.rb", "ext/**/MANIFEST", "ext/**/extconf.rb",
"tests/**/*",
"spec/**/*"
]
DIST_FILES = FileList[
"pkg/*.tgz", "pkg/*.gem"
]
SPEC = Gem::Specification.new do |s|
s.name = GEM_NAME
s.version = PKG_VERSION
s.email = "[email protected]"
s.homepage = "http://augeas.net/"
s.summary = "Ruby bindings for augeas"
s.authors = [ "Bryan Kearney", "David Lutterkort" ]
s.files = PKG_FILES
s.licenses = ['LGPL-2.1+']
s.autorequire = "augeas"
s.required_ruby_version = '>= 1.8.1'
s.extensions = "ext/augeas/extconf.rb"
s.description = "Provides bindings for augeas."
end
Gem::PackageTask.new(SPEC) do |pkg|
pkg.need_tar = true
pkg.need_zip = true
end
desc "Build (S)RPM for #{PKG_NAME}"
task :rpm => [ :package ] do |t|
system("sed -e 's/@VERSION@/#{PKG_VERSION}/' #{SPEC_FILE} > pkg/#{SPEC_FILE}")
Dir::chdir("pkg") do |dir|
dir = File::expand_path(".")
system("rpmbuild --define '_topdir #{dir}' --define '_sourcedir #{dir}' --define '_srcrpmdir #{dir}' --define '_rpmdir #{dir}' --define '_builddir #{dir}' -ba #{SPEC_FILE} > rpmbuild.log 2>&1")
if $? != 0
raise "rpmbuild failed"
end
end
end
desc "Release a version to the site"
task :dist => [ :rpm ] do |t|
puts "Copying files"
unless sh "scp -p #{DIST_FILES.to_s} et:/var/www/sites/augeas.et.redhat.com/download/ruby"
$stderr.puts "Copy to et failed"
break
end
puts "Commit and tag #{PKG_VERSION}"
system "git commit -a -m 'Released version #{PKG_VERSION}'"
system "git tag -s -m 'Tag release #{PKG_VERSION}' release-#{PKG_VERSION}"
end
task :sync do |t|
system "rsync -rav doc/site/ et:/var/www/sites/augeas.et.redhat.com/docs/ruby/"
end
task :default => [:build, :test]