Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 216 lines (149 sloc) 4.973 kb
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
1
2 # Build the tar.gz, tar.bz2, and .gem files for an RMagick Release
7680d1f update comments
rmagick authored
3 # Expects the CVS tag for release RMagick x.y.z to be in the form RMagick_x-y-z.
7ac054f Polish
rmagick authored
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 #
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
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'
2b4da3d Use README.rc instead of README.txt
rmagick authored
12 require 'redcloth'
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
13 require 'find'
14 require 'fileutils'
15 include FileUtils
16
17
18 CVSSERVER = ":ext:rmagick@rubyforge.org/var/cvs/rmagick"
19
20
7ac054f Polish
rmagick authored
21 # CVS_Tag is the CVS tag for this release. Dist_Directory is CVS_Tag,
22 # modified for use as a directory name.
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
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
7ac054f Polish
rmagick authored
47 # Change the version number placeholders in a file.
48 # Returns an array of lines from the file.
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
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
7ac054f Polish
rmagick authored
65 # Rewrite a file containing embedded version number placeholders.
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
66 def reversion_file(name)
67 lines = reversion(name)
68 tmp_name = name + "_tmp"
69 mv name, tmp_name
70 begin
6ce0330 Fixed bug that prevented rake from correctly creating the ruby gem and d...
Omer Bar-or authored
71 File.open(name, "w") { |f| lines.each { |line| f.write line } }
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
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
db5249d Convert README.rc to README.txt, delete README.rc, leave README.txt in t...
rmagick authored
96 task "README.txt" do
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
97 Dir.chdir Dist_Directory do
2b4da3d Use README.rc instead of README.txt
rmagick authored
98 reversion_file "README.rc"
99 body = File.readlines "README.rc"
100 body = RedCloth.new(body.join).to_html + "\n"
db5249d Convert README.rc to README.txt, delete README.rc, leave README.txt in t...
rmagick authored
101 File.open("README.txt", "w") { |f| f.write body }
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
102 end
103 end
104
105
106
107
db5249d Convert README.rc to README.txt, delete README.rc, leave README.txt in t...
rmagick authored
108 task README => "README.txt" do
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
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">
2b4da3d Use README.rc instead of README.txt
rmagick authored
118 <meta name="GENERATOR" content="RedCloth">
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
119 </head>
120 <body>
121 END_HTML_HEAD
db5249d Convert README.rc to README.txt, delete README.rc, leave README.txt in t...
rmagick authored
122 html.write File.readlines("README.txt")
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
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
2b4da3d Use README.rc instead of README.txt
rmagick authored
149 rm "README.rc", :verbose => true
8a0d7b4 Don't include README.txt in the tarball.
rmagick authored
150 rm "README.txt", :verbose => true
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
151 chmod 0644, FileList["doc/*.html", "doc/ex/*.rb", "doc/ex/images/*", "examples/*.rb"]
152 end
153 end
154
155
156
157
158 task :manifest do
159 now = Time.new
160 now = now.strftime("%H:%M:%S %m/%d/%y")
161 puts "generating #{MANIFEST}"
162
163 Dir.chdir Dist_Directory do
164 File.open(MANIFEST, "w") do |f|
165 f.puts "MANIFEST for #{Release} - #{now}\n\n"
166 Find.find('.') do |name|
167 next if File.directory? name
168 f.puts name[2..-1] # remove leading "./"
169 end
170 end
171 end
172 end
173
174
175
176
177 task :export do
178 sh "cvs -d#{CVSSERVER} export -r #{CVS_Tag} -d #{Dist_Directory} RMagick"
179 end
180
181
182
183
db5249d Convert README.rc to README.txt, delete README.rc, leave README.txt in t...
rmagick authored
184 task :collateral => [README, :gemspec, :extconf, :doc]
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
185
7ac054f Polish
rmagick authored
186 GEM = Dist_Directory.downcase + ".gem"
187
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
188 task :default => [:export, :collateral, :fix_files, :manifest] do
44b0d3d To build 7z tarball, pipe output from tar to 7z
rmagick authored
189 sh "tar czf #{Release}.tar.gz #{Dist_Directory}"
190 sh "tar cjf #{Release}.tar.bz2 #{Dist_Directory}"
191 sh "tar c #{Release} | 7z a -t7z -m0=lzma -mx=9 -mfb=64 -ms=on -si#{Release}.tar #{Release}.tar.lzma"
ac35220 Build a lzma compressed tarball.
rmagick authored
192
193 # Extract with
194 # 7z e RMagick-x.y.z.tar.lzma -so | tar xv
44b0d3d To build 7z tarball, pipe output from tar to 7z
rmagick authored
195 #sh "tar cf #{Release}.tar #{Dist_Directory}"
196 #sh "7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on #{Release}.tar.lzma #{Release}.tar"
197 #rm_rf Release+".tar", :verbose => true
198
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
199 Dir.chdir(Dist_Directory) do
200 sh "gem build rmagick.gemspec"
201 mv GEM, "../", :verbose => true
202 end
203 end
204
205
206
207
208 task :clean do
209 rm_rf Dist_Directory, :verbose => true
210 rm_rf Release+".tar.gz", :verbose => true
211 rm_rf Release+".tar.bz2", :verbose => true
ac35220 Build a lzma compressed tarball.
rmagick authored
212 rm_rf Release+".tar.lzma", :verbose => true
e08186e New. Rakefile for building the release tarballs and gem.
rmagick authored
213 rm_rf GEM, :verbose => true
214 end
215
Something went wrong with that request. Please try again.