Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Specified version was ignored #29

Merged
merged 3 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,26 @@ SECURE="off"
OVMF="/usr/share/OVMF"

case "${BOOT_MODE,,}" in
full)
DEST="macos"
"full" )
DEST="$PROCESS"
BOOT_DESC=" 1920x1080"
ROM="OVMF_CODE.fd"
VARS="OVMF_VARS-1920x1080.fd"
;;
hd)
DEST="macos_hd"
"hd" )
DEST="${PROCESS}_hd"
BOOT_DESC=" 1024x768"
ROM="OVMF_CODE.fd"
VARS="OVMF_VARS-1024x768.fd"
;;
default)
"default" )
BOOT_DESC=""
DEST="macos_default"
ROM="OVMF_CODE.fd"
VARS="OVMF_VARS.fd"
DEST="${PROCESS}_default"
;;
*)
error "Unknown BOOT_MODE, value \"${BOOT_MODE}\" is not recognized!"
exit 33
error "Unknown BOOT_MODE, value \"${BOOT_MODE}\" is not recognized!" && exit 33
;;
esac

Expand Down
47 changes: 33 additions & 14 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,63 @@ set -Eeuo pipefail
: "${VERSION:="sonoma"}" # OSX Version

TMP="$STORAGE/tmp"
BASE_FILE="BaseSystem"
BASE_IMG_ID="InstallMedia"
BASE_IMG="$STORAGE/base.dmg"
BASE_TMP="$TMP/$BASE_FILE.dmg"

downloadImage() {

local board
local version="$1"
local file="BaseSystem"
local path="$TMP/$file.dmg"

case "${version,,}" in
"sonoma" | "14"* )
board="Mac-A61BADE1FDAD7B05" ;;
"ventura" | "13"* )
board="Mac-4B682C642B45593E" ;;
"monterey" | "12"* )
board="Mac-B809C3757DA9BB8D" ;;
"bigsur" | "big-sur" | "11"* )
board="Mac-2BD1B31983FE1663" ;;
"catalina" | "10"* )
board="Mac-00BE6ED71E35EB86" ;;
*)
error "Unknown VERSION specified, value \"${version}\" is not recognized!"
return 1 ;;
esac

local msg="Downloading macOS ($version) image"
info "$msg..." && html "$msg..."

rm -rf "$TMP"
mkdir -p "$TMP"

local msg="Downloading macOS ($VERSION) image"
info "$msg..." && html "$msg..."

/run/progress.sh "$BASE_TMP" "" "$msg ([P])..." &
/run/progress.sh "$path" "" "$msg ([P])..." &

if ! /run/fetch-macOS-v2.py --action download -s "$VERSION" -n "$BASE_FILE" -o "$TMP"; then
error "Failed to fetch macOS ($VERSION)!"
if ! /run/fetch-macOS-v2.py --action download -b "$board" -n "$file" -o "$TMP"; then
error "Failed to fetch macOS \"$version\" with board id \"$board\"!"
fKill "progress.sh"
return 1
fi

fKill "progress.sh"

if [ ! -f "$BASE_TMP" ] || [ ! -s "$BASE_TMP" ]; then
error "Failed to find file $BASE_TMP !"
if [ ! -f "$path" ] || [ ! -s "$path" ]; then
error "Failed to find file \"$path\" !"
return 1
fi

echo "$VERSION" > "$STORAGE/$PROCESS.version"
echo "$version" > "$STORAGE/$PROCESS.version"

mv "$BASE_TMP" "$BASE_IMG"
mv "$path" "$BASE_IMG"
rm -rf "$TMP"

return 0
}

if [ ! -f "$BASE_IMG" ] || [ ! -s "$BASE_IMG" ]; then
if ! downloadImage; then
if ! downloadImage "$VERSION"; then
rm -rf "$TMP"
exit 34
fi
Expand All @@ -52,7 +71,7 @@ STORED_VERSION=$(cat "$STORAGE/$PROCESS.version")

if [ "$VERSION" != "$STORED_VERSION" ]; then
info "Different version detected, switching base image from $STORED_VERSION to $VERSION"
if ! downloadImage; then
if ! downloadImage "$VERSION"; then
rm -rf "$TMP"
exit 34
fi
Expand Down