packtory 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27cb2492004a82f696dfd78d5aaab669a9fa9fec7391d84a2fbe5ed049bce612
4
- data.tar.gz: fa5db1bab4451e2364cdd98062157355499f33208538cd5807e3ef39bf481fc4
3
+ metadata.gz: 6a7d98a0c6496136f736656de91783bfaf8d3b3cea65043eb5f326145fecd013
4
+ data.tar.gz: 9f88ebd4c88dfbbacad221bffa3eb046c19b9035fb5e62d1279e37a2a2b7f7e1
5
5
  SHA512:
6
- metadata.gz: ec25d2bd6b0c37613e070890493270f79335bb795b13659253bbc0cacb0344db49fc8a10f1e4067cfcb070c0c6dfc11ed0cdcc67ed4bc15453dd4464bd1752e2
7
- data.tar.gz: 8b68c017d373c376a648d7668b516aa4ac307e3f4cfd19731f69bcd99a2b30bb28f1c9f44b2bc36b2de3e3bc225c452156db9c457449b0258edba056f6f02d9f
6
+ metadata.gz: 9402607bf4d7a9aea39301f8c5ecda8fd190e311c7e57bac7180da8d1b3ce643eb00562addbd0162fa6535cd5eb2735c63b62404c5de9bfb563427bdec8f948b
7
+ data.tar.gz: d57a1818e84972e27f11352b55f58171e29ab9b4c44e8e12007a402a31d51c6cabc4370eb53f11e4503d4f9afccbd09bb6a092a13f2d42eba02388c9372994fa
data/README.md CHANGED
@@ -1,9 +1,85 @@
1
- ## Overview
1
+ # Overview
2
2
 
3
- This is packtory, an integrated, easy to use packaging tool for your
4
- Ruby gem, Node module, and Python module.
3
+ This is packtory, an easy to use system packaging tool for your Ruby
4
+ gems. Build package for Debian, RPM, and _soon_ Homebrew, directly
5
+ from your gem repo.
5
6
 
6
- ## State
7
+ Support for building native extensions is available, using a post-install step of the target package.
7
8
 
8
- Still a work in progress. Stay tuned for when ready for human
9
- consumption.
9
+ # How to use
10
+
11
+ To install,
12
+
13
+ ```
14
+ gem install packtory
15
+ packtory <root_path_to_gem>
16
+ ```
17
+
18
+ By default, this will build a Debian package that is compatible to install in Ubuntu and Debian.
19
+
20
+ To specify the package output:
21
+
22
+ ```
23
+ env PACKAGE_OUTPUT=rpm packtory
24
+ ```
25
+
26
+ Additional options are available as follows:
27
+
28
+ ```
29
+ ; Specify a gemspec file to use
30
+ env GEM_SPECFILE="subpath_to/gemname.gemspec" packtory <root_path_to_gem>
31
+
32
+ ; Specify a Gemfile to use, otherwise, packtory will auto-generate a clean one.
33
+ env BUNDLE_GEMFILE="$build/spec/gemfiles/Gemfile.19" packtory <root_path_to_gem>
34
+
35
+ ; Specify the version of ruby system package
36
+ env PACKAGE_RUBY_VERSION="2.5.1" packtory <root_path_to_gem>
37
+
38
+ ; Specify additional system dependencies of the generated package
39
+ env PACKAGE_DEPENDENCIES="mysql,mysql-dev,libxml++>=2.6" packtory <root_path_to_gem>
40
+ ```
41
+
42
+ # Requirements
43
+
44
+ This gem depends on `fpm` to build the final system package. You will need to install it manually:
45
+
46
+ ```
47
+ gem install fpm
48
+ ```
49
+
50
+ And if building for RPM, you will need the package that contains the `rpmbuild` binary.
51
+
52
+ ```
53
+ ; In Debian/Ubuntu
54
+ apt install rpm
55
+
56
+ ; In Fedora/CentOS
57
+ yum install rpm-build
58
+
59
+ ; In Homebrew
60
+ brew install rpm
61
+ ```
62
+
63
+ # Compatibility
64
+
65
+ If not specified, this buildpack will detect for a gemspec (\*.gemspec) file at the root path of your repo, then use that to gather the files of your gem and gem dependencies. After which, it vendorized all files to build the target package.
66
+
67
+ If a gem has native extensions, the extensions are not built at the time of building the package, but rather, a post-install script is included, that builds them right after the target package is installed in the system. If any native extensions requires other system libraries, you may specify additional package dependencies to be installed prior to installing the target package.
68
+
69
+ As of this version, this buildpack do not support packaging gems without a specific gemspec file.
70
+
71
+ # Limitations
72
+
73
+ Note, the build process will not load the code of your gem or the other dependencies. Only the code in the gemspec is loaded using the ruby version of the build environment. Please make sure the gemspec may be loaded properly, and additional code requirements are compatible.
74
+
75
+ # Contribution and Improvements
76
+
77
+ Please fork the code, make the changes, and submit a pull request for us to review your contributions.
78
+
79
+ ## Feature requests
80
+
81
+ If you think it would be nice to have a particular feature that is presently not implemented, we would love to hear that and consider working on it. Just open an issue in Github.
82
+
83
+ # Questions
84
+
85
+ Please open a Github Issue if you have any other questions or problems.
data/bin/support/fpm ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env bash
2
+
3
+ packtory_dir=$(cd "$(dirname $0)/../../"; pwd)
4
+ packtory_bundle_path=$packtory_dir/bundle
5
+
6
+ if [ -d "$packtory_bundle_path" ]; then
7
+ export PACKTORY_BUNDLE_PATH="$packtory_bundle_path"
8
+ fpm_ruby=$(cd "$(dirname $0)"; pwd)/fpm_vendor_ruby
9
+ else
10
+ fpm_ruby="$(which fpm)"
11
+
12
+ if [ -z "$fpm_ruby" ]; then
13
+ fpm_ruby="fpm"
14
+ fi
15
+ fi
16
+
17
+ $fpm_ruby "$@"
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ bundle_path = ENV['PACKTORY_BUNDLE_PATH']
4
+ require File.join(bundle_path, 'bundler/setup.rb')
5
+
6
+ require 'fpm'
7
+ require 'fpm/command'
8
+
9
+ exit(FPM::Command.run || 0)
data/lib/packtory.rb CHANGED
@@ -16,4 +16,8 @@ module Packtory
16
16
  def self.gem_build_extensions_path
