33 Commits

Author SHA1 Message Date
Martin Afanasjew
d4f5f0cec7 brew.sh: rename 'chdir' to 'safe_cd'
This is inspired by `safe_system` with basically the same implication
(fail on error), making the name a lot less confusing and avoiding a
clash with the `chdir` function previously defined in `bin/brew`.

Closes #414.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-06-29 13:38:50 +02:00
Elliot Saba
2ca6dbbe9d brew.rb: Don't ask xcrun for output if no CLT is installed (#334)
This avoids `xcrun` popups when installing Homebrew on a non-Xcode
non-CLT machine.
2016-06-08 14:53:10 +02:00
Martin Afanasjew
898cb93f78 brew.sh: fix code style inconsistency
Originally introduced by me in 77975168e0f2d5e6627d049d6055bc159e3fd89d.
2016-05-25 01:53:14 +02:00
Martin Afanasjew
406fdbb391 brew.sh: drop obsolete source in update-preinstall
No need to source `cmd/update.sh` if `homebrew-update` is not going to
be called directly. Amends 750bb24a787dc6e4a13f2b842a3e8dcb8d5fb761.
2016-05-18 18:26:05 +02:00
Xu Cheng
77836cfb3f fix shellcheck complaint 2016-05-13 14:41:29 +08:00
Xu Cheng
6eb2287221 move git shell function to brew.sh
git is also used in analytics.sh
2016-05-13 14:40:14 +08:00
Xu Cheng
750bb24a78 brew.sh: use brew update in update-preinstall
Preinstall update should be performed in a separate process,
so it can maintain and close its own update lock.
2016-05-13 14:39:16 +08:00
Xu Cheng
92934db202 move brew shell function to brew.sh 2016-05-13 14:37:18 +08:00
Mike McQuaid
931e292bf1 Make bottle code cross-platform. 2016-05-08 16:51:22 +01:00
Mike McQuaid
60e3737f17 update: improve some edge cases.
- When running `brew update` and there’s been no changes from upstream
on any repositories there’s no need to call the (relatively) slow `brew
update-report` when we already know what it will say (“Already up-to
date.”).
- When any`git fetch`es fail then throw out an error at the end of the
output and produce a failing exit code (closes #65).
2016-05-03 14:24:41 +01:00
Xu Cheng
98aff27317 add brew analytics command (#173) 2016-05-01 22:04:46 +08:00
Mike McQuaid
0e8140b012 brew.sh: error out if no Ruby found.
This is a nicer error message than the `exec` failing at a later stage.
2016-04-18 15:16:43 +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
Mike McQuaid
4a7cd160c3 Auto-update when running brew install/upgrade.
Also, slightly tweak the behavior of `brew update` in this case so that
it doesn't print annoying output and still allows the `brew edit` flow
for people with `HOMEBREW_DEVELOPER` set.
2016-04-11 09:31:50 +01:00
Max Nordlund
b21f699ff2 Implement the brew help command
This is also used by `brew <cmd> --help`. The basic idea is to have the
documentation as a top level comment in each command file. To find these
comments, they have to be like this `#:`.

This is also used by the `brew man` command to keep the documentation
DRY, and for that there are now a header and footer for the man page.
2016-04-10 22:59:24 +02:00
Martin Afanasjew
6a82bc49c7 brew.sh: make sure to always use system 'awk'
This should prevent issues like #47 and make us more resilient.
2016-04-08 16:32:05 +02:00
Martin Afanasjew
f3cc0596a6 brew.sh: tweak HOMEBREW_PROCESSOR on Linux
`uname -p` seems to be less useful on Linux (Debian 8 yields `unknown`),
thus prefer `uname -m` on those systems to determine the processor type.

Closes #35.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-04-07 08:25:41 +02:00
Martin Afanasjew
2ca97490af brew.sh: fix HOMEBREW_OS_VERSION on Linux et al.
On Linux (and other non-OS X platforms), `HOMEBREW_OS_VERSION` was
*always* replaced with the product name, leading to less useful user
agent. E.g., on a reasonably up-to-date Debian system:
  Linuxbrew/0.9.9 (Linux; unknown Linuxbrew)

With this fix the user agent is instead (first if `lsb_release` is
available and outputs something, second otherwise):
  Linuxbrew/0.9.9 (Linux; unknown Debian GNU/Linux 8.3 (jessie))
  Linuxbrew/0.9.9 (Linux; unknown 3.16.0-4-amd64)
2016-04-07 08:25:41 +02:00
Martin Afanasjew
d83cd56603 brew.sh: avoid unnecessary 'cat'
Bash can read directly from a file in its command substitution.
2016-04-07 08:25:41 +02:00
Martin Afanasjew
b2fe2945d3 brew.sh: simplify HOMEBREW_OSX_VERSION_NUMERIC
Use `printf -v` and strip out the unnecessary `echo`, thus avoiding two
unnecessary command substitutions.
2016-04-07 08:25:41 +02:00
Martin Afanasjew
3a99d8093c brew.sh: streamline setting HOMEBREW_{OSX,LINUX}
For uses like this one, `case` is much more compact and easier to read.
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
Martin Afanasjew
15b42301e5 brew.sh: make analytics 'curl' fully asynchronous
If analytics are enabled and `brew` is used in a command substitution
context, e.g. `brew search` for tab completion, the result is that even
though the Google Analytics `curl` process runs in the background it
still is attached to the captured `stdout`, thus could theoretically
contribute to the result of the command substitution and consequently
makes the command substitution block on the completion of this process.
Redirecting `stdout` (and `stderr` for good measure) to `/dev/null`
makes this process truly asynchronous in these contexts.

Furthermore, even if the process is in the background, it is still
included in the shell's job list and thus shell internals like `wait`
(used in `cmd/update.sh`) have to wait on this process, even if they
never intended to do so. Removing the analytics process from the job
list via `disown` avoids this unintended effect.

Fixes #29.

Closes #34.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-04-06 10:28:06 +02:00
Mike McQuaid
0b79f48aad Add opt-in Google Analytics.
Add the first Google Analytics usage to monitor the command names that
are run by Homebrew.
2016-04-04 12:25:11 +01:00
Mike McQuaid
77611bafb1 Make Homebrew user agent consistent, use a slash.
Generally it seems user agents are all `software/version` but ours is
not. Also, set the user agent in a way that it's shared between Bash
and Ruby code.

Closes https://github.com/Homebrew/legacy-homebrew/pull/50480.
2016-04-04 12:18:21 +01:00
Xu Cheng
edf000e4cd Core/formula separation Part 2(b)
* move shell completion scripts to where can be auto picked up

Let's use switching new remote as opportunity to put shell completion
scripts to where they should be and avoid git conflict during the process.

* add Library/Formula and Library/Aliases symlinks

Formulae and Aliases has been relocated to homebrew/core tap.
The symlinks are pointed to new location to keep backward compatibility.

* remove formula_renames and tap_migrations

They have been replaced by the json files in the core tap.

* update: set new remote

* bump Homebrew version to 0.9.9
2016-04-03 18:34:17 +08:00
Xu Cheng
1084b53d52 bump Homebrew version to 0.9.8
So we can know whether a Homebrew installation is pre or post
core/formula separation.

Will update to 0.9.9 when moving core code to new repo.
2016-04-02 21:51:36 +08:00
Mike McQuaid
2c3a7e8c75 Fix brew update user agent.
This needs to be `Homebrew $HOMEBREW_VERSION` so we can be adequately
filtered.

Closes Homebrew/homebrew#49961.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-03-11 13:32:54 +08:00
Xu Cheng
e8caa48cc2 brew.sh: add tap-pin to sudo check list 2016-03-09 19:35:41 +08:00
Martin Afanasjew
bd679c7dc3 brew.sh: improve empty argument handling
Follow-up to Homebrew/homebrew#49327 that leaves empty argument handling to the Ruby code
(it is a bit more sophisticated and distinguished between `help` and an
empty argument list and treats them differently) instead of hard-wiring
the former to the `help` command.

Closes Homebrew/homebrew#49538.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-02-27 18:34:31 +01:00
Martin Afanasjew
2ab4f74527 brew.sh: drop reference to removed 'update-ruby'
This is a follow-up fix to a minor oversight in Homebrew/homebrew#49523.
2016-02-26 14:33:40 +01:00
Misty De Meo
d431f20d88 brew: print help when no commands given
Fixes Homebrew/homebrew#49325.

Closes Homebrew/homebrew#49327.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-19 09:04:22 +00:00
Mike McQuaid
691e4aec11 bin/brew: move logic to Library.
`bin/brew` is getting a bit bloated and it's annoying to open all of
`HOMEBREW_PREFIX` in your editor of choice and have it search through
the `Cellar`. Let's instead keep the bare minimum in `bin/brew` and
move the rest to `Library`.

Closes Homebrew/homebrew#49185.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-16 09:31:58 +00:00