-
-
Save mnewt/433dd0e18a7693710cdf7e19a80a3bdd to your computer and use it in GitHub Desktop.
backup Homebrew packages. See http://www.topbug.net/blog/2013/12/07/back-up-homebrew-packages/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
brew_command=/usr/local/bin/brew | |
brew_cask_command="$brew_command cask" | |
echo '#!/bin/bash' | |
echo '' | |
echo 'trap ctrl_c INT' | |
echo 'function ctrl_c() {' | |
echo 'echo "** Trapped CTRL-C"' | |
echo 'exit 1' | |
echo '}' | |
echo '' | |
echo 'brew_command=/usr/local/bin/brew' | |
echo 'brew_cask_command="$brew_command cask"' | |
echo 'failed_items=""' | |
echo 'function install_package() {' | |
echo 'echo EXECUTING: brew install $1 $2' | |
echo '$brew_command install $1 $2' | |
echo '[ $? -ne 0 ] && $failed_items="$failed_items $1" # package failed to install.' | |
echo '}' | |
echo 'function install_cask_package() {' | |
echo 'echo EXECUTING: brew cask install $1' | |
echo '$brew_cask_command install $1' | |
echo '[ $? -ne 0 ] && $failed_items="$failed_items $1" # package failed to install.' | |
echo '}' | |
$brew_command tap | while read tap; do echo "$brew_command tap $tap"; done | |
$brew_command list | while read item; | |
do | |
echo "install_package $item '$($brew_command info $item | /usr/bin/grep 'Built from source with:' | /usr/bin/sed 's/^[ \t]*Built from source with:/ /g; s/\,/ /g')'" | |
done | |
$brew_cask_command list | while read item; | |
do | |
echo "install_cask_package $item" | |
done | |
echo '[ ! -z $failed_items ] && echo The following items were failed to install: && echo $failed_items' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment