From 9139a594639ab147098aa02671437a05d22491a4 Mon Sep 17 00:00:00 2001 From: Alexander Willner Date: Mon, 6 Aug 2018 22:51:06 +0200 Subject: [PATCH] new release --- Makefile | 9 ++- .../Contents/Resources/runMojaveVirtualbox.sh | 58 ++++++++++++------- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 7662c50..512e97b 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ help: @echo " * test : test shell scripts" @echo " * style : style shell scripts" @echo " * harden : harden shell scripts" + @echo " * release : make new release" @echo " * feedback : create a GitHub issue" image: all @@ -61,4 +62,10 @@ dependencies: @type shellharden >/dev/null 2>&1 || (echo "Run 'brew install shellharden' first." >&2 ; exit 1) @type shfmt >/dev/null 2>&1 || (echo "Run 'brew install shfmt' first." >&2 ; exit 1) -.PHONY: image clean feedback test harden style check +release: + @cp runMojaveVirtualbox.sh app/RunMojaveVirtualbox.app/Contents/Resources/ + @cd app; rm -f RunMojaveVirtualbox.app.zip || true + @cd app; zip -r RunMojaveVirtualbox.app.zip RunMojaveVirtualbox.app/ + @open https://github.com/AlexanderWillner/runMacOSinVirtualBox/releases + +.PHONY: image clean feedback test harden style check release diff --git a/app/RunMojaveVirtualbox.app/Contents/Resources/runMojaveVirtualbox.sh b/app/RunMojaveVirtualbox.app/Contents/Resources/runMojaveVirtualbox.sh index 0f38e6b..492cb68 100644 --- a/app/RunMojaveVirtualbox.app/Contents/Resources/runMojaveVirtualbox.sh +++ b/app/RunMojaveVirtualbox.app/Contents/Resources/runMojaveVirtualbox.sh @@ -13,7 +13,10 @@ # Core parameters ############################################################# readonly PATH="$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin" -readonly SCRIPTPATH="$( cd "$(dirname "$0")" || exit; pwd -P )" +readonly SCRIPTPATH="$( + cd "$(dirname "$0")" || exit + pwd -P +)" readonly INST_VERS="$(find /Applications -maxdepth 1 -type d -name 'Install macOS*' | wc -l | tr -d '[:space:]')" readonly INST_VER="$(find /Applications -maxdepth 1 -type d -name 'Install macOS*' -print -quit)" readonly INST_BIN="$INST_VER/Contents/Resources/createinstallmedia" @@ -34,7 +37,6 @@ readonly FILE_CFG="$SCRIPTPATH/config.plist" readonly FILE_LOG="$HOME/Library/Logs/runMojaveVirtualbox.log" ############################################################################### - # Logging ##################################################################### exec 3>&1 exec 4>&2 @@ -42,7 +44,6 @@ exec 1>>"$FILE_LOG" exec 2>&1 ############################################################################### - # Define methods ############################################################## debug() { echo "DEBUG: $1" >&3 @@ -52,24 +53,24 @@ debug() { error() { echo "ERROR: $1" >&4 log "$1" - if [ -d "$SCRIPTPATH/ProgressDialog.app" ]; then + if [ -d "$SCRIPTPATH/ProgressDialog.app" ]; then osascript -e 'tell application "ProgressDialog"' -e 'activate' \ - -e 'set name of window 1 to "Installing macOS Mojave on Virtualbox"' \ - -e 'set message of window 1 to "'"ERROR: $1"'."' \ - -e 'set percent of window 1 to (100)' \ - -e 'end tell' + -e 'set name of window 1 to "Installing macOS Mojave on Virtualbox"' \ + -e 'set message of window 1 to "'"ERROR: $1"'."' \ + -e 'set percent of window 1 to (100)' \ + -e 'end tell' fi } info() { echo -n "$1" >&3 log "$1" - if [ -d "$SCRIPTPATH/ProgressDialog.app" ]; then + if [ -d "$SCRIPTPATH/ProgressDialog.app" ]; then osascript -e 'tell application "ProgressDialog"' -e 'activate' \ - -e 'set name of window 1 to "Installing macOS Mojave on Virtualbox"' \ - -e 'set message of window 1 to "'"$1"'...'"$2"'%."' \ - -e 'set percent of window 1 to ('"$2"')' \ - -e 'end tell' + -e 'set name of window 1 to "Installing macOS Mojave on Virtualbox"' \ + -e 'set message of window 1 to "'"$1"'...'"$2"'%."' \ + -e 'set percent of window 1 to ('"$2"')' \ + -e 'end tell' fi } @@ -80,11 +81,15 @@ result() { log() { datestring="$(date +'%Y-%m-%d %H:%M:%S')" - echo "[$datestring] $1" >> "$FILE_LOG" + echo "[$datestring] $1" >>"$FILE_LOG" } runChecks() { - info "Running checks (around 1 second)..." 0; result "." + info "Running checks (around 1 second)..." 0 + result "." + if [ -d "$SCRIPTPATH/ProgressDialog.app" ]; then + open "$SCRIPTPATH/ProgressDialog.app" + fi if [ "$INST_VERS" = "0" ]; then open 'https://beta.apple.com/sp/betaprogram/redemption#macos' error "No macOS installer found. Opening the web page for you (press enter in the terminal when done)..." @@ -116,15 +121,24 @@ runChecks() { fi if ! type xz >/dev/null 2>&1; then error "'xz' not installed. Trying to install automatically, if you've brew installed..." - if type brew >/dev/null 2>&1 ; then + if type brew >/dev/null 2>&1; then brew install xz || exit 3 else exit 3 fi fi + awk >/dev/null 2>&1 + if [ ! $? -eq 1 ]; then + error "Something is wrong with your 'awk' installation. Trying to fix it automatically, if you've brew installed..." + if type brew >/dev/null 2>&1; then + brew upgrade awk || exit 6 + else + exit 6 + fi + fi if [ "$(VBoxManage list extpacks | grep 'USB 3.0')" = "" ]; then error "VirtualBox USB 3.0 Extension Pack not installed. Trying to install automatically, if you've brew installed..." - if type brew >/dev/null 2>&1; then + if type brew >/dev/null 2>&1; then brew cask install virtualbox-extension-pack || exit 4 else exit 4 @@ -186,7 +200,7 @@ extractAPFS() { } createClover() { - info "Creating clover image '$DST_CLOVER.iso' (around 30 seconds)..." + info "Creating clover image '$DST_CLOVER.iso' (around 30 seconds)..." if [ ! -e "$DST_CLOVER.iso" ]; then result "." extractAPFS @@ -272,13 +286,13 @@ cleanup() { debug "From function ${funcstack[0]} (line $linecallfunc)." debug "Look at $FILE_LOG for details (or use Console.app)." fi - if [ -d "$SCRIPTPATH/ProgressDialog.app" ]; then - osascript -e 'tell application "ProgressDialog"' -e 'quit' -e 'end tell'; + if [ -d "$SCRIPTPATH/ProgressDialog.app" ]; then + osascript -e 'tell application "ProgressDialog"' -e 'quit' -e 'end tell' fi } main() { - while [ "$#" -ne 0 ] ; do + while [ "$#" -ne 0 ]; do ARG="$1" shift # get rid of $1, we saved in ARG already case "$ARG" in @@ -298,4 +312,4 @@ main() { # Run script ################################################################## [[ "${BASH_SOURCE[0]}" == "${0}" ]] && trap 'cleanup "${?}" "${LINENO}" "${BASH_LINENO}" "${BASH_COMMAND}" $(printf "::%s" ${FUNCNAME[@]:-})' EXIT && main "${@:-}" -############################################################################### \ No newline at end of file +###############################################################################