Skip to content
This repository
Newer
Older
100644 215 lines (147 sloc) 4.837 kb
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
1
2 # Build the tar.gz, tar.bz2, and .gem files for an RMagick Release
3
7ac054fc »
2007-12-15 Polish
4 # To use: cd to $HOME
5 # run: rake -f path/to/build_tarball.rake clean
6 # rake -f path/to/build_tarball.rake release=tag beta=whatever
7 #
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
8 # Specify the release as release=RMagick_x-y-z or nothing if release=HEAD
9 # Specify a beta Release as beta=beta1
10
11 require 'rubygems'
2b4da3d6 »
2008-04-22 Use README.rc instead of README.txt
12 require 'redcloth'
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
13 require 'find'
14 require 'fileutils'
15 include FileUtils
16
17
18 CVSSERVER = ":ext:rmagick@rubyforge.org/var/cvs/rmagick"
19
20
7ac054fc »
2007-12-15 Polish
21 # CVS_Tag is the CVS tag for this release. Dist_Directory is CVS_Tag,
22 # modified for use as a directory name.
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
23 if ENV.include?("release")
24 CVS_Tag = ENV["release"]
25 Dist_Directory = CVS_Tag.tr('_-','-.')
26 else
27 CVS_Tag = "HEAD"
28 Dist_Directory = "RMagick-0.0.0"
29 end
30
31
32 # RMagick_Version is just X.Y.Z
33 RMagick_Version = Dist_Directory.sub(/RMagick-/, "")
34
35 # RMagick_Version2 is X.Y.Z + "-beta1" if beta=beta1
36 RMagick_Version2 = RMagick_Version + (ENV.include?("beta") ? "-" + ENV["beta"] : "")
37
38 # Release is RMagick-X.Y.Z, plus "-beta1" if beta=beta1
39 Release = Dist_Directory + (ENV.include?("beta") ? "-" + ENV["beta"] : "")
40
41 README = "README.html"
42 MANIFEST = "ext/RMagick/MANIFEST"
43
44
45
46
7ac054fc »
2007-12-15 Polish
47 # Change the version number placeholders in a file.
48 # Returns an array of lines from the file.
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
49 def reversion(name)
50 now = Time.new
51 now = now.strftime("%m/%d/%y")
52
53 lines = File.readlines name
54 lines.each do |line|
55 line.gsub!(%r{0\.0\.0\$}, RMagick_Version2)
56 line.gsub!(%r{0\.0\.0}, RMagick_Version)
57 line.gsub!(%r{YY/MM/DD}, now)
58 end
59 lines
60 end
61
62
63
64
7ac054fc »
2007-12-15 Polish
65 # Rewrite a file containing embedded version number placeholders.
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
66 def reversion_file(name)
67 lines = reversion(name)
68 tmp_name = name + "_tmp"
69 mv name, tmp_name
70 begin
71 File.open(name, "w") { |f| f.write lines }
72 rescue
73 mv tmp_name, name
74 ensure
75 rm tmp_name
76 end
77 end
78
79
80
81
82 task :extconf do
83 Dir.chdir(Dist_Directory) { reversion_file "ext/RMagick/extconf.rb" }
84 end
85
86
87
88
89 task :gemspec do
90 Dir.chdir(Dist_Directory) { reversion_file "rmagick.gemspec" }
91 end
92
93
94
95
2b4da3d6 »
2008-04-22 Use README.rc instead of README.txt
96 task "README.tmp" do
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
97 Dir.chdir Dist_Directory do
2b4da3d6 »
2008-04-22 Use README.rc instead of README.txt
98 reversion_file "README.rc"
99 body = File.readlines "README.rc"
100 body = RedCloth.new(body.join).to_html + "\n"
101 File.open("README.tmp", "w") { |f| f.write body }
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
102 end
103 end
104
105
106
107
2b4da3d6 »
2008-04-22 Use README.rc instead of README.txt
108 task README => "README.tmp" do
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
109 puts "writing #{README}"
110 Dir.chdir Dist_Directory do
111 File.open(README, "w") do |html|
112 html.write <<END_HTML_HEAD
113 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
114 <html>
115 <head>
116 <title>RMagick #{RMagick_Version2} README</title>
117 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2b4da3d6 »
2008-04-22 Use README.rc instead of README.txt
118 <meta name="GENERATOR" content="RedCloth">
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
119 </head>
120 <body>
121 END_HTML_HEAD
2b4da3d6 »
2008-04-22 Use README.rc instead of README.txt
122 html.write File.readlines("README.tmp")
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
123 html.write <<END_HTML_TAIL
124 </body>
125 </html>
126 END_HTML_TAIL
127 end
128 end
129 end
130
131
132
133
134 task :doc do
135 Dir.chdir(File.join(Dist_Directory, "doc")) do
136 FileList["*.html"].each { |d| reversion_file(d) }
137 end
138 end
139
140
141
142
143 # Remove files we don't want in the tarball.
144 # Ensure files are not executable. (ref: bug #10080)
145 task :fix_files do
146 Dir.chdir Dist_Directory do
147 rm_rf "test", :verbose => true
148 rm "lib/rvg/to_c.rb", :verbose => true
2b4da3d6 »
2008-04-22 Use README.rc instead of README.txt
149 rm "README.rc", :verbose => true
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
150 chmod 0644, FileList["doc/*.html", "doc/ex/*.rb", "doc/ex/images/*", "examples/*.rb"]
151 end
152 end
153
154
155
156
157 task :manifest do
158 now = Time.new
159 now = now.strftime("%H:%M:%S %m/%d/%y")
160 puts "generating #{MANIFEST}"
161
162 Dir.chdir Dist_Directory do
163 File.open(MANIFEST, "w") do |f|
164 f.puts "MANIFEST for #{Release} - #{now}\n\n"
165 Find.find('.') do |name|
166 next if File.directory? name
167 f.puts name[2..-1] # remove leading "./"
168 end
169 end
170 end
171 end
172
173
174
175
176 task :export do
177 sh "cvs -d#{CVSSERVER} export -r #{CVS_Tag} -d #{Dist_Directory} RMagick"
178 end
179
180
181
182
183 task :collateral => ["README.html", :gemspec, :extconf, :doc]
184
7ac054fc »
2007-12-15 Polish
185 GEM = Dist_Directory.downcase + ".gem"
186
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
187 task :default => [:export, :collateral, :fix_files, :manifest] do
44b0d3df »
2008-03-22 To build 7z tarball, pipe output from tar to 7z
188 sh "tar czf #{Release}.tar.gz #{Dist_Directory}"
189 sh "tar cjf #{Release}.tar.bz2 #{Dist_Directory}"
190 sh "tar c #{Release} | 7z a -t7z -m0=lzma -mx=9 -mfb=64 -ms=on -si#{Release}.tar #{Release}.tar.lzma"
ac35220f »
2008-03-21 Build a lzma compressed tarball.
191
192 # Extract with
193 # 7z e RMagick-x.y.z.tar.lzma -so | tar xv
44b0d3df »
2008-03-22 To build 7z tarball, pipe output from tar to 7z
194 #sh "tar cf #{Release}.tar #{Dist_Directory}"
195 #sh "7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on #{Release}.tar.lzma #{Release}.tar"
196 #rm_rf Release+".tar", :verbose => true
197
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
198 Dir.chdir(Dist_Directory) do
199 sh "gem build rmagick.gemspec"
200 mv GEM, "../", :verbose => true
201 end
202 end
203
204
205
206
207 task :clean do
208 rm_rf Dist_Directory, :verbose => true
209 rm_rf Release+".tar.gz", :verbose => true
210 rm_rf Release+".tar.bz2", :verbose => true
ac35220f »
2008-03-21 Build a lzma compressed tarball.
211 rm_rf Release+".tar.lzma", :verbose => true
e08186e1 »
2007-12-09 New. Rakefile for building the release tarballs and gem.
212 rm_rf GEM, :verbose => true
213 end
214
Something went wrong with that request. Please try again.