-
Notifications
You must be signed in to change notification settings - Fork 14
/
Rakefile
73 lines (58 loc) · 2.34 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
require 'erb'
def calculate_minor_version
matching_versions = File.readlines('build/debian/changelog').grep(/opensprints \(#{ENV['VERSION']}-.*\) unstable; urgency=low/)
minors = matching_versions.map do |version|
(/opensprints \(#{ENV['VERSION']}-(.*)\) unstable; urgency=low/).match(version)[1]
end
minors.map(&:to_i).max
end
OPENSPRINTS_VERSION = "#{ENV['VERSION']}-#{calculate_minor_version}"
CHANGELOG_TEMPLATE = ERB.new(<<END)
opensprints (<%= OPENSPRINTS_VERSION %>) unstable; urgency=low
<%= message %>
-- Evan Farrar <[email protected]> <%= Time.now.strftime("%a, %d %b %Y %R:%S %z") %>
END
def message
"Changed some stuff"
end
task :update_changelog => :check_version_provided do
old_changelog = File.read("build/debian/changelog")
OPENSPRINTS_VERSION = "#{ENV['VERSION']}-#{(calculate_minor_version||0)+1}"
changelog = CHANGELOG_TEMPLATE.result + old_changelog
File.open("build/debian/changelog", "w") {|f| f << changelog }
print "Changelogged..."
end
task :build => :check_version_provided do
here = Dir.pwd
abort("You need to provide the arduino ide in firmware/arduino/arduino-0017") unless File.exists?("firmware/arduino/arduino-0017")
`rm -rf /tmp/build` if File.exists?('/tmp/build')
`cp -R build /tmp/build`
`cp -R ../opensprints /tmp/build/`
Dir.chdir('/tmp/build')
`debuild --no-tgz-check`
Dir.chdir(here)
print "Packaged..."
end
task :upload => :check_version_provided do
`scp /tmp/opensprints_#{OPENSPRINTS_VERSION}_i386.deb opensprints.org:/home/efarrar/packages.opensprints.org/debian/dists/jaunty/opensprints/binary-i386/`
print 'Uploaded...'
end
task :release do
`ssh opensprints.org -C 'cd /home/efarrar/packages.opensprints.org/debian; dpkg-scanpackages dists/jaunty/opensprints/binary-i386/ /dev/null | gzip -9c > dists/jaunty/opensprints/binary-i386/Packages.gz'`
puts 'Released!'
end
task :check_version_provided do
abort("Sorry, need to provide a major version number") unless ENV['VERSION']
end
task :package => [:update_changelog, :build, :upload, :release] do
puts "Finished version #{OPENSPRINTS_VERSION}"
end
task :build_deb => [:update_changelog, :build] do
end
task :testing_package => [:build_deb] do
`cp /tmp/opensprints_#{OPENSPRINTS_VERSION}_i386.deb /media/disk`
puts "Finished version #{OPENSPRINTS_VERSION}"
end
task :default do
sh "bacon --automatic --quiet"
end