209 Commits

Author SHA1 Message Date
Xu Cheng
dff6bfde9a
ruby.sh: add test flag 2016-07-11 21:12:57 +08:00
Xu Cheng
534bf08ec3
brew.sh: new HOMEBREW_RUBY_PATH resolution logic
* Use vendor Ruby if it's present
* Install vendor Ruby for system without Ruby 2.x
2016-07-11 21:12:56 +08:00
Andrew Janke
f4b3dadb64 gist-logs: close temp file before passing to curl (#418)
Ensures that the data gets written to disk so curl can see it, avoiding
intermittent JSON parsing errors in gist creation.
2016-07-03 17:21:13 -04:00
Martin Afanasjew
1c27a75ca4 utils/lock.sh: remove redundant 'local' 2016-06-29 22:38:42 +02:00
Martin Afanasjew
b1811f2ef3 analytics: make Linux UUID generation more robust
Not every Linux system has a pre-installed `uuidgen` command (Debian
has a package `uuid-runtime` but doesn't install it by default). In
contrast, `/proc/sys/kernel/random/uuid` is always available on a modern
Linux system and produces type/version 4 UUIDs, just like `uuidgen`.

Closes #416.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-06-29 21:07:25 +02:00
Martin Afanasjew
271023c5e1 analytics: handle UUID generation errors
Avoid writing an empty UUID to the Git configuration file and disable
analytics temporarily to avoid sending bogus data with an invalid UUID.
2016-06-29 21:07:25 +02:00
Martin Afanasjew
324a34d8ea utils/git: provide git_path and git_version 2016-06-19 22:12:34 +02:00
Xu Cheng
8d64b6a02d introduce global lock directory (#337)
Since #292, HOMEBREW_CACHE was moved to a per-user directory. This makes
it unsuitable to store global lock files on multiple users environment.

Therefore, introducing a global lock directory `/Library/Lock.d` to
store lock files from formula lockers as well as `brew update`.
2016-06-08 17:29:03 +08:00
Mike McQuaid
8e0e1642ad Use curl for the GitHub API (#295)
* Move GitHub API module to utils/github.rb.

* Move curl method to utils/curl.rb.

* global: use long curl arguments and an array.

This makes the code more self-documenting.

* utils/curl: support reading curl's output.

* utils/github: use curl instead of open-uri.

It has far better proxy support.

* pull: set Homebrew user agent.

* gist-logs: remove trailing whitespace.

* gist-logs: use first instead of [0].

Easier to read.

* gist-logs: use curl-based GitHub.open method.
2016-06-03 13:05:18 +01:00
Martin Afanasjew
8486f6e04d Prefer $stderr over STDERR for consistency (#304)
Prior to this change there were only 3 instances of `STD(IN|OUT|ERR)`
versus 74 instances of `$std(in|out|err)` in the Homebrew code base. The
latter variant is also strongly suggested by bbatsov's Ruby Style Guide.
2016-06-01 09:45:49 +02:00
Mike McQuaid
7829af7508 bottle/test-bot: deep merge bottle JSON hashes. 2016-05-28 20:11:07 +01:00
Mike McQuaid
8ecfab8a59 utils/lock.sh: default to system Ruby if available (#271)
This avoids weird issues with custom Rubies.

Closes #253.
2016-05-23 14:36:25 +01:00
Xu Cheng
ad8f50ec6d add utils/lock.sh
a Bash implementation of lock using `flock(2)`.
2016-05-12 15:36:46 +08:00
Martin Afanasjew
44af0d80e8 utils/bottles: fix Regexp escaping for Ruby 1.8
Make sure `Regexp.escape` gets a string as Ruby 1.8 is unable to convert
the symbol to a string automatically. Related to changes from #168.
2016-05-08 20:35:52 +02:00
Mike McQuaid
931e292bf1 Make bottle code cross-platform. 2016-05-08 16:51:22 +01:00
Mike McQuaid
b7ac58b35e Don't report cask to analytics. 2016-05-04 17:50:36 +01:00
Mike McQuaid
0ef21ddf87 analytics: move to a class.
Global namespaces are good to avoid when possible.
2016-05-03 14:21:08 +01:00
Xu Cheng
98aff27317 add brew analytics command (#173) 2016-05-01 22:04:46 +08:00
Zhiming Wang
c63400d56b analytics: relocate UUID to homebrew.analyticsuuid in .git/config
This way analytics related settings and parameters (currently
analyticsdisabled, analyticsmessage and analyticsuuid) are all kept in
the same place.

Note that in this commit we offer a path of migration: if
~/.homebrew_analytics_user_uuid already exists, read the UUID from it,
write to homebrew.analyticsuuid, and remove it.

See more detailed discussions in #145.

Closes #162.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-04-30 22:40:55 +02:00
Andrew Janke
05efd70dc3 Analytics: Separate user-supplied and internal-use DISABLE_ANALYTICS (#155)
This prevents `brew` self-calls from interacting with the stickiness of
HOMEBREW_NO_ANALYTICS being persisted to the brew repo and accidentally
disabling analytics permanently when it should have been for just one run,
while restoring the stickiness of an explicit user-supplied
HOMEBREW_NO_ANALYTICS.
2016-04-26 04:28:38 -04:00
Xu Cheng
7aaaf9d8db fix setup-analytics (#154)
DO not invoke git config because HOMEBREW_NO_ANALYTICS, otherwise
it will disable analytics for everyone when running `brew update`
in following manners:
 * `brew update` will set HOMEBREW_NO_ANALYTICS because the absence of
   `homebrew.analyticsmessage`
 * `brew update-report` will set `homebrew.analyticsdisabled` because of
    HOMEBREW_NO_ANALYTICS.

Also reduce file IO.
2016-04-26 15:53:52 +08:00
Mike McQuaid
df489cfde2 More analytics tweaks.
Provide a single command that can be run to disable analytics, run it if
`HOMEBREW_NO_ANALYTICS` is ever set and remove the user UUID file in
that case too.

References https://github.com/Homebrew/brew/issues/142.
2016-04-25 18:51:00 -05:00
Mike McQuaid
1451553188 Ship analytics for Homebrew.
For more information and opt-out instructions please read:
https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Analytics.md#analytics
2016-04-23 14:27:09 +01:00
Andrew Janke
a3b70d38a7 brew-audit: pull style checks in to main audit output
This collects all violations for each formula in a single place, instead
of doing `brew style` outputs for all formulae first, and then the other
audit checks.

Closes #112.

Signed-off-by: Andrew Janke <andrew@apjanke.net>
2016-04-21 14:45:33 -04:00
Mike McQuaid
2671b9f55d analytics: roll tracking ID.
Someone else has been sending weird data to ours and it has bad initial
test data so let's roll it before we ship it to everyone on Saturday.
2016-04-21 08:06:12 +01:00
Mike McQuaid
f6d5ae2253 analytics: add more documentation, Linuxbrew ID. (#98) 2016-04-16 11:39:57 +01:00
Mike McQuaid
4e8c6e633c Document disabling of opt-in Homebrew analytics. (#79) 2016-04-12 12:17:56 +01:00
Mike McQuaid
0c85113053 Homebrew (opt-in) Analytics tweaks. (#57)
- add `HOMEBREW_PRODUCT` global variable
- only differentiate between `/usr/local` and `non-/usr/local` Homebrew
  prefixes to avoid sharing sensitive user information
- note if e.g. build errors are occurring under CI
- Add `HOMEBREW_NO_ANALYTICS` variable (this will be how people opt-out
  when this is enabled for everyone)
- Add `HOMEBREW_ANALYTICS_DEBUG` variable to output all the analytics
  that are sent
- Move Bash analytics code to `Library/Homebrew/utils/analytics.sh`
- Add documentation for our analytics and why/what/when/how and opt-out
- Only official Homebrew commands are reported
- Ruby analytics are now reported in a forked, background process
2016-04-12 11:02:22 +01:00
Martin Afanasjew
8ab2fb6868 analytics: avoid unnecessary string interpolation 2016-04-07 08:25:41 +02:00
Martin Afanasjew
e747648c53 always prefer HOMEBREW_CURL over plain 'curl' 2016-04-07 08:25:41 +02:00
Carlos D'Agostino
fa3c55aa65 utils/analytics: fix usage of undefined variable. 2016-04-04 17:14:03 +01:00
Mike McQuaid
1238c65ba1 utils: add analytics functions. 2016-04-04 12:27:47 +01:00
Xu Cheng
5560f5550d git: check homebrew/core existence before installing brewed git 2016-04-02 21:51:36 +08:00
Xu Cheng
e0e277ecde utils/git: various improvement
* Use `ENV/scm/git` to check whether git is installed.
* Use `brew install git` to enforce pre-install checks such as sudo
  check.
2016-03-21 19:07:38 +08:00
Baptiste Fontaine
169b8fc039 Revert "minor perf improvements"
This reverts commit 16a2a8274a7808e63a6c78475e12a7c0ef5812ef.
2015-12-26 23:00:38 +01:00
Baptiste Fontaine
48681c3f3a minor perf improvements
Closes Homebrew/homebrew#47224.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2015-12-26 22:58:26 +01:00
Xu Cheng
3638c057f0 FormulaInstaller: reset git_available? when installing git
Closes Homebrew/homebrew#43693

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-09-09 12:22:03 +08:00
Xu Cheng
c8efb05826 doctor: use Utils.git_available? instead of git? 2015-09-09 12:21:08 +08:00
Xu Cheng
4529df1246 git_available?: cache the result 2015-09-09 12:19:16 +08:00
Xu Cheng
71f794260b add git utils
Two methods:
* `Utils.git_available?` checks whether git is installed.
* `Utils.ensure_git_installed!` installs git for users who don't install
  Xcode or CLT.
2015-09-02 15:24:52 +08:00
Mike McQuaid
2c959a7d58 More API documentation.
And remove the documented stuff from the `example-formula.rb`.

Closes Homebrew/homebrew#43241.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-29 15:43:16 +01:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Jack Nagel
ff11789933 Close the socket after sending the file descriptor to the child
Fixes Homebrew/homebrew#39691.
2015-05-12 21:53:04 -04:00
Jack Nagel
c07da9485f The forked build process should never run at_exit handlers
We don't use at_exit anywhere that matters, but the test framework does.
2015-04-28 01:39:28 -04:00
Jack Nagel
913c12fd43 Keep subprocess code inside begin block 2015-04-25 23:22:58 -04:00
Jack Nagel
f7ded45bc7 Clean up socket and filesystem resources separately 2015-04-25 23:17:13 -04:00
Xu Cheng
06f72ab38f move safe_fork into a standalone method 2015-04-15 19:51:54 +08:00
Jack Nagel
aaaab946ec Make inreplace errors fatal
Closes Homebrew/homebrew#32649.
Closes Homebrew/homebrew#32703.
2014-09-28 01:11:31 -05:00
Jack Nagel
5c24b7330b Read if no block is passed to Utils.popen_read 2014-07-11 15:52:39 -05:00
Jack Nagel
ad27b21cd1 Add popen wrapper that does not invoke the shell 2014-07-05 13:50:54 -05:00