Commit graph

28 commits

Author SHA1 Message Date
Federico Bond
2b2f60921c Fix Error in checklinks. Closes #5752 2014-08-12 17:05:00 -03:00
Roland Walker
4713c79c89 Open.popen3 does not set $?, unless Ruby 1.8
This is possibly the cause of other glitches such as random
failures on Travis.

Ruby 1.8 popen3 does set global $? for the exit status, Ruby
1.9 and above does not.  For Ruby 2.0 users (Mavericks and
above with recent Homebrew), success or failure of the current
external command was determined by the exit status of some
previous command.

Closes caskroom/homebrew-fonts#186
2014-07-28 14:03:06 -04:00
Roland Walker
d9d3011c81 ignore non-XML hdiutil output preceding plists
unless `--debug` is in effect.  This reverts to previous
behavior WRT DMG licenses.  Trailing non-XML garbage will
still be emitted.
2014-07-14 14:15:51 -04:00
Roland Walker
deb79403e5 Improve plist handling for hdiutil commands
- Raise `CaskError` instead of `Plist::ParseError` from module
- Improve error message when parse result is empty
- remove leading garbage text and emit it to stderr (seen in #5060)
- remove trailing garbage text and emit it to stderr (seen in #4819)

This has the incidental effect of emitting DMG licenses during
installation, which seems desirable as permanent functionality.

If not permanent, the warnings to STDERR should still be kept
temporarily to help get better bug reports on `hdiutil`.

A bug wrt DMG licenses must have been introduced in one of
#4892, #4887, #4889, #4900, #4975, #4978, or #4857.  Presumably,
the cause is that STDERR was previously silenced when running
`hdiutil`.  It would be cleaner (and more reliable) to redirect
STDERR and examine it separately, rather than clean up the
merged outputs.

closes #4819
closes #5060
2014-06-25 10:30:49 -04:00
Roland Walker
99e6e02ab4 Remove comment recommending :silence_stderr
As parameter to the `run` method, but also exposed as interface to Cask authors
in eg `uninstall` `:script`.  The existing DSL design: `:stderr => :silence`
is more flexible/extensible.

References: #4688
2014-06-19 15:06:53 -04:00
Roland Walker
0b3134bc1c Merge pull request #4890 from rolandwalker/caskerror_exception_status
show process exit status in CaskError exception text
2014-06-14 20:33:28 -04:00
Roland Walker
bca0abb6bc process exit status in CaskError exception text 2014-06-14 20:19:59 -04:00
Roland Walker
630b1e3f89 add more detail to plist parse error messages 2014-06-14 20:03:13 -04:00
Roland Walker
9593e614b5 defensive driving against errors running hdiutil
This may not be strictly necessary.  But it should help track
down the `hdiutil` errors, which are persistent, but occasional,
and hard to reproduce. (We pass a flag to `hdiutil` to make
respond in XML.)
2014-06-14 10:55:04 -04:00
Roland Walker
4d199ada2d force UTF-8 encodings
Fixes #4677.  This change is necessitated by Homebrew's recent
switch to Ruby 2.x.  These changes may be incomplete and/or
may not work well with Ruby 1.8.  Travis should test Ruby 1.8
compatibility.
2014-06-07 17:04:42 -04:00
Roland Walker
660b4b08bf enforce valid values for :stderr on command.run 2014-02-15 12:21:27 -05:00
Roland Walker
5548bc4756 test valid keys in _process_options
add monkeypatch on Hash in utils.rb for `assert_valid_keys` method
2014-02-10 10:57:55 -05:00
Roland Walker
545fc276dc allow command.run without arguments
ie only an exectuable
2014-02-10 10:53:38 -05:00
Roland Walker
7d8abee751 don't choke when :args is not present
in _process_options
2014-02-10 10:53:30 -05:00
Victor Robertson
7f5fbf448c Process SystemCommand arguments in list format
Previously, SystemCommand commands and arguments were processed as
strings which caused problems during shell interpretation if the
arguments were not escaped properly.  Now all commands are expressed
as arrays and no longer require their arguments to be escaped.
Additionally, stderr and stdout could have been interleaved in the
past and now they are always separated.
2014-02-07 06:27:05 -06:00
Roland Walker
3cc22374f9 doubledash hygiene for external cmd: sudo, AND
also includes doubledash hygiene for any child commands following each sudo
2014-01-31 12:58:39 -05:00
Roland Walker
216444849e Add copious debugging with --debug
- add new file "cask/utils.rb" analogous to "utils.rb" in Homebrew
- define odebug and odumpcask, analogs of ohai and friends, but
  which only give output when --debug is in effect
- move the debug setting from an instance variable in Cask::CLI
  to a method Cask.debug, defined in "lib/cask/options.rb", which
  was added in #2276. (Perhaps options.rb should be merged back
  into Cask::CLI).
- sprinkle odebug statements liberally throughout the codebase
- update tests
2014-01-28 10:15:43 -05:00
Roland Walker
768b21eae8 always submit external commands in list form
For safety.
- This is a step toward reworking system_command.rb so that
invocations are done in list form on the back end, avoiding
surprises from quoting and shell metacharacters.
- There is one transitional hack here: the _quote method in
Cask::SystemCommand is modified to avoid double-quoting.  The
_quote method itself will go away in a future revision when
only list-forms are used.
- Casks using system are not touched. It seems natural to
address that when creating the DSL for after_install/before_install.
2014-01-24 20:58:03 -05:00
Roland Walker
7a0f9ef37f always use full path to external utilities
per #2029
2014-01-23 12:20:32 -05:00
phinze
27856b09f8 more robust plist parsing, and better error handling
hdiutil can output DMG agreement information before the output plist
xml, and our plist parser was choking on that text before the xml
started.

so now we scan to the beginning of an xml document before trying to
parse the xml.

also added much more explicit error handling around the plist parsing,
to hopefully catch related and future plist-related errors.

refs #914
2013-11-03 13:07:18 -06:00
phinze
c85ef168fc require most commands to succeed; cleanup on install failure
- add `run!` method which raises if command does not succeed
- use `run!` when the command we are running must succeed for things to
  move forward. this should help produce clearer error messages in
  failure scenarios.
- move caveats earlier in the install process so reports can be made
  about potential failures
- remove the destination tree on cask install failure, so the cask will
  not be considered installed
2013-10-20 16:52:51 -05:00
Kevin Deldycke
cc4e796a74 Add new cask for Prey project.
This cask install the batch version of Prey package, as detailed in:
http://support.preyproject.com/kb/installation/how-to-deploy-prey-in-batch-mode-mac-os

As it requires an API key to be installed, a warning is displayed to the
user with an explanation on how to fix the issue.

Also added -E option to sudo invocation so environment variables can be
passed to the installer.

closes #953

Signed-off-by: phinze <paul.t.hinze@gmail.com>
2013-10-20 13:18:54 -05:00
phinze
a9cd8e7101 fix a few bugs around recent changes
- re-added a lost nil guard on `Dmg` containers
 - `FakeSystemCommand` was still returning an array of split lines
   instead of a string, even though its real counterpart switched to
   string when install/uninstall landed
 - flushed out an alfred cli bug
 - moved plist parsing down to SystemCommand layer
2013-09-22 14:44:31 -05:00
phinze
711e44b405 reverse default for SystemCommand's print option
we were setting it to false basically everywhere and it was getting
a little silly
2013-09-22 13:44:29 -05:00
Paul Hinze
3c9423e8c6 naked pkg support + major container refactor
`Cask::Installer` was already much too complex, so I took this
opportunity to throw a `Cask::Container` abstraction around the
extraction part of the package install step.

It goes like this: a Cask's URL points to a Container of some sort. The
containers we currently support are: dmg, zip, tar, and (new) naked.
Naked refers to a raw file that just needs to be copied in place. This
currently just means a pkg file, but in the future it may expand.

A Container knows how to do two things: identify a path as being its
type (`Container.me?`) and extracting the contents of its container to
the proper destination for a Cask (`Container#extract`).

The first Cask we have that supports the naked pkg type is
`heroku-toolbelt`. (Thanks to @sheerun for the Cask definition.)

Other miscellania batched in with this refactor:

 - switched to an explicit require strategy rather than globbing
 - `Cask::Installer` is instantiated now to match its interface with
   other similar collaorators
 - simplified zip and tar identification to shorter strings rather than
   exact matches of full `file -Izb` output
 - `Cask::SystemCommand` gets explicit output redirection options
 - many rogue backticks replaced to properly use `SystemCommand`
 - fixed misnamed test file `link_checker_spec.rb`
 - remove some extraneous `after` clauses in tests; leaning more on
   `test/support/cleanup.rb` to uninstall for us
 - pkg uninstall `:files` gets a `-rf` to support removing dirs

refs #839 and #1043
2013-09-21 21:59:07 -05:00
phinze
171456dc98 support for install/uninstall
accepts a single argument, which is a relative path to a pkg
inside the extracted Cask; homebrew-cask will attempt to install this
pkg after the Cask is extracted via `installer`

because of the many different ways uninstallers work, this
has several features:

 - `:script`: a script in the Cask which serves as an uninstaller (e.g.
   Vagrant, VirtualBox), uses `:args`, and `:input` keys to interact
   with said script
 - `:pkgutil`: a regexp which captures all package_ids installed by this
   cask; homebrew-cask will list all files installed under these ids and
   remove them
 - `:launchctl`: a list of bundle_ids for services that should be
   removed by homebrew-cask
 - `:files`: a fallback list of files to manually remove; helps when
   uninstallers miss something

refs #661
2013-07-21 22:01:38 -05:00
phinze
ce94c6de2a update alfred linking to work with Alfred 2.0
i'm not going to worry about backwards compatibility with Alfred 1.X -
forward to the future!

closes #18
2013-05-11 13:53:10 -05:00
phinze
d4cecf35c9 programmatically modify alfred scope
refs #18
2013-04-28 13:56:26 -05:00