Tokens like "b4", "beta1", "p195", &c. are now treated as atoms rather
than being broken down even further. Additionally, we enable support for
padding in the middle of versions strings, so we can successfully
compare something like "2.1-p195" with "2.1.0-p194" by inferring that
"2.1" is really "2.1.0".
This fixes the comparison "9.9.3-P1" > "9.9.3" which previously has not
been handled correctly.
The initializer for Formula does a number of validations, but it does
them in a weird order, and some attributes aren't validated under
certain circumstances. This became even more of a mess when most
software package attributes were moved into the SoftwareSpec class.
This commit removes the last vestiges of storing these attributes as
instance variables. In particular, it eliminates #set_instance_variable
and #validate_variable, replacing them with methods that operate on
SoftwareSpec instances, and generate more useful errors.
Doing these validations unconditionally in the initializer means we bail
out much earlier if the formula has invalid attributes or is not fully
specified, and no longer need to validate in #prefix.
Technically we don't need to validate in #brew either, but we continue
to do so anyway as a safety measure, and because we cannot enforce calls
to super in subclasses.
The heuristic used by the default version comparison is simple. A
version string is scanned for strings of digits, split into an array of
these strings, and then an element-wise comparison is done.
This fails when presented with something like
Version.new("1.0.0beta7") <=> Version.new("1.0.0")
because the first three digits match, and the fourth digit of the
receiver (7) is greater than the assumed fourth digit of the parameter
(0).
Fix this by defining an element-wise comparator on a new VersionElement
class. This allows us to correctly compare "alpha", "beta", and "rc"
style version strings, and keeps the logic out of the main version
comparison.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This will allow us to do comparisons like
if MacOS.version >= :lion
and hopefully deprecate the MacOS.<name>? family of methods, which are
counterinitutive.
the ghc formula had an explicit version because we had trouble parsing
the version from the 64-bit URL. It is working now, so add a test to
ensure it isn't broken in the future.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Commit 2695821e98 ("Only use the bottle if its version is up-to-date")
essentially broke the ImageMagick bottle, because the version parsing
logic returns "1" as the bottle version.
Fixing this requires only a slight modification to the bottle URL regex;
includes a test.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
SourceForge links can end with /download which appears to be part of
what is used to drive mirror selection. Modifying the version detection
extension of pathname.rb to detect this case for both sourceforge.net
and sf.net download selections.
This is sufficient for version detection but may not be sufficient for
other uses of /download links. I have not found any problems with links
that use /download, though.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Sphinx currently has a download name 'http://sphinxsearch.com/downloads/sphinx-1.10-beta.tar.gz', which homebrew currently can't correctly identify - with a small change to the regex for 'foobar-4.5.0-beta1' (make that trailing number optional) - it works like a charm.
Signed-off-by: David Höppner <0xffea@gmail.com>