17
17
  File.expand_path('../../bin/support/gem_build_extensions', __FILE__)
18
18
  end
19
+
20
+ def self.bin_support_fpm_path
21
+ File.expand_path('../../bin/support/fpm', __FILE__)
22
+ end
19
23
  end
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  module Packtory
2
4
  class Command
3
5
  def self.run(argv)
@@ -8,22 +10,22 @@ module Packtory
8
10
  if ENV['FPM_EXEC_PATH']
9
11
  @fpm_exec_path = File.expand_path(ENV['FPM_EXEC_PATH'])
10
12
  else
11
- @fpm_exec_path = `which fpm`.strip
13
+ @fpm_exec_path = Packtory.bin_support_fpm_path
12
14
  end
13
15
 
14
16
  if @fpm_exec_path.nil? || @fpm_exec_path.empty?
15
- puts 'ERROR: `fpm` executable is not in path. Perhaps, install fpm first?'
17
+ say 'ERROR: `fpm` executable is not in path. Perhaps, install fpm first?'
16
18
  exit 1
17
19
  end
18
20
 
19
21
  if argv[0].nil? || argv[0].empty?
20
- puts 'ERROR: Build path not specified, aborting.'
22
+ say 'ERROR: Build path not specified, aborting.'
21
23
  exit 1
22
24
  end
23
25
 
24
26
  @build_path = File.expand_path(argv[0])
25
27
  unless File.exists?(@build_path)
26
- puts 'ERROR: Build path %s do not exist, aborting.' % @build_path
28
+ say 'ERROR: Build path %s do not exist, aborting.' % @build_path
27
29
  exit 1
28
30
  end
29
31
 
@@ -35,6 +37,15 @@ module Packtory
35
37
  Packer.config[:fpm_exec_path] = @fpm_exec_path
36
38
  Packer.config[:path] = @build_path
37
39
 
40
+ if ENV['FPM_EXEC_VERBOSE'] && ENV['FPM_EXEC_VERBOSE'] == '1'
41
+ Packer.config[:fpm_exec_verbose] = true
42
+ end
43
+
44
+ if !ENV['FPM_EXEC_LOG'].nil? && !ENV['FPM_EXEC_LOG'].empty?
45
+ Packer.config[:fpm_exec_verbose] = true
46
+ Packer.config[:fpm_exec_log] = ENV['FPM_EXEC_LOG']
47
+ end
48
+
38
49
  self
