Modernize brew diy

This commit is contained in:
Jack Nagel 2014-03-15 12:55:14 -05:00
parent e236901e56
commit 30b4961dde
3 changed files with 21 additions and 16 deletions

View File

@ -98,14 +98,15 @@ Note that these flags should only appear after a command.
If `--installed` is passed, show dependencies for all installed formulae. If `--installed` is passed, show dependencies for all installed formulae.
* `diy [--set-name <name>] [--set-version <version>]`: * `diy [--name=<name>] [--version=<version>]`:
Automatically determine the installation prefix for non-Homebrew software. Automatically determine the installation prefix for non-Homebrew software.
Using the output from this command, you can install your own software into 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 Cellar and then link it into Homebrew's prefix with `brew link`.
The options `--set-name` and `--set-version` each take an argument and allow The options `--name=<name>` and `--version=<version>` each take an argument
you to explicitly set the name and version of the package you are installing. and allow you to explicitly set the name and version of the package you are
installing.
* `doctor`: * `doctor`:
Check your system for potential problems. Doctor exits with a non-zero status Check your system for potential problems. Doctor exits with a non-zero status

View File

@ -1,31 +1,35 @@
module Homebrew extend self module Homebrew extend self
def diy def diy
%w[name version].each do |opt|
if ARGV.include? "--set-#{opt}"
opoo "--set-#{opt} is deprecated, please use --#{opt}=<#{opt}> instead"
end
end
path = Pathname.getwd path = Pathname.getwd
version = if ARGV.include? '--set-version' version = ARGV.value "version"
version ||= if ARGV.include? "--set-version"
ARGV.next ARGV.next
elsif path.version.to_s.empty? elsif path.version.to_s.empty?
raise "Couldn't determine version, try --set-version" raise "Couldn't determine version, set it with --version=<version>"
else else
path.version path.version
end end
name = if ARGV.include? '--set-name' name = ARGV.value "name"
name ||= if ARGV.include? "--set-name"
ARGV.next ARGV.next
else else
path.basename.to_s =~ /(.*?)-?#{version}/ basename = path.basename.to_s
if $1.to_s.empty? basename[/(.*?)-?#{Regexp.escape(version)}/, 1] || basename
path.basename
else
$1
end
end end
prefix = HOMEBREW_CELLAR/name/version prefix = HOMEBREW_CELLAR/name/version
if File.file? 'CMakeLists.txt' if File.file? "CMakeLists.txt"
puts "-DCMAKE_INSTALL_PREFIX=#{prefix}" puts "-DCMAKE_INSTALL_PREFIX=#{prefix}"
elsif File.file? 'Makefile.am' elsif File.file? "Makefile.am"
puts "--prefix=#{prefix}" puts "--prefix=#{prefix}"
else else
raise "Couldn't determine build system" raise "Couldn't determine build system"

View File

@ -110,14 +110,14 @@ If \fB\-\-all\fR is passed, show dependencies for all formulae\.
If \fB\-\-installed\fR is passed, show dependencies for all installed formulae\. If \fB\-\-installed\fR is passed, show dependencies for all installed formulae\.
. .
.TP .TP
\fBdiy [\-\-set\-name <name>] [\-\-set\-version <version>]\fR \fBdiy [\-\-name=<name>] [\-\-version=<version>]\fR
Automatically determine the installation prefix for non\-Homebrew software\. Automatically determine the installation prefix for non\-Homebrew software\.
. .
.IP .IP
Using the output from this command, you can install your own software into the Cellar and then link it into Homebrew\'s prefix with \fBbrew link\fR\. Using the output from this command, you can install your own software into the Cellar and then link it into Homebrew\'s prefix with \fBbrew link\fR\.
. .
.IP .IP
The options \fB\-\-set\-name\fR and \fB\-\-set\-version\fR each take an argument and allow you to explicitly set the name and version of the package you are installing\. The options \fB\-\-name=<name>\fR and \fB\-\-version=<version>\fR each take an argument and allow you to explicitly set the name and version of the package you are installing\.
. .
.TP .TP
\fBdoctor\fR \fBdoctor\fR