diff --git a/.yardopts b/.yardopts index c5f8c7a986..77aa469b60 100644 --- a/.yardopts +++ b/.yardopts @@ -7,7 +7,7 @@ --exclude Library/Homebrew/compat/ Library/Homebrew/**/*.rb - +share/doc/homebrew/*.html Library/Homebrew/*.md -Library/Homebrew/manpages/*.md share/doc/homebrew/*.md *.md diff --git a/Library/Contributions/example-formula.rb b/Library/Contributions/example-formula.rb deleted file mode 100644 index 61c810a10e..0000000000 --- a/Library/Contributions/example-formula.rb +++ /dev/null @@ -1,488 +0,0 @@ -# This is a non-functional example formula to showcase all features and -# therefore, it's overly complex and dupes stuff just to comment on it. -# You may want to use `brew create` to start your own new formula! -# Documentation: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md - -## Naming -- Every Homebrew formula is a class of the type `Formula`. -# Ruby classes have to start Upper case and dashes are not allowed. -# So we transform: `example-formula.rb` into `ExampleFormula`. Further, -# Homebrew does enforce that the name of the file and the class correspond. -# Check with `brew search` that the name is free. -class ExampleFormula < Formula - desc "Example formula" # shows up in `brew info`, and can be searched with `brew search --desc`. - homepage "https://www.example.com" # used by `brew home example-formula`. - revision 1 # This is used when there's no new version but it needs recompiling for another reason. - # 0 is default & unwritten. - - # The URL of the archive. Prefer https (security and proxy issues): - url "https://packed.sources.and.we.prefer.https.example.com/archive-1.2.3.tar.bz2" - mirror "https://in.case.the.host.is.down.example.com" # `mirror` is optional. - mirror "https://in.case.the.mirror.is.down.example.com" # Mirrors are limitless, but don't go too wild. - - # Optionally specify the download strategy `:using => ...` - # `:git`, `:hg`, `:svn`, `:bzr`, `:cvs`, - # `:curl` (normal file download. Will also extract.) - # `:nounzip` (without extracting) - # `:post` (download via an HTTP POST) - # `S3DownloadStrategy` (download from S3 using signed request) - url "https://some.dont.provide.archives.example.com", :using => :git, :tag => "1.2.3" - - # version is seldom needed, because it's usually autodetected from the URL/tag. - version "1.2-final" - - # For integrity and security, we verify the hash (`openssl dgst -sha256 `) - # You should use SHA256. Never use md5. - # Either generate the sha locally or leave it empty & `brew install` will tell you the expected. - sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7" - - # Stable-only dependencies should be nested inside a `stable` block rather than - # using a conditional. It is preferrable to also pull the URL and checksum into - # the block if one is necessary. - stable do - url "https://example.com/foo-1.0.tar.gz" - sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7" - - depends_on "libxml2" - depends_on "libffi" - end - - # Optionally, specify a repository to be used. Brew then generates a - # `--HEAD` option. Remember to also test it. - # The download strategies (:using =>) are the same as for `url`. - # "master" is the default branch and doesn't need stating with a :branch conditional - head "https://we.prefer.https.over.git.example.com/.git" - head "https://example.com/.git", :branch => "name_of_branch", :revision => "abc123" - head "https://hg.is.awesome.but.git.has.won.example.com/", :using => :hg # If autodetect fails. - - head do - url "https://example.com/repo.git" - - depends_on "autoconf" => :build - depends_on "automake" => :build - depends_on "libtool" => :build - end - - # The optional devel block is only executed if the user passes `--devel`. - # Use this to specify a not-yet-released version of a software. - devel do - url "https://example.com/archive-2.0-beta.tar.gz" - sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7" - - depends_on "cairo" - depends_on "pixman" - end - - ## Options - - # Options can be used as arguments to `brew install`. - # To switch features on/off: `"with-something"` or `"with-otherthing"`. - # To use another software: `"with-other-software"` or `"without-foo"` - # Note, that for dependencies that are `:optional` or `:recommended`, options - # are generated automatically. - # Build a universal (On newer Intel Macs this means a combined 32-bit and - # 64-bit binary/library). LATER: better explain what this means for PPC. - option :universal - option "with-spam", "The description goes here without a dot at the end" - option "with-qt", "Text here overwrites the autogenerated one from `depends_on 'qt'`" - - ## Bottles - - # Bottles are pre-built and added by the Homebrew maintainers for you. - # If you maintain your own repository, you can add your own bottle links. - # https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Bottles.md - # You can ignore this block entirely if submitting to Homebrew/Homebrew, It'll be - # handled for you by the Brew Test Bot. - bottle do - root_url "http://mikemcquaid.com" # Optional root to calculate bottle URLs - prefix "/opt/homebrew" # Optional HOMEBREW_PREFIX in which the bottles were built. - cellar "/opt/homebrew/Cellar" # Optional HOMEBREW_CELLAR in which the bottles were built. - revision 1 # Making the old bottle outdated without bumping the version of the formula. - sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7" => :yosemite - sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7" => :mavericks - sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7" => :mountain_lion - end - - def pour_bottle? - # Only needed if this formula has to check if using the pre-built - # bottle is fine. - true - end - - ## keg_only - - # Software that will not be sym-linked into the `brew --prefix` will only - # live in its Cellar. Other formulae can depend on it and then brew will - # add the necessary includes and libs (etc.) during the brewing of that - # other formula. But generally, keg_only formulae are not in your PATH - # and not seen by compilers if you build your own software outside of - # Homebrew. This way, we don't shadow software provided by OS X. - keg_only :provided_by_osx - keg_only "because I want it so" - - ## Dependencies - - # The dependencies for this formula. Use strings for the names of other - # formulae. Homebrew provides some :special dependencies for stuff that - # requires certain extra handling (often changing some ENV vars or - # deciding if to use the system provided version or not.) - - # `:build` means this dep is only needed during build. - depends_on "cmake" => :build - # Explictly name formulae in other taps. Non-optional tap dependencies won't - # be accepted in core. - depends_on "homebrew/dupes/tcl-tk" => :optional - # `:recommended` dependencies are built by default. But a `--without-...` - # option is generated to opt-out. - depends_on "readline" => :recommended - # `:optional` dependencies are NOT built by default but a `--with-...` - # options is generated. - depends_on "glib" => :optional - # If you need to specify that another formula has to be built with/out - # certain options (note, no `--` needed before the option): - depends_on "zeromq" => "with-pgm" - depends_on "qt" => ["with-qtdbus", "developer"] # Multiple options. - # Optional and enforce that boost is built with `--with-c++11`. - depends_on "boost" => [:optional, "with-c++11"] - # If a dependency is only needed in certain cases: - depends_on "sqlite" if MacOS.version == :leopard - depends_on :xcode # If the formula really needs full Xcode. - depends_on :tex # Homebrew does not provide a Tex Distribution. - depends_on :fortran # Checks that `gfortran` is available or `FC` is set. - depends_on :mpi => :cc # Needs MPI with `cc` - depends_on :mpi => [:cc, :cxx, :optional] # Is optional. MPI with `cc` and `cxx`. - depends_on :macos => :lion # Needs at least Mac OS X "Lion" aka. 10.7. - depends_on :apr # If a formula requires the CLT-provided apr library to exist. - depends_on :arch => :intel # If this formula only builds on Intel architecture. - depends_on :arch => :x86_64 # If this formula only builds on Intel x86 64-bit. - depends_on :arch => :ppc # Only builds on PowerPC? - depends_on :ld64 # Sometimes ld fails on `MacOS.version < :leopard`. Then use this. - depends_on :x11 # X11/XQuartz components. Non-optional X11 deps should go in Homebrew/Homebrew-x11 - depends_on :osxfuse # Permits the use of the upstream signed binary or our source package. - depends_on :tuntap # Does the same thing as above. This is vital for Yosemite and above. - depends_on :mysql => :recommended - # It is possible to only depend on something if - # `build.with?` or `build.without? "another_formula"`: - depends_on :mysql # allows brewed or external mysql to be used - depends_on :postgresql if build.without? "sqlite" - depends_on :hg # Mercurial (external or brewed) is needed - - # If any Python >= 2.7 < 3.x is okay (either from OS X or brewed): - depends_on :python - # to depend on Python >= 2.7 but use system Python where possible - depends_on :python if MacOS.version <= :snow_leopard - # Python 3.x if the `--with-python3` is given to `brew install example` - depends_on :python3 => :optional - - # Modules/Packages from other languages, such as :chicken, :jruby, :lua, - # :node, :ocaml, :perl, :python, :rbx, :ruby, can be specified by - depends_on "some_module" => :lua - - ## Conflicts - - # If this formula conflicts with another one: - conflicts_with "imagemagick", :because => "because this is just a stupid example" - - ## Failing with a certain compiler? - - # If it is failing for certain compiler: - fails_with :llvm do # :llvm is really llvm-gcc - build 2334 - cause "Segmentation fault during linking." - end - - fails_with :clang do - build 600 - cause "multiple configure and compile errors" - end - - ## Resources - - # Additional downloads can be defined as resources and accessed in the - # install method. Resources can also be defined inside a stable, devel, or - # head block. This mechanism replaces ad-hoc "subformula" classes. - resource "additional_files" do - url "https://example.com/additional-stuff.tar.gz" - sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2" - end - - ## Patches - - # External patches can be declared using resource-style blocks. - patch do - url "https://example.com/example_patch.diff" - sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2" - end - - # A strip level of -p1 is assumed. It can be overridden using a symbol - # argument: - patch :p0 do - url "https://example.com/example_patch.diff" - sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2" - end - - # Patches can be declared in stable, devel, and head blocks. This form is - # preferred over using conditionals. - stable do - patch do - url "https://example.com/example_patch.diff" - sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2" - end - end - - # Embedded (__END__) patches are declared like so: - patch :DATA - patch :p0, :DATA - - # Patches can also be embedded by passing a string. This makes it possible - # to provide multiple embedded patches while making only some of them - # conditional. - patch :p0, "..." - - ## The install method. - - def install - # Now the sources (from `url`) are downloaded, hash-checked and - # Homebrew has changed into a temporary directory where the - # archive has been unpacked or the repository has been cloned. - - # Print a warning (do this rarely) - opoo "Dtrace features are experimental!" if build.with? "dtrace" - - # Sometimes we have to change a bit before we install. Mostly we - # prefer a patch but if you need the `prefix` of this formula in the - # patch you have to resort to `inreplace`, because in the patch - # you don't have access to any var defined by the formula. Only - # HOMEBREW_PREFIX is available in the embedded patch. - # inreplace supports regular expressions. - inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool" - - # To call out to the system, we use the `system` method and we prefer - # you give the args separately as in the line below, otherwise a subshell - # has to be opened first. - system "./bootstrap.sh", "--arg1", "--prefix=#{prefix}" - - # For Cmake, we have some necessary defaults in `std_cmake_args`: - system "cmake", ".", *std_cmake_args - - # If the arguments given to configure (or make or cmake) are depending - # on options defined above, we usually make a list first and then - # use the `args << if ` to append to: - args = ["--option1", "--option2"] - args << "--i-want-spam" if build.with? "spam" - args << "--qt-gui" if build.with? "qt" # "--with-qt" ==> build.with? "qt" - args << "--some-new-stuff" if build.head? # if head is used instead of url. - args << "--universal-binary" if build.universal? - - # If there are multiple conditional arguments use a block instead of lines. - if build.head? - args << "--i-want-pizza" - args << "--and-a-cold-beer" if build.with? "cold-beer" - end - - # If a formula presents a user with a choice, but the choice must be fulfilled: - if build.with? "example2" - args << "--with-example2" - else - args << "--with-example1" - end - - # The `build.with?` and `build.without?` are smart enough to do the - # right thing with respect to defaults defined via `:optional` and - # `:recommended` dependencies. - - # If you need to give the path to lib/include of another brewed formula - # please use the `opt_prefix` instead of the `prefix` of that other - # formula. The reasoning behind this is that `prefix` has the exact - # version number and if you update that other formula, things might - # break if they remember that exact path. In contrast to that, the - # `$(brew --prefix)/opt/formula` is the same path for all future - # versions of the formula! - args << "--with-readline=#{Formula["readline"].opt_prefix}" if build.with? "readline" - - # Most software still uses `configure` and `make`. - # Check with `./configure --help` what our options are. - system "./configure", "--disable-debug", "--disable-dependency-tracking", - "--disable-silent-rules", "--prefix=#{prefix}", - *args # our custom arg list (needs `*` to unpack) - - # If your formula's build system is not thread safe: - ENV.deparallelize - - # A general note: The commands here are executed line by line, so if - # you change some variable or call a method like ENV.deparallelize, it - # only affects the lines after that command. - - # Do something only for clang - if ENV.compiler == :clang - # modify CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS in one go: - ENV.append_to_cflags "-I ./missing/includes" - end - - # Overwriting any env var: - ENV["LDFLAGS"] = "--tag CC" - # Is the formula struggling to find the pkgconfig file? Point it to it. - # This is done automatically for `keg_only` formulae. - ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["glib"].opt_lib}/pkgconfig" - - # Need to install into the bin but the makefile doesn't mkdir -p prefix/bin? - bin.mkpath - # Need a custom directory? - (share/"concept").mkpath - # Installing something into another custom directory? - (share/"concept2").install "ducks.txt" - # No "make", "install" available? - bin.install "binary1" - include.install "example.h" - lib.install "example.dylib" - man1.install "example.1" - man3.install "example.3" - pkgshare.install "examples" - # Maybe you'd like to remove a broken or unnecessary element? - # Empty directories will be removed by Homebrew automatically post-install! - rm "bin/example" - rm_rf "share/pointless" - - # If there is a "make", "install" available, please use it! - system "make", "install" - - # We are in a temporary directory and don't have to care about cleanup. - - # Instead of `system "cp"` or something, call `install` on the Pathname - # objects as they are smarter with respect to correcting access rights. - # (`install` is a Homebrew mixin into Ruby's Pathname) - - # The pathnames defined in the formula - prefix # == HOMEBREW_PREFIX+"Cellar"+name+version - bin # == prefix+"bin" - doc # == share+"doc"+name - include # == prefix+"include" - info # == share+"info" - lib # == prefix+"lib" - libexec # == prefix+"libexec" - buildpath # The temporary directory where build occurs. - - man # share+"man" - man1 # man+"man1" - man2 # man+"man2" - man3 # man+"man3" - man4 # man+"man4" - man5 # man+"man5" - man6 # man+"man6" - man7 # man+"man7" - man8 # man+"man8" - sbin # prefix+"sbin" - share # prefix+"share" - pkgshare # prefix+"share"+name - frameworks # prefix+"Frameworks" - kext_prefix # prefix+"Library/Extensions" - # Configuration stuff that will survive formula updates - etc # HOMEBREW_PREFIX+"etc" - # Generally we don't want var stuff inside the keg - var # HOMEBREW_PREFIX+"var" - bash_completion # prefix+"etc/bash_completion.d" - zsh_completion # share+"zsh/site-functions" - # Further possibilities with the pathnames: - # http://www.ruby-doc.org/stdlib-1.8.7/libdoc/pathname/rdoc/Pathname.html - - # Copy `./example_code/simple/ones` to share/demos - (share/"demos").install "example_code/simple/ones" - # Copy `./example_code/simple/ones` to share/demos/examples - (share/"demos").install "example_code/simple/ones" => "examples" - - # Additional downloads can be defined as resources (see above). - # The stage method will create a temporary directory and yield - # to a block. - resource("additional_files").stage { bin.install "my/extra/tool" } - - # `name` and `version` are accessible too, if you need them. - end - - ## Caveats - - def caveats; <<-EOS.undent - Are optional. Something the user should know? - EOS - end - - def caveats - s = <<-EOS.undent - Print some important notice to the user when `brew info ` is - called or when brewing a formula. - This is optional. You can use all the vars like #{version} here. - EOS - s += "Some issue only on older systems" if MacOS.version < :mountain_lion - s - end - - ## Test (is required for new formula & makes us happy) - - test do - # `test do` will create, run in, and delete a temporary directory. - - # We are fine if the executable does not error out, so we know linking - # and building the software was ok. - system bin/"foobar", "--version" - - (testpath/"Test.file").write <<-EOS.undent - writing some test file, if you need to - EOS - # To capture the output of a command, we use backtics: - assert_equal "OK", ` test.file`.strip - - # Need complete control over stdin, stdout? - require "open3" - Open3.popen3("#{bin}/example", "argument") do |stdin, stdout, _| - stdin.write("some text") - stdin.close - assert_equal "result", stdout.read - end - - # The test will fail if it returns false, or if an exception is raised. - # Failed assertions and failed `system` commands will raise exceptions. - end - - ## Plist handling - - # Does your plist need to be loaded at startup? - plist_options :startup => true - # Or only when necessary or desired by the user? - plist_options :manual => "foo" - # Or perhaps you'd like to give the user a choice? Ooh fancy. - plist_options :startup => "true", :manual => "foo start" - - # Define this method to provide a plist. - # Looking for another example? Check out Apple's handy manpage => - # https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/plist.5.html - def plist; <<-EOS.undent - - - - - Label - #{plist_name} - ProgramArguments - - #{opt_bin}/example - --do-this - - RunAtLoad - - KeepAlive - - StandardErrorPath - /dev/null - StandardOutPath - /dev/null - - EOS - end -end - -__END__ -# Room for a patch after the `__END__` -# Read about how to get a patch in here: -# https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md -# In short, `brew install --interactive --git ` and make your edits. -# Then `git diff >> path/to/your/formula.rb` -# Note, that HOMEBREW_PREFIX will be replaced in the path before it is -# applied. A patch can consit of several hunks. diff --git a/Library/Homebrew/README.md b/Library/Homebrew/README.md index f154675e2d..00036f1319 100644 --- a/Library/Homebrew/README.md +++ b/Library/Homebrew/README.md @@ -1,4 +1,8 @@ -# Homebrew Public API -We're (finally) working on a documented public API for Homebrew. It's currently a work in progress; a bunch of public stuff is documented and a bunch of private stuff is undocumented. Sorry about that! +# Homebrew's Formula API +This is the (partially) documented public API for Homebrew. It's currently a work in progress. Sorry about that! -The main class you should look at is {Formula}. Assume everything else is private for now. +The main class you should look at is the {Formula} class (and classes linked from there). That's the class that's used to create Homebrew formulae (i.e. package descriptions). Assume anything else you stumble upon is private. + +You may also find the [Formula Cookbook](Formula-Cookbook.md) and [Ruby Style Guide](https://github.com/styleguide/ruby) helpful in creating formulae. + +Good luck! diff --git a/Library/Homebrew/build_options.rb b/Library/Homebrew/build_options.rb index 05f8507de1..2e8f741d4f 100644 --- a/Library/Homebrew/build_options.rb +++ b/Library/Homebrew/build_options.rb @@ -1,13 +1,28 @@ class BuildOptions + # @private def initialize(args, options) @args = args @options = options end + # True if a {Formula} is being built with a specific option + # (which isn't named `with-*` or `without-*`). + # @deprecated def include?(name) @args.include?("--#{name}") end + # True if a {Formula} is being built with a specific option. + #
args << "--i-want-spam" if build.with? "spam"
+  #
+  # args << "--qt-gui" if build.with? "qt" # "--with-qt" ==> build.with? "qt"
+  #
+  # # If a formula presents a user with a choice, but the choice must be fulfilled:
+  # if build.with? "example2"
+  #   args << "--with-example2"
+  # else
+  #   args << "--with-example1"
+  # end
def with?(val) name = val.respond_to?(:option_name) ? val.option_name : val @@ -20,47 +35,65 @@ class BuildOptions end end + # True if a {Formula} is being built without a specific option. + #
args << "--no-spam-plz" if build.without? "spam"
   def without?(name)
     !with? name
   end
 
+  # True if a {Formula} is being built as a bottle (i.e. binary package).
   def bottle?
     include? "build-bottle"
   end
 
+  # True if a {Formula} is being built with {Formula.head} instead of {Formula.stable}.
+  # 
args << "--some-new-stuff" if build.head?
+ #
# If there are multiple conditional arguments use a block instead of lines.
+  #  if build.head?
+  #    args << "--i-want-pizza"
+  #    args << "--and-a-cold-beer" if build.with? "cold-beer"
+  #  end
def head? include? "HEAD" end + # True if a {Formula} is being built with {Formula.devel} instead of {Formula.stable}. + #
args << "--some-beta" if build.devel?
def devel? include? "devel" end + # True if a {Formula} is being built with {Formula.stable} instead of {Formula.devel} or {Formula.head}. This is the default. + #
args << "--some-beta" if build.devel?
def stable? !(head? || devel?) end - # True if the user requested a universal build. + # True if a {Formula} is being built universally. + # e.g. on newer Intel Macs this means a combined x86_64/x86 binary/library. + #
args << "--universal-binary" if build.universal?
def universal? include?("universal") && option_defined?("universal") end - # True if the user requested to enable C++11 mode. + # True if a {Formula} is being built in C++11 mode. def cxx11? include?("c++11") && option_defined?("c++11") end - # Request a 32-bit only build. + # True if a {Formula} is being built in 32-bit/x86 mode. # This is needed for some use-cases though we prefer to build Universal # when a 32-bit version is needed. def build_32_bit? include?("32-bit") && option_defined?("32-bit") end + # @private def used_options @options & @args end + # @private def unused_options @options - @args end diff --git a/Library/Homebrew/cmd/create.rb b/Library/Homebrew/cmd/create.rb index 88b8c0df38..e83c9facd1 100644 --- a/Library/Homebrew/cmd/create.rb +++ b/Library/Homebrew/cmd/create.rb @@ -118,7 +118,7 @@ class FormulaCreator def template; <<-EOS.undent # Documentation: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md - # #{HOMEBREW_CONTRIB}/example-formula.rb + # http://www.rubydoc.info/github/Homebrew/homebrew/master/frames # PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! class #{Formulary.class_s(name)} < Formula diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb index 5c4abbe395..208c07d47e 100644 --- a/Library/Homebrew/cmd/man.rb +++ b/Library/Homebrew/cmd/man.rb @@ -3,6 +3,7 @@ require "formula" module Homebrew SOURCE_PATH=HOMEBREW_REPOSITORY/"Library/Homebrew/manpages" TARGET_PATH=HOMEBREW_REPOSITORY/"share/man/man1" + DOC_PATH=HOMEBREW_REPOSITORY/"share/doc/homebrew" LINKED_PATH=HOMEBREW_PREFIX/"share/man/man1" def man @@ -21,12 +22,15 @@ module Homebrew else Homebrew.install_gem_setup_path! "ronn" + puts "Writing HTML fragments to #{DOC_PATH}" puts "Writing manpages to #{TARGET_PATH}" target_file = nil Dir["#{SOURCE_PATH}/*.md"].each do |source_file| - target_file = TARGET_PATH/File.basename(source_file, ".md") - safe_system "ronn --roff --pipe --organization='Homebrew' --manual='brew' #{source_file} > #{target_file}" + target_html = DOC_PATH/"#{File.basename(source_file, ".md")}.html" + safe_system "ronn --fragment --pipe --organization='Homebrew' --manual='brew' #{source_file} > #{target_html}" + target_man = TARGET_PATH/File.basename(source_file, ".md") + safe_system "ronn --roff --pipe --organization='Homebrew' --manual='brew' #{source_file} > #{target_man}" end system "man", target_file if ARGV.flag? "--verbose" diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index 4ed8c7f00d..ab710a6d09 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -1,3 +1,4 @@ +# @private module CompilerConstants GNU_GCC_VERSIONS = %w[4.3 4.4 4.5 4.6 4.7 4.8 4.9 5] GNU_GCC_REGEXP = /^gcc-(4\.[3-9]|5)$/ diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index a85eff305e..7553540c9f 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -1,12 +1,20 @@ require "formula" require "compilers" +# Homebrew extends Ruby's `ENV` to make our code more readable. +# Implemented in {SharedEnvExtension} and either {Superenv} or +# {Stdenv} (depending on the build mode). +# @see Superenv +# @see Stdenv +# @see http://www.rubydoc.info/stdlib/Env Ruby's ENV API module SharedEnvExtension include CompilerConstants + # @private CC_FLAG_VARS = %w[CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS] + # @private FC_FLAG_VARS = %w[FCFLAGS FFLAGS] - + # @private SANITIZED_VARS = %w[ CDPATH GREP_OPTIONS CLICOLOR_FORCE CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH @@ -18,11 +26,13 @@ module SharedEnvExtension LIBRARY_PATH ] + # @private def setup_build_environment(formula = nil) @formula = formula reset end + # @private def reset SANITIZED_VARS.each { |k| delete(k) } end @@ -72,6 +82,10 @@ module SharedEnvExtension append key, path, File::PATH_SEPARATOR if File.directory? path end + # Prepends a directory to `PATH`. + # Is the formula struggling to find the pkgconfig file? Point it to it. + # This is done automatically for `keg_only` formulae. + #
ENV.prepend_path "PKG_CONFIG_PATH", "#{Formula["glib"].opt_lib}/pkgconfig"
def prepend_path(key, path) prepend key, path, File::PATH_SEPARATOR if File.directory? path end @@ -126,6 +140,13 @@ module SharedEnvExtension self["FCFLAGS"] end + # Outputs the current compiler. + # @return [Symbol] + #
# Do something only for clang
+  # if ENV.compiler == :clang
+  #   # modify CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS in one go:
+  #   ENV.append_to_cflags "-I ./missing/includes"
+  # end
def compiler @compiler ||= if (cc = ARGV.cc) warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP @@ -147,6 +168,7 @@ module SharedEnvExtension end end + # @private def determine_cc COMPILER_SYMBOL_MAP.invert.fetch(compiler, compiler) end @@ -159,13 +181,14 @@ module SharedEnvExtension end end - # Snow Leopard defines an NCURSES value the opposite of most distros + # Snow Leopard defines an NCURSES value the opposite of most distros. # See: https://bugs.python.org/issue6848 - # Currently only used by aalib in core + # Currently only used by aalib in core. def ncurses_define append "CPPFLAGS", "-DNCURSES_OPAQUE=0" end + # @private def userpaths! paths = ORIGINAL_PATHS.map { |p| p.realpath.to_s rescue nil } - %w[/usr/X11/bin /opt/X11/bin] self["PATH"] = paths.unshift(*self["PATH"].split(File::PATH_SEPARATOR)).uniq.join(File::PATH_SEPARATOR) @@ -212,12 +235,14 @@ module SharedEnvExtension end # ld64 is a newer linker provided for Xcode 2.5 + # @private def ld64 ld64 = Formulary.factory("ld64") self["LD"] = ld64.bin/"ld" append "LDFLAGS", "-B#{ld64.bin}/" end + # @private def gcc_version_formula(name) version = name[GNU_GCC_REGEXP, 1] gcc_version_name = "gcc#{version.delete(".")}" @@ -230,6 +255,7 @@ module SharedEnvExtension end end + # @private def warn_about_non_apple_gcc(name) begin gcc_formula = gcc_version_formula(name) diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index d05ccf1a38..fef9915402 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -2,9 +2,11 @@ require "hardware" require "os/mac" require "extend/ENV/shared" +# @deprecated module Stdenv include SharedEnvExtension + # @private SAFE_CFLAGS_FLAGS = "-w -pipe" DEFAULT_FLAGS = "-march=core2 -msse4" @@ -14,6 +16,7 @@ module Stdenv end end + # @private def setup_build_environment(formula = nil) super @@ -69,6 +72,7 @@ module Stdenv end end + # @private def determine_pkg_config_libdir paths = [] paths << "#{HOMEBREW_PREFIX}/lib/pkgconfig" @@ -106,11 +110,13 @@ module Stdenv end end + # @private def determine_cc s = super MacOS.locate(s) || Pathname.new(s) end + # @private def determine_cxx dir, base = determine_cc.split dir / base.to_s.sub("gcc", "g++").sub("clang", "clang++") @@ -295,6 +301,7 @@ module Stdenv end end + # @private def replace_in_cflags(before, after) CC_FLAG_VARS.each do |key| self[key] = self[key].sub(before, after) if key?(key) @@ -308,6 +315,7 @@ module Stdenv # Sets architecture-specific flags for every environment variable # given in the list `flags`. + # @private def set_cpu_flags(flags, default = DEFAULT_FLAGS, map = Hardware::CPU.optimization_flags) cflags =~ /(-Xarch_#{Hardware::CPU.arch_32_bit} )-march=/ xarch = $1.to_s @@ -319,6 +327,7 @@ module Stdenv append flags, map.fetch(effective_arch, default) end + # @private def effective_arch if ARGV.build_bottle? ARGV.bottle_arch || Hardware.oldest_cpu @@ -332,6 +341,7 @@ module Stdenv end end + # @private def set_cpu_cflags(default = DEFAULT_FLAGS, map = Hardware::CPU.optimization_flags) set_cpu_flags CC_FLAG_VARS, default, map end @@ -346,5 +356,6 @@ module Stdenv end # This method does nothing in stdenv since there's no arg refurbishment + # @private def refurbish_args; end end diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 95a8773cdd..5216b579cc 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -1,20 +1,23 @@ require "os/mac" require "extend/ENV/shared" -### Why `superenv`? -# 1) Only specify the environment we need (NO LDFLAGS for cmake) -# 2) Only apply compiler specific options when we are calling that compiler -# 3) Force all incpaths and libpaths into the cc instantiation (less bugs) -# 4) Cater toolchain usage to specific Xcode versions -# 5) Remove flags that we don't want or that will break builds -# 6) Simpler code -# 7) Simpler formula that *just work* -# 8) Build-system agnostic configuration of the tool-chain - +# ### Why `superenv`? +# +# 1. Only specify the environment we need (NO LDFLAGS for cmake) +# 2. Only apply compiler specific options when we are calling that compiler +# 3. Force all incpaths and libpaths into the cc instantiation (less bugs) +# 4. Cater toolchain usage to specific Xcode versions +# 5. Remove flags that we don't want or that will break builds +# 6. Simpler code +# 7. Simpler formula that *just work* +# 8. Build-system agnostic configuration of the tool-chain module Superenv include SharedEnvExtension - attr_accessor :keg_only_deps, :deps, :x11 + # @private + attr_accessor :keg_only_deps, :deps + + attr_accessor :x11 alias_method :x11?, :x11 def self.extended(base) @@ -22,6 +25,7 @@ module Superenv base.deps = [] end + # @private def self.bin return unless MacOS.has_apple_developer_tools? @@ -36,6 +40,7 @@ module Superenv delete("as_nl") end + # @private def setup_build_environment(formula = nil) super send(compiler) @@ -302,6 +307,7 @@ module Superenv append "HOMEBREW_CCCFG", "h", "" if compiler == :clang end + # @private def refurbish_args append "HOMEBREW_CCCFG", "O", "" end @@ -312,6 +318,7 @@ module Superenv end end + # @private def noop(*_args); end noops = [] diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb index 741fca57f3..a6321931ca 100644 --- a/Library/Homebrew/extend/fileutils.rb +++ b/Library/Homebrew/extend/fileutils.rb @@ -1,7 +1,8 @@ require "fileutils" require "tmpdir" -# We enhance FileUtils to make our Formula code more readable. +# Homebrew extends Ruby's `FileUtils` to make our code more readable. +# @see http://ruby-doc.org/stdlib-1.8.7/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API module FileUtils # Create a temporary directory then yield. When the block returns, # recursively delete the temporary directory. @@ -23,8 +24,10 @@ module FileUtils end module_function :mktemp - # A version of mkdir that also changes to that folder in a block. + # @private alias_method :old_mkdir, :mkdir + + # A version of mkdir that also changes to that folder in a block. def mkdir(name, &_block) old_mkdir(name) if block_given? @@ -42,6 +45,7 @@ module FileUtils # never backported into the 1.9.3 branch. Fixed in 2.0.0. # The monkey-patched method here is copied directly from upstream fix. if RUBY_VERSION < "2.0.0" + # @private class Entry_ alias_method :old_copy_metadata, :copy_metadata def copy_metadata(path) @@ -82,23 +86,27 @@ module FileUtils end end - private - - # Run scons using a Homebrew-installed version, instead of whatever - # is in the user's PATH + # Run `scons` using a Homebrew-installed version rather than whatever is in the `PATH`. def scons(*args) system Formulary.factory("scons").opt_bin/"scons", *args end + # Run the `rake` from the `ruby` Homebrew is using rather than whatever is in the `PATH`. def rake(*args) system RUBY_BIN/"rake", *args end - alias_method :old_ruby, :ruby if method_defined?(:ruby) + if method_defined?(:ruby) + # @private + alias_method :old_ruby, :ruby + end + + # Run the `ruby` Homebrew is using rather than whatever is in the `PATH`. def ruby(*args) system RUBY_PATH, *args end + # Run `xcodebuild` without Homebrew's compiler environment variables set. def xcodebuild(*args) removed = ENV.remove_cc_etc system "xcodebuild", *args diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index c71a636e97..ed831f2cbd 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -3,12 +3,15 @@ require "mach" require "resource" require "metafiles" -# we enhance pathname to make our code more readable +# Homebrew extends Ruby's `Pathname` to make our code more readable. +# @see http://ruby-doc.org/stdlib-1.8.7/libdoc/pathname/rdoc/Pathname.html Ruby's Pathname API class Pathname include MachO + # @private BOTTLE_EXTNAME_RX = /(\.[a-z0-9_]+\.bottle\.(\d+\.)?tar\.gz)$/ + # Moves a file from the original location to the {Pathname}'s. def install(*sources) sources.each do |src| case src @@ -77,8 +80,12 @@ class Pathname end private :install_symlink_p + if method_defined?(:write) + # @private + alias_method :old_write, :write + end + # we assume this pathname object is a file obviously - alias_method :old_write, :write if method_defined?(:write) def write(content, *open_args) raise "Will not overwrite #{self}" if exist? dirname.mkpath @@ -131,6 +138,7 @@ class Pathname end private :default_stat + # @private def cp(dst) opoo "Pathname#cp is deprecated, use FileUtils.cp" if file? @@ -141,6 +149,7 @@ class Pathname dst end + # @private def cp_path_sub(pattern, replacement) raise "#{self} does not exist" unless self.exist? @@ -157,8 +166,10 @@ class Pathname end end - # extended to support common double extensions + # @private alias_method :extname_old, :extname + + # extended to support common double extensions def extname(path = to_s) BOTTLE_EXTNAME_RX.match(path) return $1 if $1 @@ -175,6 +186,7 @@ class Pathname # I don't trust the children.length == 0 check particularly, not to mention # it is slow to enumerate the whole directory just to see if it is empty, # instead rely on good ol' libc and the filesystem + # @private def rmdir_if_possible rmdir true @@ -189,17 +201,20 @@ class Pathname false end + # @private def chmod_R(perms) opoo "Pathname#chmod_R is deprecated, use FileUtils.chmod_R" require "fileutils" FileUtils.chmod_R perms, to_s end + # @private def version require "version" Version.parse(self) end + # @private def compression_type case extname when ".jar", ".war" @@ -240,10 +255,12 @@ class Pathname end end + # @private def text_executable? /^#!\s*\S+/ === open("r") { |f| f.read(1024) } end + # @private def incremental_hash(klass) digest = klass.new if digest.respond_to?(:file) @@ -255,6 +272,7 @@ class Pathname digest.hexdigest end + # @private def sha1 require "digest/sha1" incremental_hash(Digest::SHA1) @@ -282,10 +300,12 @@ class Pathname children.select(&:directory?) end + # @private def resolved_path self.symlink? ? dirname+readlink : self end + # @private def resolved_path_exists? link = readlink rescue ArgumentError @@ -295,6 +315,7 @@ class Pathname (dirname+link).exist? end + # @private def make_relative_symlink(src) dirname.mkpath File.symlink(src.relative_path_from(dirname), self) @@ -308,6 +329,7 @@ class Pathname self + other.to_s end unless method_defined?(:/) + # @private def ensure_writable saved_perms = nil unless writable_real? @@ -319,10 +341,12 @@ class Pathname chmod saved_perms if saved_perms end + # @private def install_info quiet_system "/usr/bin/install-info", "--quiet", to_s, "#{dirname}/dir" end + # @private def uninstall_info quiet_system "/usr/bin/install-info", "--delete", "--quiet", to_s, "#{dirname}/dir" end @@ -389,6 +413,7 @@ class Pathname end end + # @private def abv out = "" n = Utils.popen_read("find", expand_path.to_s, "-type", "f", "!", "-name", ".DS_Store").split("\n").size @@ -403,7 +428,9 @@ class Pathname # the Regexp literals, which forces string interpolation to happen only # once instead of each time the method is called. This is fixed in 1.9+. if RUBY_VERSION <= "1.8.7" + # @private alias_method :old_chop_basename, :chop_basename + def chop_basename(path) base = File.basename(path) if /\A#{Pathname::SEPARATOR_PAT}?\z/o =~ base @@ -414,7 +441,9 @@ class Pathname end private :chop_basename + # @private alias_method :old_prepend_prefix, :prepend_prefix + def prepend_prefix(prefix, relpath) if relpath.empty? File.dirname(prefix) @@ -437,6 +466,7 @@ class Pathname end end +# @private module ObserverPathnameExtension class << self attr_accessor :n, :d diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 7ec035dd79..7a9bb0f69d 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -22,11 +22,38 @@ require "keg" # correspond. # Make sure you check with `brew search` that the name is free! # @abstract +# @see SharedEnvExtension +# @see FileUtils +# @see Pathname +# @see http://www.rubydoc.info/github/Homebrew/homebrew/file/share/doc/homebrew/Formula-Cookbook.md Formula Cookbook +# @see https://github.com/styleguide/ruby Ruby Style Guide +# +#
class Wget < Formula
+#   homepage "https://www.gnu.org/software/wget/"
+#   url "https://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz"
+#   sha256 "52126be8cf1bddd7536886e74c053ad7d0ed2aa89b4b630f76785bac21695fcd"
+#
+#   def install
+#     system "./configure", "--prefix=#{prefix}"
+#     system "make", "install"
+#   end
+# end
class Formula include FileUtils include Utils::Inreplace extend Enumerable + # @!method inreplace(paths, before = nil, after = nil) + # Actually implemented in {Utils::Inreplace.inreplace}. + # Sometimes we have to change a bit before we install. Mostly we + # prefer a patch but if you need the `prefix` of this formula in the + # patch you have to resort to `inreplace`, because in the patch + # you don't have access to any var defined by the formula. Only + # HOMEBREW_PREFIX is available in the embedded patch. + # inreplace supports regular expressions. + #
inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool"
+ # @see Utils::Inreplace.inreplace + # The name of this {Formula}. # e.g. `this-formula` attr_reader :name @@ -43,12 +70,15 @@ class Formula # The stable (and default) {SoftwareSpec} for this {Formula} # This contains all the attributes (e.g. URL, checksum) that apply to the # stable version of this formula. + # @private + attr_reader :stable # The development {SoftwareSpec} for this {Formula}. # Installed when using `brew install --devel` # `nil` if there is no development version. # @see #stable + # @private attr_reader :devel # The HEAD {SoftwareSpec} for this {Formula}. @@ -57,6 +87,7 @@ class Formula # commit in the version control system. # `nil` if there is no HEAD version. # @see #stable + # @private attr_reader :head # The currently active {SoftwareSpec}. @@ -67,6 +98,7 @@ class Formula # A symbol to indicate currently active {SoftwareSpec}. # It's either :stable, :devel or :head # @see #active_spec + # @private attr_reader :active_spec_sym # Used for creating new Homebrew versions of software without new upstream @@ -84,12 +116,14 @@ class Formula # When installing a bottle (binary package) from a local path this will be # set to the full path to the bottle tarball. If not, it will be `nil`. + # @private attr_accessor :local_bottle_path # The {BuildOptions} for this {Formula}. Lists the arguments passed and any # {#options} in the {Formula}. Note that these may differ at different times # during the installation of a {Formula}. This is annoying but the result of # state that we're trying to eliminate. + # @return [BuildOptions] attr_accessor :build # @private @@ -165,16 +199,19 @@ class Formula public # Is the currently active {SoftwareSpec} a {#stable} build? + # @private def stable? active_spec == stable end # Is the currently active {SoftwareSpec} a {#devel} build? + # @private def devel? active_spec == devel end # Is the currently active {SoftwareSpec} a {#head} build? + # @private def head? active_spec == head end @@ -221,6 +258,9 @@ class Formula end # A named Resource for the currently active {SoftwareSpec}. + # Additional downloads can be defined as {#resource}s. + # {Resource#stage} will create a temporary directory and yield to a block. + #
resource("additional_files").stage { bin.install "my/extra/tool" }
def resource(name) active_spec.resource(name) end @@ -246,40 +286,49 @@ class Formula end # The {Dependency}s for the currently active {SoftwareSpec}. + # @private def deps active_spec.deps end # The {Requirement}s for the currently active {SoftwareSpec}. + # @private def requirements active_spec.requirements end # The cached download for the currently active {SoftwareSpec}. + # @private def cached_download active_spec.cached_download end # Deletes the download for the currently active {SoftwareSpec}. + # @private def clear_cache active_spec.clear_cache end # The list of patches for the currently active {SoftwareSpec}. + # @private def patchlist active_spec.patches end # The options for the currently active {SoftwareSpec}. + # @private def options active_spec.options end # The deprecated options for the currently active {SoftwareSpec}. + # @private def deprecated_options active_spec.deprecated_options end + # The deprecated option flags for the currently active {SoftwareSpec}. + # @private def deprecated_flags active_spec.deprecated_flags end @@ -290,6 +339,7 @@ class Formula end # All the {.fails_with} for the currently active {SoftwareSpec}. + # @private def compiler_failures active_spec.compiler_failures end @@ -297,11 +347,13 @@ class Formula # If this {Formula} is installed. # This is actually just a check for if the {#installed_prefix} directory # exists and is not empty. + # @private def installed? (dir = installed_prefix).directory? && dir.children.length > 0 end # If at least one version of {Formula} is installed. + # @private def any_version_installed? require "tab" rack.directory? && rack.subdirs.any? { |keg| (keg/Tab::FILENAME).file? } @@ -316,6 +368,7 @@ class Formula # The latest prefix for this formula. Checks for {#head}, then {#devel} # and then {#stable}'s {#prefix} + # @private def installed_prefix if head && (head_prefix = prefix(PkgVersion.new(head.version, revision))).directory? head_prefix @@ -330,6 +383,7 @@ class Formula # The currently installed version for this formula. Will raise an exception # if the formula is not installed. + # @private def installed_version Keg.new(installed_prefix).version end @@ -342,6 +396,7 @@ class Formula # The parent of the prefix; the named directory in the cellar containing all # installed versions of this software + # @private def rack prefix.parent end @@ -349,6 +404,12 @@ class Formula # The directory where the formula's binaries should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. + # + # Need to install into the {.bin} but the makefile doesn't mkdir -p prefix/bin? + #
bin.mkpath
+ # + # No `make install` available? + #
bin.install "binary1"
def bin prefix+"bin" end @@ -363,6 +424,9 @@ class Formula # The directory where the formula's headers should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. + # + # No `make install` available? + #
include.install "example.h"
def include prefix+"include" end @@ -377,6 +441,9 @@ class Formula # The directory where the formula's libraries should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. + # + # No `make install` available? + #
lib.install "example.dylib"
def lib prefix+"lib" end @@ -402,6 +469,9 @@ class Formula # The directory where the formula's man1 pages should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. + # + # No `make install` available? + #
man1.install "example.1"
def man1 man+"man1" end @@ -416,6 +486,9 @@ class Formula # The directory where the formula's man3 pages should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. + # + # No `make install` available? + #
man3.install "man.3"
def man3 man+"man3" end @@ -466,6 +539,18 @@ class Formula # The directory where the formula's shared files should be installed. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. + # + # Need a custom directory? + #
(share/"concept").mkpath
+ # + # Installing something into another custom directory? + #
(share/"concept2").install "ducks.txt"
+ # + # Install `./example_code/simple/ones` to share/demos + #
(share/"demos").install "example_code/simple/ones"
+ # + # Install `./example_code/simple/ones` to share/demos/examples + #
(share/"demos").install "example_code/simple/ones" => "examples"
def share prefix+"share" end @@ -474,6 +559,9 @@ class Formula # with the name of the formula appended to avoid linking conflicts. # This is symlinked into `HOMEBREW_PREFIX` after installation or with # `brew link` for formulae that are not keg-only. + # + # No `make install` available? + #
pkgshare.install "examples"
def pkgshare prefix+"share"+name end @@ -537,20 +625,49 @@ class Formula # The directory used for as the prefix for {#etc} and {#var} files on # installation so, despite not being in `HOMEBREW_CELLAR`, they are installed # there after pouring a bottle. + # @private def bottle_prefix prefix+".bottle" end + # The directory where the formula's installation logs will be written. + # @private def logs HOMEBREW_LOGS+name end - # override this to provide a plist + # This method can be overridden to provide a plist. + # For more examples read Apple's handy manpage: + # https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/plist.5.html + #
def plist; <<-EOS.undent
+  #  
+  #  
+  #  
+  #  
+  #    Label
+  #      #{plist_name}
+  #    ProgramArguments
+  #    
+  #      #{opt_bin}/example
+  #      --do-this
+  #    
+  #    RunAtLoad
+  #    
+  #    KeepAlive
+  #    
+  #    StandardErrorPath
+  #    /dev/null
+  #    StandardOutPath
+  #    /dev/null
+  #  
+  #  EOS
+  #end
def plist nil end alias_method :startup_plist, :plist - # plist name, i.e. the name of the launchd service + + # The {.plist} name (the name of the launchd service). def plist_name "homebrew.mxcl."+name end @@ -559,10 +676,12 @@ class Formula prefix+(plist_name+".plist") end + # @private def plist_manual self.class.plist_manual end + # @private def plist_startup self.class.plist_startup end @@ -573,6 +692,7 @@ class Formula # # This is the prefered way to refer a formula in plists or from another # formula, as the path is stable even when the software is updated. + #
args << "--with-readline=#{Formula["readline"].opt_prefix}" if build.with? "readline"
def opt_prefix Pathname.new("#{HOMEBREW_PREFIX}/opt/#{name}") end @@ -619,6 +739,7 @@ class Formula # Can be overridden to run commands on both source and bottle installation. def post_install; end + # @private def post_install_defined? method(:post_install).owner == self.class end @@ -631,7 +752,23 @@ class Formula self.build = build end - # tell the user about any caveats regarding this package, return a string + # Tell the user about any caveats regarding this package. + # @return [String] + #
def caveats
+  #   <<-EOS.undent
+  #     Are optional. Something the user should know?
+  #   EOS
+  # end
+ # + #
def caveats
+  #   s = <<-EOS.undent
+  #     Print some important notice to the user when `brew info ` is
+  #     called or when brewing a formula.
+  #     This is optional. You can use all the vars like #{version} here.
+  #   EOS
+  #   s += "Some issue only on older systems" if MacOS.version < :mountain_lion
+  #   s
+  # end
def caveats nil end @@ -642,6 +779,7 @@ class Formula keg_only_reason && keg_only_reason.valid? end + # @private def keg_only_reason self.class.keg_only_reason end @@ -651,6 +789,7 @@ class Formula # skip_clean "bin/foo", "lib/bar" # keep .la files with: # skip_clean :la + # @private def skip_clean?(path) return true if path.extname == ".la" && self.class.skip_clean_paths.include?(:la) to_check = path.relative_path_from(prefix).to_s @@ -662,6 +801,7 @@ class Formula # allow overwriting certain files. e.g. # link_overwrite "bin/foo", "lib/bar" # link_overwrite "share/man/man1/baz-*" + # @private def link_overwrite?(path) # Don't overwrite files not created by Homebrew. return false unless path.stat.uid == File.stat(HOMEBREW_BREW_FILE).uid @@ -685,10 +825,12 @@ class Formula false end + # @private def require_universal_deps? false end + # @private def patch unless patchlist.empty? ohai "Patching" @@ -710,6 +852,7 @@ class Formula end end + # @private def lock @lock = FormulaLock.new(name) @lock.lock @@ -719,27 +862,33 @@ class Formula end end + # @private def unlock @lock.unlock unless @lock.nil? @oldname_lock.unlock unless @oldname_lock.nil? end + # @private def pinnable? @pin.pinnable? end + # @private def pinned? @pin.pinned? end + # @private def pin @pin.pin end + # @private def unpin @pin.unpin end + # @private def ==(other) instance_of?(other.class) && name == other.name && @@ -747,10 +896,12 @@ class Formula end alias_method :eql?, :== + # @private def hash name.hash end + # @private def <=>(other) return unless Formula === other name <=> other.name @@ -760,10 +911,12 @@ class Formula name end + # @private def inspect "#" end + # @private def file_modified? git = which("git") @@ -798,40 +951,48 @@ class Formula end # an array of all core {Formula} names + # @private def self.core_names @core_names ||= Dir["#{HOMEBREW_LIBRARY}/Formula/*.rb"].map { |f| File.basename f, ".rb" }.sort end # an array of all core {Formula} files + # @private def self.core_files @core_files ||= Pathname.glob("#{HOMEBREW_LIBRARY}/Formula/*.rb") end # an array of all tap {Formula} names + # @private def self.tap_names @tap_names ||= Tap.flat_map(&:formula_names).sort end # an array of all tap {Formula} files + # @private def self.tap_files @tap_files ||= Tap.flat_map(&:formula_files) end # an array of all {Formula} names + # @private def self.names @names ||= (core_names + tap_names.map { |name| name.split("/")[-1] }).sort.uniq end # an array of all {Formula} files + # @private def self.files @files ||= core_files + tap_files end # an array of all {Formula} names, which the tap formulae have the fully-qualified name + # @private def self.full_names @full_names ||= core_names + tap_names end + # @private def self.each files.each do |file| begin @@ -846,6 +1007,7 @@ class Formula end # An array of all racks currently installed. + # @private def self.racks @racks ||= if HOMEBREW_CELLAR.directory? HOMEBREW_CELLAR.subdirs.reject(&:symlink?) @@ -855,6 +1017,7 @@ class Formula end # An array of all installed {Formula} + # @private def self.installed @installed ||= racks.map do |rack| begin @@ -864,6 +1027,7 @@ class Formula end.compact end + # @private def self.aliases Dir["#{HOMEBREW_LIBRARY}/Aliases/*"].map { |f| File.basename f }.sort end @@ -872,10 +1036,12 @@ class Formula Formulary.factory(name) end + # @private def tap? HOMEBREW_TAP_DIR_REGEX === path end + # @private def tap if path.to_s =~ HOMEBREW_TAP_DIR_REGEX "#{$1}/#{$2}" @@ -884,6 +1050,7 @@ class Formula end end + # @private def print_tap_action(options = {}) if tap? verb = options[:verb] || "Installing" @@ -892,29 +1059,35 @@ class Formula end # True if this formula is provided by Homebrew itself + # @private def core_formula? path == Formulary.core_path(name) end + # @private def env self.class.env end + # @private def conflicts self.class.conflicts end # Returns a list of Dependency objects in an installable order, which # means if a depends on b then b will be ordered before a in this list + # @private def recursive_dependencies(&block) Dependency.expand(self, &block) end # The full set of Requirements for this formula's dependency tree. + # @private def recursive_requirements(&block) Requirement.expand(self, &block) end + # @private def to_hash hsh = { "name" => name, @@ -969,14 +1142,17 @@ class Formula hsh end + # @private def fetch active_spec.fetch end + # @private def verify_download_integrity(fn) active_spec.verify_download_integrity(fn) end + # @private def run_test old_home = ENV["HOME"] build, self.build = self.build, Tab.for_formula(self) @@ -992,17 +1168,28 @@ class Formula ENV["HOME"] = old_home end + # @private def test_defined? false end + # @private def test end + # @private def test_fixtures(file) HOMEBREW_LIBRARY.join("Homebrew", "test", "fixtures", file) end + # This method is overriden in {Formula} subclasses to provide the installation instructions. + # The sources (from {.url}) are downloaded, hash-checked and + # Homebrew changes into a temporary directory where the + # archive was unpacked or repository cloned. + #
def install
+  #   system "./configure", "--prefix=#{prefix}"
+  #   system "make", "install"
+  # end
def install end @@ -1018,8 +1205,29 @@ class Formula EOS end - # Pretty titles the command and buffers stdout/stderr - # Throws if there's an error + public + + # To call out to the system, we use the `system` method and we prefer + # you give the args separately as in the line below, otherwise a subshell + # has to be opened first. + #
system "./bootstrap.sh", "--arg1", "--prefix=#{prefix}"
+ # + # For CMake we have some necessary defaults in {#std_cmake_args}: + #
system "cmake", ".", *std_cmake_args
+ # + # If the arguments given to configure (or make or cmake) are depending + # on options defined above, we usually make a list first and then + # use the `args << if ` to append to: + #
args = ["--with-option1", "--with-option2"]
+  #
+  # # Most software still uses `configure` and `make`.
+  # # Check with `./configure --help` what our options are.
+  # system "./configure", "--disable-debug", "--disable-dependency-tracking",
+  #                       "--disable-silent-rules", "--prefix=#{prefix}",
+  #                       *args # our custom arg list (needs `*` to unpack)
+  #
+  # # If there is a "make", "install" available, please use it!
+  # system "make", "install"
def system(cmd, *args) verbose = ARGV.verbose? # remove "boring" arguments so that the important ones are more likely to @@ -1178,13 +1386,17 @@ class Formula # A one-line description of the software. Used by users to get an overview # of the software and Homebrew maintainers. # Shows when running `brew info`. + # + #
desc "Example formula"
attr_rw :desc - # @!attribute [w] + # @!attribute [w] homepage # The homepage for the software. Used by users to get more information # about the software and Homebrew maintainers as a point of contact for # e.g. submitting patches. # Can be opened with running `brew home`. + # + #
homepage "https://www.example.com"
attr_rw :homepage # The `:startup` attribute set by {.plist_options}. @@ -1195,12 +1407,14 @@ class Formula # @private attr_reader :plist_manual - # @!attribute [w] + # @!attribute [w] revision # Used for creating new Homebrew versions of software without new upstream # versions. For example, if we bump the major version of a library this # {Formula} {.depends_on} then we may need to update the `revision` of this # {Formula} to install a new version linked against the new library version. # `0` if unset. + # + #
revision 1
attr_rw :revision # A list of the {.stable}, {.devel} and {.head} {SoftwareSpec}s. @@ -1212,6 +1426,15 @@ class Formula # @!attribute [w] url # The URL used to download the source for the {#stable} version of the formula. # We prefer `https` for security and proxy reasons. + # Optionally specify the download strategy with `:using => ...` + # `:git`, `:hg`, `:svn`, `:bzr`, `:cvs`, + # `:curl` (normal file download. Will also extract.) + # `:nounzip` (without extracting) + # `:post` (download via an HTTP POST) + # `S3DownloadStrategy` (download from S3 using signed request) + # + #
url "https://packed.sources.and.we.prefer.https.example.com/archive-1.2.3.tar.bz2"
+ #
url "https://some.dont.provide.archives.example.com", :using => :git, :tag => "1.2.3"
def url(val, specs = {}) stable.url(val, specs) end @@ -1220,6 +1443,8 @@ class Formula # The version string for the {#stable} version of the formula. # The version is autodetected from the URL and/or tag so only needs to be # declared if it cannot be autodetected correctly. + # + #
version "1.2-final"
def version(val = nil) stable.version(val) end @@ -1230,45 +1455,100 @@ class Formula # there can be more than one. Generally we add them when the main {.url} # is unreliable. If {.url} is really unreliable then we may swap the # {.mirror} and {.url}. + # + #
mirror "https://in.case.the.host.is.down.example.com"
+    # mirror "https://in.case.the.mirror.is.down.example.com
def mirror(val) stable.mirror(val) end - # @!attribute [w] sha1 - # @scope class - # To verify the {#cached_download}'s integrity and security we verify the - # SHA-1 hash matches what we've declared in the {Formula}. To quickly fill - # this value you can leave it blank and run `brew fetch --force` and it'll - # tell you the currently valid value. - # @!attribute [w] sha256 # @scope class - # Similar to {.sha1} but using a SHA-256 hash instead. - + # To verify the {#cached_download}'s integrity and security we verify the + # SHA-256 hash matches what we've declared in the {Formula}. To quickly fill + # this value you can leave it blank and run `brew fetch --force` and it'll + # tell you the currently valid value. + # + #
sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7"
Checksum::TYPES.each do |type| define_method(type) { |val| stable.send(type, val) } end + # @!attribute [w] bottle + # Adds a {.bottle} {SoftwareSpec}. + # This provides a pre-built binary package built by the Homebrew maintainers for you. + # It will be installed automatically if there is a binary package for your platform and you haven't passed or previously used any options on this formula. + # If you maintain your own repository, you can add your own bottle links. + # https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Bottles.md + # You can ignore this block entirely if submitting to Homebrew/Homebrew, It'll be + # handled for you by the Brew Test Bot. + # + #
bottle do
+    #   root_url "http://mikemcquaid.com" # Optional root to calculate bottle URLs
+    #   prefix "/opt/homebrew" # Optional HOMEBREW_PREFIX in which the bottles were built.
+    #   cellar "/opt/homebrew/Cellar" # Optional HOMEBREW_CELLAR in which the bottles were built.
+    #   revision 1 # Making the old bottle outdated without bumping the version/revision of the formula.
+    #   sha256 "4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865" => :yosemite
+    #   sha256 "53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3" => :mavericks
+    #   sha256 "1121cfccd5913f0a63fec40a6ffd44ea64f9dc135c66634ba001d10bcf4302a2" => :mountain_lion
+    # end
def bottle(*, &block) stable.bottle(&block) end + # @private def build stable.build end + # @!attribute [w] stable + # Allows adding {.depends_on} and {#patch}es just to the {.stable} {SoftwareSpec}. + # This is required instead of using a conditional. + # It is preferrable to also pull the {url} and {.sha256} into the block if one is added. + # + #
stable do
+    #   url "https://example.com/foo-1.0.tar.gz"
+    #   sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7"
+    #
+    #   depends_on "libxml2"
+    #   depends_on "libffi"
+    # end
def stable(&block) @stable ||= SoftwareSpec.new return @stable unless block_given? @stable.instance_eval(&block) end + # @!attribute [w] devel + # Adds a {.devel} {SoftwareSpec}. + # This can be installed by passing the `--devel` option to allow + # installing non-stable (e.g. beta) versions of software. + # + #
devel do
+    #   url "https://example.com/archive-2.0-beta.tar.gz"
+    #   sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7"
+    #
+    #   depends_on "cairo"
+    #   depends_on "pixman"
+    # end
def devel(&block) @devel ||= SoftwareSpec.new return @devel unless block_given? @devel.instance_eval(&block) end + # @!attribute [w] head + # Adds a {.head} {SoftwareSpec}. + # This can be installed by passing the `--HEAD` option to allow + # installing software directly from a branch of a version-control repository. + # If called as a method this provides just the {url} for the {SoftwareSpec}. + # If a block is provided you can also add {.depends_on} and {#patch}es just to the {.head} {SoftwareSpec}. + # The download strategies (e.g. `:using =>`) are the same as for {url}. + # `master` is the default branch and doesn't need stating with a `:branch` parameter. + #
head "https://we.prefer.https.over.git.example.com/.git"
+ #
head "https://example.com/.git", :branch => "name_of_branch", :revision => "abc123"
+ # or (if autodetect fails): + #
head "https://hg.is.awesome.but.git.has.won.example.com/", :using => :hg
def head(val = nil, specs = {}, &block) @head ||= HeadSoftwareSpec.new if block_given? @@ -1280,7 +1560,13 @@ class Formula end end - # Define a named resource using a {SoftwareSpec} style block + # Additional downloads can be defined as resources and accessed in the + # install method. Resources can also be defined inside a stable, devel, or + # head block. This mechanism replaces ad-hoc "subformula" classes. + #
resource "additional_files" do
+    #   url "https://example.com/additional-stuff.tar.gz"
+    #   sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2"
+    # end
def resource(name, klass = Resource, &block) specs.each do |spec| spec.resource(name, klass, &block) unless spec.resource_defined?(name) @@ -1291,10 +1577,71 @@ class Formula specs.each { |spec| spec.go_resource(name, &block) } end + # The dependencies for this formula. Use strings for the names of other + # formulae. Homebrew provides some :special dependencies for stuff that + # requires certain extra handling (often changing some ENV vars or + # deciding if to use the system provided version or not.) + #
# `:build` means this dep is only needed during build.
+    # depends_on "cmake" => :build
+ #
depends_on "homebrew/dupes/tcl-tk" => :optional
+ #
# `:recommended` dependencies are built by default.
+    # # But a `--without-...` option is generated to opt-out.
+    # depends_on "readline" => :recommended
+ #
# `:optional` dependencies are NOT built by default.
+    # # But a `--with-...` options is generated.
+    # depends_on "glib" => :optional
+ #
# If you need to specify that another formula has to be built with/out
+    # # certain options (note, no `--` needed before the option):
+    # depends_on "zeromq" => "with-pgm"
+    # depends_on "qt" => ["with-qtdbus", "developer"] # Multiple options.
+ #
# Optional and enforce that boost is built with `--with-c++11`.
+    # depends_on "boost" => [:optional, "with-c++11"]
+ #
# If a dependency is only needed in certain cases:
+    # depends_on "sqlite" if MacOS.version == :leopard
+    # depends_on :xcode # If the formula really needs full Xcode.
+    # depends_on :tex # Homebrew does not provide a Tex Distribution.
+    # depends_on :fortran # Checks that `gfortran` is available or `FC` is set.
+    # depends_on :mpi => :cc # Needs MPI with `cc`
+    # depends_on :mpi => [:cc, :cxx, :optional] # Is optional. MPI with `cc` and `cxx`.
+    # depends_on :macos => :lion # Needs at least Mac OS X "Lion" aka. 10.7.
+    # depends_on :apr # If a formula requires the CLT-provided apr library to exist.
+    # depends_on :arch => :intel # If this formula only builds on Intel architecture.
+    # depends_on :arch => :x86_64 # If this formula only builds on Intel x86 64-bit.
+    # depends_on :arch => :ppc # Only builds on PowerPC?
+    # depends_on :ld64 # Sometimes ld fails on `MacOS.version < :leopard`. Then use this.
+    # depends_on :x11 # X11/XQuartz components. Non-optional X11 deps should go in Homebrew/Homebrew-x11
+    # depends_on :osxfuse # Permits the use of the upstream signed binary or our source package.
+    # depends_on :tuntap # Does the same thing as above. This is vital for Yosemite and above.
+    # depends_on :mysql => :recommended
+ #
# It is possible to only depend on something if
+    # # `build.with?` or `build.without? "another_formula"`:
+    # depends_on :mysql # allows brewed or external mysql to be used
+    # depends_on :postgresql if build.without? "sqlite"
+    # depends_on :hg # Mercurial (external or brewed) is needed
+ # + #
# If any Python >= 2.7 < 3.x is okay (either from OS X or brewed):
+    # depends_on :python
+ #
# to depend on Python >= 2.7 but use system Python where possible
+    # depends_on :python if MacOS.version <= :snow_leopard
+ #
# Python 3.x if the `--with-python3` is given to `brew install example`
+    # depends_on :python3 => :optional
def depends_on(dep) specs.each { |spec| spec.depends_on(dep) } end + # @!attribute [w] option + # Options can be used as arguments to `brew install`. + # To switch features on/off: `"with-something"` or `"with-otherthing"`. + # To use other software: `"with-other-software"` or `"without-foo"` + # Note, that for {.depends_on} that are `:optional` or `:recommended`, options + # are generated automatically. + # + # There are also some special options: + # - `:universal`: build a universal binary/library (e.g. on newer Intel Macs + # this means a combined x86_64/x86 binary/library). + #
option "with-spam", "The description goes here without a dot at the end"
+ #
option "with-qt", "Text here overwrites the autogenerated one from 'depends_on "qt" => :optional'"
+ #
option :universal
def option(name, description = "") specs.each { |spec| spec.option(name, description) } end @@ -1303,19 +1650,62 @@ class Formula specs.each { |spec| spec.deprecated_option(hash) } end + # External patches can be declared using resource-style blocks. + #
patch do
+    #   url "https://example.com/example_patch.diff"
+    #   sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2"
+    # end
+ # + # A strip level of `-p1` is assumed. It can be overridden using a symbol + # argument: + #
patch :p0 do
+    #   url "https://example.com/example_patch.diff"
+    #   sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2"
+    # end
+ # + # Patches can be declared in stable, devel, and head blocks. This form is + # preferred over using conditionals. + #
stable do
+    #   patch do
+    #     url "https://example.com/example_patch.diff"
+    #     sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2"
+    #   end
+    # end
+ # + # Embedded (`__END__`) patches are declared like so: + #
patch :DATA
+    # patch :p0, :DATA
+ # + # Patches can also be embedded by passing a string. This makes it possible + # to provide multiple embedded patches while making only some of them + # conditional. + #
patch :p0, "..."
def patch(strip = :p1, src = nil, &block) specs.each { |spec| spec.patch(strip, src, &block) } end + # Defines launchd plist handling. + # + # Does your plist need to be loaded at startup? + #
plist_options :startup => true
+ # + # Or only when necessary or desired by the user? + #
plist_options :manual => "foo"
+ # + # Or perhaps you'd like to give the user a choice? Ooh fancy. + #
plist_options :startup => "true", :manual => "foo start"
def plist_options(options) @plist_startup = options[:startup] @plist_manual = options[:manual] end + # @private def conflicts @conflicts ||= [] end + # If this formula conflicts with another one. + #
conflicts_with "imagemagick", :because => "because this is just a stupid example"
def conflicts_with(*names) opts = Hash === names.last ? names.pop : {} names.each { |name| conflicts << FormulaConflict.new(name, opts[:because]) } @@ -1327,10 +1717,19 @@ class Formula skip_clean_paths.merge(paths) end + # @private def skip_clean_paths @skip_clean_paths ||= Set.new end + # Software that will not be sym-linked into the `brew --prefix` will only + # live in its Cellar. Other formulae can depend on it and then brew will + # add the necessary includes and libs (etc.) during the brewing of that + # other formula. But generally, keg_only formulae are not in your PATH + # and not seen by compilers if you build your own software outside of + # Homebrew. This way, we don't shadow software provided by OS X. + #
keg_only :provided_by_osx
+ #
keg_only "because I want it so"
def keg_only(reason, explanation = "") @keg_only_reason = KegOnlyReason.new(reason, explanation) end @@ -1340,22 +1739,21 @@ class Formula define_method(:skip_cxxstdlib_check?) { true } if check_type == :skip end + # Marks the {Formula} as failing with a particular compiler so it will fall back to others. # For Apple compilers, this should be in the format: - # fails_with compiler do - # cause "An explanation for why the build doesn't work." - # build "The Apple build number for the newest incompatible release." + #
fails_with :llvm do # :llvm is really llvm-gcc
+    #   build 2334
+    #   cause "Segmentation fault during linking."
     # end
     #
+    # fails_with :clang do
+    #   build 600
+    #   cause "multiple configure and compile errors"
+    # end
+ # # The block may be omitted, and if present the build may be omitted; # if so, then the compiler will be blacklisted for *all* versions. # - # For GNU GCC compilers, this should be in the format: - # fails_with compiler => major_version do - # cause - # version "The official release number for the latest incompatible - # version, for instance 4.8.1" - # end - # # `major_version` should be the major release number only, for instance # '4.8' for the GCC 4.8 series (4.8.0, 4.8.1, etc.). # If `version` or the block is omitted, then the compiler will be @@ -1364,9 +1762,9 @@ class Formula # For example, if a bug is only triggered on GCC 4.8.1 but is not # encountered on 4.8.2: # - # fails_with :gcc => '4.8' do + #
fails_with :gcc => '4.8' do
     #   version '4.8.1'
-    # end
+    # end
def fails_with(compiler, &block) specs.each { |spec| spec.fails_with(compiler, &block) } end @@ -1375,15 +1773,42 @@ class Formula specs.each { |spec| spec.needs(*standards) } end + # Test (is required for new formula and makes us happy). + # @return [Boolean] + # + # The block will create, run in and delete a temporary directory. + # + # We are fine if the executable does not error out, so we know linking + # and building the software was ok. + #
system bin/"foobar", "--version"
+ # + #
(testpath/"test.file").write <<-EOS.undent
+    #   writing some test file, if you need to
+    # EOS
+    # assert_equal "OK", shell_output("test_command test.file").strip
+ # + # Need complete control over stdin, stdout? + #
require "open3"
+    # Open3.popen3("#{bin}/example", "argument") do |stdin, stdout, _|
+    #   stdin.write("some text")
+    #   stdin.close
+    #   assert_equal "result", stdout.read
+    # end
+ # + # The test will fail if it returns false, or if an exception is raised. + # Failed assertions and failed `system` commands will raise exceptions. + def test(&block) define_method(:test, &block) end + # @private def link_overwrite(*paths) paths.flatten! link_overwrite_paths.merge(paths) end + # @private def link_overwrite_paths @link_overwrite_paths ||= Set.new end diff --git a/Library/Homebrew/mach.rb b/Library/Homebrew/mach.rb index f7ca428e6e..49382291cb 100644 --- a/Library/Homebrew/mach.rb +++ b/Library/Homebrew/mach.rb @@ -1,21 +1,26 @@ module ArchitectureListExtension + # @private def fat? length > 1 end + # @private def intel_universal? intersects_all?(Hardware::CPU::INTEL_32BIT_ARCHS, Hardware::CPU::INTEL_64BIT_ARCHS) end + # @private def ppc_universal? intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::PPC_64BIT_ARCHS) end # Old-style 32-bit PPC/Intel universal, e.g. ppc7400 and i386 + # @private def cross_universal? intersects_all?(Hardware::CPU::PPC_32BIT_ARCHS, Hardware::CPU::INTEL_32BIT_ARCHS) end + # @private def universal? intel_universal? || ppc_universal? || cross_universal? end @@ -24,6 +29,7 @@ module ArchitectureListExtension (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).any? { |a| self.include? a } end + # @private def remove_ppc! (Hardware::CPU::PPC_32BIT_ARCHS+Hardware::CPU::PPC_64BIT_ARCHS).each { |a| delete a } end @@ -46,12 +52,13 @@ module ArchitectureListExtension end module MachO + # @private OTOOL_RX = /\t(.*) \(compatibility version (?:\d+\.)*\d+, current version (?:\d+\.)*\d+\)/ # Mach-O binary methods, see: # /usr/include/mach-o/loader.h # /usr/include/mach-o/fat.h - + # @private def mach_data @mach_data ||= begin offsets = [] @@ -132,18 +139,22 @@ module MachO arch == :ppc64 end + # @private def dylib? mach_data.any? { |m| m.fetch(:type) == :dylib } end + # @private def mach_o_executable? mach_data.any? { |m| m.fetch(:type) == :executable } end + # @private def mach_o_bundle? mach_data.any? { |m| m.fetch(:type) == :bundle } end + # @private class Metadata attr_reader :path, :dylib_id, :dylibs @@ -171,6 +182,7 @@ module MachO end end + # @private def mach_metadata @mach_metadata ||= Metadata.new(self) end @@ -180,10 +192,12 @@ module MachO # to be absolute paths. # Returns an empty array both for software that links against no libraries, # and for non-mach objects. + # @private def dynamically_linked_libraries mach_metadata.dylibs end + # @private def dylib_id mach_metadata.dylib_id end diff --git a/Library/Homebrew/manpages/brew.1.md b/Library/Homebrew/manpages/brew.1.md index 2ef86a1697..71b5dc3df8 100644 --- a/Library/Homebrew/manpages/brew.1.md +++ b/Library/Homebrew/manpages/brew.1.md @@ -92,7 +92,7 @@ Note that these flags should only appear after a command. and version, but if it fails, you'll have to make your own template. The wget formula serves as a simple example. For a complete cheat-sheet, have a look at - `$(brew --repository)/Library/Contributions/example-formula.rb` + If `--autotools` is passed, create a basic template for an Autotools-style build. If `--cmake` is passed, create a basic template for a CMake-style build. diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 63cdaadfae..84e2363ca4 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -80,6 +80,7 @@ def oh1(title) puts "#{Tty.green}==>#{Tty.white} #{title}#{Tty.reset}" end +# Print a warning (do this rarely) def opoo(warning) $stderr.puts "#{Tty.yellow}Warning#{Tty.reset}: #{warning}" end diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index 8ed32bc5b3..ee47da4571 100644 --- a/Library/Homebrew/utils/inreplace.rb +++ b/Library/Homebrew/utils/inreplace.rb @@ -8,6 +8,13 @@ module Utils end module Inreplace + # Sometimes we have to change a bit before we install. Mostly we + # prefer a patch but if you need the `prefix` of this formula in the + # patch you have to resort to `inreplace`, because in the patch + # you don't have access to any var defined by the formula. Only + # HOMEBREW_PREFIX is available in the embedded patch. + # inreplace supports regular expressions. + #
inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool"
def inreplace(paths, before = nil, after = nil) errors = {} diff --git a/share/doc/homebrew/Formula-Cookbook.md b/share/doc/homebrew/Formula-Cookbook.md index dd4a2acdc0..815d93e074 100644 --- a/share/doc/homebrew/Formula-Cookbook.md +++ b/share/doc/homebrew/Formula-Cookbook.md @@ -81,7 +81,7 @@ Formulae aren’t that complicated. [etl](https://github.com/Homebrew/homebrew/b And then [Git](https://github.com/Homebrew/homebrew/tree/master/Library/Formula/git.rb) and [flac](https://github.com/Homebrew/homebrew/tree/master/Library/Formula/flac.rb) show more advanced functionality. -A more complete example-formula [cheat-sheet](https://github.com/Homebrew/homebrew/blob/master/Library/Contributions/example-formula.rb) shows almost all the stuff you can use in a Formula. +Refer to the [Formula class API documentation](http://www.rubydoc.info/github/Homebrew/homebrew/master/frames) which shows all the stuff you can use in a Formula. ## Grab the URL diff --git a/share/doc/homebrew/brew.1.html b/share/doc/homebrew/brew.1.html new file mode 100644 index 0000000000..8767081e16 --- /dev/null +++ b/share/doc/homebrew/brew.1.html @@ -0,0 +1,599 @@ +
+

NAME

+

+ brew - The missing package manager for OS X +

+ +

SYNOPSIS

+ +

brew --version
+brew command [--verbose|-v] [options] [formula] ...

+ +

DESCRIPTION

+ +

Homebrew is the easiest and most flexible way to install the UNIX tools Apple +didn't include with OS X.

+ +

ESSENTIAL COMMANDS

+ +

For the full command list, see the COMMANDS section.

+ +

With --verbose or -v, many commands print extra debugging information. +Note that these flags should only appear after a command.

+ +
+
install formula

Install formula.

+
remove formula

Uninstall formula.

+
update

Fetch the newest version of Homebrew from GitHub using git(1).

+
list

List all installed formulae.

+
search text|/text/

Perform a substring search of formula names for text. If text is +surrounded with slashes, then it is interpreted as a regular expression. +The search for text is extended online to some popular taps. +If no search term is given, all locally available formulae are listed.

+
+ + +

COMMANDS

+ +
    +
  • audit [--strict] [--online] [formulae]: +Check formulae for Homebrew coding style violations. This should be +run before submitting a new formula.

    + +

    If no formulae are provided, all of them are checked.

    + +

    If --strict is passed, additional checks are run. This should be used +when creating for new formulae.

    + +

    If --online is passed, additional slower checks that require a network +connection are run. This should be used when creating for new formulae.

    + +

    audit exits with a non-zero status if any errors are found. This is useful, +for instance, for implementing pre-commit hooks.

  • +
  • cat formula: +Display the source to formula.

  • +
  • cleanup [--force] [--prune=<days>] [-ns] [formulae]: +For all installed or specific formulae, remove any older versions from the +cellar. By default, does not remove out-of-date keg-only brews, as other +software may link directly to specific versions. In addition old downloads from +the Homebrew download-cache are deleted.

    + +

    If --force is passed, remove out-of-date keg-only brews as well.

    + +

    If --prune=<days> is specified, remove all cache files older than days.

    + +

    If -n is passed, show what would be removed, but do not actually remove anything.

    + +

    If -s is passed, scrubs the cache, removing downloads for even the latest +versions of formula. Note downloads for any installed formula will still not be +deleted. If you want to delete those too: rm -rf $(brew --cache)

  • +
  • command cmd: +Display the path to the file which is used when invoking brew <cmd>.

  • +
  • commands [--quiet [--include-aliases]]: +Show a list of built-in and external commands.

    + +

    If --quiet is passed, list only the names of commands without the header. +With --include-aliases, the aliases of internal commands will be included.

  • +
  • config: +Show Homebrew and system configuration useful for debugging. If you file +a bug report, you will likely be asked for this information if you do not +provide it.

  • +
  • create <URL> [--autotools|--cmake] [--no-fetch] [--set-name <name>] [--set-version <version>]: +Generate a formula for the downloadable file at URL and open it in the editor. +Homebrew will attempt to automatically derive the formula name +and version, but if it fails, you'll have to make your own template. The wget +formula serves as a simple example. For a complete cheat-sheet, have a look at

    + +

    http://www.rubydoc.info/github/Homebrew/homebrew/master/frames

    + +

    If --autotools is passed, create a basic template for an Autotools-style build. +If --cmake is passed, create a basic template for a CMake-style build.

    + +

    If --no-fetch is passed, Homebrew will not download URL to the cache and +will thus not add the SHA256 to the formula for you.

    + +

    The options --set-name and --set-version each take an argument and allow +you to explicitly set the name and version of the package you are creating.

  • +
  • deps [--1] [-n] [--union] [--tree] [--all] [--installed] [--skip-build] [--skip-optional] formulae: +Show dependencies for formulae. When given multiple formula arguments, +show the intersection of dependencies for formulae, except when passed +--tree, --all, or --installed.

    + +

    If --1 is passed, only show dependencies one level down, instead of +recursing.

    + +

    If -n is passed, show dependencies in topological order.

    + +

    If --union is passed, show the union of dependencies for formulae, +instead of the intersection.

    + +

    If --tree is passed, show dependencies as a tree.

    + +

    If --all is passed, show dependencies for all formulae.

    + +

    If --installed is passed, show dependencies for all installed formulae.

    + +

    By default, deps shows dependencies for formulae. To skip the :build +type dependencies, pass --skip-build. Similarly, pass --skip-optional +to skip :optional dependencies.

  • +
  • diy [--name=<name>] [--version=<version>]: +Automatically determine the installation prefix for non-Homebrew software.

    + +

    Using the output from this command, you can install your own software into +the Cellar and then link it into Homebrew's prefix with brew link.

    + +

    The options --name=<name> and --version=<version> each take an argument +and allow you to explicitly set the name and version of the package you are +installing.

  • +
  • doctor: +Check your system for potential problems. Doctor exits with a non-zero status +if any problems are found.

  • +
  • edit: +Open all of Homebrew for editing.

  • +
  • edit formula: +Open formula in the editor.

  • +
  • fetch [--force] [-v] [--devel|--HEAD] [--deps] [--build-from-source|--force-bottle] formulae: +Download the source packages for the given formulae. +For tarballs, also print SHA1 and SHA-256 checksums.

    + +

    If --HEAD or --devel is passed, fetch that version instead of the +stable version.

    + +

    If -v is passed, do a verbose VCS checkout, if the URL represents a CVS. +This is useful for seeing if an existing VCS cache has been updated.

    + +

    If --force is passed, remove a previously cached version and re-fetch.

    + +

    If --deps is passed, also download dependencies for any listed formulae.

    + +

    If --build-from-source is passed, download the source rather than a +bottle.

    + +

    If --force-bottle is passed, download a bottle if it exists for the current +version of OS X, even if it would not be used during installation.

  • +
  • home: +Open Homebrew's own homepage in a browser.

  • +
  • home formula: +Open formula's homepage in a browser.

  • +
  • info formula: +Display information about formula.

  • +
  • info --github formula: +Open a browser to the GitHub History page for formula formula.

    + +

    To view formula history locally: brew log -p <formula>.

  • +
  • info --json=<version> (--all|--installed|formulae): +Print a JSON representation of formulae. Currently the only accepted value +for version is v1.

    + +

    Pass --all to get information on all formulae, or --installed to get +information on all installed formulae.

    + +

    See the docs for examples of using the JSON: +https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Querying-Brew.md

  • +
  • install [--debug] [--env=<std|super>] [--ignore-dependencies] [--only-dependencies] [--cc=<compiler>] [--build-from-source|--force-bottle] [--devel|--HEAD] formula: +Install formula.

    + +

    formula is usually the name of the formula to install, but it can be specified +several different ways. See SPECIFYING FORMULAE.

    + +

    If --debug is passed and brewing fails, open an interactive debugging +session with access to IRB or a shell inside the temporary build directory.

    + +

    If --env=std is passed, use the standard build environment instead of superenv.

    + +

    If --env=super is passed, use superenv even if the formula specifies the +standard build environment.

    + +

    If --ignore-dependencies is passed, skip installing any dependencies of +any kind. If they are not already present, the formula will probably fail +to install.

    + +

    If --only-dependencies is passed, install the dependencies with specified +options but do not install the specified formula.

    + +

    If --cc=<compiler> is passed, attempt to compile using compiler. +compiler should be the name of the compiler's executable, for instance +gcc-4.2 for Apple's GCC 4.2, or gcc-4.9 for a Homebrew-provided GCC +4.9.

    + +

    If --build-from-source is passed, compile from source even if a bottle +is provided for formula.

    + +

    If --force-bottle is passed, install from a bottle if it exists +for the current version of OS X, even if custom options are given.

    + +

    If --devel is passed, and formula defines it, install the development version.

    + +

    If --HEAD is passed, and formula defines it, install the HEAD version, +aka master, trunk, unstable.

    + +

    To install a newer version of HEAD use +brew rm <foo> && brew install --HEAD <foo>.

  • +
  • install --interactive [--git] formula: +Download and patch formula, then open a shell. This allows the user to +run ./configure --help and otherwise determine how to turn the software +package into a Homebrew formula.

    + +

    If --git is passed, Homebrew will create a Git repository, useful for +creating patches to the software.

  • +
  • irb [--examples]: +Enter the interactive Homebrew Ruby shell.

    + +

    If --examples is passed, several examples will be shown.

  • +
  • leaves: +Show installed formulae that are not dependencies of another installed formula.

  • +
  • ln, link [--overwrite] [--dry-run] [--force] formula: +Symlink all of formula's installed files into the Homebrew prefix. This +is done automatically when you install formulae but can be useful for DIY +installations.

    + +

    If --overwrite is passed, Homebrew will delete files which already exist in +the prefix while linking.

    + +

    If --dry-run or -n is passed, Homebrew will list all files which would +be linked or which would be deleted by brew link --overwrite, but will not +actually link or delete any files.

    + +

    If --force is passed, Homebrew will allow keg-only formulae to be linked.

  • +
  • linkapps [--local] [formulae]: +Find installed formulae that have compiled .app-style "application" +packages for OS X, and symlink those apps into /Applications, allowing +for easier access.

    + +

    If no formulae are provided, all of them will have their .apps symlinked.

    + +

    If provided, --local will move them into the user's ~/Applications +directory instead of the system directory. It may need to be created, first.

  • +
  • ls, list [--full-name] +List all installed formulae. If --full-name is passed, print formulae with +full-qualified names.

  • +
  • ls, list --unbrewed +List all files in the Homebrew prefix not installed by Homebrew.

  • +
  • ls, list [--versions [--multiple]] [--pinned] [formulae]: +List the installed files for formulae. Combined with --verbose, recursively +list the contents of all subdirectories in each formula's keg.

    + +

    If --versions is passed, show the version number for installed formulae, +or only the specified formulae if formulae are given. With --multiple, +only show formulae with multiple versions installed.

    + +

    If --pinned is passed, show the versions of pinned formulae, or only the +specified (pinned) formulae if formulae are given. +See also pin, unpin.

  • +
  • log [git-log-options] formula ...: +Show the git log for the given formulae. Options that git-log(1) +recognizes can be passed before the formula list.

  • +
  • missing [formulae]: +Check the given formulae for missing dependencies.

    + +

    If no formulae are given, check all installed brews.

  • +
  • migrate [--force] formulae: +Migrate renamed packages to new name, where formulae are old names of +packages.

    + +

    If --force is passed, then treat installed formulae and passed formulae +like if they are from same taps and migrate them anyway.

  • +
  • options [--compact] [--all] [--installed] formula: +Display install options specific to formula.

    + +

    If --compact is passed, show all options on a single line separated by +spaces.

    + +

    If --all is passed, show options for all formulae.

    + +

    If --installed is passed, show options for all installed formulae.

  • +
  • outdated [--quiet | --verbose | --json=v1 ]: +Show formulae that have an updated version available.

    + +

    By default, version information is displayed in interactive shells, and +suppressed otherwise.

    + +

    If --quiet is passed, list only the names of outdated brews (takes +precedence over --verbose).

    + +

    If --verbose is passed, display detailed version information.

    + +

    If --json=<version> is passed, the output will be in JSON format. The only +valid version is v1.

  • +
  • pin formulae: +Pin the specified formulae, preventing them from being upgraded when +issuing the brew upgrade command. See also unpin.

  • +
  • prune: +Remove dead symlinks from the Homebrew prefix. This is generally not +needed, but can be useful when doing DIY installations.

  • +
  • reinstall formula: +Uninstall then install formula

  • +
  • rm, remove, uninstall [--force] formula: +Uninstall formula.

    + +

    If --force is passed, and there are multiple versions of formula +installed, delete all installed versions.

  • +
  • search, -S: +Display all locally available formulae for brewing (including tapped ones). +No online search is performed if called without arguments.

  • +
  • search, -S text|/text/: +Perform a substring search of formula names for text. If text is +surrounded with slashes, then it is interpreted as a regular expression. +The search for text is extended online to some popular taps.

  • +
  • search --debian|--fedora|--fink|--macports|--opensuse|--ubuntu text: +Search for text in the given package manager's list.

  • +
  • sh [--env=std]: +Instantiate a Homebrew build environment. Uses our years-battle-hardened +Homebrew build logic to help your ./configure && make && make install +or even your gem install succeed. Especially handy if you run Homebrew +in a Xcode-only configuration since it adds tools like make to your PATH +which otherwise build-systems would not find.

  • +
  • switch name version: +Symlink all of the specific version of name's install to Homebrew prefix.

  • +
  • tap [--full] [] [URL]: +Tap a formula repository or list existing taps. This command can be invoked +in three ways.

    + +
      +
    • tap without arguments displays existing taps.

    • +
    • tap <user/repo> taps a formula repository from GitHub using HTTPS. +Since so many taps are hosted on GitHub, this command is a shortcut for +tap user/repo https://github.com/#{user}/homebrew-#{repo}.

    • +
    • tap <user/repo> <URL> taps a formula repository from anywhere, using +any transport protocol that git handles. The one-argument form of tap +simplifies but also limits. This two-argument command makes no +assumptions, so taps can be cloned from places other than GitHub and +using protocols other than HTTPS, e.g., SSH, GIT, HTTP, FTP(S), RSYNC.

    • +
    + + +

    By default, the repository is cloned as a shallow copy (--depth=1), but +if --full is passed, a full clone will be used.

  • +
  • tap --repair: +Migrate tapped formulae from symlink-based to directory-based structure.

  • +
  • tap --list-official: +List all official taps.

  • +
  • tap --list-pinned: +List all pinned taps.

  • +
  • tap-info tap: +Display information about tap.

  • +
  • tap-info --json=<version> (--installed|taps): +Print a JSON representation of taps. Currently the only accepted value +for version is v1.

    + +

    Pass --installed to get information on installed taps.

    + +

    See the docs for examples of using the JSON: +https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Querying-Brew.md

  • +
  • tap-pin tap: +Pin tap, prioritizing its formulae over core when formula names are supplied +by the user. See also tap-unpin.

  • +
  • tap-unpin tap: +Unpin tap so its formulae are no longer prioritized. See also tap-pin.

  • +
  • test [--devel|--HEAD] [--debug] formula: +A few formulae provide a test method. brew test <formula> runs this +test method. There is no standard output or return code, but it should +generally indicate to the user if something is wrong with the installed +formula.

    + +

    To test the development or head version of a formula, use --devel or +--HEAD.

    + +

    If --debug is passed and the test fails, an interactive debugger will be +launched with access to IRB or a shell inside the temporary test directory.

    + +

    Example: brew install jruby && brew test jruby

  • +
  • unlink formula: +Remove symlinks for formula from the Homebrew prefix. This can be useful +for temporarily disabling a formula: +brew unlink foo && commands && brew link foo.

  • +
  • unlinkapps [--local] [formulae]: +Removes links created by brew linkapps.

    + +

    If no formulae are provided, all linked app will be removed.

  • +
  • unpack [--git|--patch] [--destdir=<path>] formulae: +Unpack the source files for formulae into subdirectories of the current +working directory. If --destdir=<path> is given, the subdirectories will +be created in the directory named by <path> instead.

    + +

    If --patch is passed, patches for formulae will be applied to the +unpacked source.

    + +

    If --git is passed, a Git repository will be initalized in the unpacked +source. This is useful for creating patches for the software.

  • +
  • unpin formulae: +Unpin formulae, allowing them to be upgraded by brew upgrade. See also +pin.

  • +
  • untap tap: +Remove a tapped repository.

  • +
  • update [--rebase]: +Fetch the newest version of Homebrew and all formulae from GitHub using + git(1).

    + +

    If --rebase is specified then git pull --rebase is used.

  • +
  • upgrade [install-options] [formulae]: +Upgrade outdated, unpinned brews.

    + +

    Options for the install command are also valid here.

    + +

    If formulae are given, upgrade only the specified brews (but do so even +if they are pinned; see pin, unpin).

  • +
  • uses [--installed] [--recursive] [--skip-build] [--skip-optional] [--devel|--HEAD] formulae: +Show the formulae that specify formulae as a dependency. When given +multiple formula arguments, show the intersection of formulae that use +formulae.

    + +

    Use --recursive to resolve more than one level of dependencies.

    + +

    If --installed is passed, only list installed formulae.

    + +

    By default, uses shows all formulae that specify formulae as a dependency. +To skip the :build type dependencies, pass --skip-build. Similarly, pass +--skip-optional to skip :optional dependencies.

    + +

    By default, uses shows usages of formula by stable builds. To find +cases where formula is used by development or HEAD build, pass +--devel or --HEAD.

  • +
  • --cache: +Display Homebrew's download cache. See also HOMEBREW_CACHE.

  • +
  • --cache formula: +Display the file or directory used to cache formula.

  • +
  • --cellar: +Display Homebrew's Cellar path. Default: $(brew --prefix)/Cellar, or if +that directory doesn't exist, $(brew --repository)/Cellar.

  • +
  • --cellar formula: +Display the location in the cellar where formula would be installed, +without any sort of versioned directory as the last path.

  • +
  • --env: +Show a summary of the Homebrew build environment.

  • +
  • --prefix: +Display Homebrew's install path. Default: /usr/local

  • +
  • --prefix formula: +Display the location in the cellar where formula is or would be installed.

  • +
  • --repository: +Display where Homebrew's .git directory is located. For standard installs, +the prefix and repository are the same directory.

  • +
  • --version: +Print the version number of brew to standard error and exit.

  • +
+ + +

EXTERNAL COMMANDS

+ +

Homebrew, like git(1), supports external commands. These are executable +scripts that reside somewhere in the PATH, named brew-<cmdname> or +brew-<cmdname>.rb, which can be invoked like brew cmdname. This allows you +to create your own commands without modifying Homebrew's internals.

+ +

Instructions for creating your own commands can be found in the docs: +https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/External-Commands.md

+ +

SPECIFYING FORMULAE

+ +

Many Homebrew commands accept one or more formula arguments. These arguments +can take several different forms:

+ +
+
The name of a formula

e.g. git, node, wget.

+
The fully-qualified name of a tapped formula

Sometimes a formula from a tapped repository may conflict with one in Homebrew/homebrew. +You can still access these formulae by using a special syntax, e.g. +homebrew/dupes/vim or homebrew/versions/node4.

+
An arbitrary URL

Homebrew can install formulae via URL, e.g. +https://raw.github.com/Homebrew/homebrew/master/Library/Formula/git.rb. +The formula file will be cached for later use.

+
+ + +

ENVIRONMENT

+ +
+
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY

When using the S3 download strategy, Homebrew will look in +these variables for access credentials (see +https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment +to retrieve these access credentials from AWS). If they are not set, +the S3 download strategy will download with a public +(unsigned) URL.

+
BROWSER

If set, and HOMEBREW_BROWSER is not, use BROWSER as the web browser +when opening project homepages.

+
EDITOR

If set, and HOMEBREW_EDITOR and VISUAL are not, use EDITOR as the text editor.

+
GIT

When using Git, Homebrew will use GIT if set, +a Homebrew-built Git if installed, or the system-provided binary.

+ +

Set this to force Homebrew to use a particular git binary.

+
HOMEBREW_BOTTLE_DOMAIN

If set, instructs Homebrew to use the given URL as a download mirror for bottles.

+
HOMEBREW_BROWSER

If set, uses this setting as the browser when opening project homepages, +instead of the OS default browser.

+
HOMEBREW_BUILD_FROM_SOURCE

If set, instructs Homebrew to compile from source even when a formula +provides a bottle.

+
HOMEBREW_CACHE

If set, instructs Homebrew to use the given directory as the download cache.

+ +

Default: ~/Library/Caches/Homebrew if it exists; otherwise, +/Library/Caches/Homebrew.

+
HOMEBREW_CURL_VERBOSE

If set, Homebrew will pass --verbose when invoking curl(1).

+
HOMEBREW_DEBUG

If set, any commands that can emit debugging information will do so.

+
HOMEBREW_DEBUG_INSTALL

When brew install -d or brew install -i drops into a shell, +HOMEBREW_DEBUG_INSTALL will be set to the name of the formula being +brewed.

+
HOMEBREW_DEBUG_PREFIX

When brew install -d or brew install -i drops into a shell, +HOMEBREW_DEBUG_PREFIX will be set to the target prefix in the Cellar +of the formula being brewed.

+
HOMEBREW_DEVELOPER

If set, Homebrew will print warnings that are only relevant to Homebrew +developers (active or budding).

+
HOMEBREW_EDITOR

If set, Homebrew will use this editor when editing a single formula, or +several formulae in the same directory.

+ +

NOTE: brew edit will open all of Homebrew as discontinuous files and +directories. TextMate can handle this correctly in project mode, but many +editors will do strange things in this case.

+
HOMEBREW_GITHUB_API_TOKEN

A personal access token for the GitHub API, which you can create at +https://github.com/settings/tokens. If set, GitHub will allow you a +greater number of API requests. See +https://developer.github.com/v3/#rate-limiting for more information. +Homebrew uses the GitHub API for features such as brew search.

+
HOMEBREW_LOGS

If set, Homebrew will use the given directory to store log files.

+
HOMEBREW_MAKE_JOBS

If set, instructs Homebrew to use the value of HOMEBREW_MAKE_JOBS as +the number of parallel jobs to run when building with make(1).

+ +

Default: the number of available CPU cores.

+
HOMEBREW_NO_EMOJI

If set, Homebrew will not print the HOMEBREW_INSTALL_BADGE on a +successful build.

+ +

Note: Homebrew will only try to print emoji on Lion or newer.

+
HOMEBREW_NO_INSECURE_REDIRECT

If set, Homebrew will not permit redirects from secure HTTPS +to insecure HTTP.

+ +

While ensuring your downloads are fully secure, this is likely +to cause from-source Sourceforge & GNOME based formulae +to fail to download.

+ +

Apache formulae are currently unaffected by this variable and +can redirect to plaintext.

+
HOMEBREW_NO_GITHUB_API

If set, Homebrew will not use the GitHub API for e.g searches or +fetching relevant issues on a failed install.

+
HOMEBREW_INSTALL_BADGE

Text printed before the installation summary of each successful build. +Defaults to the beer emoji.

+
HOMEBREW_SVN

When exporting from Subversion, Homebrew will use HOMEBREW_SVN if set, +a Homebrew-built Subversion if installed, or the system-provided binary.

+ +

Set this to force Homebrew to use a particular svn binary.

+
HOMEBREW_TEMP

If set, instructs Homebrew to use HOMEBREW_TEMP as the temporary directory +for building packages. This may be needed if your system temp directory and +Homebrew Prefix are on different volumes, as OS X has trouble moving +symlinks across volumes when the target does not yet exist.

+ +

This issue typically occurs when using FileVault or custom SSD +configurations.

+
HOMEBREW_VERBOSE

If set, Homebrew always assumes --verbose when running commands.

+
VISUAL

If set, and HOMEBREW_EDITOR is not, use VISUAL as the text editor.

+
+ + +

USING HOMEBREW BEHIND A PROXY

+ +

Homebrew uses several commands for downloading files (e.g. curl, git, svn). +Many of these tools can download via a proxy. It's common for these tools +to read proxy parameters from environment variables.

+ +

For the majority of cases setting http_proxy is enough. You can set this in +your shell profile, or you can use it before a brew command:

+ +
http_proxy=http://<host>:<port> brew install foo
+
+ +

If your proxy requires authentication:

+ +
http_proxy=http://<user>:<password>@<host>:<port> brew install foo
+
+ +

SEE ALSO

+ +

Homebrew Documentation: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/

+ +

git(1), git-log(1)

+ +

AUTHORS

+ +

Homebrew's current maintainers are Misty De Meo, Adam Vandenberg, Xu Cheng, Mike McQuaid, Baptiste Fontaine, Brett Koonce, Dominyk Tiller, Tim Smith and Alex Dunn.

+ +

Homebrew was originally created by Max Howell.

+ +

BUGS

+ +

See Issues on GitHub: https://github.com/Homebrew/homebrew/issues

+ +
diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1 index 121c221737..d7e33e54a3 100644 --- a/share/man/man1/brew.1 +++ b/share/man/man1/brew.1 @@ -92,7 +92,7 @@ If \fB\-\-quiet\fR is passed, list only the names of commands without the header \fBcreate [\-\-autotools|\-\-cmake] [\-\-no\-fetch] [\-\-set\-name ] [\-\-set\-version ]\fR: Generate a formula for the downloadable file at \fIURL\fR and open it in the editor\. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you\'ll have to make your own template\. The wget formula serves as a simple example\. For a complete cheat\-sheet, have a look at . .IP -\fB$(brew \-\-repository)/Library/Contributions/example\-formula\.rb\fR +\fIhttp://www\.rubydoc\.info/github/Homebrew/homebrew/master/frames\fR . .IP If \fB\-\-autotools\fR is passed, create a basic template for an Autotools\-style build\. If \fB\-\-cmake\fR is passed, create a basic template for a CMake\-style build\.