Skip to content

Commit

Permalink
new release
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWillner committed Aug 6, 2018
1 parent 8284449 commit 9139a59
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,15 +37,13 @@ readonly FILE_CFG="$SCRIPTPATH/config.plist"
readonly FILE_LOG="$HOME/Library/Logs/runMojaveVirtualbox.log"
###############################################################################


# Logging #####################################################################
exec 3>&1
exec 4>&2
exec 1>>"$FILE_LOG"
exec 2>&1
###############################################################################


# Define methods ##############################################################
debug() {
echo "DEBUG: $1" >&3
Expand All @@ -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
}

Expand All @@ -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)..."
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -298,4 +312,4 @@ main() {

# Run script ##################################################################
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && trap 'cleanup "${?}" "${LINENO}" "${BASH_LINENO}" "${BASH_COMMAND}" $(printf "::%s" ${FUNCNAME[@]:-})' EXIT && main "${@:-}"
###############################################################################
###############################################################################

0 comments on commit 9139a59

Please sign in to comment.