1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-25 09:44:02 +00:00

add osx updater from https://github.com/AquariaOSE/updater for easier deployment

This commit is contained in:
fgenesis 2022-04-01 18:05:53 +02:00
parent 2d6ac020e4
commit a04af25d88
9 changed files with 459 additions and 0 deletions

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>updater.sh</string>
<key>CFBundleIdentifier</key>
<string>com.bit-blot.aquaria</string>
<key>CFBundleIconFile</key>
<string>aquaria.icns</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>Aqou</string>
<key>CFBundleShortVersionString</key>
<string>1.1.3+</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>CFBundleName</key>
<string>Aquaria-opensource-updater</string>
</dict>
</plist>

View file

@ -0,0 +1,78 @@
#!/bin/sh
hascmd() {
# because `which` is non-POSIX
type "$1" >/dev/null 2>&1
return $?
}
# title, text, detail
msgbox()
{
echo "
#-------[ $1 ]--------
# $2
#---------------------------------
$3
"
if [ -n "$DISPLAY" ]; then
if hascmd kdialog; then
kdialog --error "$2\n\n$3" --title "$1" 2>/dev/null # kdialog auto-expands \n
elif hascmd zenity; then
zenity --error --title="$1" --text="$2\n\n$3" # zenity auto-expands \n
elif hascmd wish; then
echo "tk_messageBox -type ok -title \"$1\" -message \"$2\" -icon error -detail \"$3\"; exit" | wish
elif hascmd osascript; then # apple specific
/usr/bin/osascript <<EOT
tell application "Finder"
activate
set myReply to button returned of (display dialog "$1\n\n$2\n\n$3" default button 1 buttons {"Close"})
end tell
EOT
elif hascmd xmessage; then
echo -e "$1\n\n$2\n$3" | xmessage -file -
fi
fi
}
MACHINE=`uname -m`
# just in case. PPC not supported.
if [ $MACHINE != "i386" ] && [ $MACHINE != "x86_64" ] && [ $MACHINE != "i686" ]; then
msgbox "Error!" "Unsupported machine architecture." "Your machine reports \"$MACHINE\", but only i386 and x86_64 are supported."
exit 1
fi
# get our very own dir
DIR=`dirname "$0"`
DIR=`cd "$DIR" && pwd`
#cd "../../updater" # this fails if started via Finder (working dir == app dir in that case)
# so here's the safe way
OLDDIR="$DIR"
DIR=`dirname "$DIR"`
DIR=`dirname "$DIR"`
cd "$DIR/updater"
# just in case
RUNCMD=""
if hascmd wish; then
RUNCMD=wish
elif hascmd tclsh; then
RUNCMD=tclsh
fi
if [ -n "$RUNCMD" ]; then
if [ -f main.tcl ]; then
"$RUNCMD" main.tcl &
else
msgbox "Oops!" "Installer script not found!" "This indicates a script error. Please let me know about it -- fg"
fi
else
msgbox "Oops!" "Tcl/Wish not installed!" "I thought this was the case on Mac OSX. Please let me know about it -- fg"
fi
cd "$OLDDIR"

View file

@ -0,0 +1 @@
APPLAqou

Binary file not shown.

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>aquaria</string>
<key>CFBundleIdentifier</key>
<string>com.bit-blot.aquaria</string>
<key>CFBundleIconFile</key>
<string>aquaria.icns</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>Aqra</string>
<key>CFBundleShortVersionString</key>
<string>1.1.3+</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>CFBundleName</key>
<string>Aquaria</string>
</dict>
</plist>

View file

@ -0,0 +1 @@
APPLAqra

Binary file not shown.

View file

