From b8c6d01d5d74805a05b2136f0b34b8d602116aed Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Thu, 29 Aug 2019 15:31:49 -0700 Subject: [PATCH 1/3] Use GNU coreutils if they're installed --- macos-guest-virtualbox.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/macos-guest-virtualbox.sh b/macos-guest-virtualbox.sh index b4c7691..724ab5c 100644 --- a/macos-guest-virtualbox.sh +++ b/macos-guest-virtualbox.sh @@ -72,6 +72,11 @@ else fi fi +# Homebrew doesn't add GNU coreutils to PATH. If they exist, use them. +if [ -d '/usr/local/opt/coreutils/libexec/gnubin' ]; then + PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" +fi + white_on_red="\e[48;2;255;0;0m\e[38;2;255;255;255m" white_on_black="\e[48;2;0;0;9m\e[38;2;255;255;255m" default_color="\033[0m" From 57a0e64df2dbabcb41a0be97df08c2fdb631fd32 Mon Sep 17 00:00:00 2001 From: Jack <31696646+myspaghetti@users.noreply.github.com> Date: Sat, 31 Aug 2019 13:44:22 +0300 Subject: [PATCH 2/3] moved dependency check to the dependency checking section --- macos-guest-virtualbox.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/macos-guest-virtualbox.sh b/macos-guest-virtualbox.sh index 724ab5c..d8050e8 100644 --- a/macos-guest-virtualbox.sh +++ b/macos-guest-virtualbox.sh @@ -72,11 +72,6 @@ else fi fi -# Homebrew doesn't add GNU coreutils to PATH. If they exist, use them. -if [ -d '/usr/local/opt/coreutils/libexec/gnubin' ]; then - PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" -fi - white_on_red="\e[48;2;255;0;0m\e[38;2;255;255;255m" white_on_black="\e[48;2;0;0;9m\e[38;2;255;255;255m" default_color="\033[0m" @@ -134,15 +129,24 @@ fi } function check_dependencies() { + # check if running on macOS and non-GNU coreutils -if [ -n "$(sw_vers 2>/dev/null)" -a -z "$(csplit --help 2>/dev/null)" ]; then - echo "" - printf 'macOS detected. Please use a package manager such as '"${white_on_black}"'homebrew'"${default_color}"', '"${white_on_black}"'nix'"${default_color}"', or '"${white_on_black}"'MacPorts'"${default_color}"'.\n' - echo "Please make sure the following packages are installed and that" - echo "their path is in the PATH variable:" - printf "${white_on_black}"'bash coreutils wget unzip dmg2img'"${default_color}"'\n' - echo "Please make sure bash and coreutils are the GNU variant." - exit +if [ -n "$(sw_vers 2>/dev/null)" ]; then + # Add Homebrew GNU coreutils to PATH if path exists + homebrew_gnubin="/usr/local/opt/coreutils/libexec/gnubin" + if [ -d "${homebrew_gnubin}" ]; then + PATH="${homebrew_gnubin}:${PATH}" + fi + # if csplit isn't GNU variant, exit + if [ -z "$(csplit --help 2>/dev/null)" ]; then + echo "" + printf 'macOS detected. Please use a package manager such as '"${white_on_black}"'homebrew'"${default_color}"', '"${white_on_black}"'nix'"${default_color}"', or '"${white_on_black}"'MacPorts'"${default_color}"'.\n' + echo "Please make sure the following packages are installed and that" + echo "their path is in the PATH variable:" + printf "${white_on_black}"'bash coreutils wget unzip dmg2img'"${default_color}"'\n' + echo "Please make sure bash and coreutils are the GNU variant." + exit + fi fi # check for unzip, coreutils, wget From c1bb67d104a8dfbd5241af72aa896f7364f2296d Mon Sep 17 00:00:00 2001 From: Jack <31696646+myspaghetti@users.noreply.github.com> Date: Sat, 31 Aug 2019 13:44:46 +0300 Subject: [PATCH 3/3] incremented version number --- macos-guest-virtualbox.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macos-guest-virtualbox.sh b/macos-guest-virtualbox.sh index d8050e8..f70b40b 100644 --- a/macos-guest-virtualbox.sh +++ b/macos-guest-virtualbox.sh @@ -2,7 +2,7 @@ # Semi-automatic installer of macOS on VirtualBox # (c) myspaghetti, licensed under GPL2.0 or higher # url: https://github.com/img2tab/macos-guest-virtualbox -# version 0.75.0 +# version 0.75.1 # Requirements: 40GB available storage on host # Dependencies: bash >= 4.0, unzip, wget, dmg2img,