39
50
  end
40
51
 
@@ -46,16 +57,16 @@ module Packtory
46
57
  end
47
58
 
48
59
  unless File.exists?(@gemspec_file)
49
- puts 'ERROR: Specified gemspec file %s not found, aborting.' % @gemspec_file
60
+ say 'ERROR: Specified gemspec file %s not found, aborting.' % @gemspec_file
50
61
  exit 1
51
62
  end
52
63
  else
53
64
  paths = Dir.glob(File.join(@build_path, '/*.gemspec'))
54
65
  if paths.empty?
55
- puts 'ERROR: No gemspec file found, aborting.'
66
+ say 'ERROR: No gemspec file found, aborting.'
56
67
  exit 1
57
68
  elsif paths.count > 1
58
- puts 'ERROR: Multiple gemspec file found, aborting.'
69
+ say 'ERROR: Multiple gemspec file found, aborting.'
59
70
  exit 1
60
71
  end
61
72
 
@@ -79,14 +90,18 @@ module Packtory
79
90
  end
80
91
 
81
92
  unless File.exists?(@bundle_gemfile)
82
- puts 'ERROR: Specified bundle gemfile %s not found, aborting.' % @bundle_gemfile
93
+ say 'ERROR: Specified bundle gemfile %s not found, aborting.' % @bundle_gemfile
83
94
  exit 1
84
95
  end
85
96
 
86
- puts 'Using Gemfile : %s' % @bundle_gemfile
97
+ say 'Using Gemfile : %s' % @bundle_gemfile
87
98
  Packer.config[:gemfile] = @bundle_gemfile
88
99
  end
89
100
 
101
+ if ENV['BUNDLER_INCLUDE']
102
+ Packer.config[:bundler_include] = true
103
+ end
104
+
90
105
  self
91
106
  end
92
107
 
@@ -95,10 +110,10 @@ module Packtory
95
110
 
96
111
  if ENV['PACKAGE_RUBY_VERSION'] && !ENV['PACKAGE_RUBY_VERSION'].empty?
97
112
  @ruby_version = ENV['PACKAGE_RUBY_VERSION']
98
- puts 'Using ruby deps : %s' % @ruby_version
113
+ say 'Using ruby deps : %s' % @ruby_version
99
114
  else
100
115
  @ruby_version = nil
101
- puts 'Using ruby deps : latest'
116
+ say 'Using ruby deps : latest'
102
117
  end
103
118
 
104
119
  Packer.config[:dependencies]['ruby'] = @ruby_version
@@ -132,9 +147,34 @@ module Packtory
132
147
  packages << :deb
133
148
  end
134
149
 
135
- puts 'Package output : %s' % packages.join(', ')
150
+ say 'Package output : %s' % packages.join(', ')
136
151
  Packer.config[:packages] = packages
137
152
 
153
+ if ENV['PACKAGE_PATH']
154
+ pkg_path = File.expand_path(ENV['PACKAGE_PATH'])
155
+
156
+ say 'Package path : %s' % pkg_path
157
+ Packer.config[:pkg_path] = pkg_path
158
+ end
159
+
160
+ self
161
+ end
162
+
163
+ def test_dumpinfo(argv)
164
+ dump_file = File.expand_path(ENV['TEST_DUMPINFO'])
165
+
166
+ info_h = {
167
+ :version => ::Packtory::VERSION,
168
+ :fpm_version => `#{@fpm_exec_path} -v`.strip
169
+ }.merge(Packer.config)
170
+
171
+ File.open(dump_file, 'w') do |f|
172
+ f.write(YAML.dump(info_h))
173
+ end
174
+
175
+ say 'Created dump file: %s' % dump_file
176
+ say File.read(dump_file)
177
+
138
178
  self
139
179
  end
140
180
 
@@ -149,10 +189,15 @@ module Packtory
149
189
  detect_deps(argv)
150
190
  detect_package_output(argv)
151
191
 
152
- puts '=================='
192
+ say '=================='
153
193
 
154
194
  Packer.setup
