Uninstall support!

Ryan C. Gordon icculus at icculus.org
Thu Jan 24 06:07:14 EST 2008

As of svn revision #462, MojoSetup has an uninstaller.

How to use:

Upgrade to the latest Subversion. Then, do nothing. The uninstaller 
support is enabled by default.

On Unix, this will write out "uninstall-$PACKAGENAME.sh" to the root of 
the installation folder. On Windows, we will eventually hook into 
Add/Remove Programs, but there's still a lot of work to do on the 
Windows port before we even consider that.

If you don't want an uninstaller included with your package, add this to 
your config.lua's Setup.Package section...

     support_uninstall = false,
     write_manifest = false,

...and you'll get the usual installer behaviour.

Also, you need the Lua parser enabled when compiling the C code (it is 
by default).

The way this works, in a nutshell:
- The installer writes out a metadata directory with the manifest of 
installed files as a Lua script (etc).
- The installer also copies itself to the metadata directory, stripping 
any attached archives (so your three gigabyte self-extracting installer 
only copies about 150 kilobytes), and also any files it needs from the 
archives, like UI plugins, etc.
- The installer writes out the shell script like this:

   exec "`dirname $0`"'/.mojosetup/mojosetup' uninstall 'duke3d' $*
   exit 1

('duke3d' being the package id.)

...so the shell script runs the copied installer binary with command 
lines to make it uninstall the package.

- (un)installer loads the manifest, which is just a Lua table, and 
prompts the user for confirmation, and shows a progress dialog, using 
the same UI plugins available to it during installation, and eventually 
deletes everything in the manifest. It reports success and we're done.

Windows will basically do the same thing, but it will launch the 
uninstaller from the Windows control panel instead of a shell script.

There are probably still minor issues to work out (for example, 
uninstalling a package deletes the uninstaller too, so if there's more 
than one package in the same directory, it'll break the other's 
uninstallation support), but it seems to be 99% good to go already. I'm 
pretty pleased with how this turned out. It's robust against manually 
moving the installation directory, too, since it doesn't use a central 
repository like loki_setup's ~/.loki/installed ...

Problems and questions: write here.

I did some more fixing on the ncurses UI today, too...next thing on my 
todo list will probably be installing Gnome/KDE/Windows start menu items.


More information about the mojosetup mailing list