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
data/lib/fpm/package/deb.rb
CHANGED
@@ -186,7 +186,7 @@ class FPM::Package::Deb < FPM::Package
|
|
186
186
|
# characters.
|
187
187
|
def name
|
188
188
|
if @name =~ /[A-Z]/
|
189
|
-
|
189
|
+
logger.warn("Debian tools (dpkg/apt) don't do well with packages " \
|
190
190
|
"that use capital letters in the name. In some cases it will " \
|
191
191
|
"automatically downcase them, in others it will not. It is confusing." \
|
192
192
|
" Best to not use any capital letters at all. I have downcased the " \
|
@@ -196,11 +196,17 @@ class FPM::Package::Deb < FPM::Package
|
|
196
196
|
end
|
197
197
|
|
198
198
|
if @name.include?("_")
|
199
|
-
|
199
|
+
logger.info("Debian package names cannot include underscores; " \
|
200
200
|
"automatically converting to dashes", :name => @name)
|
201
201
|
@name = @name.gsub(/[_]/, "-")
|
202
202
|
end
|
203
203
|
|
204
|
+
if @name.include?(" ")
|
205
|
+
logger.info("Debian package names cannot include spaces; " \
|
206
|
+
"automatically converting to dashes", :name => @name)
|
207
|
+
@name = @name.gsub(/[ ]/, "-")
|
208
|
+
end
|
209
|
+
|
204
210
|
return @name
|
205
211
|
end # def name
|
206
212
|
|
@@ -226,7 +232,7 @@ class FPM::Package::Deb < FPM::Package
|
|
226
232
|
if value.nil?
|
227
233
|
return nil
|
228
234
|
else
|
229
|
-
|
235
|
+
logger.info("deb field", field => value.split(": ", 2).last)
|
230
236
|
return value.split(": ",2).last
|
231
237
|
end
|
232
238
|
end
|
@@ -330,21 +336,36 @@ class FPM::Package::Deb < FPM::Package
|
|
330
336
|
|
331
337
|
# If we are given --deb-shlibs but no --after-install script, we
|
332
338
|
# should implicitly create a before/after scripts that run ldconfig
|
333
|
-
if attributes[:deb_shlibs]
|
339
|
+
if attributes[:deb_shlibs]
|
334
340
|
if !script?(:after_install)
|
335
|
-
|
341
|
+
logger.info("You gave --deb-shlibs but no --after-install, so " \
|
336
342
|
"I am adding an after-install script that runs " \
|
337
343
|
"ldconfig to update the system library cache")
|
338
344
|
scripts[:after_install] = template("deb/ldconfig.sh.erb").result(binding)
|
339
345
|
end
|
340
346
|
if !script?(:after_remove)
|
341
|
-
|
347
|
+
logger.info("You gave --deb-shlibs but no --after-remove, so " \
|
342
348
|
"I am adding an after-remove script that runs " \
|
343
349
|
"ldconfig to update the system library cache")
|
344
350
|
scripts[:after_remove] = template("deb/ldconfig.sh.erb").result(binding)
|
345
351
|
end
|
346
352
|
end
|
347
353
|
|
354
|
+
if script?(:before_upgrade) or script?(:after_upgrade)
|
355
|
+
if script?(:before_install) or script?(:before_upgrade)
|
356
|
+
scripts[:before_install] = template("deb/preinst_upgrade.sh.erb").result(binding)
|
357
|
+
end
|
358
|
+
if script?(:before_remove)
|
359
|
+
scripts[:before_remove] = template("deb/prerm_upgrade.sh.erb").result(binding)
|
360
|
+
end
|
361
|
+
if script?(:after_install) or script?(:after_upgrade)
|
362
|
+
scripts[:after_install] = template("deb/postinst_upgrade.sh.erb").result(binding)
|
363
|
+
end
|
364
|
+
if script?(:after_remove)
|
365
|
+
scripts[:after_remove] = template("deb/postrm_upgrade.sh.erb").result(binding)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
348
369
|
write_control_tarball
|
349
370
|
|
350
371
|
# Tar up the staging_path into data.tar.{compression type}
|
@@ -363,13 +384,24 @@ class FPM::Package::Deb < FPM::Package
|
|
363
384
|
"Unknown compression type '#{self.attributes[:deb_compression]}'"
|
364
385
|
end
|
365
386
|
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
387
|
+
# Write the changelog file
|
388
|
+
dest_changelog = File.join(staging_path, "usr/share/doc/#{name}/changelog.Debian.gz")
|
389
|
+
FileUtils.mkdir_p(File.dirname(dest_changelog))
|
390
|
+
File.new(dest_changelog, "wb", 0644).tap do |changelog|
|
391
|
+
Zlib::GzipWriter.new(changelog, Zlib::BEST_COMPRESSION).tap do |changelog_gz|
|
392
|
+
if attributes[:deb_changelog]
|
393
|
+
logger.info("Writing user-specified changelog", :source => attributes[:deb_changelog])
|
394
|
+
File.new(attributes[:deb_changelog]).tap do |fd|
|
395
|
+
chunk = nil
|
396
|
+
# Ruby 1.8.7 doesn't have IO#copy_stream
|
397
|
+
changelog_gz.write(chunk) while chunk = fd.read(16384)
|
398
|
+
end.close
|
399
|
+
else
|
400
|
+
logger.info("Creating boilerplate changelog file")
|
401
|
+
changelog_gz.write(template("deb/changelog.erb").result(binding))
|
402
|
+
end
|
403
|
+
end.close
|
404
|
+
end # No need to close, GzipWriter#close will close it.
|
373
405
|
|
374
406
|
attributes.fetch(:deb_init_list, []).each do |init|
|
375
407
|
name = File.basename(init, ".init")
|
@@ -445,13 +477,13 @@ class FPM::Package::Deb < FPM::Package
|
|
445
477
|
name_re = /^[^ \(]+/
|
446
478
|
name = dep[name_re]
|
447
479
|
if name =~ /[A-Z]/
|
448
|
-
|
480
|
+
logger.warn("Downcasing dependency '#{name}' because deb packages " \
|
449
481
|
" don't work so good with uppercase names")
|
450
482
|
dep = dep.gsub(name_re) { |n| n.downcase }
|
451
483
|
end
|
452
484
|
|
453
485
|
if dep.include?("_")
|
454
|
-
|
486
|
+
logger.warn("Replacing dependency underscores with dashes in '#{dep}' because " \
|
455
487
|
"debs don't like underscores")
|
456
488
|
dep = dep.gsub("_", "-")
|
457
489
|
end
|
@@ -493,13 +525,13 @@ class FPM::Package::Deb < FPM::Package
|
|
493
525
|
name_re = /^[^ \(]+/
|
494
526
|
name = provides[name_re]
|
495
527
|
if name =~ /[A-Z]/
|
496
|
-
|
528
|
+
logger.warn("Downcasing provides '#{name}' because deb packages " \
|
497
529
|
" don't work so good with uppercase names")
|
498
530
|
provides = provides.gsub(name_re) { |n| n.downcase }
|
499
531
|
end
|
500
532
|
|
501
533
|
if provides.include?("_")
|
502
|
-
|
534
|
+
logger.warn("Replacing 'provides' underscores with dashes in '#{provides}' because " \
|
503
535
|
"debs don't like underscores")
|
504
536
|
provides = provides.gsub("_", "-")
|
505
537
|
end
|
@@ -530,25 +562,25 @@ class FPM::Package::Deb < FPM::Package
|
|
530
562
|
|
531
563
|
# Make the control.tar.gz
|
532
564
|
with(build_path("control.tar.gz")) do |controltar|
|
533
|
-
|
565
|
+
logger.info("Creating", :path => controltar, :from => control_path)
|
534
566
|
|
535
567
|
args = [ tar_cmd, "-C", control_path, "-zcf", controltar,
|
536
568
|
"--owner=0", "--group=0", "--numeric-owner", "." ]
|
537
569
|
safesystem(*args)
|
538
570
|
end
|
539
571
|
|
540
|
-
|
572
|
+
logger.debug("Removing no longer needed control dir", :path => control_path)
|
541
573
|
ensure
|
542
574
|
FileUtils.rm_r(control_path)
|
543
575
|
end # def write_control_tarball
|
544
576
|
|
545
577
|
def write_control
|
546
578
|
# warn user if epoch is set
|
547
|
-
|
579
|
+
logger.warn("epoch in Version is set", :epoch => self.epoch) if self.epoch
|
548
580
|
|
549
581
|
# calculate installed-size if necessary:
|
550
582
|
if attributes[:deb_installed_size].nil?
|
551
|
-
|
583
|
+
logger.info("No deb_installed_size set, calculating now.")
|
552
584
|
total = 0
|
553
585
|
Find.find(staging_path) do |path|
|
554
586
|
stat = File.lstat(path)
|
@@ -564,14 +596,14 @@ class FPM::Package::Deb < FPM::Package
|
|
564
596
|
# Write the control file
|
565
597
|
with(control_path("control")) do |control|
|
566
598
|
if attributes[:deb_custom_control]
|
567
|
-
|
599
|
+
logger.debug("Using '#{attributes[:deb_custom_control]}' template for the control file")
|
568
600
|
control_data = File.read(attributes[:deb_custom_control])
|
569
601
|
else
|
570
|
-
|
602
|
+
logger.debug("Using 'deb.erb' template for the control file")
|
571
603
|
control_data = template("deb.erb").result(binding)
|
572
604
|
end
|
573
605
|
|
574
|
-
|
606
|
+
logger.debug("Writing control file", :path => control)
|
575
607
|
File.write(control, control_data)
|
576
608
|
File.chmod(0644, control)
|
577
609
|
edit_file(control) if attributes[:edit?]
|
@@ -587,7 +619,7 @@ class FPM::Package::Deb < FPM::Package
|
|
587
619
|
next unless script?(scriptname)
|
588
620
|
|
589
621
|
with(control_path(filename)) do |controlscript|
|
590
|
-
|
622
|
+
logger.debug("Writing control script", :source => filename, :target => controlscript)
|
591
623
|
File.write(controlscript, script(scriptname))
|
592
624
|
# deb maintainer scripts are required to be executable
|
593
625
|
File.chmod(0755, controlscript)
|
@@ -630,7 +662,7 @@ class FPM::Package::Deb < FPM::Package
|
|
630
662
|
|
631
663
|
def write_shlibs
|
632
664
|
return unless attributes[:deb_shlibs]
|
633
|
-
|
665
|
+
logger.info("Adding shlibs", :content => attributes[:deb_shlibs])
|
634
666
|
File.open(control_path("shlibs"), "w") do |out|
|
635
667
|
out.write(attributes[:deb_shlibs])
|
636
668
|
end
|
data/lib/fpm/package/dir.rb
CHANGED
@@ -64,7 +64,7 @@ class FPM::Package::Dir < FPM::Package
|
|
64
64
|
|
65
65
|
destination = File.join(staging_path, destination)
|
66
66
|
|
67
|
-
|
67
|
+
logger["method"] = "input"
|
68
68
|
begin
|
69
69
|
::Dir.chdir(chdir) do
|
70
70
|
begin
|
@@ -87,7 +87,7 @@ class FPM::Package::Dir < FPM::Package
|
|
87
87
|
self.vendor = [ENV["USER"], Socket.gethostname].join("@")
|
88
88
|
ensure
|
89
89
|
# Clean up any logger context we added.
|
90
|
-
|
90
|
+
logger.remove("method")
|
91
91
|
end # def input
|
92
92
|
|
93
93
|
# Output this package to the given directory.
|
@@ -96,11 +96,11 @@ class FPM::Package::Dir < FPM::Package
|
|
96
96
|
|
97
97
|
output_path = File.expand_path(output_path)
|
98
98
|
::Dir.chdir(staging_path) do
|
99
|
-
|
99
|
+
logger["method"] = "output"
|
100
100
|
clone(".", output_path)
|
101
101
|
end
|
102
102
|
ensure
|
103
|
-
|
103
|
+
logger.remove("method")
|
104
104
|
end # def output
|
105
105
|
|
106
106
|
private
|
@@ -116,7 +116,7 @@ class FPM::Package::Dir < FPM::Package
|
|
116
116
|
# The above will copy, recursively, /tmp/hello/world into
|
117
117
|
# /tmp/example/hello/world
|
118
118
|
def clone(source, destination)
|
119
|
-
|
119
|
+
logger.debug("Cloning path", :source => source, :destination => destination)
|
120
120
|
# Edge case check; abort if the temporary directory is the source.
|
121
121
|
# If the temporary dir is the same path as the source, it causes
|
122
122
|
# fpm to recursively (and forever) copy the staging directory by
|
@@ -132,12 +132,15 @@ class FPM::Package::Dir < FPM::Package
|
|
132
132
|
end
|
133
133
|
|
134
134
|
# For single file copies, permit file destinations
|
135
|
-
|
135
|
+
fileinfo = File.lstat(source)
|
136
|
+
if fileinfo.file? && !File.directory?(destination)
|
136
137
|
if destination[-1,1] == "/"
|
137
138
|
copy(source, File.join(destination, source))
|
138
139
|
else
|
139
140
|
copy(source, destination)
|
140
141
|
end
|
142
|
+
elsif fileinfo.symlink?
|
143
|
+
copy(source, destination)
|
141
144
|
else
|
142
145
|
# Copy all files from 'path' into staging_path
|
143
146
|
Find.find(source) do |path|
|
@@ -152,7 +155,7 @@ class FPM::Package::Dir < FPM::Package
|
|
152
155
|
# Files will be hardlinked if possible, but copied otherwise.
|
153
156
|
# Symlinks should be copied as symlinks.
|
154
157
|
def copy(source, destination)
|
155
|
-
|
158
|
+
logger.debug("Copying path", :source => source, :destination => destination)
|
156
159
|
directory = File.dirname(destination)
|
157
160
|
if !File.directory?(directory)
|
158
161
|
FileUtils.mkdir_p(directory)
|
@@ -161,7 +164,7 @@ class FPM::Package::Dir < FPM::Package
|
|
161
164
|
if File.directory?(source)
|
162
165
|
if !File.symlink?(source)
|
163
166
|
# Create a directory if this path is a directory
|
164
|
-
|
167
|
+
logger.debug("Creating", :directory => destination)
|
165
168
|
if !File.directory?(destination)
|
166
169
|
FileUtils.mkdir(destination)
|
167
170
|
end
|
@@ -169,22 +172,22 @@ class FPM::Package::Dir < FPM::Package
|
|
169
172
|
# Linking symlinked directories causes a hardlink to be created, which
|
170
173
|
# results in the source directory being wiped out during cleanup,
|
171
174
|
# so copy the symlink.
|
172
|
-
|
175
|
+
logger.debug("Copying symlinked directory", :source => source,
|
173
176
|
:destination => destination)
|
174
177
|
FileUtils.copy_entry(source, destination)
|
175
178
|
end
|
176
179
|
else
|
177
180
|
# Otherwise try copying the file.
|
178
181
|
begin
|
179
|
-
|
182
|
+
logger.debug("Linking", :source => source, :destination => destination)
|
180
183
|
File.link(source, destination)
|
181
184
|
rescue Errno::ENOENT, Errno::EXDEV, Errno::EPERM
|
182
185
|
# Hardlink attempt failed, copy it instead
|
183
|
-
|
186
|
+
logger.debug("Copying", :source => source, :destination => destination)
|
184
187
|
copy_entry(source, destination)
|
185
188
|
rescue Errno::EEXIST
|
186
189
|
sane_path = destination.gsub(staging_path, "")
|
187
|
-
|
190
|
+
logger.error("Cannot copy file, the destination path is probably a directory and I attempted to write a file.", :path => sane_path, :staging => staging_path)
|
188
191
|
end
|
189
192
|
end
|
190
193
|
|
data/lib/fpm/package/gem.rb
CHANGED
@@ -62,13 +62,13 @@ class FPM::Package::Gem < FPM::Package
|
|
62
62
|
path = download(gem, gem_version)
|
63
63
|
end
|
64
64
|
|
65
|
-
|
65
|
+
logger.info("Using gem file", :path => path)
|
66
66
|
return path
|
67
67
|
end # def download_if_necessary
|
68
68
|
|
69
69
|
def download(gem_name, gem_version=nil)
|
70
70
|
|
71
|
-
|
71
|
+
logger.info("Trying to download", :gem => gem_name, :version => gem_version)
|
72
72
|
|
73
73
|
gem_fetch = [ "#{attributes[:gem_gem]}", "fetch", gem_name]
|
74
74
|
|
@@ -79,7 +79,7 @@ class FPM::Package::Gem < FPM::Package
|
|
79
79
|
FileUtils.mkdir(download_dir) unless File.directory?(download_dir)
|
80
80
|
|
81
81
|
::Dir.chdir(download_dir) do |dir|
|
82
|
-
|
82
|
+
logger.debug("Downloading in directory #{dir}")
|
83
83
|
safesystem(*gem_fetch)
|
84
84
|
end
|
85
85
|
|
@@ -203,7 +203,7 @@ class FPM::Package::Gem < FPM::Package
|
|
203
203
|
# No such file or directory - /tmp/something/weird/bin
|
204
204
|
tmp = bin_path
|
205
205
|
while ::Dir.entries(tmp).size == 2 || tmp == "/" # just [ "..", "." ] is an empty directory
|
206
|
-
|
206
|
+
logger.info("Deleting empty bin_path", :path => tmp)
|
207
207
|
::Dir.rmdir(tmp)
|
208
208
|
tmp = File.dirname(tmp)
|
209
209
|
end
|
data/lib/fpm/package/npm.rb
CHANGED
@@ -24,25 +24,17 @@ class FPM::Package::NPM < FPM::Package
|
|
24
24
|
"global" => "true"
|
25
25
|
}
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
if attributes.include?(:prefix) && !attributes[:prefix].nil?
|
32
|
-
settings["prefix"] = staging_path(attributes[:prefix])
|
33
|
-
else
|
34
|
-
@logger.info("Setting default npm install prefix",
|
35
|
-
:prefix => "/usr/local")
|
36
|
-
settings["prefix"] = staging_path("/usr/local")
|
37
|
-
end
|
27
|
+
settings["registry"] = attributes[:npm_registry] if attributes[:npm_registry_given?]
|
28
|
+
set_default_prefix unless attributes[:prefix_given?]
|
38
29
|
|
30
|
+
settings["prefix"] = staging_path(attributes[:prefix])
|
39
31
|
FileUtils.mkdir_p(settings["prefix"])
|
40
32
|
|
41
33
|
npm_flags = []
|
42
34
|
settings.each do |key, value|
|
43
35
|
# npm lets you specify settings in a .npmrc but the same key=value settings
|
44
36
|
# are valid as '--key value' command arguments to npm. Woo!
|
45
|
-
|
37
|
+
logger.debug("Configuring npm", key => value)
|
46
38
|
npm_flags += [ "--#{key}", value ]
|
47
39
|
end
|
48
40
|
|
@@ -105,5 +97,21 @@ class FPM::Package::NPM < FPM::Package
|
|
105
97
|
# but I will wait for that feature request.
|
106
98
|
end
|
107
99
|
|
100
|
+
def set_default_prefix
|
101
|
+
attributes[:prefix] = self.class.default_prefix
|
102
|
+
attributes[:prefix_given?] = true
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.default_prefix
|
106
|
+
npm_prefix = safesystemout("npm", "prefix", "-g").chomp
|
107
|
+
if npm_prefix.count("\n") > 0
|
108
|
+
raise FPM::InvalidPackageConfiguration, "`npm prefix -g` returned unexpected output."
|
109
|
+
elsif !File.directory?(npm_prefix)
|
110
|
+
raise FPM::InvalidPackageConfiguration, "`npm prefix -g` returned a non-existent directory"
|
111
|
+
end
|
112
|
+
logger.info("Setting default npm install prefix", :prefix => npm_prefix)
|
113
|
+
npm_prefix
|
114
|
+
end
|
115
|
+
|
108
116
|
public(:input)
|
109
117
|
end # class FPM::Package::NPM
|
data/lib/fpm/package/osxpkg.rb
CHANGED
@@ -82,7 +82,7 @@ class FPM::Package::OSXpkg < FPM::Package
|
|
82
82
|
next unless script?(scriptname)
|
83
83
|
|
84
84
|
with(scripts_path(filename)) do |pkgscript|
|
85
|
-
|
85
|
+
logger.info("Writing pkg script", :source => filename, :target => pkgscript)
|
86
86
|
File.write(pkgscript, script(scriptname))
|
87
87
|
# scripts are required to be executable
|
88
88
|
File.chmod(0755, pkgscript)
|
@@ -110,7 +110,7 @@ class FPM::Package::OSXpkg < FPM::Package
|
|
110
110
|
self.version = pkginfo_elem.attribute("version").value
|
111
111
|
# set name to the last dot element of the identifier
|
112
112
|
self.name = identifier.split(".").last
|
113
|
-
|
113
|
+
logger.info("inferring name #{self.name} from pkg-id #{identifier}")
|
114
114
|
end
|
115
115
|
end # def extract_info
|
116
116
|
|
data/lib/fpm/package/pear.rb
CHANGED
@@ -41,73 +41,73 @@ class FPM::Package::PEAR < FPM::Package
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# Create a temporary config file
|
44
|
-
|
44
|
+
logger.debug("Creating pear config file")
|
45
45
|
config = File.expand_path(build_path("pear.config"))
|
46
46
|
installroot = attributes[:prefix] || "/usr/share"
|
47
47
|
safesystem("pear", "config-create", staging_path(installroot), config)
|
48
48
|
|
49
49
|
if attributes[:pear_php_dir]
|
50
|
-
|
50
|
+
logger.info("Setting php_dir", :php_dir => attributes[:pear_php_dir])
|
51
51
|
safesystem("pear", "-c", config, "config-set", "php_dir", "#{staging_path(installroot)}/#{attributes[:pear_php_dir]}")
|
52
52
|
end
|
53
53
|
|
54
54
|
if attributes[:pear_data_dir]
|
55
|
-
|
55
|
+
logger.info("Setting data_dir", :data_dir => attributes[:pear_data_dir])
|
56
56
|
safesystem("pear", "-c", config, "config-set", "data_dir", "#{staging_path(installroot)}/#{attributes[:pear_data_dir]}")
|
57
57
|
end
|
58
58
|
|
59
59
|
bin_dir = attributes[:pear_bin_dir] || "usr/bin"
|
60
|
-
|
60
|
+
logger.info("Setting bin_dir", :bin_dir => bin_dir)
|
61
61
|
safesystem("pear", "-c", config, "config-set", "bin_dir", bin_dir)
|
62
62
|
|
63
63
|
php_bin = attributes[:pear_php_bin] || "/usr/bin/php"
|
64
|
-
|
64
|
+
logger.info("Setting php_bin", :php_bin => php_bin)
|
65
65
|
safesystem("pear", "-c", config, "config-set", "php_bin", php_bin)
|
66
66
|
|
67
67
|
# do channel-discover if required
|
68
68
|
if !attributes[:pear_channel].nil?
|
69
|
-
|
69
|
+
logger.info("Custom channel specified", :channel => attributes[:pear_channel])
|
70
70
|
channel_list = safesystemout("pear", "-c", config, "list-channels")
|
71
71
|
if channel_list !~ /#{Regexp.quote(attributes[:pear_channel])}/
|
72
|
-
|
72
|
+
logger.info("Discovering new channel", :channel => attributes[:pear_channel])
|
73
73
|
safesystem("pear", "-c", config, "channel-discover", attributes[:pear_channel])
|
74
74
|
end
|
75
75
|
input_package = "#{attributes[:pear_channel]}/#{input_package}"
|
76
|
-
|
76
|
+
logger.info("Prefixing package name with channel", :package => input_package)
|
77
77
|
end
|
78
78
|
|
79
79
|
# do channel-update if requested
|
80
80
|
if attributes[:pear_channel_update?]
|
81
81
|
channel = attributes[:pear_channel] || "pear"
|
82
|
-
|
82
|
+
logger.info("Updating the channel", :channel => channel)
|
83
83
|
safesystem("pear", "-c", config, "channel-update", channel)
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
logger.info("Installing pear package", :package => input_package,
|
87
87
|
:directory => staging_path)
|
88
88
|
::Dir.chdir(staging_path) do
|
89
89
|
safesystem("pear", "-c", config, "install", "-n", "-f", input_package)
|
90
90
|
end
|
91
91
|
|
92
92
|
pear_cmd = "pear -c #{config} remote-info #{input_package}"
|
93
|
-
|
93
|
+
logger.info("Fetching package information", :package => input_package, :command => pear_cmd)
|
94
94
|
name = %x{#{pear_cmd} | sed -ne '/^Package\s*/s/^Package\s*//p'}.chomp
|
95
95
|
self.name = "#{attributes[:pear_package_name_prefix]}-#{name}"
|
96
96
|
self.version = %x{#{pear_cmd} | sed -ne '/^Installed\s*/s/^Installed\s*//p'}.chomp
|
97
97
|
self.description = %x{#{pear_cmd} | sed -ne '/^Summary\s*/s/^Summary\s*//p'}.chomp
|
98
|
-
|
98
|
+
logger.debug("Package info", :name => self.name, :version => self.version,
|
99
99
|
:description => self.description)
|
100
100
|
|
101
101
|
# Remove the stuff we don't want
|
102
102
|
delete_these = [".depdb", ".depdblock", ".filemap", ".lock", ".channel", "cache", "temp", "download", ".channels", ".registry"]
|
103
103
|
Find.find(staging_path) do |path|
|
104
104
|
if File.file?(path)
|
105
|
-
|
105
|
+
logger.info("replacing staging_path in file", :replace_in => path, :staging_path => staging_path)
|
106
106
|
begin
|
107
107
|
content = File.read(path).gsub(/#{Regexp.escape(staging_path)}/, "")
|
108
108
|
File.write(path, content)
|
109
109
|
rescue ArgumentError => e
|
110
|
-
|
110
|
+
logger.warn("error replacing staging_path in file", :replace_in => path, :error => e)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
FileUtils.rm_r(path) if delete_these.include?(File.basename(path))
|