155
- unless ENV['TEST_NOBUILD']
195
+
196
+ if ENV['TEST_DUMPINFO']
197
+ test_dumpinfo(argv)
198
+ elsif ENV['TEST_NOBUILD']
199
+ # do nothing
200
+ else
156
201
  Packer.build_package
157
202
  end
158
203
  end
@@ -6,9 +6,7 @@ module Packtory
6
6
  if !Packer.config[:fpm_exec_path].nil? && !Packer.config[:fpm_exec_path].empty?
7
7
  Packer.config[:fpm_exec_path]
8
8
  else
9
- fep = `which fpm`.strip
10
- fep = 'fpm' if fep.empty?
11
- fep
9
+ Packtory.bin_support_fpm_path
12
10
  end
13
11
  end
14
12
 
@@ -24,13 +22,18 @@ module Packtory
24
22
  cmd = build_cmd(sfiles_map, pkg_file, opts)
25
23
 
26
24
  Bundler.ui.info 'CMD: %s' % cmd
27
- Bundler.clean_system('%s >/dev/null 2>&1' % cmd)
25
+
26
+ if Packer.config[:fpm_exec_verbose]
27
+ Bundler.clean_system('%s' % cmd)
28
+ else
29
+ Bundler.clean_system('%s >/dev/null 2>&1' % cmd)
30
+ end
28
31
 
29
32
  pkg_file
30
33
  end
31
34
 
32
35
  def build_cmd(sfiles_map, pkg_file, opts = { })
33
- cmd = '%s --log warn -f -s dir' % self.class.fpm_exec_path
36
+ cmd = '%s --log %s -f -s dir' % [ self.class.fpm_exec_path, Packer.config[:fpm_exec_log] || 'warn' ]
34
37
 
35
38
  case opts[:type]
36
39
  when :rpm
@@ -12,6 +12,7 @@ module Packtory
12
12
 
13
13
  DEFAULT_CONFIG = {
14
14
  :path => nil,
15
+ :pkg_path => nil,
15
16
  :gemspec => nil,
16
17
  :gemfile => nil,
17
18
  :binstub => nil,
@@ -26,8 +27,12 @@ module Packtory
26
27
  :bundle_working_path => nil,
27
28
 
28
29
  :fpm_exec_path => nil,
30
+ :fpm_exec_verbose => false,
31
+ :fpm_exec_log => nil,
32
+
29
33
  :bundler_silent => false,
30
- :bundler_local => false
34
+ :bundler_local => false,
35
+ :bundler_include => false
31
36
  }
32
37
 
33
38
  DEFAULT_PACKAGES = [ :deb, :rpm ]
@@ -230,10 +235,24 @@ module Packtory
230
235
  rubygems_dir = Bundler.rubygems.gem_dir
231
236
  FileUtils.mkpath(File.join(rubygems_dir, 'specifications'))
232
237
 
238
+ cached_gems = { }
233
239
  @bundle_def.specs.each do |spec|
234
240
  next unless spec.source.is_a?(Bundler::Source::Rubygems)
241
+ cached_gems[spec.name] = spec.source.send(:cached_gem, spec)
242
+ end
243
+
244
+ if @opts[:bundler_include]
245
+ bundler_source = Bundler::Source::Rubygems.new('remotes' => 'https://rubygems.org')
246
+ @bundler_spec = Bundler::RemoteSpecification.
247
+ new('bundler', Bundler::VERSION,
248
+ Gem::Platform::RUBY, bundler_source.fetchers.first)
249
+ @bundler_spec.remote = Bundler::Source::Rubygems::Remote.new(bundler_source.remotes.first)
250
+
251
+ bundler_source.send(:fetch_gem, @bundler_spec)
252
+ cached_gems['bundler'] = bundler_source.send(:cached_gem, @bundler_spec)
253
+ end
235
254
 
236
- cached_gem = spec.source.send(:cached_gem, spec)
255
+ cached_gems.each do |gem_name, cached_gem|
237
256
  installer = Gem::Installer.at(cached_gem, :path => rubygems_dir)
238
257
  installer.extract_files
239
258
  installer.write_spec
@@ -280,7 +299,11 @@ GEMFILE
280
299
  end
281
300
 
282
301
  def pkg_path
283
- File.join(root_path, 'pkg')
302
+ if @opts[:pkg_path].nil?
303
+ File.join(root_path, 'pkg')
304
+ else
305
+ @opts[:pkg_path]
306
+ end
284
307
  end
