language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | Homebrew | brew | 0a2dd832b932d492c23d2a2b6d06baa3d5879e79.json | Install specific Rubocop version.
Closes Homebrew/homebrew#39620. | Library/Homebrew/cmd/style.rb | @@ -6,7 +6,7 @@ def style
ARGV.formulae.map(&:path)
end
- Homebrew.install_gem_setup_path! "rubocop"
+ Homebrew.install_gem_setup_path! "rubocop", "0.31.0"
args = [
"--format", "simple", "--config", | true |
Other | Homebrew | brew | 0a2dd832b932d492c23d2a2b6d06baa3d5879e79.json | Install specific Rubocop version.
Closes Homebrew/homebrew#39620. | Library/Homebrew/utils.rb | @@ -121,13 +121,16 @@ def self.git_last_commit
HOMEBREW_REPOSITORY.cd { `git show -s --format="%cr" HEAD 2>/dev/null`.chuzzle }
end
- def self.install_gem_setup_path! gem, executable=gem
+ def self.install_gem_setup_path! gem, version=nil, executable=gem
require "rubygems"
ENV["PATH"] = "#{Gem.user_dir}/bin:#{ENV["PATH"]}"
- unless quiet_system "gem", "list", "--installed", gem
+ args = [gem]
+ args << "-v" << version if version
+
+ unless quiet_system "gem", "list", "--installed", *args
safe_system "gem", "install", "--no-ri", "--no-rdoc",
- "--user-install", gem
+ "--user-install", *args
end
unless which executable | true |
Other | Homebrew | brew | d78686b42102bd25ecade0ac9006dc9baf150c39.json | SUPPORTERS.md: add another backer URL. | SUPPORTERS.md | @@ -445,7 +445,7 @@ These wonderful people supported our Kickstarter by giving us £10 or more:
* [Slobodan Miskovic](https://miskovic.ca)
* [Kurt Ostergaard](http://KurtOstergaard.com)
* [Simply Business](http://www.simplybusiness.co.uk/)
-* Tate Johnson
+* [Tate Johnson](http://tatey.com)
* [Gerry Cardinal III](http://gerrycardinal.com/)
* [Andrew Kalek](http://anlek.com)
* [Bryan Coe](http://www.BryanACoe.com) | false |
Other | Homebrew | brew | 64c092708747eb6d989430ba947b9378b5aab59e.json | sandbox: fix the rules
1. `script` (used to fake the tty) requires write access to /dev/ptmx
and /dev/ttys*
2. sandbox profile only accepts `[0-9]` instead of `\d`. | Library/Homebrew/sandbox.rb | @@ -110,10 +110,11 @@ class SandboxProfile
(debug deny) ; log all denied operations to /var/log/system.log
<%= rules.join("\n") %>
(allow file-write*
+ (literal "/dev/ptmx")
(literal "/dev/dtracehelper")
(literal "/dev/null")
- (regex #"^/dev/fd/\\d+$")
- (regex #"^/dev/tty\\d*$")
+ (regex #"^/dev/fd/[0-9]+$")
+ (regex #"^/dev/ttys?[0-9]*$")
)
(deny file-write*) ; deny non-whitelist file write operations
(allow default) ; allow everything else | false |
Other | Homebrew | brew | 41ecce78982e9e1ca6ece946005dbd7a79c72e95.json | Push URL audits down to ResourceAuditor | Library/Homebrew/cmd/audit.rb | @@ -313,119 +313,6 @@ def audit_urls
if homepage =~ %r[^http://((?:build|cloud|developer|download|extensions|git|glade|help|library|live|nagios|news|people|projects|rt|static|wiki|www)\.)?gnome\.org]
problem "Gnome homepages should be https:// links (URL is #{homepage})."
end
-
- urls = @specs.map(&:url)
-
- # Check GNU urls; doesn't apply to mirrors
- urls.grep(%r[^(?:https?|ftp)://(?!alpha).+/gnu/]) do |u|
- problem "\"http://ftpmirror.gnu.org\" is preferred for GNU software (url is #{u})."
- end
-
- mirrors = @specs.map(&:mirrors).flatten
- dupes = urls & mirrors
-
- dupes.each do |dupe|
- problem "URL should not be duplicated as a mirror: #{dupe}"
- end
-
- # the rest of the checks apply to mirrors as well.
- urls += mirrors
-
- # Check a variety of SSL/TLS links that don't consistently auto-redirect
- # or are overly common errors that need to be reduced & fixed over time.
- urls.each do |p|
- # Skip the main url link, as it can't be made SSL/TLS yet.
- next if p =~ %r[/ftpmirror\.gnu\.org]
-
- case p
- when %r[^http://ftp\.gnu\.org/]
- problem "ftp.gnu.org urls should be https://, not http:// (url is #{p})."
- when %r[^http://[^/]*\.apache\.org/]
- problem "Apache urls should be https://, not http (url is #{p})."
- when %r[^http://code\.google\.com/]
- problem "code.google.com urls should be https://, not http (url is #{p})."
- when %r[^http://fossies\.org/]
- problem "Fossies urls should be https://, not http (url is #{p})."
- when %r[^http://mirrors\.kernel\.org/]
- problem "mirrors.kernel urls should be https://, not http (url is #{p})."
- when %r[^http://([^/]*\.|)bintray\.com/]
- problem "Bintray urls should be https://, not http (url is #{p})."
- when %r[^http://tools\.ietf\.org/]
- problem "ietf urls should be https://, not http (url is #{p})."
- end
- end
-
- # Check SourceForge urls
- urls.each do |p|
- # Skip if the URL looks like a SVN repo
- next if p =~ %r[/svnroot/]
- next if p =~ %r[svn\.sourceforge]
-
- # Is it a sourceforge http(s) URL?
- next unless p =~ %r[^https?://.*\b(sourceforge|sf)\.(com|net)]
-
- if p =~ /(\?|&)use_mirror=/
- problem "Don't use #{$1}use_mirror in SourceForge urls (url is #{p})."
- end
-
- if p =~ /\/download$/
- problem "Don't use /download in SourceForge urls (url is #{p})."
- end
-
- if p =~ %r[^https?://sourceforge\.]
- problem "Use http://downloads.sourceforge.net to get geolocation (url is #{p})."
- end
-
- if p =~ %r[^https?://prdownloads\.]
- problem "Don't use prdownloads in SourceForge urls (url is #{p}).\n" +
- "\tSee: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/"
- end
-
- if p =~ %r[^http://\w+\.dl\.]
- problem "Don't use specific dl mirrors in SourceForge urls (url is #{p})."
- end
-
- if p.start_with? "http://downloads"
- problem "Use https:// URLs for downloads from SourceForge (url is #{p})."
- end
- end
-
- # Check for Google Code download urls, https:// is preferred
- # Intentionally not extending this to SVN repositories due to certificate
- # issues.
- urls.grep(%r[^http://.*\.googlecode\.com/files.*]) do |u|
- problem "Use https:// URLs for downloads from Google Code (url is #{u})."
- end
-
- # Check for new-url Google Code download urls, https:// is preferred
- urls.grep(%r[^http://code\.google\.com/]) do |u|
- problem "Use https:// URLs for downloads from code.google (url is #{u})."
- end
-
- # Check for git:// GitHub repo urls, https:// is preferred.
- urls.grep(%r[^git://[^/]*github\.com/]) do |u|
- problem "Use https:// URLs for accessing GitHub repositories (url is #{u})."
- end
-
- # Check for git:// Gitorious repo urls, https:// is preferred.
- urls.grep(%r[^git://[^/]*gitorious\.org/]) do |u|
- problem "Use https:// URLs for accessing Gitorious repositories (url is #{u})."
- end
-
- # Check for http:// GitHub repo urls, https:// is preferred.
- urls.grep(%r[^http://github\.com/.*\.git$]) do |u|
- problem "Use https:// URLs for accessing GitHub repositories (url is #{u})."
- end
-
- # Use new-style archive downloads
- urls.select { |u| u =~ %r[https://.*github.*/(?:tar|zip)ball/] && u !~ %r[\.git$] }.each do |u|
- problem "Use /archive/ URLs for GitHub tarballs (url is #{u})."
- end
-
- # Don't use GitHub .zip files
- urls.select { |u| u =~ %r[https://.*github.*/(archive|releases)/.*\.zip$] && u !~ %r[releases/download] }.each do |u|
- problem "Use GitHub tarballs rather than zipballs (url is #{u})."
- end
end
def audit_specs
@@ -828,13 +715,14 @@ def devel_only?(formula)
class ResourceAuditor
attr_reader :problems
- attr_reader :version, :checksum, :using, :specs, :url, :name
+ attr_reader :version, :checksum, :using, :specs, :url, :mirrors, :name
def initialize(resource)
@name = resource.name
@version = resource.version
@checksum = resource.checksum
@url = resource.url
+ @mirrors = resource.mirrors
@using = resource.using
@specs = resource.specs
@problems = []
@@ -844,6 +732,7 @@ def audit
audit_version
audit_checksum
audit_download_strategy
+ audit_urls
self
end
@@ -941,6 +830,116 @@ def audit_download_strategy
end
end
+ def audit_urls
+ # Check GNU urls; doesn't apply to mirrors
+ if url =~ %r[^(?:https?|ftp)://(?!alpha).+/gnu/]
+ problem "\"http://ftpmirror.gnu.org\" is preferred for GNU software (url is #{url})."
+ end
+
+ if mirrors.include?(url)
+ problem "URL should not be duplicated as a mirror: #{url}"
+ end
+
+ urls = [url] + mirrors
+
+ # Check a variety of SSL/TLS links that don't consistently auto-redirect
+ # or are overly common errors that need to be reduced & fixed over time.
+ urls.each do |p|
+ # Skip the main url link, as it can't be made SSL/TLS yet.
+ next if p =~ %r[/ftpmirror\.gnu\.org]
+
+ case p
+ when %r[^http://ftp\.gnu\.org/]
+ problem "ftp.gnu.org urls should be https://, not http:// (url is #{p})."
+ when %r[^http://[^/]*\.apache\.org/]
+ problem "Apache urls should be https://, not http (url is #{p})."
+ when %r[^http://code\.google\.com/]
+ problem "code.google.com urls should be https://, not http (url is #{p})."
+ when %r[^http://fossies\.org/]
+ problem "Fossies urls should be https://, not http (url is #{p})."
+ when %r[^http://mirrors\.kernel\.org/]
+ problem "mirrors.kernel urls should be https://, not http (url is #{p})."
+ when %r[^http://([^/]*\.|)bintray\.com/]
+ problem "Bintray urls should be https://, not http (url is #{p})."
+ when %r[^http://tools\.ietf\.org/]
+ problem "ietf urls should be https://, not http (url is #{p})."
+ end
+ end
+
+ # Check SourceForge urls
+ urls.each do |p|
+ # Skip if the URL looks like a SVN repo
+ next if p =~ %r[/svnroot/]
+ next if p =~ %r[svn\.sourceforge]
+
+ # Is it a sourceforge http(s) URL?
+ next unless p =~ %r[^https?://.*\b(sourceforge|sf)\.(com|net)]
+
+ if p =~ /(\?|&)use_mirror=/
+ problem "Don't use #{$1}use_mirror in SourceForge urls (url is #{p})."
+ end
+
+ if p =~ /\/download$/
+ problem "Don't use /download in SourceForge urls (url is #{p})."
+ end
+
+ if p =~ %r[^https?://sourceforge\.]
+ problem "Use http://downloads.sourceforge.net to get geolocation (url is #{p})."
+ end
+
+ if p =~ %r[^https?://prdownloads\.]
+ problem "Don't use prdownloads in SourceForge urls (url is #{p}).\n" +
+ "\tSee: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/"
+ end
+
+ if p =~ %r[^http://\w+\.dl\.]
+ problem "Don't use specific dl mirrors in SourceForge urls (url is #{p})."
+ end
+
+ if p.start_with? "http://downloads"
+ problem "Use https:// URLs for downloads from SourceForge (url is #{p})."
+ end
+ end
+
+ # Check for Google Code download urls, https:// is preferred
+ # Intentionally not extending this to SVN repositories due to certificate
+ # issues.
+ urls.grep(%r[^http://.*\.googlecode\.com/files.*]) do |u|
+ problem "Use https:// URLs for downloads from Google Code (url is #{u})."
+ end
+
+ # Check for new-url Google Code download urls, https:// is preferred
+ urls.grep(%r[^http://code\.google\.com/]) do |u|
+ problem "Use https:// URLs for downloads from code.google (url is #{u})."
+ end
+
+ # Check for git:// GitHub repo urls, https:// is preferred.
+ urls.grep(%r[^git://[^/]*github\.com/]) do |u|
+ problem "Use https:// URLs for accessing GitHub repositories (url is #{u})."
+ end
+
+ # Check for git:// Gitorious repo urls, https:// is preferred.
+ urls.grep(%r[^git://[^/]*gitorious\.org/]) do |u|
+ problem "Use https:// URLs for accessing Gitorious repositories (url is #{u})."
+ end
+
+ # Check for http:// GitHub repo urls, https:// is preferred.
+ urls.grep(%r[^http://github\.com/.*\.git$]) do |u|
+ problem "Use https:// URLs for accessing GitHub repositories (url is #{u})."
+ end
+
+ # Use new-style archive downloads
+ urls.select { |u| u =~ %r[https://.*github.*/(?:tar|zip)ball/] && u !~ %r[\.git$] }.each do |u|
+ problem "Use /archive/ URLs for GitHub tarballs (url is #{u})."
+ end
+
+ # Don't use GitHub .zip files
+ urls.select { |u| u =~ %r[https://.*github.*/(archive|releases)/.*\.zip$] && u !~ %r[releases/download] }.each do |u|
+ problem "Use GitHub tarballs rather than zipballs (url is #{u})."
+ end
+ end
+
+
def problem text
@problems << text
end | false |
Other | Homebrew | brew | 5c414dca5b5affb374bb5409b6d5564a448498dd.json | add audit check for explicit Python linkage
Verifies that CPython extension modules are not explicitly linked to a
Python framework, which should never be necessary.
Python's distutils uses -undefined dynamic_lookup, as seen here:
https://github.com/python/cpython/blob/9a77656/configure.ac#L2214-L2245
Closes Homebrew/homebrew#39405.
Signed-off-by: Tim D. Smith <git@tim-smith.us> | Library/Homebrew/formula_cellar_checks.rb | @@ -156,6 +156,23 @@ def check_openssl_links
EOS
end
+ def check_python_framework_links lib
+ python_modules = Pathname.glob lib/"python*/site-packages/**/*.so"
+ framework_links = python_modules.select do |obj|
+ dlls = obj.dynamically_linked_libraries
+ dlls.any? { |dll| /Python\.framework/.match dll }
+ end
+ return if framework_links.empty?
+
+ <<-EOS.undent
+ python modules have explicit framework links
+ These python extension modules were linked directly to a Python
+ framework binary. They should be linked with -undefined dynamic_lookup
+ instead of -lpython or -framework Python.
+ #{framework_links * "\n "}
+ EOS
+ end
+
def audit_installed
audit_check_output(check_manpages)
audit_check_output(check_infopages)
@@ -168,6 +185,7 @@ def audit_installed
audit_check_output(check_shadowed_headers)
audit_check_output(check_easy_install_pth(formula.lib))
audit_check_output(check_openssl_links)
+ audit_check_output(check_python_framework_links(formula.lib))
end
private | false |
Other | Homebrew | brew | 86612c253db302a4e5e2c4790f1cadc1d31812c6.json | anticipate python 3.5 in .pth audit | Library/Homebrew/formula_cellar_checks.rb | @@ -127,7 +127,7 @@ def check_shadowed_headers
end
def check_easy_install_pth lib
- pth_found = Dir["#{lib}/python{2.7,3.4}/site-packages/easy-install.pth"].map { |f| File.dirname(f) }
+ pth_found = Dir["#{lib}/python{2.7,3}*/site-packages/easy-install.pth"].map { |f| File.dirname(f) }
return if pth_found.empty?
<<-EOS.undent | false |
Other | Homebrew | brew | 83bcde23170ceed42f6b86b5ea66a5ce20e00ff4.json | Update links to GitHub's personal access token
The link for the page that allows creation of API tokens has changed
from /settings/applications to /settings/tokens. Also the wording
on that page calls them "personal access tokens", so update
Homebrew to be consistent with that.
Closes Homebrew/homebrew#39378.
Signed-off-by: Tim D. Smith <git@tim-smith.us> | Library/Homebrew/cmd/gist-logs.rb | @@ -27,7 +27,7 @@ def gistify_logs f
auth = :AUTH_TOKEN
unless HOMEBREW_GITHUB_API_TOKEN
- puts 'You can create an API token: https://github.com/settings/applications'
+ puts 'You can create a personal access token: https://github.com/settings/tokens'
puts 'and then set HOMEBREW_GITHUB_API_TOKEN as authentication method.'
puts
| true |
Other | Homebrew | brew | 83bcde23170ceed42f6b86b5ea66a5ce20e00ff4.json | Update links to GitHub's personal access token
The link for the page that allows creation of API tokens has changed
from /settings/applications to /settings/tokens. Also the wording
on that page calls them "personal access tokens", so update
Homebrew to be consistent with that.
Closes Homebrew/homebrew#39378.
Signed-off-by: Tim D. Smith <git@tim-smith.us> | Library/Homebrew/manpages/brew.1.md | @@ -554,8 +554,8 @@ can take several different forms:
editors will do strange things in this case.
* HOMEBREW\_GITHUB\_API\_TOKEN:
- A personal GitHub API Access token, which you can create at
- <https://github.com/settings/applications>. If set, GitHub will allow you a
+ 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`. | true |
Other | Homebrew | brew | 83bcde23170ceed42f6b86b5ea66a5ce20e00ff4.json | Update links to GitHub's personal access token
The link for the page that allows creation of API tokens has changed
from /settings/applications to /settings/tokens. Also the wording
on that page calls them "personal access tokens", so update
Homebrew to be consistent with that.
Closes Homebrew/homebrew#39378.
Signed-off-by: Tim D. Smith <git@tim-smith.us> | Library/Homebrew/utils.rb | @@ -332,7 +332,7 @@ def initialize(error)
super <<-EOS.undent
GitHub #{error}
HOMEBREW_GITHUB_API_TOKEN may be invalid or expired, check:
- https://github.com/settings/applications
+ https://github.com/settings/tokens
EOS
end
end | true |
Other | Homebrew | brew | 83bcde23170ceed42f6b86b5ea66a5ce20e00ff4.json | Update links to GitHub's personal access token
The link for the page that allows creation of API tokens has changed
from /settings/applications to /settings/tokens. Also the wording
on that page calls them "personal access tokens", so update
Homebrew to be consistent with that.
Closes Homebrew/homebrew#39378.
Signed-off-by: Tim D. Smith <git@tim-smith.us> | share/man/man1/brew.1 | @@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
-.TH "BREW" "1" "April 2015" "Homebrew" "brew"
+.TH "BREW" "1" "May 2015" "Homebrew" "brew"
.
.SH "NAME"
\fBbrew\fR \- The missing package manager for OS X
@@ -579,7 +579,7 @@ If set, Homebrew will use this editor when editing a single formula, or several
.
.TP
HOMEBREW_GITHUB_API_TOKEN
-A personal GitHub API Access token, which you can create at \fIhttps://github\.com/settings/applications\fR\. If set, GitHub will allow you a greater number of API requests\. See \fIhttps://developer\.github\.com/v3/#rate\-limiting\fR for more information\. Homebrew uses the GitHub API for features such as \fBbrew search\fR\.
+A personal access token for the GitHub API, which you can create at \fIhttps://github\.com/settings/tokens\fR\. If set, GitHub will allow you a greater number of API requests\. See \fIhttps://developer\.github\.com/v3/#rate\-limiting\fR for more information\. Homebrew uses the GitHub API for features such as \fBbrew search\fR\.
.
.TP
HOMEBREW_MAKE_JOBS | true |
Other | Homebrew | brew | 241831e263fc87bce3205204e296f11374878872.json | Add upgrade --all flag to bash completion script
Closes Homebrew/homebrew#39359.
Signed-off-by: Jack Nagel <jacknagel@gmail.com> | Library/Contributions/brew_bash_completion.sh | @@ -413,6 +413,7 @@ _brew_upgrade ()
case "$cur" in
--*)
__brewcomp "
+ --all
--build-from-source --build-bottle --force-bottle
--debug
--verbose | false |
Other | Homebrew | brew | 2e3a0263d4c91525dbb907122c87e90af75c20a2.json | audit: require https for all *.googlecode.com resources
Closes Homebrew/homebrew#39206.
Signed-off-by: Jack Nagel <jacknagel@gmail.com> | Library/Homebrew/cmd/audit.rb | @@ -381,6 +381,8 @@ def audit_urls
end
# Check for Google Code download urls, https:// is preferred
+ # Intentionally not extending this to SVN repositories due to certificate
+ # issues.
urls.grep(%r[^http://.*\.googlecode\.com/files.*]) do |u|
problem "Use https:// URLs for downloads from Google Code (url is #{u})."
end | false |
Other | Homebrew | brew | 74ea4bd31c44fec56b76aa0e6816003322e905d6.json | fileutils: use rm_rf to clean temp dir
Honestly, I don't know why git is broken under sandbox. But this seems
fix the problem in Homebrew/homebrew#38978.
Closes Homebrew/homebrew#39138.
Signed-off-by: Xu Cheng <xucheng@me.com> | Library/Homebrew/extend/fileutils.rb | @@ -19,7 +19,7 @@ def mktemp(prefix=name)
cd(prev)
end
ensure
- ignore_interrupts { rm_r(tmp) }
+ ignore_interrupts { rm_rf(tmp) }
end
end
module_function :mktemp | false |
Other | Homebrew | brew | fe588311cc7894818d6a6e9a8d916d26c47a0b47.json | Use predicate method | Library/Homebrew/cmd/test-bot.rb | @@ -147,7 +147,7 @@ def run
File.write(log_file_path, @output) if ARGV.include? "--keep-logs"
end
- exit 1 if ARGV.include?("--fail-fast") && @status == :failed
+ exit 1 if ARGV.include?("--fail-fast") && failed?
end
private | false |
Other | Homebrew | brew | a14085acd31b06bcac7b12c8d36b5951a2f71033.json | Default HOMEBREW_TEMP to Dir.tmpdir | Library/Homebrew/config.rb | @@ -49,7 +49,7 @@ def mkpath
HOMEBREW_LOGS = Pathname.new(ENV['HOMEBREW_LOGS'] || '~/Library/Logs/Homebrew/').expand_path
-HOMEBREW_TEMP = Pathname.new(ENV.fetch('HOMEBREW_TEMP', '/tmp'))
+HOMEBREW_TEMP = Pathname.new(ENV["HOMEBREW_TEMP"] || Dir.tmpdir)
if not defined? HOMEBREW_LIBRARY_PATH
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent.join("Homebrew") | false |
Other | Homebrew | brew | ba26567b0309d70030df9929d949c7988b250c4c.json | Manage sandbox test resources in setup/teardown | Library/Homebrew/test/test_sandbox.rb | @@ -4,25 +4,25 @@
class SandboxTest < Homebrew::TestCase
def setup
skip "sandbox not implemented" unless Sandbox.available?
+ @sandbox = Sandbox.new
+ @dir = Pathname.new(Dir.mktmpdir)
+ @file = @dir/"foo"
+ end
+
+ def teardown
+ @dir.rmtree
end
def test_allow_write
- s = Sandbox.new
- testpath = Pathname.new(TEST_TMPDIR)
- foo = testpath/"foo"
- s.allow_write foo
- s.exec "touch", foo
- assert_predicate foo, :exist?
- foo.unlink
+ @sandbox.allow_write @file
+ @sandbox.exec "touch", @file
+ assert_predicate @file, :exist?
end
def test_deny_write
- s = Sandbox.new
- testpath = Pathname.new(TEST_TMPDIR)
- bar = testpath/"bar"
shutup do
- assert_raises(ErrorDuringExecution) { s.exec "touch", bar }
+ assert_raises(ErrorDuringExecution) { @sandbox.exec "touch", @file }
end
- refute_predicate bar, :exist?
+ refute_predicate @file, :exist?
end
end | false |
Other | Homebrew | brew | ff34b1af3b0baf0ab64b3ad7bc2ec8972a8f3527.json | manpage: add missing document
Closes Homebrew/homebrew#38351.
Closes Homebrew/homebrew#38960.
Signed-off-by: Xu Cheng <xucheng@me.com> | Library/Homebrew/manpages/brew.1.md | @@ -94,7 +94,7 @@ Note that these flags should only appear after a command.
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]` <formulae>:
+ * `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`.
@@ -113,6 +113,10 @@ Note that these flags should only appear after a command.
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.
@@ -222,6 +226,11 @@ Note that these flags should only appear after a command.
If `--git` is passed, Homebrew will create a Git repository, useful for
creating patches to the software.
+ * `irb [--example]`:
+ Enter the interactive Homebrew Ruby shell.
+
+ If `--example` is passed, several examples will be shown.
+
* `leaves`:
Show installed formulae that are not dependencies of another installed formula.
@@ -333,6 +342,9 @@ Note that these flags should only appear after a command.
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` [<tap>]:
Tap a new formula repository from GitHub, or list existing taps.
| true |
Other | Homebrew | brew | ff34b1af3b0baf0ab64b3ad7bc2ec8972a8f3527.json | manpage: add missing document
Closes Homebrew/homebrew#38351.
Closes Homebrew/homebrew#38960.
Signed-off-by: Xu Cheng <xucheng@me.com> | share/man/man1/brew.1 | @@ -101,7 +101,7 @@ If \fB\-\-no\-fetch\fR is passed, Homebrew will not download \fIURL\fR to the ca
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 creating\.
.
.TP
-\fBdeps [\-\-1] [\-n] [\-\-union] [\-\-tree] [\-\-all] [\-\-installed]\fR \fIformulae\fR
+\fBdeps [\-\-1] [\-n] [\-\-union] [\-\-tree] [\-\-all] [\-\-installed] [\-\-skip\-build] [\-\-skip\-optional]\fR \fIformulae\fR
Show dependencies for \fIformulae\fR\. When given multiple formula arguments, show the intersection of dependencies for \fIformulae\fR, except when passed \fB\-\-tree\fR, \fB\-\-all\fR, or \fB\-\-installed\fR\.
.
.IP
@@ -122,6 +122,9 @@ If \fB\-\-all\fR is passed, show dependencies for all formulae\.
.IP
If \fB\-\-installed\fR is passed, show dependencies for all installed formulae\.
.
+.IP
+By default, \fBdeps\fR shows dependencies for \fIformulae\fR\. To skip the \fB:build\fR type dependencies, pass \fB\-\-skip\-build\fR\. Similarly, pass \fB\-\-skip\-optional\fR to skip \fB:optional\fR dependencies\.
+.
.TP
\fBdiy [\-\-name=<name>] [\-\-version=<version>]\fR
Automatically determine the installation prefix for non\-Homebrew software\.
@@ -240,6 +243,13 @@ Download and patch \fIformula\fR, then open a shell\. This allows the user to ru
If \fB\-\-git\fR is passed, Homebrew will create a Git repository, useful for creating patches to the software\.
.
.TP
+\fBirb [\-\-example]\fR
+Enter the interactive Homebrew Ruby shell\.
+.
+.IP
+If \fB\-\-example\fR is passed, several examples will be shown\.
+.
+.TP
\fBleaves\fR
Show installed formulae that are not dependencies of another installed formula\.
.
@@ -355,6 +365,10 @@ Search for \fItext\fR in the given package manager\'s list\.
Instantiate a Homebrew build environment\. Uses our years\-battle\-hardened Homebrew build logic to help your \fB\./configure && make && make install\fR or even your \fBgem install\fR 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\.
.
.TP
+\fBswitch\fR \fIname\fR \fIversion\fR
+Symlink all of the specific \fIversion\fR of \fIname\fR\'s install to Homebrew prefix\.
+.
+.TP
\fBtap\fR [\fItap\fR]
Tap a new formula repository from GitHub, or list existing taps\.
. | true |
Other | Homebrew | brew | cac6f2f07079c28450240800ba2ffd3b4104ea35.json | Fix variable name | Library/Homebrew/cmd/test.rb | @@ -38,7 +38,7 @@ def test
Utils.safe_fork do
if Sandbox.available? && ARGV.sandbox?
sandbox = Sandbox.new
- formula.logs.mkpath
+ f.logs.mkpath
sandbox.record_log(f.logs/"sandbox.test.log")
sandbox.allow_write_temp_and_cache
sandbox.allow_write_log(f) | false |
Other | Homebrew | brew | b42259f628eb6c7452b3d54b54b1fbd699c8c794.json | Fix variable name | Library/Homebrew/cmd/test.rb | @@ -39,7 +39,7 @@ def test
if Sandbox.available? && ARGV.sandbox?
sandbox = Sandbox.new
formula.logs.mkpath
- sandbox.record_log(formula.logs/"sandbox.test.log")
+ sandbox.record_log(f.logs/"sandbox.test.log")
sandbox.allow_write_temp_and_cache
sandbox.allow_write_log(f)
sandbox.exec(*args) | false |
Other | Homebrew | brew | c72505925184d305387ba6fab40c9501e7b3881b.json | upgrade: announce usage of --all.
Tell users that we will soon be migrating `--all` so it is required if
you wish to upgrade all formulae.
Closes Homebrew/homebrew#38572. | Library/Homebrew/cmd/upgrade.rb | @@ -5,10 +5,17 @@ module Homebrew
def upgrade
Homebrew.perform_preinstall_checks
- if ARGV.named.empty?
+ if ARGV.include?("--all") || ARGV.named.empty?
+ unless ARGV.include? "--all"
+ opoo <<-EOS.undent
+ brew upgrade with no arguments will change behaviour soon!
+ It currently upgrades all formula but this will soon change to require '--all'.
+ Please update any workflows, documentation and scripts!
+ EOS
+ end
outdated = Homebrew.outdated_brews(Formula.installed)
exit 0 if outdated.empty?
- else
+ elsif ARGV.named.any?
outdated = Homebrew.outdated_brews(ARGV.formulae)
(ARGV.formulae - outdated).each do |f|
@@ -20,6 +27,11 @@ def upgrade
end
end
exit 1 if outdated.empty?
+ else
+ # This will currently never be reached but is implemented to make the
+ # migration to --all easier in the future (as just the ARGV.named.empty?
+ # will need removed above).
+ odie "Either --all or one or more formulae must be specified!"
end
unless upgrade_pinned? | true |
Other | Homebrew | brew | c72505925184d305387ba6fab40c9501e7b3881b.json | upgrade: announce usage of --all.
Tell users that we will soon be migrating `--all` so it is required if
you wish to upgrade all formulae.
Closes Homebrew/homebrew#38572. | Library/Homebrew/manpages/brew.1.md | @@ -390,11 +390,15 @@ Note that these flags should only appear after a command.
If `--rebase` is specified then `git pull --rebase` is used.
- * `upgrade [install-options]` [<formulae>]:
+ * `upgrade [--all] [install-options]` [<formulae>]:
Upgrade outdated, unpinned brews.
Options for the `install` command are also valid here.
+ If `--all` is passed, upgrade all formulae. This is currently the same
+ behaviour as without `--all` but soon `--all` will be required to upgrade
+ all formulae.
+
If <formulae> are given, upgrade only the specified brews (but do so even
if they are pinned; see `pin`, `unpin`).
| true |
Other | Homebrew | brew | c72505925184d305387ba6fab40c9501e7b3881b.json | upgrade: announce usage of --all.
Tell users that we will soon be migrating `--all` so it is required if
you wish to upgrade all formulae.
Closes Homebrew/homebrew#38572. | share/man/man1/brew.1 | @@ -415,13 +415,16 @@ Fetch the newest version of Homebrew and all formulae from GitHub using \fBgit\f
If \fB\-\-rebase\fR is specified then \fBgit pull \-\-rebase\fR is used\.
.
.TP
-\fBupgrade [install\-options]\fR [\fIformulae\fR]
+\fBupgrade [\-\-all] [install\-options]\fR [\fIformulae\fR]
Upgrade outdated, unpinned brews\.
.
.IP
Options for the \fBinstall\fR command are also valid here\.
.
.IP
+If \fB\-\-all\fR is passed, upgrade all formulae\. This is currently the same behaviour as without \fB\-\-all\fR but soon \fB\-\-all\fR will be required to upgrade all formulae\.
+.
+.IP
If \fIformulae\fR are given, upgrade only the specified brews (but do so even if they are pinned; see \fBpin\fR, \fBunpin\fR)\.
.
.TP | true |
Other | Homebrew | brew | 8fe0b5681056fe2540aba05721bfc6cde363e8d8.json | Add support for extracting LHA archives | Library/Homebrew/download_strategy.rb | @@ -63,6 +63,10 @@ def lzippath
"#{HOMEBREW_PREFIX}/opt/lzip/bin/lzip"
end
+ def lhapath
+ "#{HOMEBREW_PREFIX}/opt/lha/bin/lha"
+ end
+
def cvspath
@cvspath ||= %W[
/usr/bin/cvs
@@ -192,6 +196,8 @@ def stage
when :lzip
with_system_path { pipe_to_tar(lzippath) }
chdir
+ when :lha
+ safe_system lhapath, "x", cached_location
when :xar
safe_system "/usr/bin/xar", "-xf", cached_location
when :rar | true |
Other | Homebrew | brew | 8fe0b5681056fe2540aba05721bfc6cde363e8d8.json | Add support for extracting LHA archives | Library/Homebrew/extend/pathname.rb | @@ -211,6 +211,8 @@ def compression_type
return :gzip_only
when ".bz2"
return :bzip2_only
+ when ".lha", ".lzh"
+ return :lha
end
# Get enough of the file to detect common file types | true |
Other | Homebrew | brew | 1f80d93d1b7921e35c8cfefcf7f6fbc1bb907a44.json | Acceptable-Formulae.md: fix a space. | share/doc/homebrew/Acceptable-Formulae.md | @@ -58,7 +58,7 @@ point it to the downloaded archive in order to avoid loading.
### We don’t like binary formulae
Our policy is that formulae in the core repository
([Homebrew/homebrew](https://github.com/Homebrew/homebrew)) must be built
-from source (or produce cross-platform binaries like e.g. Java).Binary-only
+from source (or produce cross-platform binaries like e.g. Java). Binary-only
formulae should go to [Homebrew/homebrew-binary](https://github.com/Homebrew/homebrew-binary).
### Stable versions | false |
Other | Homebrew | brew | 71c7781ecd673722b1fe8a9547cb57e9e6fb55a5.json | remove Bintray.version method
Closes Homebrew/homebrew#38587.
Signed-off-by: Xu Cheng <xucheng@me.com> | Library/Homebrew/bottles.rb | @@ -55,10 +55,6 @@ def self.repository(tap=nil)
return "bottles" if tap.to_s.empty?
"bottles-#{tap.sub(/^homebrew\/(homebrew-)?/i, "")}"
end
-
- def self.version(path)
- BottleVersion.parse(path).to_s
- end
end
class BottleCollector | false |
Other | Homebrew | brew | b3a38ea871434dae7c84f14c9e7ef9d8d968bb92.json | brew-test-bot: use pkg_version when uploading bottles | Library/Homebrew/cmd/test-bot.rb | @@ -771,8 +771,14 @@ def test_bot
formula_packaged = {}
Dir.glob("*.bottle*.tar.gz") do |filename|
- version = Bintray.version filename
formula_name = bottle_filename_formula_name filename
+ canonical_formula_name = if tap
+ "#{tap}/#{formula_name}"
+ else
+ formula_name
+ end
+ formula = Formulary.factory canonical_formula_name
+ version = formula.pkg_version
bintray_package = Bintray.package formula_name
existing_bottle = existing_bottles[formula_name]
| false |
Other | Homebrew | brew | e1611c4c224e83a1231cd1e5726bda37834feb87.json | brew-pull: use pkg_version when publishing bottles | Library/Homebrew/cmd/pull.rb | @@ -170,8 +170,7 @@ def pull
changed_formulae.each do |f|
ohai "Publishing on Bintray:"
package = Bintray.package f.name
- bottle = Bottle.new(f, f.bottle_specification)
- version = Bintray.version(bottle.url)
+ version = f.pkg_version
curl "--silent", "--fail",
"-u#{bintray_user}:#{bintray_key}", "-X", "POST",
"https://api.bintray.com/content/homebrew/#{repo}/#{package}/#{version}/publish" | false |
Other | Homebrew | brew | 913c12fd43909469829023d6d7d3de92e9503406.json | Keep subprocess code inside begin block | Library/Homebrew/utils/fork.rb | @@ -8,9 +8,8 @@ def self.safe_fork(&block)
read, write = IO.pipe
pid = fork do
- ENV["HOMEBREW_ERROR_PIPE"] = server.path
-
begin
+ ENV["HOMEBREW_ERROR_PIPE"] = server.path
server.close
read.close
write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) | false |
Other | Homebrew | brew | f5d6d80d5bac2c83a89021481812b461c54cfba3.json | ENV.deparallelize: add block form for temporary change
Closes Homebrew/homebrew#39026. | Library/Homebrew/extend/ENV/std.rb | @@ -78,8 +78,22 @@ def determine_pkg_config_libdir
paths.select { |d| File.directory? d }.join(File::PATH_SEPARATOR)
end
+ # Removes the MAKEFLAGS environment variable, causing make to use a single job.
+ # This is useful for makefiles with race conditions.
+ # When passed a block, MAKEFLAGS is removed only for the duration of the block and is restored after its completion.
+ # Returns the value of MAKEFLAGS.
def deparallelize
+ old = self['MAKEFLAGS']
remove 'MAKEFLAGS', /-j\d+/
+ if block_given?
+ begin
+ yield
+ ensure
+ self['MAKEFLAGS'] = old
+ end
+ end
+
+ old
end
alias_method :j1, :deparallelize
| true |
Other | Homebrew | brew | f5d6d80d5bac2c83a89021481812b461c54cfba3.json | ENV.deparallelize: add block form for temporary change
Closes Homebrew/homebrew#39026. | Library/Homebrew/extend/ENV/super.rb | @@ -241,8 +241,21 @@ def determine_cccfg
public
+ # Removes the MAKEFLAGS environment variable, causing make to use a single job.
+ # This is useful for makefiles with race conditions.
+ # When passed a block, MAKEFLAGS is removed only for the duration of the block and is restored after its completion.
+ # Returns the value of MAKEFLAGS.
def deparallelize
- delete('MAKEFLAGS')
+ old = delete('MAKEFLAGS')
+ if block_given?
+ begin
+ yield
+ ensure
+ self['MAKEFLAGS'] = old
+ end
+ end
+
+ old
end
alias_method :j1, :deparallelize
| true |
Other | Homebrew | brew | f5d6d80d5bac2c83a89021481812b461c54cfba3.json | ENV.deparallelize: add block form for temporary change
Closes Homebrew/homebrew#39026. | Library/Homebrew/test/test_ENV.rb | @@ -114,6 +114,14 @@ def test_switching_compilers_updates_compiler
assert_equal compiler, @env.compiler
end
end
+
+ def test_deparallelize_block_form_restores_makeflags
+ @env['MAKEFLAGS'] = '-j4'
+ @env.deparallelize do
+ assert_nil @env['MAKEFLAGS']
+ end
+ assert_equal '-j4', @env['MAKEFLAGS']
+ end
end
class StdenvTests < Homebrew::TestCase | true |
Other | Homebrew | brew | ec7b513a538a779e4ae585dfc9656865d0fb1e57.json | search: add homebrew/tex to search params
Closes Homebrew/homebrew#38855.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/cmd/search.rb | @@ -15,7 +15,7 @@ def search
elsif ARGV.include? '--debian'
exec_browser "https://packages.debian.org/search?keywords=#{ARGV.next}&searchon=names&suite=all§ion=all"
elsif ARGV.include? '--opensuse'
- exec_browser "http://software.opensuse.org/search?q=#{ARGV.next}"
+ exec_browser "https://software.opensuse.org/search?q=#{ARGV.next}"
elsif ARGV.include? '--fedora'
exec_browser "https://admin.fedoraproject.org/pkgdb/packages/%2A#{ARGV.next}%2A/"
elsif ARGV.include? '--ubuntu'
@@ -85,6 +85,7 @@ def search
%w{Homebrew binary},
%w{Homebrew python},
%w{Homebrew php},
+ %w{Homebrew tex},
%w{Homebrew x11},
%w{Caskroom cask},
] | false |
Other | Homebrew | brew | f56101a26ad435dcf87fec6363fc18b0c7938e58.json | Migrating-A-Formula-To-A-Tap: add commit format. | share/doc/homebrew/Migrating-A-Formula-To-A-Tap.md | @@ -2,7 +2,7 @@
There are times when we may wish to migrate a formula from Homebrew's core (the main repository) into a tap (another repository). To do this:
1. Create a pull request to the new tap adding the formula file as-is from the main Homebrew repository. Fix any test failures that may occur due to the stricter requirements for new formulae than existing formula (e.g. `brew audit --strict` must pass for that formula).
-2. Create a pull request to the main repository deleting the formula file and add it to `Library/Homebrew/tap_migrations.rb`.
+2. Create a pull request to the main repository deleting the formula file and add it to `Library/Homebrew/tap_migrations.rb` with a commit message like `gv: migrating to homebrew/x11`.
3. Put a link for each pull request in the other pull request so the maintainers can merge them both at once.
Congratulations, you've moved a formula to a tap! | false |
Other | Homebrew | brew | fbc47d86ad799124f2ae9c7fcf842bf3d39a46d8.json | sandbox: add deny_write_homebrew_library method | Library/Homebrew/cmd/postinstall.rb | @@ -25,9 +25,7 @@ def run_post_install(formula)
sandbox.allow_write_log(formula)
sandbox.allow_write_cellar(formula)
sandbox.allow_write_path HOMEBREW_PREFIX
- sandbox.deny_write_path HOMEBREW_LIBRARY
- sandbox.deny_write_path HOMEBREW_REPOSITORY/".git"
- sandbox.deny_write HOMEBREW_BREW_FILE
+ sandbox.deny_write_homebrew_library
sandbox.exec(*args)
else
exec(*args) | true |
Other | Homebrew | brew | fbc47d86ad799124f2ae9c7fcf842bf3d39a46d8.json | sandbox: add deny_write_homebrew_library method | Library/Homebrew/sandbox.rb | @@ -53,6 +53,12 @@ def allow_write_log(formula)
allow_write_path HOMEBREW_LOGS/formula.name
end
+ def deny_write_homebrew_library
+ deny_write_path HOMEBREW_LIBRARY
+ deny_write_path HOMEBREW_REPOSITORY/".git"
+ deny_write HOMEBREW_BREW_FILE
+ end
+
def exec(*args)
begin
seatbelt = Tempfile.new(["homebrew", ".sb"], HOMEBREW_TEMP) | true |
Other | Homebrew | brew | 4db3e51c8ec307ba0d068e4403f7a66805b3c3ff.json | test_pkg_version: remove illegal testcase
`Version` will not end with /_\d+/.
Closes Homebrew/homebrew#38822.
Signed-off-by: Xu Cheng <xucheng@me.com> | Library/Homebrew/test/test_pkg_version.rb | @@ -12,7 +12,6 @@ def test_parse
assert_equal PkgVersion.new(Version.new("1.0"), 0), PkgVersion.parse("1.0")
assert_equal PkgVersion.new(Version.new("1.0"), 0), PkgVersion.parse("1.0_0")
assert_equal PkgVersion.new(Version.new("2.1.4"), 0), PkgVersion.parse("2.1.4_0")
- assert_equal PkgVersion.new(Version.new("2.1.4_1"), 0), PkgVersion.parse("2.1.4_1_0")
assert_equal PkgVersion.new(Version.new("1.0.1e"), 1), PkgVersion.parse("1.0.1e_1")
end
| false |
Other | Homebrew | brew | 39b890e255fbee0f1bce1cc1e9ead28ff4be9e2e.json | Remove test that may alter the repository | Library/Homebrew/test/test_ENV.rb | @@ -127,24 +127,12 @@ def setup
class SuperenvTests < Homebrew::TestCase
include SharedEnvTests
- attr_reader :env, :bin
-
def setup
@env = {}.extend(Superenv)
- @bin = HOMEBREW_REPOSITORY/"Library/ENV/#{MacOS::Xcode.version}"
- bin.mkpath
- end
-
- def test_bin
- assert_equal bin, Superenv.bin
end
def test_initializes_deps
- assert_equal [], env.deps
- assert_equal [], env.keg_only_deps
- end
-
- def teardown
- bin.rmtree
+ assert_equal [], @env.deps
+ assert_equal [], @env.keg_only_deps
end
end | false |
Other | Homebrew | brew | d4c8f83381b909c7448c435244745d9ad08cc54b.json | Inline error message | Library/Homebrew/global.rb | @@ -107,9 +107,3 @@ module Homebrew
require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
ORIGINAL_PATHS = ENV['PATH'].split(File::PATH_SEPARATOR).map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
-
-SUDO_BAD_ERRMSG = <<-EOS.undent
- You can use brew with sudo, but only if the brew executable is owned by root.
- However, this is both not recommended and completely unsupported so do so at
- your own risk.
-EOS | true |
Other | Homebrew | brew | d4c8f83381b909c7448c435244745d9ad08cc54b.json | Inline error message | Library/brew.rb | @@ -102,7 +102,12 @@ def require? path
if sudo_check.include? cmd
if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
- raise "Cowardly refusing to `sudo brew #{cmd}`\n#{SUDO_BAD_ERRMSG}"
+ raise <<-EOS.undent
+ Cowardly refusing to `sudo brew #{cmd}`
+ You can use brew with sudo, but only if the brew executable is owned by root.
+ However, this is both not recommended and completely unsupported so do so at
+ your own risk.
+ EOS
end
end
| true |
Other | Homebrew | brew | 6278e08aec7697f15bfdc1c9a1032f8612f5357b.json | Use real repo to run tests | Library/Homebrew/test/test_ENV.rb | @@ -127,24 +127,12 @@ def setup
class SuperenvTests < Homebrew::TestCase
include SharedEnvTests
- attr_reader :env, :bin
-
def setup
@env = {}.extend(Superenv)
- @bin = HOMEBREW_REPOSITORY/"Library/ENV/#{MacOS::Xcode.version}"
- bin.mkpath
- end
-
- def test_bin
- assert_equal bin, Superenv.bin
end
def test_initializes_deps
- assert_equal [], env.deps
- assert_equal [], env.keg_only_deps
- end
-
- def teardown
- bin.rmtree
+ assert_equal [], @env.deps
+ assert_equal [], @env.keg_only_deps
end
end | true |
Other | Homebrew | brew | 6278e08aec7697f15bfdc1c9a1032f8612f5357b.json | Use real repo to run tests | Library/Homebrew/test/test_formula.rb | @@ -178,19 +178,7 @@ def test_path
end
def test_factory
- name = 'foo-bar'
- path = HOMEBREW_PREFIX+"Library/Formula/#{name}.rb"
- path.dirname.mkpath
- File.open(path, 'w') do |f|
- f << %{
- class #{Formulary.class_s(name)} < Formula
- url 'foo-1.0'
- end
- }
- end
- assert_kind_of Formula, Formulary.factory(name)
- ensure
- path.unlink
+ assert_kind_of Formula, Formulary.factory("tree")
end
def test_class_specs_are_always_initialized | true |
Other | Homebrew | brew | 6278e08aec7697f15bfdc1c9a1032f8612f5357b.json | Use real repo to run tests | Library/Homebrew/test/testing_env.rb | @@ -1,6 +1,7 @@
# Require this file to build a testing environment.
-$:.push(File.expand_path(__FILE__+'/../..'))
+repo_root = Pathname.new File.expand_path("../../../..", __FILE__)
+$: << repo_root.join("Library", "Homebrew").to_s
require 'extend/module'
require 'extend/fileutils'
@@ -19,8 +20,10 @@
# Constants normally defined in global.rb
HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix")
-HOMEBREW_REPOSITORY = HOMEBREW_PREFIX
+HOMEBREW_REPOSITORY = repo_root
+HOMEBREW_BREW_FILE = HOMEBREW_REPOSITORY+"bin"+"brew"
HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY+'Library'
+HOMEBREW_LIBRARY_PATH = HOMEBREW_LIBRARY+"Homebrew"
HOMEBREW_CACHE = HOMEBREW_PREFIX.parent+'cache'
HOMEBREW_CACHE_FORMULA = HOMEBREW_PREFIX.parent+'formula_cache'
HOMEBREW_CELLAR = HOMEBREW_PREFIX.parent+'cellar'
@@ -48,8 +51,7 @@
ORIGINAL_PATHS = ENV['PATH'].split(File::PATH_SEPARATOR).map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
# Test environment setup
-%w{ENV Formula}.each { |d| HOMEBREW_LIBRARY.join(d).mkpath }
-%w{cache formula_cache cellar logs}.each { |d| HOMEBREW_PREFIX.parent.join(d).mkpath }
+%w{prefix cache formula_cache cellar logs}.each { |d| HOMEBREW_PREFIX.parent.join(d).mkpath }
# Test fixtures and files can be found relative to this path
TEST_DIRECTORY = File.dirname(File.expand_path(__FILE__)) | true |
Other | Homebrew | brew | 033964fe87afe7ee95837c4e0050d3c6253e03c2.json | pull: fetch bottles with --retry. | Library/Homebrew/cmd/pull.rb | @@ -177,7 +177,7 @@ def pull
"https://api.bintray.com/content/homebrew/#{repo}/#{package}/#{version}/publish"
puts
sleep 2
- safe_system "brew", "fetch", "--force-bottle", f.name
+ safe_system "brew", "fetch", "--retry", "--force-bottle", f.name
end
else
opoo "You must set BINTRAY_USER and BINTRAY_KEY to add or update bottles on Bintray!" | false |
Other | Homebrew | brew | e370cd784bd678704046f3f508a016811ed8d725.json | formula_cellar_checks: fix memcached shadowing. | Library/Homebrew/formula_cellar_checks.rb | @@ -108,11 +108,8 @@ def check_shadowed_headers
return if formula.name == formula_name
end
- if MacOS.version < :mavericks &&
- (formula.name.start_with?("postgresql") ||
- formula.name.start_with?("memcached"))
- return
- end
+ return if MacOS.version < :mavericks && formula.name.start_with?("postgresql")
+ return if MacOS.version < :yosemite && formula.name.start_with?("memcached")
return if formula.keg_only? || !formula.include.directory?
| false |
Other | Homebrew | brew | 36576333274a609b6546d7f4c05f05909d87cfda.json | formula_cellar_checks: ignore memcached shadowing. | Library/Homebrew/formula_cellar_checks.rb | @@ -108,7 +108,12 @@ def check_shadowed_headers
return if formula.name == formula_name
end
- return if MacOS.version < :mavericks && formula.name.start_with?("postgresql")
+ if MacOS.version < :mavericks &&
+ (formula.name.start_with?("postgresql") ||
+ formula.name.start_with?("memcached"))
+ return
+ end
+
return if formula.keg_only? || !formula.include.directory?
files = relative_glob(formula.include, "**/*.h") | false |
Other | Homebrew | brew | 2f757ee5aae8fb480118196c0e62e43b165715ca.json | bottle_version: support openssl style | Library/Homebrew/bottle_version.rb | @@ -7,6 +7,10 @@ def self._parse spec
m = /[a-z]{3}\d-(\d{1}-\d{8})/.match(stem)
return m.captures.first unless m.nil?
+ # e.g. 1.0.2a-1 from openssl-1.0.2a-1.yosemite.bottle.1.tar.gz
+ m = /-(\d+\.\d+(\.\d+)+[a-z]-\d+)/.match(stem)
+ return m.captures.first unless m.nil?
+
# e.g. perforce-2013.1.610569-x86_64.mountain_lion.bottle.tar.gz
m = /-([\d\.]+-x86(_64)?)/.match(stem)
return m.captures.first unless m.nil? | true |
Other | Homebrew | brew | 2f757ee5aae8fb480118196c0e62e43b165715ca.json | bottle_version: support openssl style | Library/Homebrew/test/test_bottle_versions.rb | @@ -80,4 +80,9 @@ def test_gcc_versions_style
assert_version_detected '5-20150215',
'gcc5-5-20150215.yosemite.bottle.tar.gz'
end
+
+ def test_openssl_style
+ assert_version_detected '1.0.2a-1',
+ 'openssl-1.0.2a-1.yosemite.bottle.1.tar.gz'
+ end
end | true |
Other | Homebrew | brew | 47aae82d33a0dc76e5f759658480b4fa4fe0bd04.json | Remove bad test | Library/Homebrew/test/test_formula.rb | @@ -242,16 +242,6 @@ def test_head_ignores_revisions
assert_equal PkgVersion.parse('HEAD'), f.pkg_version
end
- def test_raises_when_non_formula_constant_exists
- const = :SomeConst
- Object.const_set(const, Module.new)
- begin
- assert_raises(FormulaUnavailableError) { Formulary.factory("some_const") }
- ensure
- Object.send(:remove_const, const)
- end
- end
-
def test_legacy_options
f = formula do
url "foo-1.0" | false |
Other | Homebrew | brew | 338a08d8d6f10596593bfdf5ebc80e83c390069f.json | Ask the formula if it can be cleaned up once | Library/Homebrew/cmd/cleanup.rb | @@ -42,12 +42,10 @@ def cleanup_cellar
def cleanup_formula f
if f.installed?
eligible_kegs = f.rack.subdirs.map { |d| Keg.new(d) }.select { |k| f.pkg_version > k.version }
- eligible_kegs.each do |keg|
- if f.can_cleanup?
- cleanup_keg(keg)
- else
- opoo "Skipping (old) keg-only: #{keg}"
- end
+ if eligible_kegs.any? && f.can_cleanup?
+ eligible_kegs.each { |keg| cleanup_keg(keg) }
+ else
+ eligible_kegs.each { |keg| opoo "Skipping (old) keg-only: #{keg}" }
end
elsif f.rack.subdirs.length > 1
# If the cellar only has one version installed, don't complain | false |
Other | Homebrew | brew | 505d06c1761dfb89961b4f6b8093c5d62248e5fb.json | Simplify cleanup eligibility check | Library/Homebrew/cmd/cleanup.rb | @@ -124,12 +124,9 @@ def can_cleanup?
true
elsif opt_prefix.directory?
# SHA records were added to INSTALL_RECEIPTS the same day as opt symlinks
- !Formula.installed.
- select{ |ff| ff.deps.map{ |d| d.to_s }.include? name }.
- map{ |ff| ff.rack.subdirs rescue [] }.
- flatten.
- map{ |keg_path| Tab.for_keg(keg_path).HEAD }.
- include? nil
+ Formula.installed.
+ select { |f| f.deps.any? { |d| d.name == name } }.
+ all? { |f| f.rack.subdirs.all? { |keg| Tab.for_keg(keg).HEAD } }
end
end
end | false |
Other | Homebrew | brew | c2dcd91bd1ff2b88836089043bbfffacbbc5c6f3.json | Eliminate a place where ARGV is mutated | Library/Homebrew/build.rb | @@ -36,13 +36,6 @@ def post_superenv_hacks
end
end
- def pre_superenv_hacks
- # Allow a formula to opt-in to the std environment.
- if (formula.env.std? || deps.any? { |d| d.name == "scons" }) && ARGV.env != "super"
- ARGV.unshift "--env=std"
- end
- end
-
def effective_build_options_for(dependent)
args = dependent.build.used_options
args |= Tab.for_formula(dependent).used_options
@@ -83,7 +76,6 @@ def install
fixopt(dep) unless dep.opt_prefix.directory?
end
- pre_superenv_hacks
ENV.activate_extensions!
if superenv? | true |
Other | Homebrew | brew | c2dcd91bd1ff2b88836089043bbfffacbbc5c6f3.json | Eliminate a place where ARGV is mutated | Library/Homebrew/formula_installer.rb | @@ -435,7 +435,12 @@ def sanitized_ARGV_options
args << "--verbose" if verbose?
args << "--debug" if debug?
args << "--cc=#{ARGV.cc}" if ARGV.cc
- args << "--env=#{ARGV.env}" if ARGV.env
+
+ if ARGV.env
+ args << "--env=#{ARGV.env}"
+ elsif formula.env.std? || formula.recursive_dependencies.any? { |d| d.name == "scons" }
+ args << "--env=std"
+ end
if formula.head?
args << "--HEAD" | true |
Other | Homebrew | brew | 06f72ab38f7330eaef9a4cc05dd31b35e8bf26f5.json | move safe_fork into a standalone method | Library/Homebrew/formula_installer.rb | @@ -11,8 +11,6 @@
require 'cmd/tap'
require 'hooks/bottles'
require 'debrew'
-require 'fcntl'
-require 'socket'
require 'sandbox'
class FormulaInstaller
@@ -458,19 +456,13 @@ def build_argv
end
def build
- socket_path = "#{Dir.mktmpdir("homebrew", HOMEBREW_TEMP)}/socket"
- server = UNIXServer.new(socket_path)
-
FileUtils.rm Dir["#{HOMEBREW_LOGS}/#{formula.name}/*"]
@start_time = Time.now
# 1. formulae can modify ENV, so we must ensure that each
# installation has a pristine ENV when it starts, forking now is
# the easiest way to do this
- read, write = IO.pipe
- ENV["HOMEBREW_ERROR_PIPE"] = socket_path
-
args = %W[
nice #{RUBY_PATH}
-W0
@@ -480,39 +472,13 @@ def build
#{formula.path}
].concat(build_argv)
- pid = fork do
- begin
- server.close
- read.close
- write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
- if Sandbox.available? && ARGV.sandbox?
- sandbox = Sandbox.new(formula)
- sandbox.exec(*args)
- else
- exec(*args)
- end
- rescue Exception => e
- Marshal.dump(e, write)
- write.close
- exit! 1
- end
- end
-
- ignore_interrupts(:quietly) do # the child will receive the interrupt and marshal it back
- begin
- socket = server.accept_nonblock
- rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
- retry unless Process.waitpid(pid, Process::WNOHANG)
+ Utils.safe_fork do
+ if Sandbox.available? && ARGV.sandbox?
+ sandbox = Sandbox.new(formula)
+ sandbox.exec(*args)
else
- socket.send_io(write)
+ exec(*args)
end
- write.close
- data = read.read
- read.close
- Process.wait(pid) unless socket.nil?
- raise Marshal.load(data) unless data.nil? or data.empty?
- raise Interrupt if $?.exitstatus == 130
- raise "Suspicious installation failure" unless $?.success?
end
raise "Empty installation" if Dir["#{formula.prefix}/*"].empty?
@@ -524,9 +490,6 @@ def build
formula.rack.rmdir_if_possible
end
raise
- ensure
- server.close
- FileUtils.rm_r File.dirname(socket_path)
end
def link(keg) | true |
Other | Homebrew | brew | 06f72ab38f7330eaef9a4cc05dd31b35e8bf26f5.json | move safe_fork into a standalone method | Library/Homebrew/utils.rb | @@ -4,6 +4,7 @@
require 'utils/json'
require 'utils/inreplace'
require 'utils/popen'
+require 'utils/fork'
require 'open-uri'
class Tty | true |
Other | Homebrew | brew | 06f72ab38f7330eaef9a4cc05dd31b35e8bf26f5.json | move safe_fork into a standalone method | Library/Homebrew/utils/fork.rb | @@ -0,0 +1,44 @@
+require "fcntl"
+require "socket"
+
+module Utils
+ def self.safe_fork(&block)
+ socket_path = "#{Dir.mktmpdir("homebrew", HOMEBREW_TEMP)}/socket"
+ server = UNIXServer.new(socket_path)
+ ENV["HOMEBREW_ERROR_PIPE"] = socket_path
+ read, write = IO.pipe
+
+ pid = fork do
+ begin
+ server.close
+ read.close
+ write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
+ yield
+ rescue Exception => e
+ Marshal.dump(e, write)
+ write.close
+ exit! 1
+ end
+ end
+
+ ignore_interrupts(:quietly) do # the child will receive the interrupt and marshal it back
+ begin
+ socket = server.accept_nonblock
+ rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
+ retry unless Process.waitpid(pid, Process::WNOHANG)
+ else
+ socket.send_io(write)
+ end
+ write.close
+ data = read.read
+ read.close
+ Process.wait(pid) unless socket.nil?
+ raise Marshal.load(data) unless data.nil? or data.empty?
+ raise Interrupt if $?.exitstatus == 130
+ raise "Suspicious failure" unless $?.success?
+ end
+ ensure
+ server.close
+ FileUtils.rm_r File.dirname(socket_path)
+ end
+end | true |
Other | Homebrew | brew | 3cc24528bffc615db84eab91f2ee8a82c77a9901.json | Revert "brew pull: add automatic tap repair"
This reverts commit bcd34ded9e4b17b8658b7ae947cd392a4e5942c0.
Closes Homebrew/homebrew#38658.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/cmd/pull.rb | @@ -187,8 +187,6 @@ def pull
ohai 'Patch changed:'
safe_system "git", "diff-tree", "-r", "--stat", revision, "HEAD"
- safe_system "brew", "tap", "--repair" if tap_name
-
if ARGV.include? '--install'
changed_formulae.each do |f|
ohai "Installing #{f.name}" | false |
Other | Homebrew | brew | 399388d8b9a29333135bd7bf2c4f7f159569d89b.json | brew pull: add automatic tap repair
At the moment, every time I pull a new formulae from a tap, I have to
fetch it with the fully qualified name, `brew fetch
homebrew/versions/duck123 `, which is fine, but then I also have to
install, test, and audit it in the same way, which isn’t fixed until I
tap repair, which gets a bit onerous.
This just adds a step to `brew pull` where it does the tap repair
automatically for taps.
Closes Homebrew/homebrew#37788.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/cmd/pull.rb | @@ -187,6 +187,8 @@ def pull
ohai 'Patch changed:'
safe_system "git", "diff-tree", "-r", "--stat", revision, "HEAD"
+ safe_system "brew", "tap", "--repair" if tap_name
+
if ARGV.include? '--install'
changed_formulae.each do |f|
ohai "Installing #{f.name}" | false |
Other | Homebrew | brew | 9cfd768bfef094122000bafbfee8172c8812afeb.json | formula: add more API docs for directories.
Closes Homebrew/homebrew#38571. | Library/Homebrew/formula.rb | @@ -262,6 +262,8 @@ def installed_prefix
end
end
+ # The currently installed version for this formula. Will raise an exception
+ # if the formula is not installed.
def installed_version
require 'keg'
Keg.new(installed_prefix).version
@@ -272,41 +274,140 @@ def installed_version
def prefix(v=pkg_version)
Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{v}")
end
+
# The parent of the prefix; the named directory in the cellar containing all
# installed versions of this software
def rack; prefix.parent end
+ # 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.
def bin; prefix+'bin' end
+
+ # The directory where the formula's documentation should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def doc; share+'doc'+name end
+
+ # 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.
def include; prefix+'include' end
+
+ # The directory where the formula's info files should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def info; share+'info' end
+
+ # 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.
def lib; prefix+'lib' end
+
+ # The directory where the formula's binaries should be installed.
+ # This is not symlinked into `HOMEBREW_PREFIX`.
+ # It is also commonly used to install files that we do not wish to be
+ # symlinked into HOMEBREW_PREFIX from one of the other directories and
+ # instead manually create symlinks or wrapper scripts into e.g. {#bin}.
def libexec; prefix+'libexec' end
+
+ # The root directory where the formula's manual pages should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
+ # Often one of the more specific `man` functions should be used instead
+ # e.g. {#man1}
def man; share+'man' end
+
+ # 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.
def man1; man+'man1' end
+
+ # The directory where the formula's man2 pages should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def man2; man+'man2' end
+
+ # 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.
def man3; man+'man3' end
+
+ # The directory where the formula's man4 pages should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def man4; man+'man4' end
+
+ # The directory where the formula's man5 pages should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def man5; man+'man5' end
+
+ # The directory where the formula's man6 pages should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def man6; man+'man6' end
+
+ # The directory where the formula's man7 pages should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def man7; man+'man7' end
+
+ # The directory where the formula's man8 pages should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def man8; man+'man8' end
+
+ # The directory where the formula's `sbin` binaries should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
+ # Generally we try to migrate these to {#bin} instead.
def sbin; prefix+'sbin' end
+
+ # 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.
def share; prefix+'share' end
+ # The directory where the formula's Frameworks should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
+ # This is not symlinked into `HOMEBREW_PREFIX`.
def frameworks; prefix+'Frameworks' end
+
+ # The directory where the formula's kernel extensions should be installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
+ # This is not symlinked into `HOMEBREW_PREFIX`.
def kext_prefix; prefix+'Library/Extensions' end
- # configuration needs to be preserved past upgrades
+ # The directory where the formula's configuration files should be installed.
+ # Anything using `etc.install` will not overwrite other files on e.g. upgrades
+ # but will write a new file named `*.default`.
+ # This directory is not inside the `HOMEBREW_CELLAR` so it is persisted
+ # across upgrades.
def etc; (HOMEBREW_PREFIX+'etc').extend(InstallRenamed) end
- # generally we don't want var stuff inside the keg
+ # The directory where the formula's variable files should be installed.
+ # This directory is not inside the `HOMEBREW_CELLAR` so it is persisted
+ # across upgrades.
def var; HOMEBREW_PREFIX+'var' end
+ # The directory where the formula's Bash completion files should be
+ # installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def bash_completion; prefix+'etc/bash_completion.d' end
+
+ # The directory where the formula's ZSH completion files should be
+ # installed.
+ # This is symlinked into `HOMEBREW_PREFIX` after installation or with
+ # `brew link` for formulae that are not keg-only.
def zsh_completion; share+'zsh/site-functions' end
- # for storing etc, var files for later copying from bottles
+ # 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.
def bottle_prefix; prefix+'.bottle' end
# override this to provide a plist | false |
Other | Homebrew | brew | c86166c43e1b980bc39bfc6c7646de984337ee85.json | pull: increase bottle publish wait timeout. | Library/Homebrew/cmd/pull.rb | @@ -176,7 +176,7 @@ def pull
"-u#{bintray_user}:#{bintray_key}", "-X", "POST",
"https://api.bintray.com/content/homebrew/#{repo}/#{package}/#{version}/publish"
puts
- sleep 1
+ sleep 2
safe_system "brew", "fetch", "--force-bottle", f.name
end
else | false |
Other | Homebrew | brew | a5c4eb2d3eae9e2fd7b7f0fd431fe763688af82b.json | cmake: adjust standard built type
Moves from None to Release, but comments out the standard release
CFLAGS so we can continue using our own.
Bumped Libgit2 as an example/test to play with.
Closes Homebrew/homebrew#37332, hopefully.
Closes Homebrew/homebrew#37361.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/formula.rb | @@ -466,17 +466,17 @@ def inspect
end
# Standard parameters for CMake builds.
- # Using Build Type "None" tells cmake to use our CFLAGS,etc. settings.
- # Setting it to Release would ignore our flags.
# Setting CMAKE_FIND_FRAMEWORK to "LAST" tells CMake to search for our
# libraries before trying to utilize Frameworks, many of which will be from
# 3rd party installs.
# Note: there isn't a std_autotools variant because autotools is a lot
# less consistent and the standard parameters are more memorable.
def std_cmake_args
%W[
+ -DCMAKE_C_FLAGS_RELEASE=
+ -DCMAKE_CXX_FLAGS_RELEASE=
-DCMAKE_INSTALL_PREFIX=#{prefix}
- -DCMAKE_BUILD_TYPE=None
+ -DCMAKE_BUILD_TYPE=Release
-DCMAKE_FIND_FRAMEWORK=LAST
-DCMAKE_VERBOSE_MAKEFILE=ON
-Wno-dev | false |
Other | Homebrew | brew | ac16822a16bc1fb33ca020f26b74e81ff85028e9.json | Prioritize TapDependency in parse_string_spec
test-bot expects the dependencies returned from SoftwareSpec#deps to
satisfy is_a?(TapDependency) if they come from a tap which might need to
be tapped. | Library/Homebrew/dependency_collector.rb | @@ -89,12 +89,12 @@ def parse_spec(spec, tags)
end
def parse_string_spec(spec, tags)
- if tags.empty?
+ if HOMEBREW_TAP_FORMULA_REGEX === spec
+ TapDependency.new(spec, tags)
+ elsif tags.empty?
Dependency.new(spec, tags)
elsif (tag = tags.first) && LANGUAGE_MODULES.include?(tag)
LanguageModuleDependency.new(tag, spec, tags[1])
- elsif HOMEBREW_TAP_FORMULA_REGEX === spec
- TapDependency.new(spec, tags)
else
Dependency.new(spec, tags)
end | false |
Other | Homebrew | brew | f5c8e3fdbd87ba53ea582d20fb539e9a83eb1d5c.json | Use UNIXSocket to pass file descriptor
This is a more standard way to pass fd in UNIX world.
At the same time, it helps to remove a few hacks and
simplifies the code in the sandbox.
Closes Homebrew/homebrew#38434.
Signed-off-by: Xu Cheng <xucheng@me.com> | Library/Homebrew/build.rb | @@ -10,6 +10,7 @@
require "extend/ENV"
require "debrew"
require "fcntl"
+require "socket"
class Build
attr_reader :formula, :deps, :reqs
@@ -172,7 +173,7 @@ def fixopt f
end
begin
- error_pipe = IO.new(ENV["HOMEBREW_ERROR_PIPE"].to_i, "w")
+ error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
# Invalidate the current sudo timestamp in case a build script calls sudo | true |
Other | Homebrew | brew | f5c8e3fdbd87ba53ea582d20fb539e9a83eb1d5c.json | Use UNIXSocket to pass file descriptor
This is a more standard way to pass fd in UNIX world.
At the same time, it helps to remove a few hacks and
simplifies the code in the sandbox.
Closes Homebrew/homebrew#38434.
Signed-off-by: Xu Cheng <xucheng@me.com> | Library/Homebrew/formula_installer.rb | @@ -11,6 +11,8 @@
require 'cmd/tap'
require 'hooks/bottles'
require 'debrew'
+require 'fcntl'
+require 'socket'
class FormulaInstaller
include FormulaCellarChecks
@@ -455,6 +457,9 @@ def build_argv
end
def build
+ socket_path = "#{Dir.mktmpdir("homebrew", HOMEBREW_TEMP)}/socket"
+ server = UNIXServer.new(socket_path)
+
FileUtils.rm Dir["#{HOMEBREW_LOGS}/#{formula.name}/*"]
@start_time = Time.now
@@ -463,8 +468,7 @@ def build
# installation has a pristine ENV when it starts, forking now is
# the easiest way to do this
read, write = IO.pipe
- # I'm guessing this is not a good way to do this, but I'm no UNIX guru
- ENV['HOMEBREW_ERROR_PIPE'] = write.to_i.to_s
+ ENV["HOMEBREW_ERROR_PIPE"] = socket_path
args = %W[
nice #{RUBY_PATH}
@@ -475,14 +479,11 @@ def build
#{formula.path}
].concat(build_argv)
- # Ruby 2.0+ sets close-on-exec on all file descriptors except for
- # 0, 1, and 2 by default, so we have to specify that we want the pipe
- # to remain open in the child process.
- args << { write => write } if RUBY_VERSION >= "2.0"
-
pid = fork do
begin
+ server.close
read.close
+ write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
exec(*args)
rescue Exception => e
Marshal.dump(e, write)
@@ -492,10 +493,17 @@ def build
end
ignore_interrupts(:quietly) do # the child will receive the interrupt and marshal it back
+ begin
+ socket = server.accept_nonblock
+ rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
+ retry unless Process.waitpid(pid, Process::WNOHANG)
+ else
+ socket.send_io(write)
+ end
write.close
data = read.read
read.close
- Process.wait(pid)
+ Process.wait(pid) unless socket.nil?
raise Marshal.load(data) unless data.nil? or data.empty?
raise Interrupt if $?.exitstatus == 130
raise "Suspicious installation failure" unless $?.success?
@@ -510,6 +518,9 @@ def build
formula.rack.rmdir_if_possible
end
raise
+ ensure
+ server.close
+ FileUtils.rm_r File.dirname(socket_path)
end
def link(keg) | true |
Other | Homebrew | brew | 3587dc441e0c7f649dbda67a12e4b4c87e434885.json | Remove duplication from cleanup methods | Library/Homebrew/cmd/cleanup.rb | @@ -25,14 +25,7 @@ def cleanup_logs
return unless HOMEBREW_LOGS.directory?
time = Time.now - 2 * 7 * 24 * 60 * 60 # two weeks
HOMEBREW_LOGS.subdirs.each do |dir|
- if dir.mtime < time
- if ARGV.dry_run?
- puts "Would remove: #{dir}"
- else
- puts "Removing: #{dir}..."
- dir.rmtree
- end
- end
+ cleanup_path(dir) { dir.rmtree } if dir.mtime < time
end
end
@@ -66,11 +59,8 @@ def cleanup_formula f
def cleanup_keg keg
if keg.linked?
opoo "Skipping (old) #{keg} due to it being linked"
- elsif ARGV.dry_run?
- puts "Would remove: #{keg} (#{keg.abv})"
else
- puts "Removing: #{keg}... (#{keg.abv})"
- keg.uninstall
+ cleanup_path(keg) { keg.uninstall }
end
end
@@ -87,17 +77,17 @@ def cleanup_cache
end
if f.version > version || ARGV.switch?('s') && !f.installed? || bottle_file_outdated?(f, file)
- cleanup_cached_file(file)
+ cleanup_path(file) { file.unlink }
end
end
end
- def cleanup_cached_file file
+ def cleanup_path(path)
if ARGV.dry_run?
- puts "Would remove: #{file} (#{file.abv})"
+ puts "Would remove: #{path} (#{path.abv})"
else
- puts "Removing: #{file}... (#{file.abv})"
- file.unlink
+ puts "Removing: #{path}... (#{path.abv})"
+ yield
end
end
| false |
Other | Homebrew | brew | cfc8ac0190a21375c98d004d6e400c74413b3dc0.json | test-bot: override existing Bintray bottles. | Library/Homebrew/cmd/test-bot.rb | @@ -786,8 +786,10 @@ def test_bot
formula_packaged[formula_name] = true
end
- content_url = "https://api.bintray.com/content/homebrew/#{bintray_repo}/#{bintray_package}/#{version}/#{filename}"
- content_url += "?publish=1&override=1" if existing_bottle
+ content_url = "https://api.bintray.com/content/homebrew"
+ content_url += "/#{bintray_repo}/#{bintray_package}/#{version}/#{filename}"
+ content_url += "?override=1"
+ content_url += "&publish=1" if existing_bottle
curl "--silent", "--fail", "-u#{bintray_user}:#{bintray_key}",
"-T", filename, content_url
puts | false |
Other | Homebrew | brew | 6370ccf9a81bbd9c0b4ddb6068a91c649529d514.json | list: exclude pypy from unbrewed
Excludes the PyPy paths from the unbrewed list, since we do the same
with Python.
Closes Homebrew/homebrew#38399. | Library/Homebrew/cmd/list.rb | @@ -34,6 +34,10 @@ def list
lib/gio/*
lib/node_modules/*
lib/python[23].[0-9]/*
+ lib/pypy/*
+ lib/pypy3/*
+ share/pypy/*
+ share/pypy3/*
share/doc/homebrew/*
share/info/dir
share/man/man1/brew.1 | false |
Other | Homebrew | brew | 27092cabc4bda0904e1616bb2e5d4d949dbd3178.json | Switch PkgVersion to use composition
Comparing PkgVersion and Version objects can produce nonsensical
results. For example, equality is not symmetric:
irb(main):002:0> PkgVersion.new("1.0", 0) == Version.new("1.0")
=> false
irb(main):003:0> Version.new("1.0") == PkgVersion.new("1.0", 0)
=> true
Rather than attempt to deal with subclass-superclass equality, let's use
composition and punt on the problem altogether. | Library/Homebrew/pkg_version.rb | @@ -1,36 +1,45 @@
-require 'version'
+require "version"
-class PkgVersion < Version
- attr_reader :version, :revision
+class PkgVersion
+ include Comparable
RX = /\A(.+?)(?:_(\d+))?\z/
def self.parse(path)
_, version, revision = *path.match(RX)
- new(version, revision)
+ version = Version.new(version)
+ new(version, revision.to_i)
end
def initialize(version, revision)
- super(version)
+ @version = version
+ @revision = version.head? ? 0 : revision
+ end
- if head?
- @revision = 0
- else
- @revision = revision.to_i
- end
+ def head?
+ version.head?
end
def to_s
if revision > 0
"#{version}_#{revision}"
else
- version
+ version.to_s
end
end
alias_method :to_str, :to_s
def <=>(other)
- return unless Version === other
- super.nonzero? || revision <=> other.revision
+ return unless PkgVersion === other
+ (version <=> other.version).nonzero? || revision <=> other.revision
end
+ alias_method :eql?, :==
+
+ def hash
+ version.hash ^ revision.hash
+ end
+
+ protected
+
+ attr_reader :version, :revision
end | true |
Other | Homebrew | brew | 27092cabc4bda0904e1616bb2e5d4d949dbd3178.json | Switch PkgVersion to use composition
Comparing PkgVersion and Version objects can produce nonsensical
results. For example, equality is not symmetric:
irb(main):002:0> PkgVersion.new("1.0", 0) == Version.new("1.0")
=> false
irb(main):003:0> Version.new("1.0") == PkgVersion.new("1.0", 0)
=> true
Rather than attempt to deal with subclass-superclass equality, let's use
composition and punt on the problem altogether. | Library/Homebrew/test/test_pkg_version.rb | @@ -7,13 +7,13 @@ def v(version)
end
def test_parse
- assert_equal PkgVersion.new("1.0", 1), PkgVersion.parse("1.0_1")
- assert_equal PkgVersion.new("1.0", 1), PkgVersion.parse("1.0_1")
- assert_equal PkgVersion.new("1.0", 0), PkgVersion.parse("1.0")
- assert_equal PkgVersion.new("1.0", 0), PkgVersion.parse("1.0_0")
- assert_equal PkgVersion.new("2.1.4", 0), PkgVersion.parse("2.1.4_0")
- assert_equal PkgVersion.new("2.1.4_1", 0), PkgVersion.parse("2.1.4_1_0")
- assert_equal PkgVersion.new("1.0.1e", 1), PkgVersion.parse("1.0.1e_1")
+ assert_equal PkgVersion.new(Version.new("1.0"), 1), PkgVersion.parse("1.0_1")
+ assert_equal PkgVersion.new(Version.new("1.0"), 1), PkgVersion.parse("1.0_1")
+ assert_equal PkgVersion.new(Version.new("1.0"), 0), PkgVersion.parse("1.0")
+ assert_equal PkgVersion.new(Version.new("1.0"), 0), PkgVersion.parse("1.0_0")
+ assert_equal PkgVersion.new(Version.new("2.1.4"), 0), PkgVersion.parse("2.1.4_0")
+ assert_equal PkgVersion.new(Version.new("2.1.4_1"), 0), PkgVersion.parse("2.1.4_1_0")
+ assert_equal PkgVersion.new(Version.new("1.0.1e"), 1), PkgVersion.parse("1.0.1e_1")
end
def test_comparison
@@ -25,16 +25,17 @@ def test_comparison
assert_operator v("HEAD"), :>, v("1.0")
assert_operator v("1.0"), :<, v("HEAD")
- v = PkgVersion.new("1.0", 0)
+ v = PkgVersion.new(Version.new("1.0"), 0)
assert_nil v <=> Object.new
assert_raises(ArgumentError) { v > Object.new }
+ assert_raises(ArgumentError) { v > Version.new("1.0") }
end
def test_to_s
- assert_equal "1.0", PkgVersion.new("1.0", 0).to_s
- assert_equal "1.0_1", PkgVersion.new("1.0", 1).to_s
- assert_equal "1.0", PkgVersion.new("1.0", 0).to_s
- assert_equal "1.0", PkgVersion.new("1.0", 0).to_s
- assert_equal "HEAD", PkgVersion.new("HEAD", 1).to_s
+ assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s
+ assert_equal "1.0_1", PkgVersion.new(Version.new("1.0"), 1).to_s
+ assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s
+ assert_equal "1.0", PkgVersion.new(Version.new("1.0"), 0).to_s
+ assert_equal "HEAD", PkgVersion.new(Version.new("HEAD"), 1).to_s
end
end | true |
Other | Homebrew | brew | 1b5fc1fb02691f0868f855443f1393568fe2b465.json | audit: enforce https for bare bintray.com domain
Closes Homebrew/homebrew#38302.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/cmd/audit.rb | @@ -338,7 +338,7 @@ def audit_urls
problem "Fossies urls should be https://, not http (url is #{p})."
when %r[^http://mirrors\.kernel\.org/]
problem "mirrors.kernel urls should be https://, not http (url is #{p})."
- when %r[^http://[^/]*\.bintray\.com/]
+ when %r[^http://([^/]*\.|)bintray\.com/]
problem "Bintray urls should be https://, not http (url is #{p})."
when %r[^http://tools\.ietf\.org/]
problem "ietf urls should be https://, not http (url is #{p})." | false |
Other | Homebrew | brew | 7de2d56f5282de4a46452ea15da4f6063c1bbbb5.json | Simplify versions code | Library/Homebrew/formula_versions.rb | @@ -7,22 +7,12 @@ class FormulaVersions
ErrorDuringExecution, LoadError,
]
- attr_reader :f
+ attr_reader :name, :repository, :entry_name
- def initialize(f)
- @f = f
- end
-
- def repository
- @repository ||= if f.tap?
- HOMEBREW_LIBRARY.join("Taps", f.tap)
- else
- HOMEBREW_REPOSITORY
- end
- end
-
- def entry_name
- @entry_name ||= f.path.relative_path_from(repository).to_s
+ def initialize(formula)
+ @name = formula.name
+ @repository = formula.tap? ? HOMEBREW_LIBRARY.join("Taps", formula.tap) : HOMEBREW_REPOSITORY
+ @entry_name = formula.path.relative_path_from(repository).to_s
end
def rev_list(branch="HEAD")
@@ -38,21 +28,22 @@ def file_contents_at_revision(rev)
end
def formula_at_revision(rev)
- FileUtils.mktemp(f.name) do
- path = Pathname.pwd.join("#{f.name}.rb")
+ FileUtils.mktemp(name) do
+ path = Pathname.pwd.join("#{name}.rb")
path.write file_contents_at_revision(rev)
+ old_const = Formulary.unload_formula(name)
+
begin
- old_const = Formulary.unload_formula(f.name)
nostdout { yield Formulary.factory(path.to_s) }
rescue *IGNORED_EXCEPTIONS => e
# We rescue these so that we can skip bad versions and
# continue walking the history
- ohai "#{e} in #{f.name} at revision #{rev}", e.backtrace if ARGV.debug?
+ ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
rescue FormulaUnavailableError
# Suppress this error
ensure
- Formulary.restore_formula(f.name, old_const)
+ Formulary.restore_formula(name, old_const)
end
end
end | false |
Other | Homebrew | brew | f51439329ba86ae6bbb9c513b03ec4f3eb23ef43.json | Remove dead code | Library/Homebrew/formula_versions.rb | @@ -25,19 +25,6 @@ def entry_name
@entry_name ||= f.path.relative_path_from(repository).to_s
end
- def each
- versions = Set.new
- rev_list do |rev|
- version = version_at_revision(rev)
- next if version.nil?
- yield version, rev if versions.add?(version)
- end
- end
-
- def repository_path
- Pathname.pwd == repository ? entry_name : f.path
- end
-
def rev_list(branch="HEAD")
repository.cd do
Utils.popen_read("git", "rev-list", "--abbrev-commit", "--remove-empty", branch, "--", entry_name) do |io|
@@ -50,10 +37,6 @@ def file_contents_at_revision(rev)
repository.cd { Utils.popen_read("git", "cat-file", "blob", "#{rev}:#{entry_name}") }
end
- def version_at_revision(rev)
- formula_at_revision(rev) { |f| f.version }
- end
-
def formula_at_revision(rev)
FileUtils.mktemp(f.name) do
path = Pathname.pwd.join("#{f.name}.rb") | false |
Other | Homebrew | brew | 6ca42964cb20a321be56180df9c568c1c016e84e.json | pathname: remove hyphen from BOTTLE_EXTNAME_RX
A hyphen is not a valid character in a Ruby symbol, and the bottle
tag should be a valid Ruby symbol for its use in the bottle stanza.
Closes Homebrew/homebrew#38235.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/extend/pathname.rb | @@ -7,7 +7,7 @@
class Pathname
include MachO
- BOTTLE_EXTNAME_RX = /(\.[-a-z0-9_]+\.bottle\.(\d+\.)?tar\.gz)$/
+ BOTTLE_EXTNAME_RX = /(\.[a-z0-9_]+\.bottle\.(\d+\.)?tar\.gz)$/
def install *sources
sources.each do |src| | false |
Other | Homebrew | brew | f6946cd9f644cb9686bf5541e11e463c0e8195af.json | audit: enforce https on *.bintray.com urls
Closes Homebrew/homebrew#38209.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/cmd/audit.rb | @@ -338,6 +338,8 @@ def audit_urls
problem "Fossies urls should be https://, not http (url is #{p})."
when %r[^http://mirrors\.kernel\.org/]
problem "mirrors.kernel urls should be https://, not http (url is #{p})."
+ when %r[^http://[^/]*\.bintray\.com/]
+ problem "Bintray urls should be https://, not http (url is #{p})."
when %r[^http://tools\.ietf\.org/]
problem "ietf urls should be https://, not http (url is #{p})."
end | false |
Other | Homebrew | brew | af66c12108466fe541403638a8742a9dc78039e3.json | Formula Cookbook: clarify new use of tag revision. | share/doc/homebrew/Formula-Cookbook.md | @@ -566,13 +566,14 @@ end
Homebrew understands `git`, `svn`, and `hg` URLs, and has a way to specify `cvs` repositories as a URL as well. You can test whether the `HEAD` is being built with `build.head?`.
-To use a specific commit, tag, or branch from a repository, specify head with the `:revision`, `:tag`, or `:branch` option, like so:
+To use a specific commit, tag, or branch from a repository, specify head with the `:tag` and `:revision`, `:revision`, or `:branch` option, like so:
```ruby
class Foo < Formula
head "https://github.com/some/package.git", :revision => "090930930295adslfknsdfsdaffnasd13"
# or :branch => "develop"
- # or :tag => "1_0_release"
+ # or :tag => "1_0_release",
+ # :revision => "090930930295adslfknsdfsdaffnasd13"
end
```
| false |
Other | Homebrew | brew | 150c052970c59b8ce4cda7c4b7d1128e60f416c3.json | add reference to Vim Syntax for Homebrew formulae
A simple vim plugin created by me. Hope it can help formula authors who use vim.
Closes Homebrew/homebrew#38150.
Signed-off-by: Xu Cheng <xucheng@me.com> | share/doc/homebrew/Tips-N'-Tricks.md | @@ -123,3 +123,7 @@ This sets the HOMEBREW_NO_EMOJI environment variable, causing homebrew to hide a
## Sublime text: Syntax for formulae including the diff
In Sublime Text 2/3, you can use Package Control to install [Homebrew-formula-syntax](https://github.com/samueljohn/Homebrew-formula-syntax).
+
+## Vim Syntax for formulae including the diff
+
+If you are vim user, you can install [brew.vim](https://github.com/xu-cheng/brew.vim) plugin. | false |
Other | Homebrew | brew | 9b75afcf4ae735cb197f0ef835e0052c94cdb666.json | Make Version#<=> allocation-free | Library/Homebrew/version.rb | @@ -201,8 +201,33 @@ def <=>(other)
return 1 if head? && !other.head?
return -1 if !head? && other.head?
- max = [tokens.length, other.tokens.length].max
- pad_to(max) <=> other.pad_to(max)
+ ltokens = tokens
+ rtokens = other.tokens
+ max = max(ltokens.length, rtokens.length)
+ l = r = 0
+
+ while l < max
+ a = ltokens[l] || NULL_TOKEN
+ b = rtokens[r] || NULL_TOKEN
+
+ if a == b
+ l += 1
+ r += 1
+ next
+ elsif a.numeric? && b.numeric?
+ return a <=> b
+ elsif a.numeric?
+ return 1 if a > NULL_TOKEN
+ l += 1
+ elsif b.numeric?
+ return -1 if b > NULL_TOKEN
+ r += 1
+ else
+ return a <=> b
+ end
+ end
+
+ return 0
end
alias_method :eql?, :==
@@ -219,22 +244,14 @@ def to_s
attr_reader :version
- def begins_with_numeric?
- tokens.first.numeric?
+ def tokens
+ @tokens ||= tokenize
end
- def pad_to(length)
- if begins_with_numeric?
- nums, rest = tokens.partition(&:numeric?)
- nums.fill(NULL_TOKEN, nums.length, length - tokens.length)
- nums.concat(rest)
- else
- tokens.dup.fill(NULL_TOKEN, tokens.length, length - tokens.length)
- end
- end
+ private
- def tokens
- @tokens ||= tokenize
+ def max(a, b)
+ a > b ? a : b
end
def tokenize | false |
Other | Homebrew | brew | 522f7ea8c729ef6a5fddc5921ba045713236c28d.json | Add tests for cp_path_sub | Library/Homebrew/test/test_pathname.rb | @@ -124,6 +124,18 @@ def test_install_renamed_directory
@dst.install @src
assert_equal "a", File.read(@dst+@src.basename+@file.basename)
end
+
+ def test_cp_path_sub_file
+ @file.write "a"
+ @file.cp_path_sub @src, @dst
+ assert_equal "a", File.read(@dst+"foo")
+ end
+
+ def test_cp_path_sub_directory
+ @dir.mkpath
+ @dir.cp_path_sub @src, @dst
+ assert_predicate @dst+@dir.basename, :directory?
+ end
end
class PathnameInstallTests < Homebrew::TestCase | false |
Other | Homebrew | brew | 8a8de3a29678eb64e7686bc5e35701edb84e9946.json | Add test for InstallRenamed on directories | Library/Homebrew/test/test_pathname.rb | @@ -117,6 +117,13 @@ def test_install_renamed
assert_equal "a", File.read(@dst+@file.basename)
assert_equal "b", File.read(@dst+"#{@file.basename}.default")
end
+
+ def test_install_renamed_directory
+ @dst.extend(InstallRenamed)
+ @file.write "a"
+ @dst.install @src
+ assert_equal "a", File.read(@dst+@src.basename+@file.basename)
+ end
end
class PathnameInstallTests < Homebrew::TestCase | false |
Other | Homebrew | brew | 4c21ad30d85b6b4e43c64c31c9466ca292df8216.json | Adjust variable in InstallRenamed test | Library/Homebrew/test/test_pathname.rb | @@ -107,15 +107,15 @@ def test_install_creates_intermediate_directories
end
def test_install_renamed
- @dir.extend(InstallRenamed)
+ @dst.extend(InstallRenamed)
@file.write "a"
- @dir.install @file
+ @dst.install @file
@file.write "b"
- @dir.install @file
+ @dst.install @file
- assert_equal "a", File.read(@dir+@file.basename)
- assert_equal "b", File.read(@dir+"#{@file.basename}.default")
+ assert_equal "a", File.read(@dst+@file.basename)
+ assert_equal "b", File.read(@dst+"#{@file.basename}.default")
end
end
| false |
Other | Homebrew | brew | 60fe954bfd6a8fe50ff576cd502ef92c25d41fe6.json | unpack: expand destdir in case a relative path is given
Fixes Homebrew/homebrew#38067. | Library/Homebrew/cmd/unpack.rb | @@ -13,7 +13,7 @@ def unpack
raise FormulaUnspecifiedError if formulae.empty?
if dir = ARGV.value("destdir")
- unpack_dir = Pathname.new(dir)
+ unpack_dir = Pathname.new(dir).expand_path
unpack_dir.mkpath
else
unpack_dir = Pathname.pwd | false |
Other | Homebrew | brew | 148ebcb72e609b3b49002cdf40a5620f4ec67344.json | Eliminate chdir from pathname tests | Library/Homebrew/test/test_pathname.rb | @@ -119,61 +119,55 @@ class PathnameInstallTests < PathnameExtensionTests
def setup_install_test
(@src+'a.txt').write 'This is sample file a.'
(@src+'b.txt').write 'This is sample file b.'
- cd(@src) { yield }
end
def test_install
- setup_install_test do
- @dst.install 'a.txt'
- end
+ setup_install_test
+ @dst.install @src+"a.txt"
assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
refute_predicate @dst+"b.txt", :exist?, "b.txt was installed."
end
def test_install_list
- setup_install_test do
- @dst.install %w[a.txt b.txt]
- end
+ setup_install_test
+ @dst.install [@src+"a.txt", @src+"b.txt"]
assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
def test_install_glob
- setup_install_test do
- @dst.install Dir['*.txt']
- end
+ setup_install_test
+ @dst.install Dir[@src+"*.txt"]
assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
def test_install_directory
- setup_install_test do
- mkdir_p 'bin'
- mv Dir['*.txt'], 'bin'
- @dst.install 'bin'
- end
+ setup_install_test
+ bin = @src+"bin"
+ bin.mkpath
+ mv Dir[@src+"*.txt"], bin
+ @dst.install bin
assert_predicate @dst+"bin/a.txt", :exist?, "a.txt was not installed"
assert_predicate @dst+"bin/b.txt", :exist?, "b.txt was not installed"
end
def test_install_rename
- setup_install_test do
- @dst.install 'a.txt' => 'c.txt'
- end
+ setup_install_test
+ @dst.install @src+"a.txt" => "c.txt"
assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
refute_predicate @dst+"b.txt", :exist?, "b.txt was installed"
end
def test_install_rename_more
- setup_install_test do
- @dst.install({'a.txt' => 'c.txt', 'b.txt' => 'd.txt'})
- end
+ setup_install_test
+ @dst.install(@src+"a.txt" => "c.txt", @src+"b.txt" => "d.txt")
assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
assert_predicate @dst+"d.txt", :exist?, "d.txt was not installed"
@@ -182,24 +176,23 @@ def test_install_rename_more
end
def test_install_rename_directory
- setup_install_test do
- mkdir_p 'bin'
- mv Dir['*.txt'], 'bin'
- @dst.install 'bin' => 'libexec'
- end
+ setup_install_test
+ bin = @src+"bin"
+ bin.mkpath
+ mv Dir[@src+"*.txt"], bin
+ @dst.install bin => "libexec"
refute_predicate @dst+"bin", :exist?, "bin was installed but not renamed"
assert_predicate @dst+"libexec/a.txt", :exist?, "a.txt was not installed"
assert_predicate @dst+"libexec/b.txt", :exist?, "b.txt was not installed"
end
def test_install_symlink
- setup_install_test do
- mkdir_p 'bin'
- mv Dir['*.txt'], 'bin'
- end
-
- @dst.install_symlink @src+'bin'
+ setup_install_test
+ bin = @src+"bin"
+ bin.mkpath
+ mv Dir[@src+"*.txt"], bin
+ @dst.install_symlink bin
assert_predicate @dst+"bin", :symlink?
assert_predicate @dst+"bin", :directory? | false |
Other | Homebrew | brew | b49d3bd0a99d2ffb7d85e0fd3a13decf820ff85c.json | Pull install tests into a separate class | Library/Homebrew/test/test_pathname.rb | @@ -95,6 +95,27 @@ def test_install_removes_original
refute_predicate @file, :exist?
end
+ def test_install_creates_intermediate_directories
+ touch @file
+ refute_predicate @dir, :directory?
+ @dir.install(@file)
+ assert_predicate @dir, :directory?
+ end
+
+ def test_install_renamed
+ @dir.extend(InstallRenamed)
+
+ @file.write "a"
+ @dir.install @file
+ @file.write "b"
+ @dir.install @file
+
+ assert_equal "a", File.read(@dir+@file.basename)
+ assert_equal "b", File.read(@dir+"#{@file.basename}.default")
+ end
+end
+
+class PathnameInstallTests < PathnameExtensionTests
def setup_install_test
(@src+'a.txt').write 'This is sample file a.'
(@src+'b.txt').write 'This is sample file b.'
@@ -186,23 +207,4 @@ def test_install_symlink
assert_predicate @dst+"bin/b.txt", :exist?
assert_predicate (@dst+"bin").readlink, :relative?
end
-
- def test_install_creates_intermediate_directories
- touch @file
- refute_predicate @dir, :directory?
- @dir.install(@file)
- assert_predicate @dir, :directory?
- end
-
- def test_install_renamed
- @dir.extend(InstallRenamed)
-
- @file.write "a"
- @dir.install @file
- @file.write "b"
- @dir.install @file
-
- assert_equal "a", File.read(@dir+@file.basename)
- assert_equal "b", File.read(@dir+"#{@file.basename}.default")
- end
end | false |
Other | Homebrew | brew | 53b7d45de8f38d1998e5c23a77064ae3df4be522.json | Do less work inside chdir blocks | Library/Homebrew/test/test_pathname.rb | @@ -96,100 +96,95 @@ def test_install_removes_original
end
def setup_install_test
- cd @src do
- (@src+'a.txt').write 'This is sample file a.'
- (@src+'b.txt').write 'This is sample file b.'
- yield
- end
+ (@src+'a.txt').write 'This is sample file a.'
+ (@src+'b.txt').write 'This is sample file b.'
+ cd(@src) { yield }
end
def test_install
setup_install_test do
@dst.install 'a.txt'
-
- assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
- refute_predicate @dst+"b.txt", :exist?, "b.txt was installed."
end
+
+ assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
+ refute_predicate @dst+"b.txt", :exist?, "b.txt was installed."
end
def test_install_list
setup_install_test do
@dst.install %w[a.txt b.txt]
-
- assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
- assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
+
+ assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
+ assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
def test_install_glob
setup_install_test do
@dst.install Dir['*.txt']
-
- assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
- assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
+
+ assert_predicate @dst+"a.txt", :exist?, "a.txt was not installed"
+ assert_predicate @dst+"b.txt", :exist?, "b.txt was not installed"
end
def test_install_directory
setup_install_test do
mkdir_p 'bin'
mv Dir['*.txt'], 'bin'
-
@dst.install 'bin'
-
- assert_predicate @dst+"bin/a.txt", :exist?, "a.txt was not installed"
- assert_predicate @dst+"bin/b.txt", :exist?, "b.txt was not installed"
end
+
+ assert_predicate @dst+"bin/a.txt", :exist?, "a.txt was not installed"
+ assert_predicate @dst+"bin/b.txt", :exist?, "b.txt was not installed"
end
def test_install_rename
setup_install_test do
@dst.install 'a.txt' => 'c.txt'
-
- assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
- refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
- refute_predicate @dst+"b.txt", :exist?, "b.txt was installed"
end
+
+ assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
+ refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
+ refute_predicate @dst+"b.txt", :exist?, "b.txt was installed"
end
def test_install_rename_more
setup_install_test do
@dst.install({'a.txt' => 'c.txt', 'b.txt' => 'd.txt'})
-
- assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
- assert_predicate @dst+"d.txt", :exist?, "d.txt was not installed"
- refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
- refute_predicate @dst+"b.txt", :exist?, "b.txt was installed but not renamed"
end
+
+ assert_predicate @dst+"c.txt", :exist?, "c.txt was not installed"
+ assert_predicate @dst+"d.txt", :exist?, "d.txt was not installed"
+ refute_predicate @dst+"a.txt", :exist?, "a.txt was installed but not renamed"
+ refute_predicate @dst+"b.txt", :exist?, "b.txt was installed but not renamed"
end
def test_install_rename_directory
setup_install_test do
mkdir_p 'bin'
mv Dir['*.txt'], 'bin'
-
@dst.install 'bin' => 'libexec'
-
- refute_predicate @dst+"bin", :exist?, "bin was installed but not renamed"
- assert_predicate @dst+"libexec/a.txt", :exist?, "a.txt was not installed"
- assert_predicate @dst+"libexec/b.txt", :exist?, "b.txt was not installed"
end
+
+ refute_predicate @dst+"bin", :exist?, "bin was installed but not renamed"
+ assert_predicate @dst+"libexec/a.txt", :exist?, "a.txt was not installed"
+ assert_predicate @dst+"libexec/b.txt", :exist?, "b.txt was not installed"
end
def test_install_symlink
setup_install_test do
mkdir_p 'bin'
mv Dir['*.txt'], 'bin'
+ end
- @dst.install_symlink @src+'bin'
-
- assert_predicate @dst+"bin", :symlink?
- assert_predicate @dst+"bin", :directory?
- assert_predicate @dst+"bin/a.txt", :exist?
- assert_predicate @dst+"bin/b.txt", :exist?
+ @dst.install_symlink @src+'bin'
- assert_predicate (@dst+"bin").readlink, :relative?
- end
+ assert_predicate @dst+"bin", :symlink?
+ assert_predicate @dst+"bin", :directory?
+ assert_predicate @dst+"bin/a.txt", :exist?
+ assert_predicate @dst+"bin/b.txt", :exist?
+ assert_predicate (@dst+"bin").readlink, :relative?
end
def test_install_creates_intermediate_directories | false |
Other | Homebrew | brew | 1351f67e91c75451fb2c7ce8f024adb86dcb542d.json | Make install_p and install_symlink_p private | Library/Homebrew/extend/pathname.rb | @@ -57,7 +57,7 @@ def install_p(src, new_basename)
FileUtils.mv src, dst
end
end
- protected :install_p
+ private :install_p
# Creates symlinks to sources in this folder.
def install_symlink *sources
@@ -79,7 +79,7 @@ def install_symlink_p(src, new_basename)
mkpath
FileUtils.ln_sf(src.relative_path_from(dst.parent), dst)
end
- protected :install_symlink_p
+ private :install_symlink_p
# we assume this pathname object is a file obviously
alias_method :old_write, :write if method_defined?(:write) | false |
Other | Homebrew | brew | edf205f5ca025254a286db4d057fe9badbf6baf0.json | aspell-dictionaries: use sha256 for resources
Closes Homebrew/homebrew#37962.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/cmd/aspell-dictionaries.rb | @@ -32,7 +32,7 @@ def aspell_dictionaries
resource "#{r.name}" do
url "#{r.url}"
mirror "#{r.mirrors.first}"
- sha1 "#{r.cached_download.sha1}"
+ sha256 "#{r.cached_download.sha256}"
end
EOS | false |
Other | Homebrew | brew | 68c7e1e30cbb96eee50472c19f866414188a5d65.json | Add protected reader for version value | Library/Homebrew/version.rb | @@ -192,7 +192,7 @@ def detected_from_url?
end
def head?
- @version == 'HEAD'
+ version == "HEAD"
end
def <=>(other)
@@ -207,16 +207,18 @@ def <=>(other)
alias_method :eql?, :==
def hash
- @version.hash
+ version.hash
end
def to_s
- @version.dup
+ version.dup
end
alias_method :to_str, :to_s
protected
+ attr_reader :version
+
def begins_with_numeric?
tokens.first.numeric?
end
@@ -236,7 +238,7 @@ def tokens
end
def tokenize
- @version.scan(SCAN_PATTERN).map! do |token|
+ version.scan(SCAN_PATTERN).map! do |token|
case token
when /\A#{AlphaToken::PATTERN}\z/o then AlphaToken
when /\A#{BetaToken::PATTERN}\z/o then BetaToken | false |
Other | Homebrew | brew | 03b309cc76f24f503e50fc4a830147242fdb84e8.json | Fix NullToken equality | Library/Homebrew/version.rb | @@ -30,6 +30,8 @@ def initialize(value=nil)
def <=>(other)
case other
+ when NullToken
+ 0
when NumericToken
other.value == 0 ? 0 : -1
when AlphaToken, BetaToken, RCToken | false |
Other | Homebrew | brew | 0d4f241d481ee5bc356366c7a1383541338d3365.json | Remove explicit type check | Library/Homebrew/version.rb | @@ -17,6 +17,10 @@ def inspect
def to_s
value.to_s
end
+
+ def numeric?
+ false
+ end
end
class NullToken < Token
@@ -76,6 +80,10 @@ def <=>(other)
-Integer(other <=> self)
end
end
+
+ def numeric?
+ true
+ end
end
class CompositeToken < StringToken
@@ -208,12 +216,12 @@ def to_s
protected
def begins_with_numeric?
- NumericToken === tokens.first
+ tokens.first.numeric?
end
def pad_to(length)
if begins_with_numeric?
- nums, rest = tokens.partition { |t| NumericToken === t }
+ nums, rest = tokens.partition(&:numeric?)
nums.fill(NULL_TOKEN, nums.length, length - tokens.length)
nums.concat(rest)
else | false |
Other | Homebrew | brew | 02cb05f22b4e66536409cd90dd7253d8ac7cd07d.json | audit: enforce https for apache.org
- including all apache.org subdomains
- for `homepage` as well
Closes Homebrew/homebrew#37778.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/cmd/audit.rb | @@ -301,6 +301,10 @@ def audit_urls
problem "Github Pages links should be https:// (URL is #{homepage})."
end
+ if homepage =~ %r[^http://[^/]*\.apache\.org/]
+ problem "Apache homepages should be https:// links (URL is #{homepage})."
+ end
+
# There's an auto-redirect here, but this mistake is incredibly common too.
# Only applies to the homepage and subdomains for now, not the FTP links.
if homepage =~ %r[^http://((?:build|cloud|developer|download|extensions|git|glade|help|library|live|nagios|news|people|projects|rt|static|wiki|www)\.)?gnome\.org]
@@ -326,8 +330,8 @@ def audit_urls
case p
when %r[^http://ftp\.gnu\.org/]
problem "ftp.gnu.org urls should be https://, not http:// (url is #{p})."
- when %r[^http://archive\.apache\.org/]
- problem "archive.apache.org urls should be https://, not http (url is #{p})."
+ when %r[^http://[^/]*\.apache\.org/]
+ problem "Apache urls should be https://, not http (url is #{p})."
when %r[^http://code\.google\.com/]
problem "code.google.com urls should be https://, not http (url is #{p})."
when %r[^http://fossies\.org/] | false |
Other | Homebrew | brew | fffba3dc7d9bdab6bbce5bed6a096e284fd78fd5.json | test-bot: remove another invalid XML character. | Library/Homebrew/cmd/test-bot.rb | @@ -823,7 +823,7 @@ def test_bot
if step.has_output?
# Remove invalid XML CData characters from step output.
- output = step.output.delete("\000\a\b\e\f")
+ output = step.output.delete("\000\a\b\e\f\x1f")
if output.bytesize > BYTES_IN_1_MEGABYTE
output = "truncated output to 1MB:\n" \ | false |
Other | Homebrew | brew | db05618561550c36d2d41b0ff5e6fea4bd6019d2.json | Use Dir.mktmpdir instead of shelling out to mktemp
Closes Homebrew/homebrew#37616. | Library/Homebrew/extend/fileutils.rb | @@ -1,29 +1,25 @@
-require 'fileutils'
+require "fileutils"
+require "tmpdir"
# We enhance FileUtils to make our Formula code more readable.
module FileUtils
# Create a temporary directory then yield. When the block returns,
# recursively delete the temporary directory.
def mktemp(prefix=name)
- # I used /tmp rather than `mktemp -td` because that generates a directory
- # name with exotic characters like + in it, and these break badly written
- # scripts that don't escape strings before trying to regexp them :(
-
- # If the user has FileVault enabled, then we can't mv symlinks from the
- # /tmp volume to the other volume. So we let the user override the tmp
- # prefix if they need to.
-
- tempd = with_system_path { `mktemp -d #{HOMEBREW_TEMP}/#{prefix}-XXXXXX` }.strip
- raise "Failed to create sandbox" if tempd.empty?
- prevd = pwd
- cd(tempd)
+ prev = pwd
+ tmp = Dir.mktmpdir(prefix, HOMEBREW_TEMP)
begin
- yield
+ cd(tmp)
+
+ begin
+ yield
+ ensure
+ cd(prev)
+ end
ensure
- cd(prevd)
- ignore_interrupts { rm_r(tempd) }
+ ignore_interrupts { rm_r(tmp) }
end
end
module_function :mktemp | false |
Other | Homebrew | brew | b03faffcc10ab7d174c8164d28739e71f9c9ce97.json | Remove unused argument | Library/Homebrew/utils.rb | @@ -326,23 +326,21 @@ def initialize(error)
end
end
- def open url, headers={}, &block
+ def open(url, &block)
# This is a no-op if the user is opting out of using the GitHub API.
return if ENV['HOMEBREW_NO_GITHUB_API']
require "net/https"
- default_headers = {
+ headers = {
"User-Agent" => HOMEBREW_USER_AGENT,
"Accept" => "application/vnd.github.v3+json",
}
- default_headers['Authorization'] = "token #{HOMEBREW_GITHUB_API_TOKEN}" if HOMEBREW_GITHUB_API_TOKEN
+ headers["Authorization"] = "token #{HOMEBREW_GITHUB_API_TOKEN}" if HOMEBREW_GITHUB_API_TOKEN
begin
- Kernel.open(url, default_headers.merge(headers)) do |f|
- yield Utils::JSON.load(f.read)
- end
+ Kernel.open(url, headers) { |f| yield Utils::JSON.load(f.read) }
rescue OpenURI::HTTPError => e
handle_api_error(e)
rescue EOFError, SocketError, OpenSSL::SSL::SSLError => e | false |
Other | Homebrew | brew | 2356131e5fc79983a53142a8cb71710fc97c01e8.json | Remove unnecessary default argument
This method is always called with two arguments. | Library/Homebrew/version.rb | @@ -161,7 +161,7 @@ def detected_from_url?
end
end
- def self.detect(url, specs={})
+ def self.detect(url, specs)
if specs.has_key?(:tag)
FromURL.new(specs[:tag][/((?:\d+\.)*\d+)/, 1])
else | false |
Other | Homebrew | brew | 097d5242c3c2b0a60694fa090f435d1a15e24e67.json | Simplify skip_executables option | Library/Homebrew/keg_fix_install_names.rb | @@ -73,8 +73,7 @@ def change_install_name(old, new, file)
# Note that this doesn't attempt to distinguish between libstdc++ versions,
# for instance between Apple libstdc++ and GNU libstdc++
def detect_cxx_stdlibs(options={})
- options = { :skip_executables => false }.merge(options)
- skip_executables = options[:skip_executables]
+ skip_executables = options.fetch(:skip_executables, false)
results = Set.new
mach_o_files.each do |file| | false |
Other | Homebrew | brew | 83080be4c1c84290bed5ed077bcb37f243c106d4.json | Use https for issue URL. | Library/Homebrew/os.rb | @@ -8,7 +8,7 @@ def self.linux?
end
if OS.mac?
- ISSUES_URL = "http://git.io/brew-troubleshooting"
+ ISSUES_URL = "https://git.io/brew-troubleshooting"
PATH_OPEN = "/usr/bin/open"
elsif OS.linux?
ISSUES_URL = "https://github.com/Homebrew/linuxbrew/wiki/troubleshooting" | false |
Other | Homebrew | brew | 21314474cdfa99e85b291bfc7480b3e253774fc8.json | audit: Clarify GNU url warning message
"ftpmirror.gnu.org" must have a protocol prefix of "http", not
"https".
Closes Homebrew/homebrew#37567.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com> | Library/Homebrew/cmd/audit.rb | @@ -311,7 +311,7 @@ def audit_urls
# Check GNU urls; doesn't apply to mirrors
urls.grep(%r[^(?:https?|ftp)://(?!alpha).+/gnu/]) do |u|
- problem "\"ftpmirror.gnu.org\" is preferred for GNU software (url is #{u})."
+ problem "\"http://ftpmirror.gnu.org\" is preferred for GNU software (url is #{u})."
end
# the rest of the checks apply to mirrors as well. | false |
Other | Homebrew | brew | 4057a68e6e074d9e3e42a7e94f89723804f9f998.json | add bottle? method to Tab
Closes Homebrew/homebrew#37621. | Library/Homebrew/tab.rb | @@ -155,6 +155,10 @@ def build_bottle?
built_as_bottle && !poured_from_bottle
end
+ def bottle?
+ built_as_bottle
+ end
+
def to_json
attributes = {
"used_options" => used_options.as_flags, | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.