packtory 0.1.2 → 0.1.5
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 +4 -4
- data/bin/packtory +2 -6
- data/bin/support/after_install_script +1 -1
- data/lib/packtory/brew_package.rb +9 -5
- data/lib/packtory/command.rb +177 -87
- data/lib/packtory/config.rb +1 -1
- data/lib/packtory/constants.rb +5 -0
- data/lib/packtory/deb_package.rb +3 -1
- data/lib/packtory/fpm_exec.rb +7 -1
- data/lib/packtory/packer.rb +54 -36
- data/lib/packtory/rpm_package.rb +9 -1
- data/lib/packtory/tgz_package.rb +3 -1
- data/lib/packtory/version.rb +1 -1
- data/lib/packtory.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5320f9a8f0811ecc5585b896491e14b27f2f60bda03d903a99e737d5a92105d2
|
4
|
+
data.tar.gz: af5b5791d65b4aec2194780ba63e2762bc877a4e103c05da99da8ba3684e0d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69d8a0dc636a8a274665c5eee514f88dcee8c96aa31a963e1e5512d922c98c2457d2d56885f8cfd5b147962a4f6a85f3d8d11b872cc177b00fd234b1f3075cf8
|
7
|
+
data.tar.gz: 7cf247440ff8e59d2e437cd91427b7275ae52a9c9ad78251eae0ead6ab83e699f7c7dc3a8246750108c18f738725fa8bc0cd441bc39e482d3ba83b84ed934e8b
|
data/bin/packtory
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
this_file = __FILE__
|
4
|
-
while File.symlink?(this_file)
|
5
|
-
this_file = File.readlink(this_file)
|
6
|
-
end
|
7
|
-
|
3
|
+
this_file = File.realpath(__FILE__)
|
8
4
|
$:.unshift File.expand_path('../../lib', this_file)
|
9
5
|
require 'packtory'
|
10
6
|
|
11
|
-
Packtory::Command.run(ARGV)
|
7
|
+
exit Packtory::Command.run(ARGV)
|
@@ -4,7 +4,7 @@ this_dir=$(cd $(dirname $0); pwd)
|
|
4
4
|
|
5
5
|
PACKAGE_PATH="<%= pg_PACKAGE_PATH %>"
|
6
6
|
|
7
|
-
# this is a special trap, in case the fpm templating
|
7
|
+
# this is a special trap, in case the fpm templating was not applied
|
8
8
|
if [[ $PACKAGE_PATH == \<* ]]; then
|
9
9
|
PACKAGE_PATH="$(dirname $(dirname "$this_dir"))"
|
10
10
|
fi
|
@@ -1,21 +1,25 @@
|
|
1
1
|
require 'bundler'
|
2
|
+
require 'digest'
|
2
3
|
|
3
4
|
module Packtory
|
4
5
|
class BrewPackage
|
5
|
-
INSTALL_PREFIX = '/usr/local/opt'
|
6
|
-
PACKAGE_PATH = '
|
6
|
+
INSTALL_PREFIX = '/usr/local/opt/%s'
|
7
|
+
PACKAGE_PATH = '%s'
|
7
8
|
|
8
9
|
def self.build_package(opts = { })
|
9
|
-
packager = Packer.new({ :bin_path => '
|
10
|
-
:
|
11
|
-
|
10
|
+
packager = Packer.new({ :bin_path => 'bin',
|
11
|
+
:install_prefix_as_code => "File.expand_path('../../%s', File.realpath(__FILE__))"
|
12
|
+
}.merge(opts))
|
12
13
|
|
13
14
|
sfiles_map = packager.prepare_files(INSTALL_PREFIX, PACKAGE_PATH)
|
15
|
+
|
16
|
+
fpm_exec = FpmExec.new(packager)
|
14
17
|
package_filename = '%s-%s.tar.gz' % [ packager.package_name, packager.version ]
|
15
18
|
pkg_file_path = fpm_exec.build(sfiles_map, package_filename, type: :tgz)
|
16
19
|
|
17
20
|
if File.exist?(pkg_file_path)
|
18
21
|
Bundler.ui.info 'Created package: %s (%s bytes)' % [ pkg_file_path, File.size(pkg_file_path) ]
|
22
|
+
Bundler.ui.info 'SHA256 checksum: %s' % Digest::SHA256.file(pkg_file_path).hexdigest
|
19
23
|
else
|
20
24
|
Bundler.ui.error '[ERROR] Package not found: %s' % [ pkg_file_path ]
|
21
25
|
end
|
data/lib/packtory/command.rb
CHANGED
@@ -1,51 +1,39 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'optparse'
|
2
3
|
|
3
4
|
module Packtory
|
4
5
|
class Command
|
6
|
+
include Packtory::Constants
|
7
|
+
attr_reader :options
|
8
|
+
|
9
|
+
def self.silent!; @@silent = true; end
|
10
|
+
def self.silent?; defined?(@@silent) ? @@silent : false; end
|
11
|
+
|
5
12
|
def self.run(argv)
|
6
13
|
self.new.run(argv)
|
7
14
|
end
|
8
15
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
16
|
+
def initialize
|
17
|
+
@options = { }
|
18
|
+
@completed = false
|
19
|
+
@exit_number = 0
|
20
|
+
end
|
21
|
+
|
22
|
+
def detect_fpm(argv)
|
23
|
+
if !ENV['FPM_EXEC_PATH'].nil? && !ENV['FPM_EXEC_PATH'].empty?
|
24
|
+
fpm_exec_path = File.expand_path(ENV['FPM_EXEC_PATH'])
|
12
25
|
else
|
13
|
-
|
26
|
+
fpm_exec_path = Packtory.bin_support_fpm_path
|
14
27
|
end
|
15
28
|
|
29
|
+
Packtory.config[:fpm_exec_path] = fpm_exec_path
|
30
|
+
|
16
31
|
if !ENV['FPM_USE_RUBY_PATH'].nil? && !ENV['FPM_USE_RUBY_PATH'].empty?
|
17
32
|
Packtory.config[:fpm_use_ruby_path] = ENV['FPM_USE_RUBY_PATH']
|
18
33
|
elsif !ENV['RUBY_PATH'].nil? && !ENV['RUBY_PATH'].empty?
|
19
34
|
Packtory.config[:fpm_use_ruby_path] = ENV['RUBY_PATH']
|
20
35
|
end
|
21
36
|
|
22
|
-
if @fpm_exec_path.nil? || @fpm_exec_path.empty?
|
23
|
-
say 'ERROR: `fpm` executable is not in path. Perhaps, install fpm first?'
|
24
|
-
exit 1
|
25
|
-
end
|
26
|
-
|
27
|
-
if argv[0].nil? || argv[0].empty?
|
28
|
-
say 'ERROR: Build path not specified, aborting.'
|
29
|
-
exit 1
|
30
|
-
end
|
31
|
-
|
32
|
-
@build_path = File.expand_path(argv[0])
|
33
|
-
unless File.exists?(@build_path)
|
34
|
-
say 'ERROR: Build path %s do not exist, aborting.' % @build_path
|
35
|
-
exit 1
|
36
|
-
end
|
37
|
-
|
38
|
-
say 'Using fpm path : %s' % @fpm_exec_path
|
39
|
-
unless Packtory.config[:fpm_use_ruby_path].nil?
|
40
|
-
say 'Fpm using ruby : %s' % Packtory.config[:fpm_use_ruby_path]
|
41
|
-
end
|
42
|
-
|
43
|
-
say 'Using fpm : %s' % `#{exec_fpm} -v`.strip
|
44
|
-
say 'Using build path : %s' % @build_path
|
45
|
-
|
46
|
-
Packtory.config[:fpm_exec_path] = @fpm_exec_path
|
47
|
-
Packtory.config[:path] = @build_path
|
48
|
-
|
49
37
|
if ENV['FPM_EXEC_VERBOSE'] && ENV['FPM_EXEC_VERBOSE'] == '1'
|
50
38
|
Packtory.config[:fpm_exec_verbose] = true
|
51
39
|
end
|
@@ -58,14 +46,6 @@ module Packtory
|
|
58
46
|
self
|
59
47
|
end
|
60
48
|
|
61
|
-
def exec_fpm
|
62
|
-
if Packtory.config[:fpm_use_ruby_path].nil?
|
63
|
-
@fpm_exec_path
|
64
|
-
else
|
65
|
-
'env FPM_USE_RUBY_PATH=%s %s' % [ Packtory.config[:fpm_use_ruby_path], @fpm_exec_path ]
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
49
|
def detect_specfile(argv)
|
70
50
|
if ENV['GEM_SPECFILE']
|
71
51
|
@gemspec_file = ENV['GEM_SPECFILE']
|
@@ -122,19 +102,30 @@ module Packtory
|
|
122
102
|
self
|
123
103
|
end
|
124
104
|
|
125
|
-
def
|
126
|
-
|
105
|
+
def detect_package_opts(argv)
|
106
|
+
packages = Packtory.config[:packages] || [ ]
|
127
107
|
|
128
|
-
if ENV['
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
108
|
+
if ENV['PACKAGE_OUTPUT'] == 'rpm'
|
109
|
+
packages << :rpm
|
110
|
+
elsif ENV['PACKAGE_OUTPUT'] == 'deb'
|
111
|
+
packages << :deb
|
112
|
+
elsif ENV['PACKAGE_OUTPUT'] == 'tgz'
|
113
|
+
packages << :tgz
|
114
|
+
elsif ENV['PACKAGE_OUTPUT'] == 'brew'
|
115
|
+
packages << :brew
|
116
|
+
elsif packages.empty?
|
117
|
+
packages << :deb
|
134
118
|
end
|
135
119
|
|
136
|
-
Packtory.config[:
|
137
|
-
|
120
|
+
Packtory.config[:packages] = packages
|
121
|
+
|
122
|
+
if ENV['PACKAGE_PATH'] && Packtory.config[:pkg_path].nil?
|
123
|
+
Packtory.config[:pkg_path] = File.expand_path(ENV['PACKAGE_PATH'])
|
124
|
+
end
|
125
|
+
|
126
|
+
if !ENV['PACKAGE_NAME'].nil? && !ENV['PACKAGE_NAME'].empty?
|
127
|
+
Packtory.config[:package_name] = ENV['PACKAGE_NAME']
|
128
|
+
end
|
138
129
|
|
139
130
|
if ENV['PACKAGE_DEPENDENCIES']
|
140
131
|
deps = ENV['PACKAGE_DEPENDENCIES'].split(',')
|
@@ -144,7 +135,6 @@ module Packtory
|
|
144
135
|
pver = $~[2]
|
145
136
|
|
146
137
|
Packtory.config[:dependencies][pname] = pver
|
147
|
-
@deps[pname] = pver
|
148
138
|
end
|
149
139
|
end
|
150
140
|
end
|
@@ -152,78 +142,178 @@ module Packtory
|
|
152
142
|
self
|
153
143
|
end
|
154
144
|
|
155
|
-
def
|
156
|
-
|
145
|
+
def detect_ruby_opts(argv)
|
146
|
+
ruby_ver = nil
|
147
|
+
if ENV['PACKAGE_RUBY_VERSION'] && !ENV['PACKAGE_RUBY_VERSION'].empty?
|
148
|
+
ruby_ver = ENV['PACKAGE_RUBY_VERSION']
|
149
|
+
end
|
157
150
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
151
|
+
Packtory.config[:dependencies]['ruby'] = ruby_ver
|
152
|
+
end
|
153
|
+
|
154
|
+
def options_parser
|
155
|
+
OptionParser.new do |opts|
|
156
|
+
opts.banner = 'Usage: %s [options]' % PACKTORY_BIN_NAME
|
157
|
+
|
158
|
+
opts.on('-t TYPE', '--type=TYPE', 'Type of package to build (e.g. deb | rpm | brew)') do |t|
|
159
|
+
Packtory.config[:packages] = [ t.to_sym ]
|
160
|
+
end
|
161
|
+
|
162
|
+
opts.on('-n PACKAGE_NAME', '--pkgname=PACKAGE_NAME', 'Override detected and set specific package name') do |n|
|
163
|
+
Packtory.config[:package_name] = n
|
164
|
+
end
|
165
|
+
|
166
|
+
opts.on('-p PACKAGE_PATH', '--pkgpath=PACKAGE_PATH', 'Path where to create package') do |p|
|
167
|
+
Packtory.config[:pkg_path] = File.expand_path(p)
|
168
|
+
end
|
169
|
+
|
170
|
+
opts.on('-v', 'Show version') do |v|
|
171
|
+
options[:show_version] = true
|
172
|
+
end
|
168
173
|
end
|
174
|
+
end
|
169
175
|
|
170
|
-
|
171
|
-
|
176
|
+
def perform_options
|
177
|
+
if options[:show_version]
|
178
|
+
show_version
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def show_version
|
183
|
+
say '%s' % Packtory::VERSION
|
184
|
+
complete_and_exit!
|
185
|
+
end
|
172
186
|
|
173
|
-
|
174
|
-
|
187
|
+
def show_man
|
188
|
+
man_path = File.expand_path('../../../man/packtory.1', __FILE__)
|
189
|
+
Kernel.exec('man %s' % man_path)
|
190
|
+
end
|
175
191
|
|
176
|
-
|
177
|
-
|
192
|
+
def show_configs
|
193
|
+
say 'Using fpm path : %s' % Packtory.config[:fpm_exec_path]
|
194
|
+
unless Packtory.config[:fpm_use_ruby_path].nil?
|
195
|
+
say 'Fpm using ruby : %s' % Packtory.config[:fpm_use_ruby_path]
|
178
196
|
end
|
197
|
+
say 'Using fpm : %s' % `#{exec_fpm} -v`.strip
|
179
198
|
|
180
|
-
|
199
|
+
say 'Package output : %s' % Packtory.config[:packages].join(', ')
|
200
|
+
|
201
|
+
unless Packtory.config[:pkg_path].nil?
|
202
|
+
say 'Package path : %s' % Packtory.config[:pkg_path]
|
203
|
+
end
|
204
|
+
|
205
|
+
unless Packtory.config[:package_name].nil?
|
206
|
+
say 'Package name : %s' % Packtory.config[:package_name]
|
207
|
+
end
|
208
|
+
|
209
|
+
if Packtory.config[:dependencies].include?('ruby')
|
210
|
+
ruby_ver = Packtory.config[:dependencies]['ruby']
|
211
|
+
if ruby_ver.nil?
|
212
|
+
say 'Ruby deps : latest'
|
213
|
+
else
|
214
|
+
say 'Ruby deps : %s' % ruby_ver
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
say '=================='
|
181
219
|
end
|
182
220
|
|
183
|
-
def
|
184
|
-
|
221
|
+
def exec_fpm
|
222
|
+
if Packtory.config[:fpm_use_ruby_path].nil?
|
223
|
+
Packtory.config[:fpm_exec_path]
|
224
|
+
else
|
225
|
+
'env FPM_USE_RUBY_PATH=%s %s' % [ Packtory.config[:fpm_use_ruby_path],
|
226
|
+
Packtory.config[:fpm_exec_path] ]
|
227
|
+
end
|
228
|
+
end
|
185
229
|
|
230
|
+
def test_dumpinfo(argv)
|
186
231
|
info_h = {
|
187
232
|
:version => ::Packtory::VERSION,
|
188
|
-
:fpm_version => `#{
|
233
|
+
:fpm_version => `#{exec_fpm} -v`.strip
|
189
234
|
}.merge(Packtory.config)
|
190
235
|
|
191
|
-
|
192
|
-
|
236
|
+
dump_file = ENV['TEST_DUMPINFO'] || '1'
|
237
|
+
if dump_file == '1'
|
238
|
+
f = StringIO.new
|
239
|
+
else
|
240
|
+
f = File.open(File.expand_path(dump_file), 'w+')
|
241
|
+
say 'Created dump file: %s' % dump_file
|
193
242
|
end
|
194
243
|
|
195
|
-
|
196
|
-
|
244
|
+
f.write(YAML.dump(info_h))
|
245
|
+
f.rewind
|
246
|
+
say f.read
|
247
|
+
f.close
|
197
248
|
|
198
249
|
self
|
199
250
|
end
|
200
251
|
|
201
|
-
def
|
202
|
-
|
203
|
-
|
204
|
-
$:.unshift(@build_path)
|
205
|
-
Dir.chdir(@build_path)
|
206
|
-
|
252
|
+
def perform_build_command(argv)
|
253
|
+
detect_fpm(argv)
|
207
254
|
detect_specfile(argv)
|
208
255
|
detect_gemfile(argv)
|
209
|
-
detect_deps(argv)
|
210
|
-
detect_package_output(argv)
|
211
256
|
|
212
|
-
|
257
|
+
$:.unshift(@build_path)
|
258
|
+
Dir.chdir(@build_path)
|
213
259
|
|
214
260
|
Packtory.setup
|
261
|
+
show_configs
|
215
262
|
|
216
263
|
if ENV['TEST_DUMPINFO']
|
217
264
|
test_dumpinfo(argv)
|
218
265
|
elsif ENV['TEST_NOBUILD']
|
219
|
-
|
266
|
+
complete_and_exit!
|
220
267
|
else
|
221
268
|
Packtory.build_package
|
222
269
|
end
|
223
270
|
end
|
224
271
|
|
272
|
+
def detect_and_perform_command(argv)
|
273
|
+
detect_package_opts(argv)
|
274
|
+
detect_ruby_opts(argv)
|
275
|
+
|
276
|
+
if argv[0] == 'build'
|
277
|
+
perform_build_command(argv)
|
278
|
+
elsif argv[0] == 'man'
|
279
|
+
show_man
|
280
|
+
elsif argv[0].nil? || argv[0] == ''
|
281
|
+
say 'ERROR: Build path not specified, aborting.'
|
282
|
+
complete_and_exit! 1
|
283
|
+
else
|
284
|
+
@build_path = File.expand_path(argv[0])
|
285
|
+
unless File.exists?(@build_path)
|
286
|
+
say 'ERROR: Build path %s do not exist, aborting.' % @build_path
|
287
|
+
complete_and_exit! 1
|
288
|
+
end
|
289
|
+
|
290
|
+
Packtory.config[:path] = @build_path
|
291
|
+
say 'Using build path : %s' % @build_path
|
292
|
+
perform_build_command(argv)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
def run(argv)
|
297
|
+
options_parser.parse!(argv)
|
298
|
+
perform_options
|
299
|
+
|
300
|
+
detect_and_perform_command(argv) unless completed?
|
301
|
+
complete_and_exit! unless completed?
|
302
|
+
|
303
|
+
@exit_number
|
304
|
+
end
|
305
|
+
|
306
|
+
def completed?; @completed; end
|
307
|
+
|
308
|
+
def complete_and_exit!(e = 0)
|
309
|
+
@completed = true
|
310
|
+
@exit_number = e
|
311
|
+
end
|
312
|
+
|
225
313
|
def say(msg)
|
226
|
-
|
314
|
+
unless self.class.silent?
|
315
|
+
puts msg
|
316
|
+
end
|
227
317
|
end
|
228
318
|
end
|
229
319
|
end
|
data/lib/packtory/config.rb
CHANGED
data/lib/packtory/deb_package.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'bundler'
|
2
|
+
require 'digest'
|
2
3
|
|
3
4
|
module Packtory
|
4
5
|
class DebPackage
|
5
|
-
INSTALL_PREFIX = '/usr/lib/ruby/vendor_ruby
|
6
|
+
INSTALL_PREFIX = '/usr/lib/ruby/vendor_ruby/%s'
|
6
7
|
|
7
8
|
def self.build_package(opts = { })
|
8
9
|
packager = Packer.new(opts)
|
@@ -14,6 +15,7 @@ module Packtory
|
|
14
15
|
|
15
16
|
if File.exist?(pkg_file_path)
|
16
17
|
Bundler.ui.info 'Created package: %s (%s bytes)' % [ pkg_file_path, File.size(pkg_file_path) ]
|
18
|
+
Bundler.ui.info 'SHA256 checksum: %s' % Digest::SHA256.file(pkg_file_path).hexdigest
|
17
19
|
else
|
18
20
|
Bundler.ui.error '[ERROR] Package not found: %s' % [ pkg_file_path ]
|
19
21
|
end
|
data/lib/packtory/fpm_exec.rb
CHANGED
@@ -77,7 +77,13 @@ module Packtory
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def template_values
|
80
|
-
values = {
|
80
|
+
values = { }.merge(@packager.template_scripts_values)
|
81
|
+
|
82
|
+
if !@prefix_path.nil?
|
83
|
+
values['pg_PACKAGE_PATH'] = @prefix_path % @packager.package_name
|
84
|
+
else
|
85
|
+
values['pg_PACKAGE_PATH'] = '<'
|
86
|
+
end
|
81
87
|
|
82
88
|
values.collect do |k, v|
|
83
89
|
'--template-value %s="%s"' % [ k, v ]
|
data/lib/packtory/packer.rb
CHANGED
@@ -42,6 +42,8 @@ module Packtory
|
|
42
42
|
@gemfile = autogenerate_clean_gemfile
|
43
43
|
end
|
44
44
|
|
45
|
+
@files = nil
|
46
|
+
|
45
47
|
self
|
46
48
|
end
|
47
49
|
|
@@ -153,7 +155,7 @@ module Packtory
|
|
153
155
|
gemfile_path = File.join(working_path, 'Gemfile')
|
154
156
|
File.open(gemfile_path, 'w') do |f|
|
155
157
|
gemfile_content = <<GEMFILE
|
156
|
-
source
|
158
|
+
source 'http://rubygems.org'
|
157
159
|
gemspec :path => '%s', :name => '%s'
|
158
160
|
GEMFILE
|
159
161
|
|
@@ -323,8 +325,6 @@ GEMFILE
|
|
323
325
|
end
|
324
326
|
end
|
325
327
|
|
326
|
-
include_packtory_tools = false
|
327
|
-
|
328
328
|
bgems = bundle_gems
|
329
329
|
bgems.each do |gem_name, bhash|
|
330
330
|
bhash[:files].each do |file|
|
@@ -334,16 +334,11 @@ GEMFILE
|
|
334
334
|
|
335
335
|
unless bhash[:spec].extensions.empty?
|
336
336
|
add_ruby_build_dependencies!
|
337
|
-
include_packtory_tools = true
|
338
|
-
|
339
337
|
files[bhash[:orig_spec].loaded_from] = File.join(BUNDLE_EXTENSIONS_PATH, '%s.gemspec' % gem_name)
|
340
338
|
end
|
341
339
|
end
|
342
340
|
|
343
|
-
|
344
|
-
files = gather_packtory_tools_for_package(files)
|
345
|
-
end
|
346
|
-
|
341
|
+
files = gather_packtory_tools_for_package(files)
|
347
342
|
files[Packtory.bundler_setup_path] = { :target_path => File.join(BUNDLE_TARGET_PATH, BUNDLE_BUNDLER_SETUP_FILE) }
|
348
343
|
|
349
344
|
files
|
@@ -388,21 +383,13 @@ GEMFILE
|
|
388
383
|
|
389
384
|
files = gather_files_for_package
|
390
385
|
files.each do |fsrc, ftarget|
|
391
|
-
tvalues = nil
|
392
|
-
|
393
386
|
if fsrc =~ /^\//
|
394
387
|
fsrc_path = fsrc
|
395
388
|
else
|
396
389
|
fsrc_path = File.join(root_path, fsrc)
|
397
390
|
end
|
398
391
|
|
399
|
-
|
400
|
-
when String
|
401
|
-
ftarget_path = File.join(prefix_path, ftarget)
|
402
|
-
when Hash
|
403
|
-
ftarget_path = File.join(prefix_path, ftarget[:target_path])
|
404
|
-
tvalues = ftarget[:values]
|
405
|
-
end
|
392
|
+
ftarget_path, tvalues = path_to_gathered_file(files, fsrc)
|
406
393
|
|
407
394
|
FileUtils.mkpath(File.dirname(ftarget_path))
|
408
395
|
FileUtils.cp_r(fsrc_path, ftarget_path)
|
@@ -418,6 +405,24 @@ GEMFILE
|
|
418
405
|
files
|
419
406
|
end
|
420
407
|
|
408
|
+
def path_to_gathered_file(files, fkey)
|
409
|
+
prefix_path = File.join(package_working_path, package_name)
|
410
|
+
|
411
|
+
ftarget = files[fkey]
|
412
|
+
ftarget_path = nil
|
413
|
+
tvalues = nil
|
414
|
+
|
415
|
+
case ftarget
|
416
|
+
when String
|
417
|
+
ftarget_path = File.join(prefix_path, ftarget)
|
418
|
+
when Hash
|
419
|
+
ftarget_path = File.join(prefix_path, ftarget[:target_path])
|
420
|
+
tvalues = ftarget[:values]
|
421
|
+
end
|
422
|
+
|
423
|
+
[ ftarget_path, tvalues ]
|
424
|
+
end
|
425
|
+
|
421
426
|
class TemplateFile
|
422
427
|
def initialize(packer, file_path, tvalues)
|
423
428
|
@packer = packer
|
@@ -453,47 +458,51 @@ GEMFILE
|
|
453
458
|
end
|
454
459
|
end
|
455
460
|
|
456
|
-
def create_binstub(binstub_fname,
|
461
|
+
def create_binstub(binstub_fname, target_prefix_path)
|
457
462
|
binstub_code = <<CODE
|
458
463
|
#!/usr/bin/ruby
|
459
464
|
|
460
465
|
ENV['RUBY_PATH'] = '/usr/bin/ruby'
|
461
466
|
|
462
|
-
|
463
|
-
|
467
|
+
package_prefix = %s
|
468
|
+
require File.join(package_prefix, '%s')
|
469
|
+
load File.join(package_prefix, '%s')
|
464
470
|
CODE
|
465
471
|
|
466
472
|
src_bin_path = File.join(package_working_path, 'bin', binstub_fname)
|
467
473
|
FileUtils.mkpath(File.dirname(src_bin_path))
|
468
474
|
|
469
|
-
if @opts[:
|
470
|
-
target_path =
|
475
|
+
if @opts[:install_prefix_as_code]
|
476
|
+
target_path = @opts[:install_prefix_as_code] % package_name
|
471
477
|
else
|
472
|
-
target_path =
|
478
|
+
target_path = '"%s"' % (target_prefix_path % package_name)
|
473
479
|
end
|
474
480
|
|
475
|
-
bundler_setup_path = File.join(
|
481
|
+
bundler_setup_path = File.join(BUNDLE_TARGET_PATH, BUNDLE_BUNDLER_SETUP_FILE)
|
476
482
|
|
477
483
|
bindir_name = gemspec.nil? ? 'bin' : gemspec.bindir
|
478
|
-
actual_bin_path = File.join(
|
484
|
+
actual_bin_path = File.join(bindir_name, binstub_fname)
|
485
|
+
|
486
|
+
File.open(src_bin_path, 'w') do |f|
|
487
|
+
f.write(binstub_code % [ target_path, bundler_setup_path, actual_bin_path ])
|
488
|
+
end
|
479
489
|
|
480
|
-
File.open(src_bin_path, 'w') { |f| f.write(binstub_code % [ bundler_setup_path, actual_bin_path ]) }
|
481
490
|
FileUtils.chmod(0755, src_bin_path)
|
482
491
|
|
483
492
|
src_bin_path
|
484
493
|
end
|
485
494
|
|
486
|
-
def build_file_map(
|
495
|
+
def build_file_map(target_prefix_path, package_path = nil)
|
487
496
|
files = { }
|
488
497
|
|
489
498
|
source_path = File.join(package_working_path, package_name, '/')
|
490
|
-
target_path =
|
499
|
+
target_path = (package_path || target_prefix_path) % package_name
|
491
500
|
files[source_path] = target_path
|
492
501
|
|
493
502
|
files
|
494
503
|
end
|
495
504
|
|
496
|
-
def add_bin_files(files,
|
505
|
+
def add_bin_files(files, target_prefix_path, package_path = nil)
|
497
506
|
bin_path = @opts[:bin_path] || DEFAULT_BIN_PATH
|
498
507
|
|
499
508
|
if @opts[:binstub].nil?
|
@@ -507,20 +516,29 @@ CODE
|
|
507
516
|
end
|
508
517
|
|
509
518
|
@opts[:binstub].each do |binstub_fname, binstub_file|
|
510
|
-
src_binstub_file = create_binstub(binstub_fname,
|
519
|
+
src_binstub_file = create_binstub(binstub_fname, target_prefix_path)
|
511
520
|
files[src_binstub_file] = binstub_file
|
512
521
|
end unless @opts[:binstub].nil?
|
513
522
|
|
514
523
|
files
|
515
524
|
end
|
516
525
|
|
517
|
-
def prepare_files(
|
518
|
-
gather_files
|
526
|
+
def prepare_files(target_prefix_path, package_path = nil)
|
527
|
+
@files = gather_files
|
519
528
|
|
520
|
-
|
521
|
-
|
529
|
+
sfiles_map = build_file_map(target_prefix_path, package_path)
|
530
|
+
sfiles_map = add_bin_files(sfiles_map, target_prefix_path, package_path)
|
522
531
|
|
523
|
-
|
532
|
+
sfiles_map
|
533
|
+
end
|
534
|
+
|
535
|
+
def after_install_script_path
|
536
|
+
ftarget_path, _ = path_to_gathered_file(@files, Packtory.after_install_script_path)
|
537
|
+
ftarget_path
|
538
|
+
end
|
539
|
+
|
540
|
+
def template_scripts_values
|
541
|
+
{ }
|
524
542
|
end
|
525
543
|
end
|
526
544
|
end
|
data/lib/packtory/rpm_package.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
require 'bundler'
|
2
|
+
require 'digest'
|
2
3
|
|
3
4
|
module Packtory
|
4
5
|
class RpmPackage
|
5
|
-
INSTALL_PREFIX = '/usr/share/ruby/vendor_ruby
|
6
|
+
INSTALL_PREFIX = '/usr/share/ruby/vendor_ruby/%s'
|
6
7
|
|
7
8
|
def self.build_package(opts = { })
|
8
9
|
packager = Packer.new(opts)
|
10
|
+
|
11
|
+
# add rubygems dependency
|
12
|
+
unless packager.opts[:dependencies].include?('rubygems')
|
13
|
+
packager.opts[:dependencies]['rubygems'] = nil
|
14
|
+
end
|
15
|
+
|
9
16
|
fpm_exec = FpmExec.new(packager, INSTALL_PREFIX)
|
10
17
|
|
11
18
|
sfiles_map = packager.prepare_files(INSTALL_PREFIX)
|
@@ -14,6 +21,7 @@ module Packtory
|
|
14
21
|
|
15
22
|
if File.exist?(pkg_file_path)
|
16
23
|
Bundler.ui.info 'Created package: %s (%s bytes)' % [ pkg_file_path, File.size(pkg_file_path) ]
|
24
|
+
Bundler.ui.info 'SHA256 checksum: %s' % Digest::SHA256.file(pkg_file_path).hexdigest
|
17
25
|
else
|
18
26
|
Bundler.ui.error '[ERROR] Package not found: %s' % [ pkg_file_path ]
|
19
27
|
end
|
data/lib/packtory/tgz_package.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'bundler'
|
2
|
+
require 'digest'
|
2
3
|
|
3
4
|
module Packtory
|
4
5
|
class TgzPackage
|
5
|
-
INSTALL_PREFIX = '
|
6
|
+
INSTALL_PREFIX = '%s'
|
6
7
|
|
7
8
|
def self.build_package(opts = { })
|
8
9
|
packager = Packer.new({ :binstub => { } }.merge(opts))
|
@@ -14,6 +15,7 @@ module Packtory
|
|
14
15
|
|
15
16
|
if File.exist?(pkg_file_path)
|
16
17
|
Bundler.ui.info 'Created package: %s (%s bytes)' % [ pkg_file_path, File.size(pkg_file_path) ]
|
18
|
+
Bundler.ui.info 'SHA256 checksum: %s' % Digest::SHA256.file(pkg_file_path).hexdigest
|
17
19
|
else
|
18
20
|
Bundler.ui.error '[ERROR] Package not found: %s' % [ pkg_file_path ]
|
19
21
|
end
|
data/lib/packtory/version.rb
CHANGED
data/lib/packtory.rb
CHANGED
@@ -5,6 +5,7 @@ module Packtory
|
|
5
5
|
autoload :Command, File.expand_path('../packtory/command', __FILE__)
|
6
6
|
|
7
7
|
autoload :Config, File.expand_path('../packtory/config', __FILE__)
|
8
|
+
autoload :Constants, File.expand_path('../packtory/constants', __FILE__)
|
8
9
|
|
9
10
|
autoload :PatchBundlerNoMetadataDeps, File.expand_path('../packtory/patch_bundler_no_metadata_deps', __FILE__)
|
10
11
|
autoload :FpmExec, File.expand_path('../packtory/fpm_exec', __FILE__)
|
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.
|
4
|
+
version: 0.1.5
|
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:
|
11
|
+
date: 2019-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/packtory/bundler/setup.rb
|
58
58
|
- lib/packtory/command.rb
|
59
59
|
- lib/packtory/config.rb
|
60
|
+
- lib/packtory/constants.rb
|
60
61
|
- lib/packtory/deb_package.rb
|
61
62
|
- lib/packtory/fpm_exec.rb
|
62
63
|
- lib/packtory/packages.rb
|
@@ -90,8 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
91
|
- !ruby/object:Gem::Version
|
91
92
|
version: '0'
|
92
93
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 2.7.7
|
94
|
+
rubygems_version: 3.0.1
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: An easy to use system packaging tool for your Ruby gems.
|