Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pear enhancements #358

Merged
merged 4 commits into from Feb 8, 2013

Conversation

@oker1
Copy link
Contributor

oker1 commented Feb 8, 2013

I've ran into some issues creating packages for the default debian php setup, so I've added options for these customizations.

Some junk was left in some pear packages, I've added those directories to the list to be deleted from staging.

Then there's the case of task:replace in pear installer, which is used to replace tokens in php files with pear config values. This is used to insert the pear directory in the executable files, I've added a workaround for this issue too. (See PHPUnit for example)

oker1 added 4 commits Feb 8, 2013
packages with executables will put their bins in bin_dir, which is
prefix/pear by default. php_bin can be used if the php interpreter is
in a different location on the target system. php_dir can be used for
overriding the directory where php files are put (useful on debian).
some packages put the pear_path value in their executable (PHPUnit for example)
which is the staging path, so it has to be replaced to the installed path, otherwise
the executable won't work
Find.find(staging_path) do |path|
if File.file?(path) && File.executable?(path)
@logger.info("replacing pear_dir in binary", :binary => path)
content = File.read(path).gsub(/#{staging_path}/, "")

This comment has been minimized.

Copy link
@jordansissel

jordansissel Feb 8, 2013

Owner

.gsub(staging_path, "") is sufficient, otherwise staging_path could be interpreted as a regexp, not a string.

if File.file?(path) && File.executable?(path)
@logger.info("replacing pear_dir in binary", :binary => path)
content = File.read(path).gsub(/#{staging_path}/, "")
File.open(path, "w") { |file| file.puts content }

This comment has been minimized.

Copy link
@jordansissel

jordansissel Feb 8, 2013

Owner

You can use File.write(path, content) instead if you wish.

@jordansissel

This comment has been minimized.

Copy link
Owner

jordansissel commented Feb 8, 2013

Other than the minor comments made, this looks good! :)

jordansissel added a commit that referenced this pull request Feb 8, 2013
Pear enhancements
@jordansissel jordansissel merged commit 40dc020 into jordansissel:master Feb 8, 2013
1 check passed
1 check passed
default The Travis build passed
Details
@jordansissel

This comment has been minimized.

Copy link
Owner

jordansissel commented Feb 8, 2013

Will fix the stuff I commented on post-merge. Thank you again for helping keep fpm awesome!

@jordansissel

This comment has been minimized.

Copy link
Owner

jordansissel commented Feb 8, 2013

diff --git a/lib/fpm/package/pear.rb b/lib/fpm/package/pear.rb
index 7eec251..732dcd3 100644
--- a/lib/fpm/package/pear.rb
+++ b/lib/fpm/package/pear.rb
@@ -91,8 +91,9 @@ class FPM::Package::PEAR < FPM::Package
     Find.find(staging_path) do |path|
       if File.file?(path) && File.executable?(path)
         @logger.info("replacing pear_dir in binary", :binary => path)
-        content = File.read(path).gsub(/#{staging_path}/, "")
-        File.open(path, "w") { |file| file.puts content }
+        staging_path_re = Regexp.new("^" + Regexp.escape(staging_path))
+        content = File.read(path).gsub(staging_path_re, "")
+        File.write(path, content)
       end
       FileUtils.rm_r(path) if delete_these.include?(File.basename(path))
@oker1

This comment has been minimized.

Copy link
Contributor Author

oker1 commented Feb 9, 2013

Thanks a lot!

prof-milki pushed a commit to prof-milki/xpm that referenced this pull request Dec 18, 2014
prof-milki pushed a commit to prof-milki/xpm that referenced this pull request Dec 27, 2014
jordansissel added a commit that referenced this pull request Apr 24, 2015
jordansissel added a commit that referenced this pull request Jun 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.