buildrdeb 0.0.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -6,16 +6,19 @@ See the official Buildr site: http://buildr.apache.org
6
6
 
7
7
  == Install buildrdeb
8
8
 
9
- * See the github instructions on how to setup to install their gems: http://gems.github.com
10
- * For the impatient:
11
- * gem sources -a http://gems.github.com
12
- * sudo gem install intalio-buildrdeb
9
+ * gem install buildrdeb
13
10
 
14
- == Documentation
11
+ == Manual
15
12
 
16
- See http://oss.intalio.com/buildrdeb
13
+ define "foo" do
14
+
15
+ package(:deb).enhance do |deb|
16
+ deb.control = _("config/control")
17
+ deb.preinst = _("config/preinst")
18
+ deb.include(_("target/myfolder"))
19
+ end
17
20
 
18
- http://intalio.github.com/buildrdeb is the cutting edge documentation if you work against the trunk.
21
+ end
19
22
 
20
23
  == License
21
24
 
data/buildrdeb.gemspec CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  Gem::Specification.new do |spec|
18
18
  spec.name = 'buildrdeb'
19
- spec.version = '0.0.3'
19
+ spec.version = '1.0.0'
20
20
  spec.author = 'Antoine Toulme'
21
21
  spec.email = "antoine@lunar-ocean.com"
22
22
  spec.homepage = "http://buildr.apache.org/"
@@ -26,43 +26,38 @@ module BuildrDeb
26
26
  # With deb we recreate the structure asked by the user
27
27
  # then we will call dpkg --build over it.
28
28
  def create_from(file_map)
29
- root = File.join("target", "_#{File.basename(name)}")
29
+ root = File.join("target", "#{File.basename(name)}-contents")
30
30
  mkpath File.join(root, "DEBIAN")
31
- #echo "THe version " + @version
32
- for file in ["control", "prerm", "postinst", "postrm", "preinst", "triggers"]
33
- thefile = eval("self."+file)
34
- targetFile = File.join(root, "DEBIAN", file)
35
- if !thefile.nil? and File.exists? thefile
36
- actualFile = File.open(thefile, "r")
37
- myfile = File.open( targetFile, "w")
38
- actualFile.each { |line|
39
- if file == "control" then
40
- if line.match /^Version: / and !@version.nil? then myfile.puts("Version: " + @version +"\n")
41
- else myfile.puts eval('"'+ line + '"') end
42
- else myfile.puts line end
31
+ for filename in ["control", "prerm", "postinst", "postrm", "preinst", "triggers"]
32
+ file = send(filename)
33
+ if file.nil?
34
+ raise "no control file was defined when packaging as a deb file" if filename == "control"
35
+ else
36
+ raise "Cannot find #{filename}: #{file} doesn't exist" if !File.exists? file
37
+ target = File.join(root, "DEBIAN", filename)
38
+ contents = File.read(file)
39
+ # Replace version if we are looking at control.
40
+ contents.gsub!(/^Version: .*$/, "Version: #{@version}") if (filename == "control" && !@version.nil?)
41
+ File.open(target, "w+") {|t|
42
+ t.write eval("\"#{contents}\"")
43
43
  }
44
- myfile.close
45
- actualFile.close
46
- File.chmod 0755, targetFile
47
- #cp send(file.to_sym), File.join(root, "DEBIAN", file)
48
- #File.chmod 0755, File.join(root, "DEBIAN", file)
44
+ File.chmod 0755, target
49
45
  end
50
46
  end
51
-
52
47
  file_map.each do |path, content|
53
48
  _path = File.join(root, path)
54
49
  if content.respond_to?(:call)
55
50
  raise "Not implemented"
56
- content.call path
57
- elsif content.nil? || File.directory?(content.to_s)
58
- mkpath _path
51
+ #content.call path
52
+ elsif content.nil?
53
+ mkdir_p _path
54
+ elsif File.directory?(content.to_s)
55
+
59
56
  else
60
- mkpath File.dirname(_path)
57
+ mkdir_p File.dirname(_path) if !File.exists?(File.dirname(_path))
61
58
  cp content.to_s, _path
62
59
  end
63
60
  end
64
-
65
-
66
61
  out = %x[ dpkg --build \"#{root}\" \"#{name}\" 2>&1 ]
67
62
  raise "dpkg failed with this error:\n#{out}" if $? != 0
68
63
  end
@@ -74,13 +69,10 @@ module BuildrDeb
74
69
 
75
70
  def package_as_deb(file_name)
76
71
  deb = DebTask.define_task(file_name)
77
- deb.tap do
78
- package ||= project.id
79
- version ||= project.version
80
- end
81
72
  deb.enhance do |task|
82
73
  task.enhance do
83
- raise "no control file was defined when packaging #{project.id} as a deb file" if task.control.nil?
74
+ package ||= project.id
75
+ version ||= project.version
84
76
  end
85
77
  end
86
78
  return deb
@@ -0,0 +1,113 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ desc "Create JRuby all-in-one distribution"
17
+ task "all-in-one" => 'all-in-one:all-in-one'
18
+
19
+ namespace :'all-in-one' do
20
+
21
+ version = "1.5.2"
22
+ jruby_distro = "jruby-bin-#{version}.tar.gz"
23
+ url = "http://jruby.org.s3.amazonaws.com/downloads/#{version}/#{jruby_distro}"
24
+ dir = "jruby-#{version}"
25
+
26
+ task "all-in-one" => [:gem,
27
+ # Prepare to run
28
+ :prepare,
29
+ # Download and extract JRuby
30
+ :download_and_extract,
31
+ # Cleanup JRuby distribution
32
+ :clean_dist,
33
+ # Install Buildr gem and dependencies
34
+ :install_dependencies,
35
+ # Add Buildr executables/scripts
36
+ :add_execs,
37
+ # Package distribution
38
+ :package
39
+ ]
40
+
41
+ desc 'Prepare to run'
42
+ task :prepare do
43
+ mkpath '_all-in-one'
44
+ cd '_all-in-one'
45
+ end
46
+
47
+ desc 'Download and extract JRuby'
48
+ task :download_and_extract do
49
+ unless File.exist? jruby_distro
50
+ puts "Downloading JRuby from #{url} ..."
51
+ sh 'wget', url
52
+ puts "[X] Downloaded JRuby"
53
+ end
54
+
55
+ rm_rf dir if File.exist? dir
56
+
57
+ puts "Extracting JRuby to #{dir} ..."
58
+ sh 'tar', 'xzf', jruby_distro
59
+ puts "[X] Extracted JRuby"
60
+ cd dir
61
+ end
62
+
63
+ desc 'Cleanup JRuby distribution'
64
+ task :clean_dist do
65
+ puts 'Cleaning...'
66
+ rm_rf 'docs'
67
+ mkpath 'jruby-docs'
68
+ mv Dir["COPYING*"], 'jruby-docs'
69
+ mv Dir["LICENSE*"], 'jruby-docs'
70
+ mv 'README', 'jruby-docs'
71
+ rm_rf 'lib/ruby/1.9'
72
+ rm_rf 'lib/ruby/gems/1.8/doc'
73
+ rm_rf 'samples'
74
+ rm_rf 'share'
75
+ end
76
+
77
+ desc 'Install Buildr gem and dependencies'
78
+ task :install_dependencies do
79
+ puts "Install Buildr gem ..."
80
+ sh "bin/jruby", '-S', 'gem', 'install', FileList['../../pkg/*-java.gem'].first,
81
+ '--no-rdoc', '--no-ri'
82
+ puts "[X] Install Buildr gem"
83
+ end
84
+
85
+ desc 'Add Buildr executables/scripts'
86
+ task :add_execs do
87
+ cp 'bin/jruby.exe', 'bin/_buildr.exe'
88
+ cp Dir["../../all-in-one/*"], 'bin'
89
+ end
90
+
91
+ desc 'Package distribution'
92
+ task :package do
93
+ puts "Zipping distribution ..."
94
+ cd '..'
95
+ new_dir = "#{spec.name}-#{spec.version}"
96
+ mv dir, new_dir
97
+ zip = "#{new_dir}.zip"
98
+ rm zip if File.exist? zip
99
+ sh 'zip', '-q', '-r', zip, new_dir
100
+ puts "[X] Zipped distribution"
101
+
102
+ puts "Tarring distribution ..."
103
+ tar = "#{new_dir}.tar.gz"
104
+ rm tar if File.exist? tar
105
+ sh 'tar', 'czf', tar, new_dir
106
+ puts "[X] Tarred distribution"
107
+
108
+ rm_rf new_dir
109
+ end
110
+
111
+ end
112
+
113
+ task(:clobber) { rm_rf '_all-in-one' }
data/rakelib/checks.rake CHANGED
@@ -18,7 +18,7 @@ desc "Check that source files contain the Apache license"
18
18
  task :license=>FileList["**/*.{rb,rake,java,gemspec,buildfile}", 'Rakefile'] do |task|
19
19
  puts "Checking that files contain the Apache license ... "
20
20
  required = task.prerequisites.select { |fn| File.file?(fn) }
21
- missing = required.reject { |fn|
21
+ missing = required.reject { |fn|
22
22
  comments = File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|^-#\s+(.*?)$|<!--(.*?)-->/m).
23
23
  map { |match| match.compact }.flatten.join("\n")
24
24
  comments =~ /Licensed to the Apache Software Foundation/ && comments =~ /http:\/\/www.apache.org\/licenses\/LICENSE-2.0/
@@ -45,7 +45,7 @@ task :dependency do
45
45
  dep_spec.runtime_dependencies.map { |trans| transitive[trans].push(trans) }.flatten.uniq }
46
46
  # For each dependency, make sure *all* its transitive dependencies are listed
47
47
  # as a Buildr dependency, and order is preserved.
48
- spec.dependencies.each_with_index do |dep, index|
48
+ spec.dependencies.select {|dep| dep.type == :runtime }.each_with_index do |dep, index|
49
49
  puts "checking #{dep.name}"
50
50
  transitive[dep].each do |trans|
51
51
  matching = spec.dependencies.find { |existing| trans =~ existing }
data/rakelib/doc.rake CHANGED
@@ -36,7 +36,17 @@ end
36
36
 
37
37
 
38
38
  begin
39
- require 'rakelib/jekylltask'
39
+ require 'jekylltask'
40
+ module TocFilter
41
+ def toc(input)
42
+ input.scan(/<(h2)(?:>|\s+(.*?)>)([^<]*)<\/\1\s*>/mi).inject(%{<ol class="toc">}) { |toc, entry|
43
+ id = entry[1][/^id=(['"])(.*)\1$/, 2]
44
+ title = entry[2].gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip
45
+ toc << %{<li><a href="##{id}">#{title}</a></li>}
46
+ } << "</ol>"
47
+ end
48
+ end
49
+ Liquid::Template.register_filter(TocFilter)
40
50
 
41
51
  desc "Generate Buildr documentation in _site/"
42
52
  JekyllTask.new :jekyll do |task|
@@ -45,9 +55,9 @@ begin
45
55
  end
46
56
 
47
57
  rescue LoadError
48
- puts "Buildr uses the mojombo-jekyll to generate the Web site. You can install it by running rake doc:setup"
58
+ puts "Buildr uses the jekyll gem to generate the Web site. You can install it by running rake doc:setup"
49
59
  task 'doc:setup' do
50
- install_gem 'mojombo-jekyll', :source=>'http://gems.github.com', :version=>'0.5.4'
60
+ install_gem 'jekyll', :version=>'0.6.2'
51
61
  if `pygmentize -V`.empty?
52
62
  args = %w{easy_install Pygments}
53
63
  args.unshift 'sudo' unless Config::CONFIG['host_os'] =~ /windows/
@@ -71,6 +81,13 @@ task :site=>['_site', :rdoc, '_reports/specs.html', '_reports/coverage', 'buildr
71
81
  cp_r '_reports/coverage', '_site'
72
82
  fail 'No coverage report in site directory' unless File.exist?('_site/coverage/index.html')
73
83
  cp 'CHANGELOG', '_site'
84
+ open("_site/.htaccess", "w") do |htaccess|
85
+ htaccess << %Q{
86
+ <FilesMatch "CHANGELOG">
87
+ ForceType 'text/plain; charset=UTF-8'
88
+ </FilesMatch>
89
+ }
90
+ end
74
91
  cp 'buildr.pdf', '_site'
75
92
  fail 'No PDF in site directory' unless File.exist?('_site/buildr.pdf')
76
93
  puts 'OK'
@@ -0,0 +1,39 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ namespace :metrics do
17
+ desc 'run Saikuro reports'
18
+ task :saikuro do
19
+ gem 'atoulme-Saikuro'
20
+ require 'saikuro'
21
+ output_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "_reports", "saikuro"))
22
+ base_dir = Pathname.new(File.expand_path(File.join(File.dirname(__FILE__), "..")))
23
+ rb_files = ["lib", "addon"].collect { |folder|
24
+ FileList[File.expand_path(File.join(File.dirname(__FILE__), "..", folder, "**", "*.rb"))]
25
+ }.flatten.collect {|path|
26
+ Pathname.new(path).relative_path_from(base_dir).to_s
27
+ }
28
+ SaikuroRunner.new.run(rb_files, output_dir)
29
+ end
30
+
31
+ desc 'generate ccn treemap'
32
+ task :ccn_treemap do
33
+ require 'saikuro_treemap'
34
+ SaikuroTreemap.generate_treemap :code_dirs => ['lib', 'addon'], :output_file => "_reports/saikuro_treemap.html"
35
+ end
36
+ end
37
+
38
+ desc 'Run all metrics tools'
39
+ task :metrics => ["metrics:saikuro", "metrics:ccn_treemap"]
data/rakelib/package.rake CHANGED
@@ -67,7 +67,7 @@ task :snapshot=>[:package] do
67
67
  cp FileList['pkg/{*.gem,*.tgz,*.zip}'], '_snapshot/gems'
68
68
  puts "Generating gem index ..."
69
69
  sh 'gem', 'generate_index', '--directory', '_snapshot'
70
- puts "Copying gem and index back to Apache"
70
+ puts "Copying gem and index back to Apache"
71
71
  sh 'rsync', '--progress', '--recursive', '_snapshot/', 'people.apache.org:public_html/buildr/snapshot/'
72
72
  end
73
73
  task(:clobber) { rm_rf '_snapshot' }
data/rakelib/release.rake CHANGED
@@ -45,6 +45,9 @@ task :release do
45
45
 
46
46
  # Upload binary and source packages to RubyForge.
47
47
  lambda do
48
+ sh 'rubyforge', 'login'
49
+ # update rubyforge projects, processors, etc. in local config
50
+ sh 'rubyforge', 'config'
48
51
  files = FileList["_release/#{spec.version}/dist/*.{gem,tgz,zip}"]
49
52
  puts "Uploading #{spec.version} to RubyForge ... "
50
53
  rubyforge = RubyForge.new.configure
@@ -63,7 +66,7 @@ task :release do
63
66
  # Create an SVN tag for this release.
64
67
  lambda do
65
68
  info = `svn info` + `git svn info` # Using either svn or git-svn
66
- if url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0]
69
+ if url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0]
67
70
  new_url = url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{spec.version}")
68
71
  unless url == new_url
69
72
  sh 'svn', 'copy', url, new_url, '-m', "Release #{spec.version}" do |ok, res|
@@ -80,7 +83,7 @@ task :release do
80
83
 
81
84
 
82
85
  # Update CHANGELOG to next release number.
83
- lambda do
86
+ lambda do
84
87
  next_version = spec.version.to_s.split('.').map { |v| v.to_i }.
85
88
  zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
86
89
  modified = "#{next_version} (Pending)\n\n" + File.read('CHANGELOG')
@@ -89,7 +92,7 @@ task :release do
89
92
  end
90
93
  puts "[X] Updated CHANGELOG and added entry for next release"
91
94
  end.call
92
-
95
+
93
96
 
94
97
  # Update source files to next release number.
95
98
  lambda do
@@ -98,7 +101,7 @@ task :release do
98
101
 
99
102
  ver_file = "lib/#{spec.name}.rb"
100
103
  if File.exist?(ver_file)
101
- modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
104
+ modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
102
105
  File.open ver_file, 'w' do |file|
103
106
  file.write modified
104
107
  end
@@ -107,7 +110,7 @@ task :release do
107
110
 
108
111
  spec_file = "#{spec.name}.gemspec"
109
112
  if File.exist?(spec_file)
110
- modified = File.read(spec_file).sub(/(s(?:pec)?\.version\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
113
+ modified = File.read(spec_file).sub(/(s(?:pec)?\.version\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
111
114
  File.open spec_file, 'w' do |file|
112
115
  file.write modified
113
116
  end
@@ -115,7 +118,7 @@ task :release do
115
118
  end
116
119
  end.call
117
120
 
118
-
121
+
119
122
  # Prepare release announcement email.
120
123
  lambda do
121
124
  changes = File.read("_release/#{spec.version}/CHANGES")[/.*?\n(.*)/m, 1]
data/rakelib/rspec.rake CHANGED
@@ -18,34 +18,53 @@ begin
18
18
  require 'spec/rake/spectask'
19
19
  directory '_reports'
20
20
 
21
+ def default_spec_opts
22
+ default = %w{--format failing_examples:failed --format html:_reports/specs.html --backtrace}
23
+ default << '--colour' if $stdout.isatty
24
+ default
25
+ end
26
+
21
27
  desc "Run all specs"
22
- Spec::Rake::SpecTask.new :spec=>'_reports' do |task|
28
+ Spec::Rake::SpecTask.new :spec=>['_reports', :compile] do |task|
29
+ ENV['USE_FSC'] = 'no'
23
30
  task.spec_files = FileList['spec/**/*_spec.rb']
24
31
  task.spec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
25
- task.spec_opts = %w{--format specdoc --format failing_examples:failed --format html:_reports/specs.html --loadby mtime --backtrace}
26
- task.spec_opts << '--colour' if $stdout.isatty
32
+ task.spec_opts = default_spec_opts
33
+ task.spec_opts << '--format specdoc'
27
34
  end
28
35
  file('_reports/specs.html') { task(:spec).invoke }
29
36
 
30
37
  desc 'Run all failed examples from previous run'
31
38
  Spec::Rake::SpecTask.new :failed do |task|
39
+ ENV['USE_FSC'] = 'no'
32
40
  task.spec_files = FileList['spec/**/*_spec.rb']
33
- task.spec_opts = %w{--format specdoc --format failing_examples:failed --example failed --backtrace}
34
- task.spec_opts << '--colour' if $stdout.isatty
41
+ task.spec_opts = default_spec_opts
42
+ task.spec_opts << '--format specdoc' << '--example failed'
35
43
  end
36
44
 
37
45
  desc 'Run RSpec and generate Spec and coverage reports (slow)'
38
- Spec::Rake::SpecTask.new :coverage=>'_reports' do |task|
46
+ Spec::Rake::SpecTask.new :coverage=>['_reports', :compile] do |task|
47
+ ENV['USE_FSC'] = 'no'
39
48
  task.spec_files = FileList['spec/**/*_spec.rb']
40
- task.spec_opts = %W{--format progress --format failing_examples:failed --format html:_reports/specs.html --backtrace}
41
- task.spec_opts << '--colour' if $stdout.isatty
49
+ task.spec_opts = default_spec_opts
50
+ task.spec_opts << '--format progress'
42
51
  task.rcov = true
43
52
  task.rcov_dir = '_reports/coverage'
44
53
  task.rcov_opts = %w{--exclude / --include-file ^lib --text-summary}
45
54
  end
46
55
  file('_reports/coverage') { task(:coverage).invoke }
47
56
 
48
-
57
+ task :load_ci_reporter do
58
+ gem 'ci_reporter'
59
+ ENV['CI_REPORTS'] = '_reports/ci'
60
+ # CI_Reporter does not quote the path to rspec_loader which causes problems when ruby is installed in C:/Program Files
61
+ ci_rep_path = Gem.loaded_specs['ci_reporter'].full_gem_path
62
+ ENV["SPEC_OPTS"] = [ENV["SPEC_OPTS"], default_spec_opts, "--require", "\"#{ci_rep_path}/lib/ci/reporter/rake/rspec_loader.rb\"", "--format", "CI::Reporter::RSpec"].join(" ")
63
+ end
64
+
65
+ desc 'Run all specs with CI reporter'
66
+ task :ci=>[:load_ci_reporter, :spec]
67
+
49
68
  # Useful for testing with JRuby when using Ruby and vice versa.
50
69
  namespace :spec do
51
70
  desc "Run all specs specifically with Ruby"
data/rakelib/setup.rake CHANGED
@@ -17,7 +17,7 @@
17
17
  require 'jruby' if RUBY_PLATFORM[/java/]
18
18
  require 'rubygems/source_info_cache'
19
19
 
20
- RAKE_SUDO = case (ENV['RAKE_SUDO'] or 'yes').strip.downcase
20
+ RAKE_SUDO = case (ENV['RAKE_SUDO'] or 'false').strip.downcase
21
21
  when 'yes', 'true'
22
22
  true
23
23
  else
@@ -35,7 +35,14 @@ def install_gem(name, options = {})
35
35
  args = []
36
36
  args << 'sudo' << 'env' << "JAVA_HOME=#{ENV['JAVA_HOME']}" if sudo_needed? and RAKE_SUDO
37
37
  args << rb_bin << '-S' << 'gem' << 'install' << name
38
- args << '--version' << dep.version_requirements.to_s
38
+
39
+ if (spec.respond_to? :requirement)
40
+ args << '--version' << dep.requirement.to_s
41
+ else
42
+ # Dependency.version_requirements deprecated in rubygems 1.3.6
43
+ args << '--version' << dep.version_requirements.to_s
44
+ end
45
+
39
46
  args << '--source' << options[:source] if options[:source]
40
47
  args << '--source' << 'http://gems.rubyforge.org'
41
48
  args << '--install-dir' << ENV['GEM_HOME'] if ENV['GEM_HOME']
@@ -49,6 +56,11 @@ desc "If you're building from sources, run this task first to setup the necessar
49
56
  task :setup do
50
57
  missing = spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty? }
51
58
  missing.each do |dep|
52
- install_gem dep.name, :version=>dep.version_requirements
59
+ if (spec.respond_to? :requirement)
60
+ install_gem dep.name, :version=>dep.requirement
61
+ else
62
+ # Dependency.version_requirements deprecated in rubygems 1.3.6
63
+ install_gem dep.name, :version=>dep.version_requirements
64
+ end
53
65
  end
54
66
  end
data/rakelib/stage.rake CHANGED
@@ -23,6 +23,7 @@ rescue LoadError
23
23
  task(:setup) { install_gem 'rubyforge' }
24
24
  end
25
25
 
26
+ gpg_cmd = 'gpg2'
26
27
 
27
28
  task :prepare do |task, args|
28
29
  # Make sure we're doing a release from checked code.
@@ -47,7 +48,12 @@ task :prepare do |task, args|
47
48
  # Need GPG to sign the packages.
48
49
  lambda do
49
50
  args.gpg or fail "Please run with gpg=<argument for gpg --local-user>"
50
- fail "No GPG user #{args.gpg}" if `gpg2 --list-keys #{args.gpg}`.empty?
51
+ gpg_ok = `gpg2 --list-keys #{args.gpg}`
52
+ if !$?.success?
53
+ gpg_ok = `gpg --list-keys #{args.gpg}`
54
+ gpg_cmd = 'gpg'
55
+ end
56
+ fail "No GPG user #{args.gpg}" if gpg_ok.empty?
51
57
  end.call
52
58
 
53
59
  task(:license).invoke
@@ -62,11 +68,18 @@ task :prepare do |task, args|
62
68
  puts "[X] We have JRuby, Scala and Groovy"
63
69
  end.call
64
70
 
71
+ # Need Prince to generate PDF
72
+ lambda do
73
+ puts "Checking that we have prince available ... "
74
+ sh 'prince --version'
75
+ puts "[X] We have prince available"
76
+ end.call
77
+
65
78
  # Need RubyForge to upload new release files.
66
79
  lambda do
67
80
  puts "[!] Make sure you have admin privileges to make a release on RubyForge"
68
81
  rubyforge = RubyForge.new.configure
69
- rubyforge.login
82
+ rubyforge.login
70
83
  rubyforge.scrape_project(spec.name)
71
84
  end.call
72
85
 
@@ -99,14 +112,14 @@ task :stage=>['setup', 'doc:setup', :clobber, :prepare] do |task, args|
99
112
  task(:package).invoke
100
113
  mkpath '_staged/dist'
101
114
  FileList['pkg/*.{gem,zip,tgz}'].each do |source|
102
- pkg = source.pathmap('_staged/dist/%n%x')
115
+ pkg = source.pathmap('_staged/dist/%n%x')
103
116
  cp source, pkg
104
117
  bytes = File.open(pkg, 'rb') { |file| file.read }
105
118
  File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
106
119
  File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
107
- sh 'gpg2', '--local-user', args.gpg, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
120
+ sh gpg_cmd, '--local-user', args.gpg, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
108
121
  end
109
- cp 'etc/KEYS', '_staged'
122
+ cp 'etc/KEYS', '_staged/dist'
110
123
  puts "[X] Created and signed release packages in _staged/dist"
111
124
  end.call
112
125
 
@@ -114,10 +127,11 @@ task :stage=>['setup', 'doc:setup', :clobber, :prepare] do |task, args|
114
127
  # want to do that before generating the site/documentation.
115
128
  lambda do
116
129
  puts "Updating download page with links to release packages ... "
117
- url = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
130
+ mirror = "http://www.apache.org/dyn/closer.cgi/#{spec.name}/#{spec.version}"
131
+ official = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
118
132
  rows = FileList['_staged/dist/*.{gem,tgz,zip}'].map { |pkg|
119
133
  name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
120
- %{| "#{name}":#{url}/#{name} | "#{md5}":#{url}/#{name}.md5 | "Sig":#{url}/#{name}.asc |}
134
+ %{| "#{name}":#{mirror}/#{name} | "#{md5}":#{official}/#{name}.md5 | "Sig":#{official}/#{name}.asc |}
121
135
  }
122
136
  textile = <<-TEXTILE
123
137
  h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
@@ -125,7 +139,7 @@ h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
125
139
  |_. Package |_. MD5 Checksum |_. PGP |
126
140
  #{rows.join("\n")}
127
141
 
128
- p>. ("Release signing keys":#{url}/KEYS)
142
+ p>. ("Release signing keys":#{official}/KEYS)
129
143
  TEXTILE
130
144
  file_name = 'doc/download.textile'
131
145
  print "Adding download links to #{file_name} ... "
@@ -154,7 +168,7 @@ p>. ("Release signing keys":#{url}/KEYS)
154
168
  sh 'rsync', '--progress', '--recursive', '_staged/', url
155
169
  puts "[X] Uploaded _staged directory to #{url}"
156
170
  end.call
157
-
171
+
158
172
 
159
173
  # Prepare a release vote email. In the distant future this will also send the
160
174
  # email for you and vote on it.
@@ -42,6 +42,9 @@ CONTROL
42
42
  Buildr::write "control2", ""
43
43
  Buildr::write "postinst", ""
44
44
  Buildr::write "prerm", ""
45
+ Buildr::write "postinst2", <<-POSTINST2
46
+ bash generate_code(#\{MY_CUSTOM_VALUE\})
47
+ POSTINST2
45
48
  end
46
49
 
47
50
  it "should throw an error if no control file is given" do
@@ -51,7 +54,7 @@ CONTROL
51
54
  project.package(:deb).postinst = _("postinst")
52
55
  project.package(:deb).prerm = _("prerm")
53
56
  end
54
- lambda { project("foo").package(:deb).invoke }.should raise_error(/no control file was defined when packaging foo as a deb file/)
57
+ lambda { project("foo").package(:deb).invoke }.should raise_error(/no control file was defined when packaging as a deb file/)
55
58
  end
56
59
 
57
60
  it "should raise an exception if the control is incorrectly formatted" do
@@ -62,7 +65,6 @@ CONTROL
62
65
  project.package(:deb).prerm = _("prerm")
63
66
  end
64
67
  lambda { project("foo").package(:deb).invoke }.should raise_error(/dpkg failed with this error:/)
65
- File.exists?("target/foo-1.0.deb").should be_false
66
68
  end
67
69
 
68
70
  it "should give a project the ability to package as deb" do
@@ -86,8 +88,9 @@ CONTROL
86
88
  project.package(:deb).postinst = _("postinst")
87
89
  project.package(:deb).prerm = _("prerm")
88
90
  project.package(:deb).include("blah.class", :path => "lib")
89
- project.package(:deb).include("folder", :as => "otherlib")
91
+ project.package(:deb).include("folder", :as => "otherlib/")
90
92
  end
93
+ project("foo").package(:deb).invoke
91
94
  lambda { project("foo").package(:deb).invoke }.should_not raise_error
92
95
  File.exists?("target/foo-1.0.deb").should be_true
93
96
  #check the contents of the deb file:
@@ -111,4 +114,35 @@ CONTROL
111
114
  project("foo").package(:deb, :file => "bar-1.0.deb").invoke
112
115
  File.exists?("bar-1.0.deb").should be_true
113
116
  end
117
+
118
+ it 'should change the version in the control file' do
119
+ write_files
120
+ define("foo", :version => "2.0") do
121
+ project.package(:deb).tap do |deb|
122
+ deb.control = _("control")
123
+ deb.postinst = _("postinst")
124
+ deb.prerm = _("prerm")
125
+ end
126
+ end
127
+ project("foo").package(:deb).invoke
128
+ File.exists?( project("foo").package(:deb).to_s).should be_true
129
+ File.exists?("target/foo-2.0.deb-contents/DEBIAN/control").should be_true
130
+ File.read("target/foo-2.0.deb-contents/DEBIAN/control").should match /^Version: 2.0$/
131
+ end
132
+
133
+ it "should evaluate the contents of the file" do
134
+ write_files
135
+ define("foo", :version => "2.0") do
136
+ project.package(:deb).tap do |deb|
137
+ deb.control = _("control")
138
+ deb.postinst = _("postinst2")
139
+ deb.prerm = _("prerm")
140
+ end
141
+ end
142
+ MY_CUSTOM_VALUE = "custom"
143
+ project("foo").package(:deb).invoke
144
+ File.exists?( project("foo").package(:deb).to_s).should be_true
145
+ File.exists?("target/foo-2.0.deb-contents/DEBIAN/postinst").should be_true
146
+ File.read("target/foo-2.0.deb-contents/DEBIAN/postinst").should match MY_CUSTOM_VALUE
147
+ end
114
148
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildrdeb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
+ - 1
7
8
  - 0
8
9
  - 0
9
- - 3
10
- version: 0.0.3
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Antoine Toulme
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-16 00:00:00 -07:00
18
+ date: 2010-09-25 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -34,9 +34,10 @@ extra_rdoc_files:
34
34
  files:
35
35
  - lib/buildrdeb/package.rb
36
36
  - lib/buildrdeb.rb
37
+ - rakelib/all-in-one.rake
37
38
  - rakelib/checks.rake
38
39
  - rakelib/doc.rake
39
- - rakelib/jekylltask.rb
40
+ - rakelib/metrics.rake
40
41
  - rakelib/package.rake
41
42
  - rakelib/release.rake
42
43
  - rakelib/rspec.rake
@@ -1,120 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with this
3
- # work for additional information regarding copyright ownership. The ASF
4
- # licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations under
14
- # the License.
15
-
16
-
17
- gem 'mojombo-jekyll', '~> 0.5.2' # skip past some buggy versions
18
- require 'rake/tasklib'
19
- require 'jekyll'
20
-
21
-
22
- class JekyllTask < Rake::TaskLib
23
- def initialize(name=:jekyll) # :yield: self
24
- @name = name
25
- @source = name
26
- @target = name
27
- yield self if block_given?
28
- task name, :auto, :needs=>[@source] do |task, args|
29
- generate args.auto
30
- end
31
- if @source != @target
32
- file @target=>FileList["#{@source}/**/*"] do
33
- generate
34
- end
35
- task 'clobber' do
36
- rm_rf @target
37
- end
38
- end
39
- end
40
-
41
- attr_accessor :source
42
- attr_accessor :target
43
-
44
- def generate(auto = false)
45
- options = { 'source'=>source, 'destination'=>target }
46
- options = Jekyll.configuration(options)
47
- site = Jekyll::Site.new(options)
48
-
49
- if auto
50
- require 'directory_watcher'
51
- puts "Auto generating: just edit a page and save, watch the console to see when we're done regenerating pages"
52
- dw = DirectoryWatcher.new(source)
53
- dw.interval = 1
54
- dw.glob = Dir.chdir(source) do
55
- dirs = Dir['*'].select { |x| File.directory?(x) }
56
- dirs -= [target]
57
- dirs = dirs.map { |x| "#{x}/**/*" }
58
- dirs += ['*']
59
- end
60
- dw.start
61
- dw.add_observer do |*args|
62
- t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
63
- puts "[#{t}] regeneration: #{args.size} files changed"
64
- site.process
65
- puts "Done"
66
- end
67
- loop { sleep 1 }
68
- else
69
- puts "Generating documentation in #{target}"
70
- site.process
71
- touch target
72
- end
73
- end
74
- end
75
-
76
-
77
- module TocFilter
78
- def toc(input)
79
- input.scan(/<(h2)(?:>|\s+(.*?)>)([^<]*)<\/\1\s*>/mi).inject(%{<ol class="toc">}) { |toc, entry|
80
- id = entry[1][/^id=(['"])(.*)\1$/, 2]
81
- title = entry[2].gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip
82
- toc << %{<li><a href="##{id}">#{title}</a></li>}
83
- } << "</ol>"
84
- end
85
- end
86
- Liquid::Template.register_filter(TocFilter)
87
-
88
-
89
-
90
- # Under Ruby 1.9 [a,b,c].to_s doesn't join the array first. (Jekyll 0.5.2 requires this)
91
- module Jekyll
92
- class HighlightBlock < Liquid::Block
93
- def render(context)
94
- if context.registers[:site].pygments
95
- render_pygments(context, super.join)
96
- else
97
- render_codehighlighter(context, super.join)
98
- end
99
- end
100
- end
101
- end
102
-
103
- # Ruby 1.9 has sane closure scoping which manages to mess Liquid filters. (Liquid 2.0.0 requires this)
104
- module Liquid
105
- class Variable
106
- def render(context)
107
- return '' if @name.nil?
108
- @filters.inject(context[@name]) do |output, filter|
109
- filterargs = filter[1].to_a.collect do |a|
110
- context[a]
111
- end
112
- begin
113
- context.invoke(filter[0], output, *filterargs)
114
- rescue FilterNotFound
115
- raise FilterNotFound, "Error - filter '#{filter[0]}' in '#{@markup.strip}' could not be found."
116
- end
117
- end
118
- end
119
- end
120
- end