186 Commits

Author SHA1 Message Date
Xu Cheng
144453368e test-bot pathname: use Utils.popen_read instead of backticks
Closes Homebrew/homebrew#37418.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-03-06 22:19:24 +08:00
Xu Cheng
328fa80f41 pathname: skip directory in env_script_all_files
Closes Homebrew/homebrew#37180.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-02-25 20:17:22 +08:00
Jack Nagel
120bd43f87 Buffer 16K at a time 2015-01-05 10:45:05 -05:00
Jack Nagel
1a69ceaf7e Recognize rpm file magic 2014-12-09 01:22:55 -05:00
Jack Nagel
0578f1ff5a Pull initialization code out of begin block 2014-11-09 18:17:10 -06:00
Jack Nagel
2d16f8c202 Make Pathname#atomic_write truly atomic
As we know, files cannot be moved across filesystems atomically. In that
case, FileUtils.mv will make a copy. But if we create the temp file in
the same directory as the target, we can avoid this and use File.rename
directly.

Additionally, the rename should be the absolute last step, so that the
original file is preserved if altering ownership and permissions fails.
2014-09-20 17:11:16 -05:00
Mike McQuaid
58cb4444da etc.install: handle recursive directory installs.
We need to install the helper module not just on `etc` but also on all
subdirectories of it too. Also, handle the case where we install
a subdirectory with etc.install.

Closes Homebrew/homebrew#26145.
2014-08-26 08:30:47 +01:00
Adam Vandenberg
fbee511eba Pathname.binread 2014-07-29 07:25:27 -07:00
Adam Vandenberg
5af3d319d6 backport binwrite from Ruby 2.1+ 2014-07-27 16:21:35 -07:00
Adam Vandenberg
8e96ce0aa5 Rename write_binary to binwrite 2014-07-27 15:30:46 -07:00
Adam Vandenberg
10e5fea01d add Pathname.write_binary 2014-07-27 11:14:51 -07:00
Adam Vandenberg
12fe7e2771 nudge formatting
Needed for Emacs' ruby highlighting to work past this point in the file.
2014-07-13 12:04:45 -07:00
Jack Nagel
c259866517 Raise Errno::ENOENT instead of RuntimeError from Pathname#install 2014-07-10 22:00:43 -05:00
Jack Nagel
284389a6bd Make comment in Pathname#install more accurate 2014-07-10 15:39:55 -05:00
Jack Nagel
cf4080a9e0 Remove a RUBY_VERSION check, add a FIXME comment 2014-07-05 16:01:09 -05:00
Jack Nagel
c73baa39cb Add explicit mkpath to Pathname#write_env_script 2014-06-17 21:51:45 -05:00
Jack Nagel
5cbc5437f5 Add explicit mkpath to Pathname#write_jar_script 2014-06-17 21:51:45 -05:00
Jack Nagel
d96f15e324 Add explicit mkpath to Pathname#write_exec_script 2014-06-17 21:51:45 -05:00
Jack Nagel
b2c42fc63c Make signature of Pathname#write compatible with Ruby 2.1+ 2014-06-17 12:14:51 -05:00
Jack Nagel
96195295a3 Deprecate Pathname#cp and Pathname#chmod_R
As far as I can tell these methods have only ever been used in the test
suite.

Since Formula includes FileUtils, it is generally simpler (and in the
case of cp, more readable) to use the FileUtils methods directly.

Closes Homebrew/homebrew#30081.
2014-06-12 09:00:58 -05:00
Jack Nagel
faaa622820 Deprecate Pathname#/ with non-string/non-pathname arguments
Ruby 2.2 will define Pathname#/ as a simple alias of Pathname#+.
In practice, this means that it will raise a TypeError unless the
argument responds to to_path or to_str.

Currently we blindly convert the argument to a string using to_s, so
deprecate this in the interest of matching the upstream behavior. In the
future we can replace this with

  alias_method :/, :+ unless method_defined?(:/)

Closes Homebrew/homebrew#30079.
2014-06-12 09:00:51 -05:00
Jack Nagel
93d8e71641 Use Digest#file if it's available 2014-06-11 12:05:19 -05:00
Jack Nagel
e3f082c294 Stop joining symbols to pathnames
Ruby 2.2's native Pathname#/ accepts only string-like objects.
2014-06-09 14:57:21 -05:00
Jack Nagel
fb3f95923b Just access the ivar directly 2014-06-08 20:04:16 -05:00
Jack Nagel
d27dc1d02f Work around encoding issue in Pathname#inspect on Ruby 2.0
Pathname#inspect on Ruby 2.0 throws away the encoding of the object's
underlying string and returns a string tagged as ASCII-8BIT.