@ -0,0 +1,327 @@
# Sorry for the bad code, but this is my first Tcl script in years...
# and never really understood this weird language -- fg
# TODO: Might fix this script for linux some day
# (it works on linux and even windows, but creates a *.app folder as output, with the mac binaries etc
package require Tcl 8.4
package require Tk
set ::OUTAPP "Aquaria-1.1.3+.app"
# setup GUI
tk appname "Aquaria updater (1.1.x -> 1.1.3+)"
label .status -anchor w -height 2 -font "tkDefaultFont 10" \
-text "Click Start. The updater will try to find your installation.
No files will be altered without your confirmation."
label .detail -anchor nw -height 3 -font "Helvetica 10"
button .btn -text "Start updating" -command { doUpdate }
image create photo imgSplash -file "splash.gif"
label .splash -image imgSplash
bind .status <Configure> [list %W configure -wraplength %w]
bind .detail <Configure> [list %W configure -wraplength %w]
pack .splash -expand y
pack .status -fill x -expand y
pack .detail -fill x -expand y
pack .btn -pady 15
update
wm minsize . [image width imgSplash] [winfo height .]
wm maxsize . [image width imgSplash] [winfo height .]
proc center_window {} {
wm withdraw .
update idletasks
set x [expr [winfo screenwidth .]/2 - [winfo reqwidth .]/2 \
- [winfo vrootx .]]
set y [expr [winfo screenheight .]/2 - [winfo reqheight .]/2 \
- [winfo vrooty .]]
wm geom . +$x+$y
wm deiconify .
}
# this is necessary on OSX, otherwise this pops up in the top left corner
center_window
# workaround for quirky window managers (see http://wiki.tcl.tk/1254)
after idle center_window
# end GUI
proc msgboxCompat { type title message detail } {
if { [catch {
set ret [tk_messageBox -type $type -title $title -message $message -detail $detail]
}] } {
# no -detail on OSX <= 10.5
set ret [tk_messageBox -type $type -title $title -message "$message\n\n$detail"]
}
return $ret
}
proc msgboxYesNo { title message detail } {
set ret [msgboxCompat yesno $title $message $detail]
return $ret
}
proc msgboxOk { title message detail } {
set ret [msgboxCompat ok $title $message $detail]
return $ret
}
proc setstatus s {
.status configure -text $s
update
}
proc setdetail s {
.detail configure -text $s
update
}
proc getVendor path {
if { [isAmbrosia $path] } {
return "Ambrosia software \[Mac\]"
}
if { [file exists "$path/Contents/MacOS/aquaria"]
&& [file exists "$path/Contents/MacOS/libSDL-1.2.0.dylib"]
&& [file isdirectory "$path/ambrosia"]
} {
return "HiB \[Mac\]"
}
if { [file exists "$path/Aquaria.exe"]
&& [file exists "$path/AQConfig.exe"]
&& [file exists "$path/fmodex.dll"]
} {
return "Plimus/HiB \[Win32\]"
}
if { [file exists "$path/libSDL-1.2.so.0"] } {
return "HiB \[Linux\]"
}
return "Opensource/Unknown"
}
proc useThatDir path {
set detail "$path
(Vendor: [getVendor $path])
Use it to create the updated version? Select \"No\" to continue searching for another one.
The original application will not be changed, and will still be usable afterwards."
set answer [msgboxYesNo "Question" "Found Aquaria app:" $detail]
return [string equal $answer "yes"]
}
proc checkSubdirs { path } {
set need {data gfx mus scripts sfx vox}
foreach i $need {
if { ! [file isdirectory [file normalize "$path/$i"]] } {
return 0
}
}
return 1
}
proc checkExe path {
if { [file isfile "$path/Contents/MacOS/aquaria"]
|| [file isfile "$path/Contents/MacOS/Aquaria"]
|| [file isfile "$path/Aquaria.exe"]
|| [file isfile "$path/aquaria"]
} {
return 1
}
return 0
}
proc isAquariaApp path {
if { [checkExe $path] } {
if { [checkSubdirs $path] } {
return 1
}
if { [isAmbrosia $path] } {
if { [checkSubdirs "$path/Contents/Resources"] } {
return 1
}
}
}
return 0
}
proc suitable { path } {
if { [isAquariaApp $path] } {
return [useThatDir $path]
}
return 0
}
proc findInstall { basedir } {
return [findInstallRec $basedir 0]
}
set ::IGNOREPATHS {"/System" "/Developer" "/Library" "/dev" "/proc" "/net"}
proc checkableEntry name {
if { [lsearch $::IGNOREPATHS $name] >= 0 } {
return 0
}
if { ! [file exists $name] } {
return 0
}
if { [string equal [file type $name] "link"] } {
return 0
}
# no -hidden on OSX <= 10.5
catch {
if { [file attributes $name -hidden] } {
return 0
}
}
return 1
}
proc filter {list script} {
set res {}
foreach e $list {if {[uplevel 1 [list $script $e]]} {lappend res $e}}
set res
}
proc findInstallRec { basedir nest } {
#puts "\[$nest\] $basedir"
# prevent stack overflow due to bad symlinks
if { $nest > 15 } {
return {}
}
# do not recurse into apps
if { [string match "*.app*" $basedir] } {
return {}
}
# Fix the directory name, this ensures the directory name is in the
# native format for the platform and contains a final directory seperator
set basedir [string trimright [file join [file normalize $basedir] { }]]
setdetail $basedir
set dirs [lsort [filter [glob -nocomplain -type {d r} -path $basedir *] checkableEntry]]
foreach dn $dirs {
if { [suitable $dn] } {
return $dn
}
}
foreach dn $dirs {
set ret [findInstallRec $dn [expr $nest + 1]]
if { [string length $ret] > 0 } {
return $ret
}
}
return {}
}
# because [file copy] is wimpy and fails for read-protected mac metadata
proc copyFilesHarder { src dst } {
set src "[file normalize $src]/"
set dst "[file normalize $dst]/"
# just in case
if { ! [file isdirectory $dst] } {
file mkdir $dst
}
set files [lsort [glob -nocomplain -type {f r d} -path $src *]]
# copy files
foreach f $files {
set t [file tail $f]
if { [file isdirectory $f] } {
copyFilesHarder $f "$dst/$t"
} else {
# do not copy file if it already exists in the same location. note that $dst has a trailing / here.
if { ! [string equal $f "$dst$t"] } {
setdetail $t
file copy -force $f $dst
}
}
}
}
proc doUpdate {} {
.btn configure -state disabled -text "Working..."
setstatus "Searching for Aquaria application..."
set app [findInstall "/"]
if { [string length $app] > 0 } {
set target "[file dirname $app]/$::OUTAPP"
file mkdir $target
copyBaseFiles $app $target
copyUpdateFiles $target
copyUserFiles
file attributes "$target/Contents/MacOS/aquaria" -permissions "+x"
set answer [msgboxYesNo "Question" "Finished! The newly built app is located at:" "$target\n\nDo you want to start it now?"]
if { [string equal $answer yes] } {
doLaunch $target
}
exit 0
} else {
msgboxOk "Nope." "Nothing found!" \
"Sorry, but this updater was unable to find a complete Aquaria installation. You can still update manually, though."
exit 1
}
}
proc isAmbrosia path {
# this does not exist in the HiB version
return [file isdirectory [file normalize "$path/Contents/Frameworks/AmbrosiaTools.framework"]]
}
proc copyBaseFiles { from to } {
setstatus "Copying files from old application... This may take a while."
# all except scripts
set fl {data gfx mus sfx vox Contents}
if { [isAmbrosia $from] } {
foreach f $fl {
copyFilesHarder "$from/Contents/Resources/$f" "$to/$f"
}
} else {
foreach f $fl {
copyFilesHarder "$from/$f" "$to/$f"
}
}
}
proc copyUpdateFiles { to } {
setstatus "Copying updated game files..."
copyFilesHarder "../files/" $to
}
proc copyUserFiles {} {
set udir "~/Library/Application Support/Aquaria"
setstatus "Copying updated user files..."
copyFilesHarder "../user/" $udir
}
proc doLaunch app {
cd $app
exec [file nativename "Contents/MacOS/aquaria"] &
exit 0
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB