earlier execution of gnu coreutils prefix check
This commit is contained in:
+22
-18
@@ -2,7 +2,7 @@
|
|||||||
# Semi-automatic installer of macOS on VirtualBox
|
# Semi-automatic installer of macOS on VirtualBox
|
||||||
# (c) myspaghetti, licensed under GPL2.0 or higher
|
# (c) myspaghetti, licensed under GPL2.0 or higher
|
||||||
# url: https://github.com/myspaghetti/macos-guest-virtualbox
|
# url: https://github.com/myspaghetti/macos-guest-virtualbox
|
||||||
# version 0.77.5
|
# version 0.77.6
|
||||||
|
|
||||||
# Requirements: 40GB available storage on host
|
# Requirements: 40GB available storage on host
|
||||||
# Dependencies: bash >= 4.0, unzip, wget, dmg2img,
|
# Dependencies: bash >= 4.0, unzip, wget, dmg2img,
|
||||||
@@ -47,11 +47,6 @@ SYSTEM_INTEGRITY_PROTECTION='0x10' # '0x10' - enabled, '0x77' - disabled
|
|||||||
# This is only necessary if you want to run connected Apple applications
|
# This is only necessary if you want to run connected Apple applications
|
||||||
# such as iCloud, iMessage, etc.
|
# such as iCloud, iMessage, etc.
|
||||||
# Make sure the package xxd is installed, otherwise the conversion will fail.
|
# Make sure the package xxd is installed, otherwise the conversion will fail.
|
||||||
if [ -n "$(gbase64 --help 2>/dev/null)" ]; then
|
|
||||||
function base64() {
|
|
||||||
gbase64 "$@"
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
MLB="bytes:$(echo -n "${DmiBoardSerial}" | base64)"
|
MLB="bytes:$(echo -n "${DmiBoardSerial}" | base64)"
|
||||||
if [ -n "$(echo -n "aabbccddee" | xxd -r -p 2>/dev/null)" ]; then
|
if [ -n "$(echo -n "aabbccddee" | xxd -r -p 2>/dev/null)" ]; then
|
||||||
# Apologies for the one-liner below; it convers the mixed-ASCII-and-base16
|
# Apologies for the one-liner below; it convers the mixed-ASCII-and-base16
|
||||||
@@ -125,7 +120,6 @@ read
|
|||||||
# check dependencies
|
# check dependencies
|
||||||
|
|
||||||
function check_bash_version() {
|
function check_bash_version() {
|
||||||
# check Bash version
|
|
||||||
if [ -z "${BASH_VERSION}" ]; then
|
if [ -z "${BASH_VERSION}" ]; then
|
||||||
echo "Can't determine BASH_VERSION. Exiting."
|
echo "Can't determine BASH_VERSION. Exiting."
|
||||||
exit
|
exit
|
||||||
@@ -139,16 +133,7 @@ elif [ "${BASH_VERSION:0:1}" -lt 4 ]; then
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_dependencies() {
|
function check_gnu_coreutils_prefix() {
|
||||||
|
|
||||||
# check if running on macOS and non-GNU coreutils
|
|
||||||
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 [ -n "$(gcsplit --help 2>/dev/null)" ]; then
|
if [ -n "$(gcsplit --help 2>/dev/null)" ]; then
|
||||||
function csplit() {
|
function csplit() {
|
||||||
gcsplit "$@"
|
gcsplit "$@"
|
||||||
@@ -159,7 +144,23 @@ if [ -n "$(sw_vers 2>/dev/null)" ]; then
|
|||||||
function split() {
|
function split() {
|
||||||
gsplit"$@"
|
gsplit"$@"
|
||||||
}
|
}
|
||||||
elif [ -z "$(csplit --help 2>/dev/null)" ]; then
|
function base64() {
|
||||||
|
gbase64 "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_dependencies() {
|
||||||
|
|
||||||
|
# check if running on macOS and non-GNU coreutils
|
||||||
|
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 ""
|
echo ""
|
||||||
printf 'macOS detected.\nPlease use a package manager such as '"${white_on_black}"'homebrew'"${default_color}"', '"${white_on_black}"'pkgsrc'"${default_color}"', '"${white_on_black}"'nix'"${default_color}"', or '"${white_on_black}"'MacPorts'"${default_color}"'.\n'
|
printf 'macOS detected.\nPlease use a package manager such as '"${white_on_black}"'homebrew'"${default_color}"', '"${white_on_black}"'pkgsrc'"${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 "Please make sure the following packages are installed and that"
|
||||||
@@ -1018,6 +1019,7 @@ or not these stages are specified.
|
|||||||
|
|
||||||
Available stage titles:
|
Available stage titles:
|
||||||
check_bash_version
|
check_bash_version
|
||||||
|
check_gnu_coreutils_prefix
|
||||||
set_variables
|
set_variables
|
||||||
welcome
|
welcome
|
||||||
check_dependencies
|
check_dependencies
|
||||||
@@ -1041,6 +1043,7 @@ Available stage titles:
|
|||||||
|
|
||||||
if [ -z "${1}" ]; then
|
if [ -z "${1}" ]; then
|
||||||
check_bash_version
|
check_bash_version
|
||||||
|
check_gnu_coreutils_prefix
|
||||||
set_variables
|
set_variables
|
||||||
welcome
|
welcome
|
||||||
check_dependencies
|
check_dependencies
|
||||||
@@ -1062,6 +1065,7 @@ if [ -z "${1}" ]; then
|
|||||||
else
|
else
|
||||||
if [ "${1}" != "stages" ]; then
|
if [ "${1}" != "stages" ]; then
|
||||||
check_bash_version
|
check_bash_version
|
||||||
|
check_gnu_coreutils_prefix
|
||||||
set_variables
|
set_variables
|
||||||
check_dependencies
|
check_dependencies
|
||||||
for argument in "$@"; do ${argument}; done
|
for argument in "$@"; do ${argument}; done
|
||||||
|
|||||||
Reference in New Issue
Block a user