ruby_packager 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.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/ruby_packager.rb +255 -0
- data/lib/ruby_packager/version.rb +3 -0
- data/ruby_packager.gemspec +24 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTdkMGRlNmI3ZGEyNjhmOTFmOTk4NGY2OGYyYTUzYzU1MTAzYmVjZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
N2VmZDcwOGY4OGNhZDNiZGVkOTgzYzEzMTFiMzkwODJjMjA1MmExZA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjAyMzUxYzkzZWUxMjM2NGZiOWQzMjQ3MzVlYzJiOWIwZDVhMzI0Yjc4YTgw
|
10
|
+
ZDJiMGU4NDdkMTdlYjJlMzkxYjRjODdkZTY1ODk1OWZkZGJjYjc1YWI5ODcz
|
11
|
+
Mzk5NGM2NmY4YjgzZWVhZDQzM2Q5NGM4YzZhMjg3YjcwYTgzY2U=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Zjc1NTA5YzRjMzU3MTI3ZDczMDQxYTlmNjA2ZjVmYzdiNDA2ODY5NjY2OTg3
|
14
|
+
ODgyNjk5ZTczNWQ1NzVmYWVkNzIxMWQ5NmU3OGNkMzUwZDlkZGMzNzYzNWJm
|
15
|
+
ZTQ0Mjg4MzhiNTdkMjZmY2ZlZmY3NDhhZDJhZWRhMmIwODRkMWY=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Arvind Kunday
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Packager
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'packager'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install packager
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,255 @@
|
|
1
|
+
require "ruby_packager/version"
|
2
|
+
|
3
|
+
module RubyPackager
|
4
|
+
class Tasks < Rake::TaskLib
|
5
|
+
def initialize(application_name, prefix)
|
6
|
+
@application_name = application_name
|
7
|
+
@prefix = prefix
|
8
|
+
@package_name = "#{@prefix}-#{application_name}"
|
9
|
+
@version = '1.0'
|
10
|
+
@dependencies = []
|
11
|
+
@autoreq = true
|
12
|
+
@install_path = "opt/#{@prefix}/apps/#{application_name}"
|
13
|
+
@links = {}
|
14
|
+
@bundle_standalone = false
|
15
|
+
@bundle_with_binstubs = false
|
16
|
+
@bundle_without = ["development", "test"]
|
17
|
+
@vendorize = true
|
18
|
+
install(FileList["Gemfile*"])
|
19
|
+
if block_given?
|
20
|
+
yield self
|
21
|
+
define_tasks
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :application_name
|
26
|
+
attr_reader :staged_files
|
27
|
+
|
28
|
+
attr_accessor :package_name
|
29
|
+
attr_accessor :version
|
30
|
+
attr_accessor :iteration
|
31
|
+
attr_accessor :epoch
|
32
|
+
attr_accessor :dependencies
|
33
|
+
attr_accessor :autoreq
|
34
|
+
attr_accessor :install_path
|
35
|
+
attr_accessor :links
|
36
|
+
attr_accessor :before_install_script
|
37
|
+
attr_accessor :after_install_script
|
38
|
+
attr_accessor :architecture
|
39
|
+
attr_accessor :bundle_standalone
|
40
|
+
attr_accessor :bundle_with_binstubs
|
41
|
+
attr_accessor :bundle_without
|
42
|
+
attr_accessor :description
|
43
|
+
attr_accessor :rpm_os
|
44
|
+
attr_accessor :vendorize
|
45
|
+
attr_accessor :rpm_user
|
46
|
+
attr_accessor :rpm_group
|
47
|
+
|
48
|
+
def install(file_list, options = {})
|
49
|
+
@staged_files ||= []
|
50
|
+
prefix = options[:prefix] ? staged_file_path(options[:prefix]) : staged_app
|
51
|
+
@staged_files += map(file_list => prefix)
|
52
|
+
end
|
53
|
+
|
54
|
+
def install_rails_app_links
|
55
|
+
install_rails_app_log_link
|
56
|
+
install_rails_app_tmp_link
|
57
|
+
end
|
58
|
+
|
59
|
+
def install_rails_app_log_link
|
60
|
+
install_link("log", "/var/log/#{@prefix}/#{application_name}")
|
61
|
+
end
|
62
|
+
|
63
|
+
def install_rails_app_tmp_link
|
64
|
+
install_link("tmp", "/var/tmp/#{application_name}")
|
65
|
+
end
|
66
|
+
|
67
|
+
def install_link(src, target)
|
68
|
+
@links[src] = target
|
69
|
+
end
|
70
|
+
|
71
|
+
def define_tasks
|
72
|
+
define_show_config_task
|
73
|
+
define_show_staging_list_task
|
74
|
+
define_bundle_file_task
|
75
|
+
define_stage_task
|
76
|
+
define_rpm_task
|
77
|
+
define_install_rpm_task
|
78
|
+
define_clean_task
|
79
|
+
end
|
80
|
+
|
81
|
+
def filename
|
82
|
+
full_version = "#{version}"
|
83
|
+
full_version += "-#{iteration}" if iteration
|
84
|
+
"pkg/#{package_name}-#{full_version}.x86_64.rpm"
|
85
|
+
end
|
86
|
+
|
87
|
+
def generate(filename, &block)
|
88
|
+
target_file = staged_app(filename)
|
89
|
+
file(target_file) do
|
90
|
+
block.call(target_file)
|
91
|
+
end
|
92
|
+
@staged_files << target_file
|
93
|
+
end
|
94
|
+
|
95
|
+
def default_links
|
96
|
+
{
|
97
|
+
"log" => "/var/log/#{@prefix}/#{application_name}",
|
98
|
+
"tmp" => "/var/tmp/#{application_name}"
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def staging_dir
|
105
|
+
'tmp/stage'
|
106
|
+
end
|
107
|
+
|
108
|
+
def map(mappings)
|
109
|
+
target_files = []
|
110
|
+
mappings.collect do |sources, prefix|
|
111
|
+
sources.each do |source|
|
112
|
+
next if File.directory?(source)
|
113
|
+
target = File.join(prefix, source)
|
114
|
+
file(target => source) do
|
115
|
+
mkpath(File.dirname(target))
|
116
|
+
cp(source, target)
|
117
|
+
end
|
118
|
+
target_files << target
|
119
|
+
end
|
120
|
+
end
|
121
|
+
target_files
|
122
|
+
end
|
123
|
+
|
124
|
+
def staged_app(path = nil)
|
125
|
+
components = [staging_dir, install_path, path].compact
|
126
|
+
File.join(*components)
|
127
|
+
end
|
128
|
+
|
129
|
+
def staged_file_path(prefix)
|
130
|
+
components = [staging_dir, prefix].compact
|
131
|
+
File.join(*components)
|
132
|
+
end
|
133
|
+
|
134
|
+
def target_files
|
135
|
+
staged_files + [staged_app("bundle")]
|
136
|
+
end
|
137
|
+
|
138
|
+
def define_bundle_file_task
|
139
|
+
file staged_app("bundle") => [staged_app("Gemfile"), staged_app("Gemfile.lock")] do
|
140
|
+
Bundler.with_clean_env do
|
141
|
+
Dir.chdir(staged_app) do
|
142
|
+
links.each { |source, target| ln_sf target, source }
|
143
|
+
if vendorize
|
144
|
+
sh("bundle package --all")
|
145
|
+
gem_cache_dir = Pathname.pwd + "vendor/cache"
|
146
|
+
mkpath "vendor"
|
147
|
+
rm_rf "vendor/cache"
|
148
|
+
ln_s gem_cache_dir, "vendor/cache"
|
149
|
+
|
150
|
+
begin
|
151
|
+
rm_rf ".bundle"
|
152
|
+
|
153
|
+
bundle_command = %w(bundle install)
|
154
|
+
bundle_command += ["--local"]
|
155
|
+
bundle_command += ["--path", "vendor/bundle"]
|
156
|
+
bundle_command += ["--standalone"] if bundle_standalone
|
157
|
+
bundle_command += ["--binstubs"] if bundle_with_binstubs
|
158
|
+
if bundle_without
|
159
|
+
bundle_command += ["--without"]
|
160
|
+
bundle_command += bundle_without
|
161
|
+
end
|
162
|
+
|
163
|
+
sh(*bundle_command)
|
164
|
+
rm_rf "vendor/cache"
|
165
|
+
touch "vendor/bundle"
|
166
|
+
rescue => e
|
167
|
+
rm_rf "vendor/bundle"
|
168
|
+
raise e
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def define_stage_task
|
177
|
+
desc "Stage RPM package contents into #{staging_dir}"
|
178
|
+
task :stage => target_files
|
179
|
+
end
|
180
|
+
|
181
|
+
def define_rpm_task
|
182
|
+
desc "Create an RPM package"
|
183
|
+
task :rpm => filename
|
184
|
+
|
185
|
+
file filename => target_files do
|
186
|
+
mkpath("pkg")
|
187
|
+
fpm_cmd = %w(fpm -s dir -t rpm)
|
188
|
+
fpm_cmd += [
|
189
|
+
"-n", package_name,
|
190
|
+
"--version", version
|
191
|
+
]
|
192
|
+
fpm_cmd += [ "--iteration", iteration ] if iteration
|
193
|
+
fpm_cmd += [ "--epoch", epoch ] if epoch
|
194
|
+
dependencies.each do |dep|
|
195
|
+
fpm_cmd += ['-d', dep]
|
196
|
+
end
|
197
|
+
fpm_cmd += ['--rpm-autoreq'] if autoreq
|
198
|
+
fpm_cmd += ['--before-install', before_install_script] if before_install_script
|
199
|
+
fpm_cmd += ['--after-install', after_install_script] if after_install_script
|
200
|
+
fpm_cmd += ['-p', filename]
|
201
|
+
fpm_cmd += ['-C', staging_dir]
|
202
|
+
fpm_cmd += ['-a', architecture] if architecture
|
203
|
+
fpm_cmd += ['--description', description] if description
|
204
|
+
fpm_cmd += ['--rpm-os', rpm_os] if rpm_os
|
205
|
+
fpm_cmd += ['--rpm-user', rpm_user] if rpm_user
|
206
|
+
fpm_cmd += ['--rpm-group', rpm_group] if rpm_group
|
207
|
+
fpm_cmd += ['.']
|
208
|
+
sh(*fpm_cmd)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def define_install_rpm_task
|
213
|
+
desc "Install the generated RPM package"
|
214
|
+
task :install_rpm => :rpm do
|
215
|
+
sh("sudo rpm --upgrade --force -p #{filename}")
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def define_show_config_task
|
220
|
+
desc "Show configuration for the RPM packager"
|
221
|
+
task :show_config do
|
222
|
+
puts <<-END_CONTENT
|
223
|
+
You can override any of these in your packager config.
|
224
|
+
application_name : #{application_name}
|
225
|
+
package_name : #{package_name}
|
226
|
+
dependencies : #{dependencies}
|
227
|
+
architecture : #{architecture}
|
228
|
+
rpm_user : #{rpm_user}
|
229
|
+
rpm_group : #{rpm_group}
|
230
|
+
before_install_script : #{before_install_script}
|
231
|
+
after_install_script : #{after_install_script}
|
232
|
+
version : #{version}
|
233
|
+
links : #{links}
|
234
|
+
install_path : #{install_path}
|
235
|
+
staged_files : #{staged_files}
|
236
|
+
|
237
|
+
END_CONTENT
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def define_show_staging_list_task
|
242
|
+
desc "Show a list of files to be included in the RPM"
|
243
|
+
task :show_staging_list do
|
244
|
+
staged_files.each { |path| puts path }
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def define_clean_task
|
249
|
+
desc "Clean the previous build directory"
|
250
|
+
task :clean do
|
251
|
+
sh("rm -rf tmp pkg")
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruby_packager/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruby_packager"
|
8
|
+
spec.version = RubyPackager::VERSION
|
9
|
+
spec.authors = ["Arvind Kunday"]
|
10
|
+
spec.email = ["hi@kunday.com"]
|
11
|
+
spec.description = %q{Rake tasks to create RPM for ruby projects}
|
12
|
+
spec.summary = %q{Based on fpm}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_dependency "rake"
|
23
|
+
spec.add_dependency "fpm"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_packager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arvind Kunday
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fpm
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Rake tasks to create RPM for ruby projects
|
56
|
+
email:
|
57
|
+
- hi@kunday.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/ruby_packager.rb
|
68
|
+
- lib/ruby_packager/version.rb
|
69
|
+
- ruby_packager.gemspec
|
70
|
+
homepage: ''
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.0.10
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Based on fpm
|
94
|
+
test_files: []
|