Skip to content

Commit

Permalink
autoupdate: version 1.1.0
Browse files Browse the repository at this point in the history
Changes:
* No longer automatically upgrades all your packages by default. You can regain
this behaviour by passing `--upgrade` to the command.
* Default behaviour is to now run `brew update` once every 24 hours.
* You can now access the command summary by passing `--help` or `-h` as well as nothing.
* Added versioning to make it slightly clearer when the autoupdate command changes.

Future plans:
* Ability to pass specific formulae to the command so you can upgrade those automatically & selectively.
* Ability to choose how often the autoupdate is run. 24 hours will remain the default, but choice is good.

Welcome ideas on improvement if you have any specific requests/ideas/etc.

Closes Homebrew#1.
  • Loading branch information
DomT4 committed Jul 30, 2015
1 parent 5ffa50c commit 2ba69c3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmd/brew-autoupdate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@

module Homebrew
def autoupdate

path = File.expand_path("~/Library/LaunchAgents/homebrew.mxcl.autoupdate.plist")

if ARGV.empty?
if ARGV.empty? || ARGV.include?("--help") || ARGV.include?("-h")
puts <<-EOS.undent
Usage:
--start = Start autoupdating every 24 hours.
--stop = Stop autoupdating, but retain plist & logs.
--delete = Cancel the autoupdate, delete the plist and logs.
--upgrade = Also automatically upgrade your packages.
--version = Output this tool's current version.
EOS
end

if ARGV.include? "--version"
puts "Version 1.1.0, July 2015"
end

if ARGV.include? "--start"
auto_args = "#{HOMEBREW_PREFIX}/bin/brew update"
# Spacing at start of line is deliberate. Don't undo.
auto_args << " && #{HOMEBREW_PREFIX}/bin/brew upgrade -v" if ARGV.include? "--upgrade"

file = <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand All @@ -29,7 +38,7 @@ def autoupdate
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/bin/date && #{HOMEBREW_PREFIX}/bin/brew update && #{HOMEBREW_PREFIX}/bin/brew upgrade -v</string>
<string>/bin/date && #{auto_args}</string>
</array>
<key>RunAtLoad</key>
<true/>
Expand Down

0 comments on commit 2ba69c3

Please sign in to comment.