317 Commits

Author SHA1 Message Date
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
Jack Nagel
ca0eff67fa Inline static exception text to remove a rescue 2014-02-18 13:27:35 -05:00
Jack Nagel
8d5f0d8bb3 Delete unused method 2014-02-12 14:28:26 -05:00
Mike McQuaid
cdbc7c9e53 Pathname: add methods to write env scripts. 2014-01-04 13:19:20 +00:00
Jack Nagel
68f6936070 Move Pathname#dynamically_linked_libraries to mach module 2013-12-14 09:35:58 -06:00
Adam Vandenberg
e523262dfa monkey around for emacs' code highlighter
The abv method has a construct that causes emacs to not highlight
the rest of pathname.rb, so move abv lower in the file.

Sorry.
2013-12-12 08:22:39 -08:00
Adam Vandenberg
7516cee374 +x wrapper scripts, so they work during post-install 2013-12-12 08:21:22 -08:00
Adam Vandenberg
268feffae4 support .lz archives
Closes Homebrew/homebrew#24775.
2013-11-29 15:18:49 -08:00
Jack Nagel
dd06522815 Recognized .pax.gz extension 2013-11-14 16:20:25 -06:00
Jack Nagel
31e0bf61fa Pathname: removed unused method alias 2013-10-14 22:05:30 -05:00
Mike McQuaid
19852bc47c Pathname: add cp_path_sub method.
This method allows copying a file to a new location by performing a
substitution on the pathname.
2013-10-10 16:46:47 +01:00
Mike McQuaid
caa2f87728 InstallRenamed: don't overwrite etc files; rename.
If an etc file exists on installation instead of overwriting it (or
requiring all the manual checks in formula) simply copy it with the
extension `.default` appended.
2013-10-10 16:46:47 +01:00
Jack Nagel
fe31e8ddb4 Use MacOS.locate to find otool
Fixes Homebrew/homebrew#23111.
2013-10-07 21:32:18 -05:00
Misty De Meo
74ab023422 Only track C++ stdlibs for C++ code
After a formula is built, scan all mach-o files for dynamic links
to see if any of them point to a C++ stdlib (libc++ or libstdc++).
If one of them is linked, record that information in the formula's tab.

This replaces the old behaviour where all files were assumed to be C++
code, and stdlibs were always tracked regardless of whether they were
actually linked against.

This also modifies the way that tabs are written - now tabs are written
with the stdlib field null, and values are only written if an stdlib
is detected.
2013-10-06 19:26:06 -07:00
Jack Nagel
50d2f632d9 Allow partial installation of resources 2013-09-17 21:29:54 -05:00
Jack Nagel
84cbfb164e Open files in binary mode where appropriate 2013-09-16 12:50:31 -05:00
Adam Vandenberg
d4cf3ef212 Implement Resources
Closes Homebrew/homebrew#20212.
2013-09-11 22:05:26 -07:00
Adam Vandenberg
7c1671667f pathname: remove unused return values
Return value was used only by one test, rewrote test to know expected value.
2013-08-13 20:41:08 -07:00
Jack Nagel
22365f2f6d Improve checksum perf by providing an output buffer 2013-08-13 15:40:48 -05:00
Jack Nagel
966e82663f Make usage of ObserverPathnameExtension more obvious
Remove use of globals.

Closes Homebrew/homebrew#21795.
2013-08-10 19:02:00 -05:00