Sparkle (for Mac)

BlitzMax Forums/Brucey's Modules/Sparkle (for Mac)

Brucey(Posted 2009) [#1]
So... you wish you had some kind of auto-update system for your Mac Apps ?
Wouldn't it be even better if the update system was the same one that many Mac apps already use?

Sparkle does just that !

Wouldn't it be great if it was so easy to implement in BlitzMax that all you had to do was Import the module (and perhaps call one function to initialise it) ? ;-)
(Note, this doesn't include the server-side files, plist modifications, and additions to the application bundle :-p )

Here's some screenshots of it in action, running on a small example I've made.
The example source :
SuperStrict

Framework BaH.Sparkle
Import BRL.GLMax2D

SparkleInit

Graphics 800, 600, 0

Local version:String = "1.0.0"

While Not KeyDown(KEY_ESCAPE)  And Not AppTerminate()

	Cls
	
	DrawText "Hello, I'm version " + version, 300, 300
	
	DrawText "Escape to Quit", 680, 580
	
	Flip

Wend

End


Version 1.0.0 is running. On second launch, up pops a window :

You can see that it has popped up independently of the application.
(Note, this won't work if you are running fullscreen, for obvious reasons. I believe there's a way you can plug directly into the API, and perhaps hold off until the user has decided to download or not)

Once you've chosen to install :

It downloads the new version for you, and will restart the application. It's important to note that you will have to catch AppTerminate() (or another application termination event if you are using something like wxMax), otherwise it won't be able to stop and start the new version).

And finally:

The old app is replaced with the new...


This is actually an older project that I put on hold due to issues at the time, which now appear to be resolved.
Still WIP, but it's heading in the right direction :-)

If you'd like to try it out, you can download version 1.0.0 of the example from here. (721kb)
Unzip, then run the App. The first time you run it, it won't ask the user anything - it's a user-experience thing. However, the second time you run it, it should ask if you'd like to update to the latest version. If you choose to, it will do the steps mentioned above.
Afterwards, you can just delete it :-)


plash(Posted 2009) [#2]
It'd be really nice to have a cross-platform solution :(
Still cool though!


Brucey(Posted 2009) [#3]
It'd be really nice to have a cross-platform solution

Yes it would!

This project also highlights just how bad basic Mac support is for BlitzMax :-(

For example, the Info.plist file (which bmk generates automatically, and puts into the bundle) requires additional entries. This you either have to do by hand, or write a shell script to run after your build, or use my BMK(NG) and auto-run a post-build script.
The Sparkle framework needs to be copied into the bundle. Again this is a post-build task.
The public key-file also needs to be copied into the bundle. ditto.

Of course, if one is using 3rd-party build tools, it's less of an issue ;-)


d-bug(Posted 2010) [#4]
A really nice one! But where must i go to get the module?


Rozek(Posted 2010) [#5]
Brucey,

thanks for this marvellous idea!

I really appreciate your work - as much as I appreciate Mark's: it's the combination of BlitzMAX with MiniB3D and your modules which makes the whole stuff outstanding!


Brucey(Posted 2010) [#6]
A really nice one! But where must i go to get the module?

I'm tidying it up a bit before I commit the code to SVN.

It also needs some documentation to explain how everything works... what files you need, and where to put them.
I'm using my BMK(NG), with the provided example, to create a custom .plist and push some other things into the bundle.


Brucey(Posted 2010) [#7]
Committed.
Although I've not finished the documentation yet.

Of interest may be the included post.bmk script in the examples folder, which automates the three steps of :
* configuring a custom info.plist file for the application bundle.
* unzipping the Sparkle.framework into the application bundle.
* copying the public dsa key file into the application bundle.

Most BlitzMax Mac developers tend to like doing everything by hand, rather, of which that option is still available :-)


d-bug(Posted 2010) [#8]
Brucey, my hero, thank you! :)


d-bug(Posted 2010) [#9]
Hm...

It seems that sparkle can't quit MaxGUI Apps. The Updater is running as it should, but when it comes to quit the app, nothing happens.

Import maxgui.drivers
Import bah.sparkle

SparkleInit()

Local win:TGadget = CreateWindow ("Hello", 100, 100, 200, 100, Null)

Repeat
	Select WaitEvent()
		Case EVENT_APPTERMINATE
			End
	End Select
Forever


The mini-Sample above does not terminate after sparkle has downloaded the update and requests Install & Restart.


d-bug(Posted 2010) [#10]
I'm not sure if you crack my balls, but I've done some modifications to your glue.m to send a EVENT_APPTERMINATE when sparkle will relaunch the app:

Added include
#include <brl.mod/system.mod/system.h>


Added setDelegate
- (id)init:(BBObject *)obj
{
	_bah_sparkle_TSUUpdater__callback(obj, self);
	[self setDelegate:self]
        return [self initForBundle:[NSBundle bundleForClass:[self class]]];
}


Added delegate to send EVENT_APPTERMINATE
Event.data "1" for reacting on sparkle and not on system.
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater
{
	bbSystemEmitEvent( BBEVENT_APPTERMINATE, &bbNullObject, 1, 0, 0, 0, &bbNullObject);
}


The application will be terminated now, but the relaunch is still not done. I tried to emit the event in -(void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update; but this prevents sparkle from installing the app.

cheers