If you simply write

  puts Pathname.new("some string with non-ascii bytes").inspect

no error will be raised, because the implementation of Pathname#inspect
does not call into Object#inspect.

However, if you wrap that pathname object in an array first, then

  puts [Pathname.new("some string with non-ascii bytes")].inspect

will raise Encoding::CompatibilityError: "inspected result must be ASCII
only or use the same encoding with default external".

Raising an error in this codepath is new in Ruby 2.0, and this specific
bug is fixed in Ruby 2.1. I've opened a bug upstream:
  https://bugs.ruby-lang.org/issues/9915

Fixes Homebrew/homebrew#29947.
2014-06-08 20:00:52 -05:00
Jack Nagel
6d0f0cb195 metafiles: simplify #copy? further 2014-06-07 23:40:28 -05:00
Jack Nagel
07257f2f48 Simplify Pathname#install_metafiles 2014-06-07 21:15:56 -05:00
Jack Nagel
fcacb25cd5 Eliminate FORMULA_META_FILES constant 2014-06-07 21:15:56 -05:00
Jack Nagel
a023f10310 Use Pathname.glob when we want pathname objects 2014-05-31 23:53:51 -05:00
Jack Nagel
68da1e7765 Add a method_defined? guard for Pathname#/
This was added to the stdlib in 391fc2eeec.
2014-05-05 15:30:28 -05:00
Alexey Muranov
911206eae6 Use #+ instead of #join to define Pathname#/
See also https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/45826/diff/ext/pathname/lib/pathname.rb

Closes Homebrew/homebrew#28972.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2014-05-05 15:27:34 -05:00
Jack Nagel
61dd796f25 Suppress a warning on Ruby 2.1+ 2014-05-03 15:03:22 -05:00
Jack Nagel
bdee729a41 Yield absolute paths from find_formula 2014-04-25 18:58:16 -05:00
Jack Nagel
d3ab439b7c Rework make_relative_symlink error handling and move it into keg 2014-04-21 12:43:06 -05:00
Jack Nagel
581e1b2c7e Use quiet_system to silence some useless warnings 2014-04-14 21:32:50 -05:00
Jack Nagel
4738974a78 Remove overzealous exceptions 2014-04-14 21:31:03 -05:00
Jack Nagel
260a351663 Recognize and extract xar files 2014-04-06 12:35:54 -05:00
Mike McQuaid
edef6508bd pathname: use ln_sf in install_symlink.
Closes Homebrew/homebrew#28136.
2014-04-06 18:12:02 +01:00
Jack Nagel
cb5da28b5c Handle untarred bzip2 files
Fixes Homebrew/homebrew#28187.
2014-04-06 11:33:50 -05:00
Jack Nagel
607605dd8f Use a case statement in Pathname#compression_type 2014-04-06 11:18:25 -05:00
Jack Nagel
2110aa2379 0644 is not executable 2014-04-04 00:07:28 -05:00
Jack Nagel
4e918666d7 Return early so we can reduce nesting of conditionals 2014-03-27 18:42:19 -05:00
Jack Nagel
ed0be26c77 Fix overly defensive handling of src parameter in make_relative_symlink
This method is for internal use only. It is unsuitable for use in
formulae, which should use install_symlink to create relative symlinks.
Thus callers are required to pass a Pathname, not a string, and we can
remove this conditional.

Further, if src is not absolute, then src.relative_path_from(dirname)
will fail. All callers currently pass absolute pathnames. Therefore we
don't need to call expand_path when printing it.
2014-03-27 17:54:07 -05:00
Jack Nagel
e9ee640024 Don't let broken symlinks halt linking 2014-03-27 09:35:10 -05:00
Jack Nagel
f6b5c83482 Fix conflicting symlink advice
Closes Homebrew/homebrew#27899.
2014-03-27 09:35:10 -05:00
Jack Nagel
e5fbc9c92e Fall back to Process.gid if we aren't a member of the file's group 2014-03-26 13:45:46 -05:00
Jack Nagel
03fca453c4 Put tempfile into binmode before writing 2014-03-26 13:45:46 -05:00
Jack Nagel
26fe9df9b2 Preserve permissions when using Pathname#atomic_write 2014-03-22 10:58:28 -05:00
Jack Nagel
7f33a84ce6 Expand paths before making relative symlink
Fixes Homebrew/homebrew#27702.
Fixes Homebrew/homebrew#27704.
2014-03-19 15:57:39 -05:00
Jack Nagel
aa7ed10968 Make relative symlinks in Pathname#install_symlink
Closes Homebrew/homebrew#27672.
2014-03-18 19:03:25 -05:00