From a71c77949c800e7fe36b5b0383723acf0e7275a6 Mon Sep 17 00:00:00 2001 From: Nathaniel Landau Date: Thu, 28 May 2015 09:02:05 -0400 Subject: [PATCH] checkDependencies now checks gems and mac apps via homebrew casks. --- lib/setupScriptFunctions.sh | 28 ++++++++++++++++++---- lib/sharedFunctions.sh | 47 ++++++++++++++++++++----------------- scriptTemplate.sh | 19 +++++++++------ setupScripts/homebrew.sh | 10 -------- 4 files changed, 62 insertions(+), 42 deletions(-) diff --git a/lib/setupScriptFunctions.sh b/lib/setupScriptFunctions.sh index 9a061a9..fc21746 100755 --- a/lib/setupScriptFunctions.sh +++ b/lib/setupScriptFunctions.sh @@ -73,6 +73,12 @@ hasCasks () { fi } +# My preferred installation of FFMPEG +install-ffmpeg () { + if [ ! $(type -P "ffmpeg") ]; then + brew install ffmpeg --with-faac --with-fdk-aac --with-ffplay --with-fontconfig --with-freetype --with-libcaca --with-libass --with-frei0r --with-libass --with-libbluray --with-libcaca --with-libquvi --with-libvidstab --with-libsoxr --with-libssh --with-libvo-aacenc --with-libvidstab --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-openssl --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools --with-webp --with-x265 + fi +} # doInstall # ------------------------------------------------------ @@ -125,25 +131,39 @@ function to_install() { function doInstall () { list="$(to_install "${RECIPES[*]}" "$($LISTINSTALLED)")" if [[ "${list}" ]]; then - seek_confirmation "Confirm each install before running?" + seek_confirmation "Confirm each package before installing?" if is_confirmed; then for item in ${list[@]} do seek_confirmation "Install ${item}?" if is_confirmed; then notice "Installing ${item}" - ${INSTALLCOMMAND} ${item} + # FFMPEG takes additional flags + if [[ "${item}" = "ffmpeg" ]]; then + install-ffmpeg + else + ${INSTALLCOMMAND} ${item} + fi fi done else for item in ${list[@]} do notice "Installing ${item}" - ${INSTALLCOMMAND} ${item} + # FFMPEG takes additional flags + if [[ "${item}" = "ffmpeg" ]]; then + install-ffmpeg + else + ${INSTALLCOMMAND} ${item} + fi done fi else - notice "Nothing to install. You've already installed all your recipes." + # only print notice when not checking dependencies via another script + if [ -z "$homebrewDependencies" ] && [ -z "$caskDependencies" ] && [ -z "$gemDependencies" ]; then + notice "Nothing to install. You've already installed all your recipes." + fi + fi } diff --git a/lib/sharedFunctions.sh b/lib/sharedFunctions.sh index 010345e..2dbb7f0 100755 --- a/lib/sharedFunctions.sh +++ b/lib/sharedFunctions.sh @@ -335,27 +335,32 @@ function help () { # ----------------------------------- function checkDependencies() { - # Check bashDependencies - for dependency in "${homebrewDependencies[@]}"; do - if type_not_exists "${dependency}"; then - # Attempt to install necessary packages via Homebrew if invoked on a Mac - if [[ "${OSTYPE}" =~ ^darwin ]]; then - seek_confirmation "We can not proceed without '${dependency}'. Would you like to install it via Homebrew?" - if is_confirmed; then - hasHomebrew # Installs Homebrew and all dependencies if needed. - if [[ "${dependency}" == "ffmpeg" ]]; then # install ffmpeg with all packages - brew install ffmpeg --with-faac --with-fdk-aac --with-ffplay --with-fontconfig --with-freetype --with-libcaca --with-libass --with-frei0r --with-libass --with-libbluray --with-libcaca --with-libquvi --with-libvidstab --with-libsoxr --with-libssh --with-libvo-aacenc --with-libvidstab --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-openssl --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools --with-webp --with-x265 - else - brew install "${dependency}" #install anything else needed - fi - else - die "Can not proceed without '${dependency}'. Please install it before running this script." - fi - else - die "Can not proceed without '${dependency}'. Please install it before running this script." - fi # /OStype - fi # not type $dependency - done + if [ -n "$homebrewDependencies" ]; then + LISTINSTALLED="brew list" + INSTALLCOMMAND="brew install" + RECIPES="${homebrewDependencies}" + + # Invoke functions from setupScriptFunctions.sh + hasHomebrew + doInstall + fi + if [ -n "$caskDependencies" ]; then + LISTINSTALLED="brew cask list" + INSTALLCOMMAND="brew cask install --appdir=/Applications" + RECIPES="${caskDependencies}" + + # Invoke functions from setupScriptFunctions.sh + hasHomebrew + hasCasks + doInstall + fi + if [ -n "$gemDependencies" ]; then + LISTINSTALLED="gem list | awk '{print $1}'" + INSTALLCOMMAND="gem install" + RECIPES="${gemDependencies}" + # Invoke functions from setupScriptFunctions.sh + doInstall + fi } # pauseScript diff --git a/scriptTemplate.sh b/scriptTemplate.sh index 285b655..8d29871 100755 --- a/scriptTemplate.sh +++ b/scriptTemplate.sh @@ -5,13 +5,15 @@ # version="1.0.0" # Sets version variable # -scriptTemplateVersion="1.3.0" # Version of scriptTemplate.sh that this script is based on -# v.1.1.0 - Added 'debug' option -# v.1.1.1 - Moved all shared variables to Utils -# - Added $PASS variable when -p is passed -# v.1.2.0 - Added 'checkDependencies' function to ensure needed +scriptTemplateVersion="1.4.0" # Version of scriptTemplate.sh that this script is based on +# v1.1.0 - Added 'debug' option +# v1.1.1 - Moved all shared variables to Utils +# - Added $PASS variable when -p is passed +# v1.2.0 - Added 'checkDependencies' function to ensure needed # Bash packages are installed prior to execution -# v.1.3.0 - Can now pass CLI without an option to $args +# v1.3.0 - Can now pass CLI without an option to $args +# v1.4.0 - checkDependencies now checks gems and mac apps via +# Homebrew cask # # HISTORY: # @@ -89,9 +91,12 @@ logFile="$HOME/Library/Logs/${scriptBasename}.log" # Arrays containing package dependencies needed to execute this script. # The script will fail if dependencies are not installed. For Mac users, # most dependencies can be installed automatically using the package -# manager 'Homebrew'. +# manager 'Homebrew'. Mac applications will be installed using +# Homebrew Casks. Ruby and gems via RVM. # ----------------------------------- homebrewDependencies=() +caskDependencies=() +gemDependencies=() function mainScript() { ############## Begin Script Here ################### diff --git a/setupScripts/homebrew.sh b/setupScripts/homebrew.sh index 66098fc..6dcdf8c 100755 --- a/setupScripts/homebrew.sh +++ b/setupScripts/homebrew.sh @@ -149,15 +149,6 @@ RECIPES=( z ) -install-ffmpeg () { - if type_not_exists 'ffmpeg'; then - seek_confirmation "Install ffmpeg?" - if is_confirmed; then - brew install ffmpeg --with-faac --with-fdk-aac --with-ffplay --with-fontconfig --with-freetype --with-libcaca --with-libass --with-frei0r --with-libass --with-libbluray --with-libcaca --with-libquvi --with-libvidstab --with-libsoxr --with-libssh --with-libvo-aacenc --with-libvidstab --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-openssl --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools --with-webp --with-x265 - fi - fi -} - htopPermissions() { seek_confirmation "Set HTOP permissions?" if is_confirmed; then @@ -173,7 +164,6 @@ htopPermissions() { hasHomebrew brewMaintenance doInstall -install-ffmpeg htopPermissions brewCleanup