buildrdeb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
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
+ require 'jruby' if RUBY_PLATFORM[/java/]
18
+ require 'rubygems/source_info_cache'
19
+
20
+ RAKE_SUDO = case (ENV['RAKE_SUDO'] or 'yes').strip.downcase
21
+ when 'yes', 'true'
22
+ true
23
+ else
24
+ false
25
+ end
26
+
27
+ # Install the specified gem. Options include:
28
+ # - :version -- Version requirement, e.g. '1.2' or '~> 1.2'
29
+ # - :source -- Gem repository, e.g. 'http://gems.github.com'
30
+ def install_gem(name, options = {})
31
+ dep = Gem::Dependency.new(name, options[:version] || '>0')
32
+ if Gem::SourceIndex.from_installed_gems.search(dep).empty?
33
+ puts "Installing #{name} ..."
34
+ rb_bin = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
35
+ args = []
36
+ args << 'sudo' << 'env' << "JAVA_HOME=#{ENV['JAVA_HOME']}" if sudo_needed? and RAKE_SUDO
37
+ args << rb_bin << '-S' << 'gem' << 'install' << name
38
+ args << '--version' << dep.version_requirements.to_s
39
+ args << '--source' << options[:source] if options[:source]
40
+ args << '--source' << 'http://gems.rubyforge.org'
41
+ args << '--install-dir' << ENV['GEM_HOME'] if ENV['GEM_HOME']
42
+ sh *args
43
+ end
44
+ end
45
+
46
+
47
+ # Setup environment for running this Rakefile (RSpec, Jekyll, etc).
48
+ desc "If you're building from sources, run this task first to setup the necessary dependencies."
49
+ task :setup do
50
+ missing = spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty? }
51
+ missing.each do |dep|
52
+ install_gem dep.name, :version=>dep.version_requirements
53
+ end
54
+ end
@@ -0,0 +1,206 @@
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
+ require 'digest/md5'
18
+ require 'digest/sha1'
19
+
20
+ begin # Releases upload Gems to RubyForge.
21
+ require 'rubyforge'
22
+ rescue LoadError
23
+ task(:setup) { install_gem 'rubyforge' }
24
+ end
25
+
26
+
27
+ task :prepare do |task, args|
28
+ # Make sure we're doing a release from checked code.
29
+ lambda do
30
+ puts "Checking there are no local changes ... "
31
+ svn = `svn status`
32
+ fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless svn.empty?
33
+ git = `git status`
34
+ fail "Cannot release unless all local changes are in Git:\n#{git}" if git[/^#\t/]
35
+ puts "[X] There are no local changes, everything is in source control"
36
+ end.call
37
+
38
+ # Make sure we have a valid CHANGELOG entry for this release.
39
+ lambda do
40
+ puts "Checking that CHANGELOG indicates most recent version and today's date ... "
41
+ expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
42
+ header = File.readlines('CHANGELOG').first.chomp
43
+ fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
44
+ puts "[x] CHANGELOG indicates most recent version and today's date"
45
+ end.call
46
+
47
+ # Need GPG to sign the packages.
48
+ lambda do
49
+ 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
+ end.call
52
+
53
+ task(:license).invoke
54
+ task(:dependency).invoke
55
+
56
+ # Need JRuby, Scala and Groovy installed to run all the specs.
57
+ lambda do
58
+ puts "Checking that we have JRuby, Scala and Groovy available ... "
59
+ sh 'jruby --version'
60
+ sh 'scala -version'
61
+ sh 'groovy -version'
62
+ puts "[X] We have JRuby, Scala and Groovy"
63
+ end.call
64
+
65
+ # Need RubyForge to upload new release files.
66
+ lambda do
67
+ puts "[!] Make sure you have admin privileges to make a release on RubyForge"
68
+ rubyforge = RubyForge.new.configure
69
+ rubyforge.login
70
+ rubyforge.scrape_project(spec.name)
71
+ end.call
72
+
73
+ # We will be speccing in one platform, so also spec the other one.
74
+ task(RUBY_PLATFORM =~ /java/ ? 'spec:ruby' : 'spec:jruby').invoke # Test the *other* platform
75
+ end
76
+
77
+
78
+ task :stage=>['setup', 'doc:setup', :clobber, :prepare] do |task, args|
79
+ mkpath '_staged'
80
+
81
+ # Start by figuring out what has changed.
82
+ lambda do
83
+ puts "Looking for changes between this release and previous one ..."
84
+ pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
85
+ changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
86
+ current = changes[spec.version.to_s]
87
+ fail "No changeset found for version #{spec.version}" unless current
88
+ File.open '_staged/CHANGES', 'w' do |file|
89
+ file.write "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})\n"
90
+ file.write current
91
+ end
92
+ puts "[X] Listed most recent changed in _staged/CHANGES"
93
+ end.call
94
+
95
+ # Create the packages (gem, tarball) and sign them. This requires user
96
+ # intervention so the earlier we do it the better.
97
+ lambda do
98
+ puts "Creating and signing release packages ..."
99
+ task(:package).invoke
100
+ mkpath '_staged/dist'
101
+ FileList['pkg/*.{gem,zip,tgz}'].each do |source|
102
+ pkg = source.pathmap('_staged/dist/%n%x')
103
+ cp source, pkg
104
+ bytes = File.open(pkg, 'rb') { |file| file.read }
105
+ File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
106
+ 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
108
+ end
109
+ cp 'etc/KEYS', '_staged'
110
+ puts "[X] Created and signed release packages in _staged/dist"
111
+ end.call
112
+
113
+ # The download page should link to the new binaries/sources, and we
114
+ # want to do that before generating the site/documentation.
115
+ lambda do
116
+ puts "Updating download page with links to release packages ... "
117
+ url = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
118
+ rows = FileList['_staged/dist/*.{gem,tgz,zip}'].map { |pkg|
119
+ name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
120
+ %{| "#{name}":#{url}/#{name} | "#{md5}":#{url}/#{name}.md5 | "Sig":#{url}/#{name}.asc |}
121
+ }
122
+ textile = <<-TEXTILE
123
+ h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
124
+
125
+ |_. Package |_. MD5 Checksum |_. PGP |
126
+ #{rows.join("\n")}
127
+
128
+ p>. ("Release signing keys":#{url}/KEYS)
129
+ TEXTILE
130
+ file_name = 'doc/download.textile'
131
+ print "Adding download links to #{file_name} ... "
132
+ modified = File.read(file_name).sub(/^h2\(#dist\).*$/) { |header| "#{header}\n\n#{textile}" }
133
+ File.open file_name, 'w' do |file|
134
+ file.write modified
135
+ end
136
+ puts "[X] Updated #{file_name}"
137
+ end.call
138
+
139
+
140
+ # Now we can create the Web site, this includes running specs, coverage report, etc.
141
+ # This will take a while, so we want to do it as last step before upload.
142
+ lambda do
143
+ puts "Creating new Web site"
144
+ task(:site).invoke
145
+ cp_r '_site', '_staged/site'
146
+ puts "[X] Created new Web site in _staged/site"
147
+ end.call
148
+
149
+
150
+ # Move everything over to people.apache.org so we can vote on it.
151
+ lambda do
152
+ url = "people.apache.org:~/public_html/#{spec.name}/#{spec.version}"
153
+ puts "Uploading _staged directory to #{url} ..."
154
+ sh 'rsync', '--progress', '--recursive', '_staged/', url
155
+ puts "[X] Uploaded _staged directory to #{url}"
156
+ end.call
157
+
158
+
159
+ # Prepare a release vote email. In the distant future this will also send the
160
+ # email for you and vote on it.
161
+ lambda do
162
+ # Need to know who you are on Apache, local user may be different (see .ssh/config).
163
+ whoami = `ssh people.apache.org whoami`.strip
164
+ base_url = "http://people.apache.org/~#{whoami}/buildr/#{spec.version}"
165
+ # Need changes for this release only.
166
+ changelog = File.read('CHANGELOG').scan(/(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/)
167
+ changes = changelog[0][2]
168
+ previous_version = changelog[1][1]
169
+
170
+ email = <<-EMAIL
171
+ To: dev@buildr.apache.org
172
+ Subject: [VOTE] Buildr #{spec.version} release
173
+
174
+ We're voting on the source distributions available here:
175
+ #{base_url}/dist/
176
+
177
+ Specifically:
178
+ #{base_url}/dist/buildr-#{spec.version}.tgz
179
+ #{base_url}/dist/buildr-#{spec.version}.zip
180
+
181
+ The documentation generated for this release is available here:
182
+ #{base_url}/site/
183
+ #{base_url}/site/buildr.pdf
184
+
185
+ The official specification against which this release was tested:
186
+ #{base_url}/site/specs.html
187
+
188
+ Test coverage report:
189
+ #{base_url}/site/coverage/index.html
190
+
191
+
192
+ The following changes were made since #{previous_version}:
193
+
194
+ #{changes.gsub(/^/, ' ')}
195
+ EMAIL
196
+ File.open 'vote-email.txt', 'w' do |file|
197
+ file.write email
198
+ end
199
+ puts "[X] Created release vote email template in 'vote-email.txt'"
200
+ puts email
201
+ end.call
202
+
203
+ end
204
+
205
+
206
+ task(:clobber) { rm_rf '_staged' }
@@ -0,0 +1,114 @@
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
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ describe BuildrDeb::DebTask do
19
+
20
+ def write_files
21
+ Buildr::write "control", <<-CONTROL
22
+ Package: acme
23
+ Version: 1.0
24
+ Section: web
25
+ Priority: optional
26
+ Architecture: all
27
+ Essential: no
28
+ Depends: libwww-perl, acme-base (>= 1.2)
29
+ Pre-Depends: perl
30
+ Recommends: mozilla | netscape
31
+ Suggests: docbook
32
+ Installed-Size: 1024
33
+ Maintainer: Joe Brockmeier <jzb@dissociatedpress.net>
34
+ Conflicts: wile-e-coyote
35
+ Replaces: sam-sheepdog
36
+ Provides: acme
37
+ Description: The description can contain free-form text
38
+ describing the function of the program, what
39
+ kind of features it has, and so on.
40
+ More descriptive text.
41
+ CONTROL
42
+ Buildr::write "control2", ""
43
+ Buildr::write "postinst", ""
44
+ Buildr::write "prerm", ""
45
+ end
46
+
47
+ it "should throw an error if no control file is given" do
48
+ write_files
49
+ define("foo", :version => "1.0") do
50
+
51
+ project.package(:deb).postinst = _("postinst")
52
+ project.package(:deb).prerm = _("prerm")
53
+ end
54
+ lambda { project("foo").package(:deb).invoke }.should raise_error(/no control file was defined when packaging foo as a deb file/)
55
+ end
56
+
57
+ it "should raise an exception if the control is incorrectly formatted" do
58
+ write_files
59
+ define("foo", :version => "1.0") do
60
+ project.package(:deb).control = _("control2")
61
+ project.package(:deb).postinst = _("postinst")
62
+ project.package(:deb).prerm = _("prerm")
63
+ end
64
+ 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
+ end
67
+
68
+ it "should give a project the ability to package as deb" do
69
+ write_files
70
+ define("foo", :version => "1.0") do
71
+ project.package(:deb).control = _("control")
72
+ project.package(:deb).postinst = _("postinst")
73
+ project.package(:deb).prerm = _("prerm")
74
+ end
75
+ lambda { project("foo").package(:deb).invoke }.should_not raise_error
76
+ File.exists?("target/foo-1.0.deb").should be_true
77
+ end
78
+
79
+ it "should let the user include files into the deb" do
80
+ write_files
81
+ Buildr::write "blah.class", "some class content"
82
+ Buildr::write "folder/file1.class", "some more content"
83
+ Buildr::write "folder/file2.class", "some other content"
84
+ define("foo", :version => "1.0") do
85
+ project.package(:deb).control = _("control")
86
+ project.package(:deb).postinst = _("postinst")
87
+ project.package(:deb).prerm = _("prerm")
88
+ project.package(:deb).include("blah.class", :path => "lib")
89
+ project.package(:deb).include("folder", :as => "otherlib")
90
+ end
91
+ lambda { project("foo").package(:deb).invoke }.should_not raise_error
92
+ File.exists?("target/foo-1.0.deb").should be_true
93
+ #check the contents of the deb file:
94
+ entries = %x[ dpkg --contents target/foo-1.0.deb ].split("\n").collect { |string| /.* (.*)/.match(string)[1]}
95
+
96
+ entries.should include("./otherlib/file1.class")
97
+ entries.should include("./otherlib/file2.class")
98
+ entries.should include("./lib/blah.class")
99
+ end
100
+
101
+
102
+ it "should let the user override the package name" do
103
+ write_files
104
+ define("foo", :version => "1.0") do
105
+ project.package(:deb, :file => "bar-1.0.deb").tap do |deb|
106
+ deb.control = _("control")
107
+ deb.postinst = _("postinst")
108
+ deb.prerm = _("prerm")
109
+ end
110
+ end
111
+ project("foo").package(:deb, :file => "bar-1.0.deb").invoke
112
+ File.exists?("bar-1.0.deb").should be_true
113
+ end
114
+ end
@@ -0,0 +1,24 @@
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
+ unless defined?(SpecHelpers)
17
+ require File.join(File.dirname(__FILE__), "/../buildr/spec/spec_helpers.rb")
18
+
19
+ # Make sure to load from these paths first, we don't want to load any
20
+ # code from Gem library.
21
+ $LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
22
+ require 'buildrdeb'
23
+
24
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buildrdeb
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Antoine Toulme
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-20 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: |
23
+ A buildr plugin contributing a new packaging method to package your project as a .deb file.
24
+
25
+ email: antoine@lunar-ocean.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - README.rdoc
32
+ - LICENSE
33
+ - NOTICE
34
+ files:
35
+ - lib/buildrdeb/package.rb
36
+ - lib/buildrdeb.rb
37
+ - rakelib/checks.rake
38
+ - rakelib/doc.rake
39
+ - rakelib/jekylltask.rb
40
+ - rakelib/package.rake
41
+ - rakelib/release.rake
42
+ - rakelib/rspec.rake
43
+ - rakelib/setup.rake
44
+ - rakelib/stage.rake
45
+ - spec/buildrdeb/package_spec.rb
46
+ - spec/spec_helpers.rb
47
+ - buildrdeb.gemspec
48
+ - LICENSE
49
+ - NOTICE
50
+ - README.rdoc
51
+ - Rakefile
52
+ has_rdoc: true
53
+ homepage: http://buildr.apache.org/
54
+ licenses: []
55
+
56
+ post_install_message: To get started run buildr --help
57
+ rdoc_options:
58
+ - --title
59
+ - Buildr4osgi
60
+ - --main
61
+ - README.rdoc
62
+ - --webcvs
63
+ - http://github.com/intalio/buildrdeb
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.3.7
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: A buildr plugin for packaging projects as .deb files
91
+ test_files: []
92
+