210 Commits

Author SHA1 Message Date
Mike McQuaid
0bca7ad9c3 pathname: don't try to calculate symlink size.
Closes https://github.com/Homebrew/homebrew/issues/47532
Closes https://github.com/Homebrew/homebrew-dupes/issues/542
2015-12-30 19:46:23 +00:00
Xu Cheng
24224dc896 pathname: improve compute_disk_usage
* Avoid parallel assignment.
* Use Pathname#size instead of File#size
* Use Pathname#directory? instead of File#directory?
* Use basename to check `.DS_Store`. Original regex has poor
  performance, and may match with incorrect file.
2015-12-30 16:27:15 +08:00
Mike McQuaid
482481d24c pathname: fix use of find on Ruby 1.8. 2015-12-30 08:23:57 +00:00
Rakesh
e4f2a1e0ef pathname: store file count and disk usage.
especially for directory instances of `Pathname` class and all
instances of `Keg` class.
2015-12-30 08:11:23 +00:00
Xu Cheng
d108bf0a55 move more deprecated methods to compat folder 2015-11-17 18:52:00 +08:00
Xu Cheng
646f94adfe move mach.rb to os/mac/mach.rb 2015-10-18 22:57:42 +08:00
Xu Cheng
235c5b6bfa ObserverPathnameExtension: only puts first 100 operations
Fixes https://github.com/Homebrew/homebrew/issues/44320#issuecomment-143951973

Closes Homebrew/homebrew#44440.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-10-08 16:12:01 +08:00
Mike McQuaid
2c959a7d58 More API documentation.
And remove the documented stuff from the `example-formula.rb`.

Closes Homebrew/homebrew#43241.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-29 15:43:16 +01:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Xu Cheng
fd7f3b9496 Pathname#abv: handle the case du returns empty string
This can happen when read permission is denied.

Fixes Homebrew/homebrew#41925.

Closes Homebrew/homebrew#42011.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-07-22 20:35:01 +08:00
Xu Cheng
f2d0a88292 remove Pathname#find_formula
Closes Homebrew/homebrew#40486.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-06-11 15:28:30 +08:00
Xu Cheng
31ca2831f3 Revert "Pathname#version: support bottle version"
This reverts commit 02fba8ce25f1e34c981cb30197e2b4711f88b266.
2015-06-07 23:51:15 +08:00
Xu Cheng
ef7eb0750c Pathname#version: support bottle version
Closes Homebrew/homebrew#40365.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-06-04 20:05:43 +08:00
Misty De Meo
8fe0b56810 Add support for extracting LHA archives 2015-04-26 11:11:56 -07:00
Dominyk Tiller
2fa87369b3 pathname: prune unnecessary whitespace
Closes Homebrew/homebrew#38413.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-04-07 18:32:29 +01:00
Shaun Jackman
6ca42964cb pathname: remove hyphen from BOTTLE_EXTNAME_RX
A hyphen is not a valid character in a Ruby symbol, and the bottle
tag should be a valid Ruby symbol for its use in the bottle stanza.

Closes Homebrew/homebrew#38235.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-03-31 18:53:26 +01:00
Shaun Jackman
1ad0de8660 pathname: Add [-0-9] to BOTTLE_EXTNAME_RX
Change [a-z_]+(32)? to [-a-z0-9_]+
The Linuxbrew bottle tag is x86_64-linux.

Closes Homebrew/homebrew#32687.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-03-31 15:07:46 +01:00
Jack Nagel
96f7a8015f Pass around only pathname objects 2015-03-26 22:22:45 -04:00
Jack Nagel
3721e0be6f Always yield a path from install_p extension 2015-03-26 22:22:45 -04:00
Jack Nagel
380b8ce46d Combine assignments 2015-03-25 20:26:04 -04:00
Jack Nagel
1351f67e91 Make install_p and install_symlink_p private 2015-03-24 21:08:12 -04:00
Jack Nagel
ab3d622da2 Always pass basename to install_symlink_p 2015-03-24 21:06:19 -04:00
Jack Nagel
6f0efd6f3d Always pass basename to install_p
Currently, when called with one argument, dst is set to self, i.e. the
directory into which the source file should be moved.

When called with a second argument (for renames), dst is the full path,
including the basename, to the moved file.

Instead, let's always pass the full path, which means we can remove the
branching logic around computing dst.
2015-03-24 21:03:45 -04:00
Jack Nagel
86006ba36b Go through regular logic when installing a file 2015-03-23 21:01:50 -04:00
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