285
308
 
286
309
  def working_path
@@ -347,42 +370,50 @@ GEMFILE
347
370
  specs = bundler_definition.specs_for([ :default ])
348
371
 
349
372
  specs.each do |spec|
350
- if spec.name != 'bundler' && (gemspec.nil? || spec.name != gemspec.name)
351
- orig_spec = spec
352
- if spec.is_a?(Bundler::EndpointSpecification)
353
- rs = spec.instance_variable_get(:@remote_specification)
354
- if rs
355
- spec = rs
356
- elsif spec._local_specification
357
- spec = spec._local_specification
358
- end
373
+ next if gemspec.nil? || spec.name == gemspec.name
374
+
375
+ if spec.name == 'bundler'
376
+ if @opts[:bundler_include]
377
+ spec = @bundler_spec
378
+ else
379
+ next
359
380
  end
381
+ end
382
+
383
+ orig_spec = spec
384
+ if spec.is_a?(Bundler::EndpointSpecification)
385
+ rs = spec.instance_variable_get(:@remote_specification)
386
+ if rs
387
+ spec = rs
388
+ elsif spec._local_specification
389
+ spec = spec._local_specification
390
+ end
391
+ end
360
392
 
361
- bhash = { }
393
+ bhash = { }
362
394
 
363
- bhash[:orig_spec] = orig_spec
364
- bhash[:spec] = spec
365
- bhash[:gem_path] = spec.full_gem_path
395
+ bhash[:orig_spec] = orig_spec
396
+ bhash[:spec] = spec
397
+ bhash[:gem_path] = spec.full_gem_path
366
398
 
367
- bhash[:files] = Dir.glob(File.join(spec.full_gem_path, '**/*')).inject([ ]) { |a, f|
368
- unless File.directory?(f)
369
- a << f.gsub('%s/' % spec.full_gem_path, '')
370
- end
399
+ bhash[:files] = Dir.glob(File.join(spec.full_gem_path, '**/*')).inject([ ]) { |a, f|
400
+ unless File.directory?(f)
401
+ a << f.gsub('%s/' % spec.full_gem_path, '')
402
+ end
371
403
 
372
- a
373
- }.uniq
404
+ a
405
+ }.uniq
374
406
 
375
- bhash[:require_paths] = spec.full_require_paths.collect { |path|
376
- path.include?(bhash[:gem_path]) ?
377
- path.gsub(bhash[:gem_path], '') : nil
378
- }.compact
407
+ bhash[:require_paths] = spec.full_require_paths.collect { |path|
408
+ path.include?(bhash[:gem_path]) ?
409
+ path.gsub(bhash[:gem_path], '') : nil
410
+ }.compact.uniq
379
411
 
380
- bgems[spec.name] = bhash
381
- end
412
+ bgems[spec.name] = bhash
382
413
  end
383
414
 
384
415
  bgems
385
- end
416
+ end
386
417
 
387
418
  def add_ruby_build_dependencies!
388
419
  unless @opts[:dependencies].include?('ruby-dev')
@@ -1,3 +1,3 @@
1
1
  module Packtory
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packtory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark John Buenconsejo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-11 00:00:00.000000000 Z
11
+ date: 2018-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,9 +24,24 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: 'A packtory
28
-
29
- '
27
+ - !ruby/object:Gem::Dependency
28
+ name: fpm
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
+ description: |
42
+ An easy to use system packaging tool for your Ruby
43
+ gems. Build package for Debian, RPM, and _soon_ Homebrew, directly
44
+ from your gem repo.
30
45
  email: hello@gemfury.com
31
46
  executables:
32
47
  - packtory
@@ -36,6 +51,8 @@ files:
36
51
  - README.md
37
52
  - bin/packtory
38
53
  - bin/support/after_install_script
54
+ - bin/support/fpm
55
+ - bin/support/fpm_vendor_ruby
39
56
  - bin/support/gem_build_extensions
40
57
  - lib/packtory.rb
41
58
  - lib/packtory/command.rb
@@ -74,5 +91,5 @@ rubyforge_project:
74
91
  rubygems_version: 2.7.7
75
92
  signing_key:
76
93
  specification_version: 4
77
- summary: A packtory
94
+ summary: An easy to use system packaging tool for your Ruby gems.
78
95
  test_files: []