Modernize brew diy
This commit is contained in:
parent
e236901e56
commit
30b4961dde
@ -98,14 +98,15 @@ Note that these flags should only appear after a command.
|
||||
|
||||
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.
|
||||
|
||||
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 `--set-name` and `--set-version` each take an argument and allow
|
||||
you to explicitly set the name and version of the package you are installing.
|
||||
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
|
||||
|
@ -1,31 +1,35 @@
|
||||
module Homebrew extend self
|
||||
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
|
||||
|
||||
version = if ARGV.include? '--set-version'
|
||||
version = ARGV.value "version"
|
||||
version ||= if ARGV.include? "--set-version"
|
||||
ARGV.next
|
||||
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
|
||||
path.version
|
||||
end
|
||||
|
||||
name = if ARGV.include? '--set-name'
|
||||
name = ARGV.value "name"
|
||||
name ||= if ARGV.include? "--set-name"
|
||||
ARGV.next
|
||||
else
|
||||
path.basename.to_s =~ /(.*?)-?#{version}/
|
||||
if $1.to_s.empty?
|
||||
path.basename
|
||||
else
|
||||
$1
|
||||
end
|
||||
basename = path.basename.to_s
|
||||
basename[/(.*?)-?#{Regexp.escape(version)}/, 1] || basename
|
||||
end
|
||||
|
||||
prefix = HOMEBREW_CELLAR/name/version
|
||||
|
||||
if File.file? 'CMakeLists.txt'
|
||||
if File.file? "CMakeLists.txt"
|
||||
puts "-DCMAKE_INSTALL_PREFIX=#{prefix}"
|
||||
elsif File.file? 'Makefile.am'
|
||||
elsif File.file? "Makefile.am"
|
||||
puts "--prefix=#{prefix}"
|
||||
else
|
||||
raise "Couldn't determine build system"
|
||||
|
@ -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\.
|
||||
.
|
||||
.TP
|
||||
\fBdiy [\-\-set\-name <name>] [\-\-set\-version <version>]\fR
|
||||
\fBdiy [\-\-name=<name>] [\-\-version=<version>]\fR
|
||||
Automatically determine the installation prefix for non\-Homebrew software\.
|
||||
.
|
||||
.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\.
|
||||
.
|
||||
.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
|
||||
\fBdoctor\fR
|
||||
|
Loading…
x
Reference in New Issue
Block a user