fpm 1.2.0 → 1.3.0
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 +7 -7
- data/CHANGELIST +22 -0
- data/CONTRIBUTORS +1 -0
- data/lib/fpm/command.rb +70 -39
- data/lib/fpm/package.rb +11 -13
- data/lib/fpm/package/cpan.rb +50 -41
- data/lib/fpm/package/deb.rb +58 -26
- data/lib/fpm/package/dir.rb +15 -12
- data/lib/fpm/package/gem.rb +4 -4
- data/lib/fpm/package/npm.rb +20 -12
- data/lib/fpm/package/osxpkg.rb +2 -2
- data/lib/fpm/package/pear.rb +14 -14
- data/lib/fpm/package/puppet.rb +8 -8
- data/lib/fpm/package/pyfpm/__init__.pyc +0 -0
- data/lib/fpm/package/pyfpm/get_metadata.pyc +0 -0
- data/lib/fpm/package/python.rb +13 -13
- data/lib/fpm/package/rpm.rb +62 -8
- data/lib/fpm/package/sh.rb +1 -1
- data/lib/fpm/util.rb +9 -5
- data/lib/fpm/version.rb +1 -1
- data/templates/deb.erb +2 -0
- data/templates/deb/changelog.erb +5 -0
- data/templates/deb/postinst_upgrade.sh.erb +31 -0
- data/templates/deb/postrm_upgrade.sh.erb +37 -0
- data/templates/deb/preinst_upgrade.sh.erb +32 -0
- data/templates/deb/prerm_upgrade.sh.erb +27 -0
- data/templates/rpm.erb +85 -8
- data/templates/sh.erb +47 -21
- metadata +131 -174
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 94e2acc2a51dca9658374538128343b060301a57
|
4
|
+
data.tar.gz: ae3771e347496bd609cfa118c602d59a9277daf5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21ce60f7679ae634fdf4a55214b93476bc0d14d41fe1806b4f25133dfa6b4035dc4acf1d4c9d3eaa420a3960a2daedf11e6dd16499dcd04be09d13718432d4ef
|
7
|
+
data.tar.gz: dab536c4438a4db9f1920a8be8903b62060ac0b7a9c1b075eeedda225364bb79ea7f55d942163167262995b0d749c9f8859caf8997656fe6378046d761894535
|
data/CHANGELIST
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
1.3.0 (????)
|
2
|
+
- Fixed a bunch of Ruby 1.8.7-related bugs. (Jordan Sissel)
|
3
|
+
- cpan: Fix bug in author handling (#744, Leon Weidauer)
|
4
|
+
- cpan: Better removal of perllocal.pod (#763, #443, #510, Mathias Lafeldt)
|
5
|
+
- rpm: Use lstat calls instead of stat, so we don't follow symlinks (#765, Shrijeet Paliwal)
|
6
|
+
- rpm and deb: Now supports script actions on upgrades. This adds two new flags:
|
7
|
+
--before-upgrade and --after-upgrade. (#772, #661; Daniel Haskin)
|
8
|
+
- rpm: Package triggers are now supported. New flags: --rpm-trigger-before-install,
|
9
|
+
--rpm-trigger-after-install, --rpm-trigger-before-uninstall,
|
10
|
+
--rpm-trigger-after-target-uninstall. (#626, Maxime Caumartin)
|
11
|
+
- rpm: Add --rpm-init flag; similar to --deb-init. (Josh Dolitsky)
|
12
|
+
- sh: Skip installation if already installed for the given version. If forced,
|
13
|
+
the old installation is renamed. (#776, Chris Gerber)
|
14
|
+
- deb: Allow Vendor field to be omitted now by specifying `--vendor ""` (#778, Nate Brown)
|
15
|
+
- general: Add --log=level flag for setting log level. Levels are error, warn, info, debug. (Jordan SIssel)
|
16
|
+
- cpan: Check for Build.PL first before Makefile.PL (#787, Daniel Jay Haskin)
|
17
|
+
- dir: Don't follow symlinks when copying files (#658, Jordan Sissel)
|
18
|
+
- deb: Automatically provide a 'changes' file in debs because lintian
|
19
|
+
complains if they are missing. (#784, Jordan Sissel)
|
20
|
+
- deb: Fix and warn for package names that have spaces (#779, Grantlyk)
|
21
|
+
- npm: Automatically set the prefix to `npm prefix -g` (#758, Brady Wetherington and Jordan Sissel)
|
22
|
+
|
1
23
|
1.2.0 (July 25, 2014)
|
2
24
|
- rpm: Add --rpm-verifyscript for adding a custom rpm verify script to
|
3
25
|
your package. (Remi Hakim)
|
data/CONTRIBUTORS
CHANGED
@@ -19,6 +19,7 @@ Oliver Hookins (github: ohookins)
|
|
19
19
|
llasram
|
20
20
|
sbuss
|
21
21
|
Brett Gailey (github: dnbert)
|
22
|
+
Daniel Haskin (github: djhaskin987)
|
22
23
|
|
23
24
|
If you have contributed (bug reports, feature requests, help in IRC, blog
|
24
25
|
posts, code, etc) and aren't listed here, please let me know if you wish to be
|
data/lib/fpm/command.rb
CHANGED
@@ -58,6 +58,16 @@ class FPM::Command < Clamp::Command
|
|
58
58
|
option ["-f", "--force"], :flag, "Force output even if it will overwrite an " \
|
59
59
|
"existing file", :default => false
|
60
60
|
option ["-n", "--name"], "NAME", "The name to give to the package"
|
61
|
+
|
62
|
+
loglevels = %w(error warn info debug)
|
63
|
+
option "--log", "LEVEL", "Set the log level. Values: #{loglevels.join(", ")}.",
|
64
|
+
:attribute_name => :log_level do |val|
|
65
|
+
val.downcase.tap do |v|
|
66
|
+
if !loglevels.include?(v)
|
67
|
+
raise FPM::Package::InvalidArgument, "Invalid log level, #{v.inspect}. Must be one of: #{loglevels.join(", ")}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end # --log
|
61
71
|
option "--verbose", :flag, "Enable verbose output"
|
62
72
|
option "--debug", :flag, "Enable debug output"
|
63
73
|
option "--debug-workspace", :flag, "Keep any file workspaces around for " \
|
@@ -85,11 +95,11 @@ class FPM::Command < Clamp::Command
|
|
85
95
|
option "--no-depends", :flag, "Do not list any dependencies in this package",
|
86
96
|
:default => false
|
87
97
|
|
88
|
-
option "--no-auto-depends", :flag, "Do not list any dependencies in this" \
|
98
|
+
option "--no-auto-depends", :flag, "Do not list any dependencies in this " \
|
89
99
|
"package automatically", :default => false
|
90
100
|
|
91
101
|
option "--provides", "PROVIDES",
|
92
|
-
"What this package provides (usually a name). This flag can be "\
|
102
|
+
"What this package provides (usually a name). This flag can be " \
|
93
103
|
"specified multiple times.", :multivalued => true,
|
94
104
|
:attribute_name => :provides
|
95
105
|
option "--conflicts", "CONFLICTS",
|
@@ -97,7 +107,7 @@ class FPM::Command < Clamp::Command
|
|
97
107
|
"specified multiple times.", :multivalued => true,
|
98
108
|
:attribute_name => :conflicts
|
99
109
|
option "--replaces", "REPLACES",
|
100
|
-
"Other packages/versions this package replaces. This flag can be "\
|
110
|
+
"Other packages/versions this package replaces. This flag can be " \
|
101
111
|
"specified multiple times.", :multivalued => true,
|
102
112
|
:attribute_name => :replaces
|
103
113
|
|
@@ -142,42 +152,59 @@ class FPM::Command < Clamp::Command
|
|
142
152
|
"files and dirs to use as input."
|
143
153
|
|
144
154
|
option "--post-install", "FILE",
|
145
|
-
"(DEPRECATED, use --after-install)
|
155
|
+
"(DEPRECATED, use --after-install) A script to be run after " \
|
146
156
|
"package installation" do |val|
|
147
157
|
@after_install = File.expand_path(val) # Get the full path to the script
|
148
158
|
end # --post-install (DEPRECATED)
|
149
159
|
option "--pre-install", "FILE",
|
150
|
-
"(DEPRECATED, use --before-install)
|
160
|
+
"(DEPRECATED, use --before-install) A script to be run before " \
|
151
161
|
"package installation" do |val|
|
152
162
|
@before_install = File.expand_path(val) # Get the full path to the script
|
153
163
|
end # --pre-install (DEPRECATED)
|
154
164
|
option "--post-uninstall", "FILE",
|
155
|
-
"(DEPRECATED, use --after-remove)
|
165
|
+
"(DEPRECATED, use --after-remove) A script to be run after " \
|
156
166
|
"package removal" do |val|
|
157
167
|
@after_remove = File.expand_path(val) # Get the full path to the script
|
158
168
|
end # --post-uninstall (DEPRECATED)
|
159
169
|
option "--pre-uninstall", "FILE",
|
160
|
-
"(DEPRECATED, use --before-remove)
|
170
|
+
"(DEPRECATED, use --before-remove) A script to be run before " \
|
161
171
|
"package removal" do |val|
|
162
172
|
@before_remove = File.expand_path(val) # Get the full path to the script
|
163
173
|
end # --pre-uninstall (DEPRECATED)
|
164
174
|
|
165
175
|
option "--after-install", "FILE",
|
166
|
-
"
|
176
|
+
"A script to be run after package installation" do |val|
|
167
177
|
File.expand_path(val) # Get the full path to the script
|
168
178
|
end # --after-install
|
169
179
|
option "--before-install", "FILE",
|
170
|
-
"
|
180
|
+
"A script to be run before package installation" do |val|
|
171
181
|
File.expand_path(val) # Get the full path to the script
|
172
|
-
end # --
|
182
|
+
end # --before-install
|
173
183
|
option "--after-remove", "FILE",
|
174
|
-
"
|
184
|
+
"A script to be run after package removal" do |val|
|
175
185
|
File.expand_path(val) # Get the full path to the script
|
176
186
|
end # --after-remove
|
177
187
|
option "--before-remove", "FILE",
|
178
|
-
"
|
188
|
+
"A script to be run before package removal" do |val|
|
179
189
|
File.expand_path(val) # Get the full path to the script
|
180
190
|
end # --before-remove
|
191
|
+
option "--after-upgrade", "FILE",
|
192
|
+
"A script to be run after package upgrade. If not specified,\n" \
|
193
|
+
"--before-install, --after-install, --before-remove, and \n" \
|
194
|
+
"--after-remove wil behave in a backwards-compatible manner\n" \
|
195
|
+
"(they will not be upgrade-case aware).\n" \
|
196
|
+
"Currently only supports deb and rpm packages." do |val|
|
197
|
+
File.expand_path(val) # Get the full path to the script
|
198
|
+
end # --after-upgrade
|
199
|
+
option "--before-upgrade", "FILE",
|
200
|
+
"A script to be run before package upgrade. If not specified,\n" \
|
201
|
+
"--before-install, --after-install, --before-remove, and \n" \
|
202
|
+
"--after-remove wil behave in a backwards-compatible manner\n" \
|
203
|
+
"(they will not be upgrade-case aware).\n" \
|
204
|
+
"Currently only supports deb and rpm packages." do |val|
|
205
|
+
File.expand_path(val) # Get the full path to the script
|
206
|
+
end # --before-upgrade
|
207
|
+
|
181
208
|
option "--template-scripts", :flag,
|
182
209
|
"Allow scripts to be templated. This lets you use ERB to template your " \
|
183
210
|
"packaging scripts (for --after-install, etc). For example, you can do " \
|
@@ -227,10 +254,16 @@ class FPM::Command < Clamp::Command
|
|
227
254
|
return 0
|
228
255
|
end
|
229
256
|
|
230
|
-
|
257
|
+
logger.level = :warn
|
258
|
+
logger.level = :info if verbose? # --verbose
|
259
|
+
logger.level = :debug if debug? # --debug
|
260
|
+
if log_level
|
261
|
+
logger.level = log_level.to_sym
|
262
|
+
end
|
263
|
+
|
231
264
|
|
232
265
|
if (stray_flags = args.grep(/^-/); stray_flags.any?)
|
233
|
-
|
266
|
+
logger.warn("All flags should be before the first argument " \
|
234
267
|
"(stray flags found: #{stray_flags}")
|
235
268
|
end
|
236
269
|
|
@@ -239,28 +272,25 @@ class FPM::Command < Clamp::Command
|
|
239
272
|
# fpm would assume you meant to add '.' to the end of the commandline.
|
240
273
|
# Let's hack that. https://github.com/jordansissel/fpm/issues/187
|
241
274
|
if input_type == "dir" and args.empty? and !chdir.nil?
|
242
|
-
|
275
|
+
logger.info("No args, but -s dir and -C are given, assuming '.' as input")
|
243
276
|
args << "."
|
244
277
|
end
|
245
278
|
|
246
|
-
|
279
|
+
logger.info("Setting workdir", :workdir => workdir)
|
247
280
|
ENV["TMP"] = workdir
|
248
281
|
|
249
282
|
validator = Validator.new(self)
|
250
283
|
if !validator.ok?
|
251
284
|
validator.messages.each do |message|
|
252
|
-
|
285
|
+
logger.warn(message)
|
253
286
|
end
|
254
287
|
|
255
|
-
|
288
|
+
logger.fatal("Fix the above problems, and you'll be rolling packages in no time!")
|
256
289
|
return 1
|
257
290
|
end
|
258
291
|
input_class = FPM::Package.types[input_type]
|
259
292
|
output_class = FPM::Package.types[output_type]
|
260
293
|
|
261
|
-
@logger.level = :info if verbose? # --verbose
|
262
|
-
@logger.level = :debug if debug? # --debug
|
263
|
-
|
264
294
|
input = input_class.new
|
265
295
|
|
266
296
|
# Merge in package settings.
|
@@ -290,7 +320,7 @@ class FPM::Command < Clamp::Command
|
|
290
320
|
input.attributes["#{attr}_given?".to_sym] = flag_given
|
291
321
|
attr = "#{attr}?" if !respond_to?(attr) # handle boolean :flag cases
|
292
322
|
input.attributes[attr.to_sym] = send(attr) if respond_to?(attr)
|
293
|
-
|
323
|
+
logger.debug("Setting attribute", attr.to_sym => send(attr))
|
294
324
|
end
|
295
325
|
end
|
296
326
|
|
@@ -305,7 +335,7 @@ class FPM::Command < Clamp::Command
|
|
305
335
|
# If --inputs was specified, read it as a file.
|
306
336
|
if !inputs.nil?
|
307
337
|
if !File.exists?(inputs)
|
308
|
-
|
338
|
+
logger.fatal("File given for --inputs does not exist (#{inputs})")
|
309
339
|
return 1
|
310
340
|
end
|
311
341
|
|
@@ -326,7 +356,7 @@ class FPM::Command < Clamp::Command
|
|
326
356
|
# if the package's attribute is currently nil *or* the flag setting for this
|
327
357
|
# attribute is non-default, use the value.
|
328
358
|
if object.send(attribute).nil? || send(attribute) != send("default_#{attribute}")
|
329
|
-
|
359
|
+
logger.info("Setting from flags: #{attribute}=#{send(attribute)}")
|
330
360
|
object.send("#{attribute}=", send(attribute))
|
331
361
|
end
|
332
362
|
end
|
@@ -369,7 +399,7 @@ class FPM::Command < Clamp::Command
|
|
369
399
|
next if path.nil?
|
370
400
|
|
371
401
|
if !File.exists?(path)
|
372
|
-
|
402
|
+
logger.error("No such file (for #{scriptname.to_s}): #{path.inspect}")
|
373
403
|
script_errors << path
|
374
404
|
end
|
375
405
|
|
@@ -381,6 +411,8 @@ class FPM::Command < Clamp::Command
|
|
381
411
|
setscript.call(:after_install)
|
382
412
|
setscript.call(:before_remove)
|
383
413
|
setscript.call(:after_remove)
|
414
|
+
setscript.call(:before_upgrade)
|
415
|
+
setscript.call(:after_upgrade)
|
384
416
|
|
385
417
|
# Bail if any setscript calls had errors. We don't need to log
|
386
418
|
# anything because we've already logged the error(s) above.
|
@@ -388,7 +420,7 @@ class FPM::Command < Clamp::Command
|
|
388
420
|
|
389
421
|
# Validate the package
|
390
422
|
if input.name.nil? or input.name.empty?
|
391
|
-
|
423
|
+
logger.fatal("No name given for this package (set name with, " \
|
392
424
|
"for example, '-n packagename')")
|
393
425
|
return 1
|
394
426
|
end
|
@@ -417,26 +449,23 @@ class FPM::Command < Clamp::Command
|
|
417
449
|
begin
|
418
450
|
output.output(package_file)
|
419
451
|
rescue FPM::Package::FileAlreadyExists => e
|
420
|
-
|
452
|
+
logger.fatal(e.message)
|
421
453
|
return 1
|
422
454
|
rescue FPM::Package::ParentDirectoryMissing => e
|
423
|
-
|
455
|
+
logger.fatal(e.message)
|
424
456
|
return 1
|
425
457
|
end
|
426
458
|
|
427
|
-
|
459
|
+
logger.log("Created package", :path => package_file)
|
428
460
|
return 0
|
429
461
|
rescue FPM::Util::ExecutableNotFound => e
|
430
|
-
|
462
|
+
logger.error("Need executable '#{e}' to convert #{input_type} to #{output_type}")
|
431
463
|
return 1
|
432
464
|
rescue FPM::InvalidPackageConfiguration => e
|
433
|
-
|
434
|
-
return 1
|
435
|
-
rescue FPM::Package::InvalidArgument => e
|
436
|
-
@logger.error("Invalid package argument: #{e}")
|
465
|
+
logger.error("Invalid package configuration: #{e}")
|
437
466
|
return 1
|
438
467
|
rescue FPM::Util::ProcessFailed => e
|
439
|
-
|
468
|
+
logger.error("Process failed: #{e}")
|
440
469
|
return 1
|
441
470
|
ensure
|
442
471
|
if debug_workspace?
|
@@ -446,7 +475,7 @@ class FPM::Command < Clamp::Command
|
|
446
475
|
[:staging_path, :build_path].each do |pathtype|
|
447
476
|
path = plugin.send(pathtype)
|
448
477
|
next unless Dir.open(path).to_a.size > 2
|
449
|
-
|
478
|
+
logger.log("plugin directory", :plugin => plugin.type, :pathtype => pathtype, :path => path)
|
450
479
|
end
|
451
480
|
end
|
452
481
|
else
|
@@ -456,8 +485,7 @@ class FPM::Command < Clamp::Command
|
|
456
485
|
end # def execute
|
457
486
|
|
458
487
|
def run(*args)
|
459
|
-
|
460
|
-
@logger.subscribe(STDOUT)
|
488
|
+
logger.subscribe(STDOUT)
|
461
489
|
|
462
490
|
# fpm initialization files, note the order of the following array is
|
463
491
|
# important, try .fpm in users home directory first and then the current
|
@@ -467,7 +495,7 @@ class FPM::Command < Clamp::Command
|
|
467
495
|
|
468
496
|
rc_files.each do |rc_file|
|
469
497
|
if File.readable? rc_file
|
470
|
-
|
498
|
+
logger.warn("Loading flags from rc file #{rc_file}")
|
471
499
|
File.readlines(rc_file).each do |line|
|
472
500
|
# reverse becasue 'unshift' pushes onto the left side of the array.
|
473
501
|
Shellwords.shellsplit(line).reverse.each do |arg|
|
@@ -480,6 +508,9 @@ class FPM::Command < Clamp::Command
|
|
480
508
|
end
|
481
509
|
|
482
510
|
super(*args)
|
511
|
+
rescue FPM::Package::InvalidArgument => e
|
512
|
+
logger.error("Invalid package argument: #{e}")
|
513
|
+
return 1
|
483
514
|
end # def run
|
484
515
|
|
485
516
|
# A simple flag validator
|
data/lib/fpm/package.rb
CHANGED
@@ -116,8 +116,6 @@ class FPM::Package
|
|
116
116
|
private
|
117
117
|
|
118
118
|
def initialize
|
119
|
-
@logger = Cabin::Channel.get
|
120
|
-
|
121
119
|
# Attributes for this specific package
|
122
120
|
@attributes = {}
|
123
121
|
|
@@ -189,7 +187,7 @@ class FPM::Package
|
|
189
187
|
|
190
188
|
# Convert this package to a new package type
|
191
189
|
def convert(klass)
|
192
|
-
|
190
|
+
logger.info("Converting #{self.type} to #{klass.type}")
|
193
191
|
|
194
192
|
exclude
|
195
193
|
|
@@ -204,7 +202,7 @@ class FPM::Package
|
|
204
202
|
:@directories, :@staging_path, :@attrs
|
205
203
|
]
|
206
204
|
ivars.each do |ivar|
|
207
|
-
|
205
|
+
#logger.debug("Copying ivar", :ivar => ivar, :value => instance_variable_get(ivar),
|
208
206
|
#:from => self.type, :to => pkg.type)
|
209
207
|
pkg.instance_variable_set(ivar, instance_variable_get(ivar))
|
210
208
|
end
|
@@ -272,20 +270,20 @@ class FPM::Package
|
|
272
270
|
|
273
271
|
# Clean up any temporary storage used by this class.
|
274
272
|
def cleanup
|
275
|
-
cleanup_staging unless
|
276
|
-
cleanup_build unless
|
273
|
+
cleanup_staging unless logger.level == :debug
|
274
|
+
cleanup_build unless logger.level == :debug
|
277
275
|
end # def cleanup
|
278
276
|
|
279
277
|
def cleanup_staging
|
280
278
|
if File.directory?(staging_path)
|
281
|
-
|
279
|
+
logger.debug("Cleaning up staging path", :path => staging_path)
|
282
280
|
FileUtils.rm_r(staging_path)
|
283
281
|
end
|
284
282
|
end # def cleanup_staging
|
285
283
|
|
286
284
|
def cleanup_build
|
287
285
|
if File.directory?(build_path)
|
288
|
-
|
286
|
+
logger.debug("Cleaning up build path", :path => build_path)
|
289
287
|
FileUtils.rm_r(build_path)
|
290
288
|
end
|
291
289
|
end # def cleanup_build
|
@@ -327,7 +325,7 @@ class FPM::Package
|
|
327
325
|
def template(path)
|
328
326
|
template_path = File.join(template_dir, path)
|
329
327
|
template_code = File.read(template_path)
|
330
|
-
|
328
|
+
logger.info("Reading template", :path => template_path)
|
331
329
|
erb = ERB.new(template_code, nil, "-")
|
332
330
|
erb.filename = template_path
|
333
331
|
return erb
|
@@ -348,7 +346,7 @@ class FPM::Package
|
|
348
346
|
|
349
347
|
def edit_file(path)
|
350
348
|
editor = ENV['FPM_EDITOR'] || ENV['EDITOR'] || 'vi'
|
351
|
-
|
349
|
+
logger.info("Launching editor", :file => path)
|
352
350
|
command = "#{editor} #{Shellwords.escape(path)}"
|
353
351
|
system("#{editor} #{Shellwords.escape(path)}")
|
354
352
|
if !$?.success?
|
@@ -377,10 +375,10 @@ class FPM::Package
|
|
377
375
|
match_path = path.sub("#{installdir.chomp('/')}/", '')
|
378
376
|
|
379
377
|
attributes[:excludes].each do |wildcard|
|
380
|
-
|
378
|
+
logger.debug("Checking path against wildcard", :path => match_path, :wildcard => wildcard)
|
381
379
|
|
382
380
|
if File.fnmatch(wildcard, match_path)
|
383
|
-
|
381
|
+
logger.info("Removing excluded path", :path => match_path, :matches => wildcard)
|
384
382
|
FileUtils.remove_entry_secure(path)
|
385
383
|
Find.prune
|
386
384
|
break
|
@@ -500,7 +498,7 @@ class FPM::Package
|
|
500
498
|
end
|
501
499
|
if File.file?(output_path)
|
502
500
|
if attributes[:force?]
|
503
|
-
|
501
|
+
logger.warn("Force flag given. Overwriting package at #{output_path}")
|
504
502
|
File.delete(output_path)
|
505
503
|
else
|
506
504
|
raise FileAlreadyExists.new(output_path)
|
data/lib/fpm/package/cpan.rb
CHANGED
@@ -73,17 +73,23 @@ class FPM::Package::CPAN < FPM::Package
|
|
73
73
|
end
|
74
74
|
|
75
75
|
unless metadata["distribution"].nil?
|
76
|
-
|
76
|
+
logger.info("Setting package name from 'distribution'",
|
77
77
|
:distribution => metadata["distribution"])
|
78
78
|
self.name = fix_name(metadata["distribution"])
|
79
79
|
else
|
80
|
-
|
80
|
+
logger.info("Setting package name from 'name'",
|
81
81
|
:name => metadata["name"])
|
82
82
|
self.name = fix_name(metadata["name"])
|
83
83
|
end
|
84
84
|
|
85
|
-
#
|
86
|
-
self.vendor =
|
85
|
+
# author is not always set or it may be a string instead of an array
|
86
|
+
self.vendor = case metadata["author"]
|
87
|
+
when String; metadata["author"]
|
88
|
+
when Array; metadata["author"].join(", ")
|
89
|
+
else
|
90
|
+
raise FPM::InvalidPackageConfiguration, "Unexpected CPAN 'author' field type: #{metadata["author"].class}. This is a bug."
|
91
|
+
end if metadata.include?("author")
|
92
|
+
|
87
93
|
self.url = metadata["resources"]["homepage"] rescue "unknown"
|
88
94
|
|
89
95
|
# TODO(sissel): figure out if this perl module compiles anything
|
@@ -92,7 +98,7 @@ class FPM::Package::CPAN < FPM::Package
|
|
92
98
|
|
93
99
|
# Install any build/configure dependencies with cpanm.
|
94
100
|
# We'll install to a temporary directory.
|
95
|
-
|
101
|
+
logger.info("Installing any build or configure dependencies")
|
96
102
|
|
97
103
|
cpanm_flags = ["-L", build_path("cpan"), moduledir]
|
98
104
|
cpanm_flags += ["-n"] if attributes[:cpan_test?]
|
@@ -144,36 +150,13 @@ class FPM::Package::CPAN < FPM::Package
|
|
144
150
|
# build/configure requirements.
|
145
151
|
# META.yml calls it 'configure_requires' and 'build_requires'
|
146
152
|
# META.json calls it prereqs/build and prereqs/configure
|
147
|
-
|
153
|
+
|
148
154
|
prefix = attributes[:prefix] || "/usr/local"
|
149
155
|
# TODO(sissel): Set default INSTALL path?
|
150
156
|
|
151
157
|
# Try Makefile.PL, Build.PL
|
152
158
|
#
|
153
|
-
if File.exists?("
|
154
|
-
if attributes[:cpan_perl_lib_path]
|
155
|
-
perl_lib_path = attributes[:cpan_perl_lib_path]
|
156
|
-
safesystem(attributes[:cpan_perl_bin],
|
157
|
-
"-Mlocal::lib=#{build_path("cpan")}",
|
158
|
-
"Makefile.PL", "PREFIX=#{prefix}", "LIB=#{perl_lib_path}",
|
159
|
-
# Empty install_base to avoid local::lib being used.
|
160
|
-
"INSTALL_BASE=")
|
161
|
-
else
|
162
|
-
safesystem(attributes[:cpan_perl_bin],
|
163
|
-
"-Mlocal::lib=#{build_path("cpan")}",
|
164
|
-
"Makefile.PL", "PREFIX=#{prefix}",
|
165
|
-
# Empty install_base to avoid local::lib being used.
|
166
|
-
"INSTALL_BASE=")
|
167
|
-
end
|
168
|
-
if attributes[:cpan_test?]
|
169
|
-
make = [ "env", "PERL5LIB=#{build_path("cpan/lib/perl5")}", "make" ]
|
170
|
-
else
|
171
|
-
make = [ "make" ]
|
172
|
-
end
|
173
|
-
safesystem(*make)
|
174
|
-
safesystem(*(make + ["test"])) if attributes[:cpan_test?]
|
175
|
-
safesystem(*(make + ["DESTDIR=#{staging_path}", "install"]))
|
176
|
-
elsif File.exists?("Build.PL")
|
159
|
+
if File.exists?("Build.PL")
|
177
160
|
# Module::Build is in use here; different actions required.
|
178
161
|
safesystem(attributes[:cpan_perl_bin],
|
179
162
|
"-Mlocal::lib=#{build_path("cpan")}",
|
@@ -197,6 +180,31 @@ class FPM::Package::CPAN < FPM::Package
|
|
197
180
|
# Empty install_base to avoid local::lib being used.
|
198
181
|
"--install_base", "")
|
199
182
|
end
|
183
|
+
elsif File.exists?("Makefile.PL")
|
184
|
+
if attributes[:cpan_perl_lib_path]
|
185
|
+
perl_lib_path = attributes[:cpan_perl_lib_path]
|
186
|
+
safesystem(attributes[:cpan_perl_bin],
|
187
|
+
"-Mlocal::lib=#{build_path("cpan")}",
|
188
|
+
"Makefile.PL", "PREFIX=#{prefix}", "LIB=#{perl_lib_path}",
|
189
|
+
# Empty install_base to avoid local::lib being used.
|
190
|
+
"INSTALL_BASE=")
|
191
|
+
else
|
192
|
+
safesystem(attributes[:cpan_perl_bin],
|
193
|
+
"-Mlocal::lib=#{build_path("cpan")}",
|
194
|
+
"Makefile.PL", "PREFIX=#{prefix}",
|
195
|
+
# Empty install_base to avoid local::lib being used.
|
196
|
+
"INSTALL_BASE=")
|
197
|
+
end
|
198
|
+
if attributes[:cpan_test?]
|
199
|
+
make = [ "env", "PERL5LIB=#{build_path("cpan/lib/perl5")}", "make" ]
|
200
|
+
else
|
201
|
+
make = [ "make" ]
|
202
|
+
end
|
203
|
+
safesystem(*make)
|
204
|
+
safesystem(*(make + ["test"])) if attributes[:cpan_test?]
|
205
|
+
safesystem(*(make + ["DESTDIR=#{staging_path}", "install"]))
|
206
|
+
|
207
|
+
|
200
208
|
else
|
201
209
|
raise FPM::InvalidPackageConfiguration,
|
202
210
|
"I don't know how to build #{name}. No Makefile.PL nor " \
|
@@ -207,8 +215,9 @@ class FPM::Package::CPAN < FPM::Package
|
|
207
215
|
# across packages.
|
208
216
|
# https://github.com/jordansissel/fpm/issues/443
|
209
217
|
# https://github.com/jordansissel/fpm/issues/510
|
210
|
-
|
211
|
-
|
218
|
+
glob_prefix = attributes[:cpan_perl_lib_path] || prefix
|
219
|
+
::Dir.glob(File.join(staging_path, glob_prefix, "**/perllocal.pod")).each do |path|
|
220
|
+
logger.debug("Removing useless file.",
|
212
221
|
:path => path.gsub(staging_path, ""))
|
213
222
|
File.unlink(path)
|
214
223
|
end
|
@@ -223,7 +232,7 @@ class FPM::Package::CPAN < FPM::Package
|
|
223
232
|
# native if found; otherwise keep the 'all' default.
|
224
233
|
Find.find(staging_path) do |path|
|
225
234
|
if path =~ /\.so$/
|
226
|
-
|
235
|
+
logger.info("Found shared library, setting architecture=native",
|
227
236
|
:path => path)
|
228
237
|
self.architecture = "native"
|
229
238
|
end
|
@@ -243,7 +252,7 @@ class FPM::Package::CPAN < FPM::Package
|
|
243
252
|
distribution = metadata["distribution"]
|
244
253
|
author = metadata["author"]
|
245
254
|
|
246
|
-
|
255
|
+
logger.info("Downloading perl module",
|
247
256
|
:distribution => distribution,
|
248
257
|
:version => cpan_version)
|
249
258
|
|
@@ -262,7 +271,7 @@ class FPM::Package::CPAN < FPM::Package
|
|
262
271
|
begin
|
263
272
|
release_response = httpfetch(metacpan_release_url)
|
264
273
|
rescue Net::HTTPServerException => e
|
265
|
-
|
274
|
+
logger.error("metacpan release query failed.", :error => e.message,
|
266
275
|
:module => package, :url => metacpan_release_url)
|
267
276
|
raise FPM::InvalidPackageConfiguration, "metacpan release query failed"
|
268
277
|
end
|
@@ -279,14 +288,14 @@ class FPM::Package::CPAN < FPM::Package
|
|
279
288
|
|
280
289
|
#url = "http://www.cpan.org/CPAN/authors/id/#{author[0,1]}/#{author[0,2]}/#{author}/#{tarball}"
|
281
290
|
url = "#{url_base}/authors/id/#{author[0,1]}/#{author[0,2]}/#{author}/#{archive}"
|
282
|
-
|
291
|
+
logger.debug("Fetching perl module", :url => url)
|
283
292
|
|
284
293
|
begin
|
285
294
|
response = httpfetch(url)
|
286
295
|
rescue Net::HTTPServerException => e
|
287
|
-
|
296
|
+
#logger.error("Download failed", :error => response.status_line,
|
288
297
|
#:url => url)
|
289
|
-
|
298
|
+
logger.error("Download failed", :error => e, :url => url)
|
290
299
|
raise FPM::InvalidPackageConfiguration, "metacpan query failed"
|
291
300
|
end
|
292
301
|
|
@@ -298,14 +307,14 @@ class FPM::Package::CPAN < FPM::Package
|
|
298
307
|
end # def download
|
299
308
|
|
300
309
|
def search(package)
|
301
|
-
|
310
|
+
logger.info("Asking metacpan about a module", :module => package)
|
302
311
|
metacpan_url = "http://api.metacpan.org/v0/module/" + package
|
303
312
|
begin
|
304
313
|
response = httpfetch(metacpan_url)
|
305
314
|
rescue Net::HTTPServerException => e
|
306
|
-
|
315
|
+
#logger.error("metacpan query failed.", :error => response.status_line,
|
307
316
|
#:module => package, :url => metacpan_url)
|
308
|
-
|
317
|
+
logger.error("metacpan query failed.", :error => e.message,
|
309
318
|
:module => package, :url => metacpan_url)
|
310
319
|
raise FPM::InvalidPackageConfiguration, "metacpan query failed"
|
311
320
|
end
|