-
Notifications
You must be signed in to change notification settings - Fork 2
Linux Version Changes and Features
This is a highly experimental Linux port. This document attempts to document some of the changes between the Mac version and this fork.
Obviously, not all of the Formulae will work straight away on linux. I've added a couple of Formula convenience syntax rules to try and simplify this.
Rather than eliminating all the Formulae and building up, I've gone for adding an extra parameter. Example:
class SomeTool < Formula
url 'http://www.example.com/nowt-2.5.tar.gz'
homepage 'http://www.example.com'
platforms :mac, :linux
def install
...
end
end
Without this line:
- On Mac, it works exactly the same as it normally does
- On Linux, will warn you and require an extra flag
--forcelinuxto be passed tobrewbefore installing the Formula. This means that even if a formula hasn't been changed to explicitly mention support, you can still try it (though it might just break)
With any platforms specified, only those platforms will be allowed, i.e.
platforms :mac
will prevent installations on linux (without changing the formulae) and
platforms :linux
will prevent installations on mac (without changing the formulae). This should allow for linux-only packages, if anyone should so desire (though if this became anything big, a better way to split the platforms should have to be thought of).
There are also now a couple of convenience functions for testing platform (You originally had to call the internal platform rules). The functions: mac and linux will return the correct value for testing platform. For example, to add a mac-only dependence on the xz library:
depends_on 'xz' => :build if mac
## Searching for executables with which
By default, Homebrew just calls the Mac system version of which to locate the executables in the system $PATH. This doesn't work in general - only the mac version seems to have a flag (-s) which explicitly silences the output, and one of the linux systems I was testing wrote the error output (if an entry could not be found) straight to the terminal - so even piping to /dev/null didn't silence it. This led to a very noisy installation process.
I have thus written a simple which function in the utils.rb library. This just splits the$PATH, and looks for the argument in each of those folders. As an extended example, this is how you would add a dependence on the xz library only if it didn't already exist:
depends_on 'xz' => :build unless which('xz')
And if you wanted to maintain an explicit mac dependence, but optional dependence on linux:
depends on 'xz' => :build if mac or not which('xz')
though it might be clearer just to be explicit with an if block, in this case.