Autoupdate
This page describes, at a high level, how the auto-update function works.
Introduction
One major barrier to releasing more often is the huge size of the VDrift releases. These large sizes are due to the large number of cars and tracks that are typically included in a release. If VDrift has auto-update functionality, then releases can be very minimal (one track and one car, for example) and people can download new cars and tracks (and keep their existing ones up to date) through an in-game interface.
The rest of this document talks exclusively about updating cars, but tracks should work similarly.
The auto-update functionality was first proposed in this forum post: http://vdrift.net/Forum/viewtopic.php?p=12999
User Interface
Several GUI pages have been added. From the main menu, the "Cars and Tracks" button takes the user to a page with options to check for updates and manage cars. When the user clicks "check for updates", the sourceforge svn browser html is scraped to get the latest revision numbers for the car folders. The car manager UI is populated from code and allows the user to see what updates are available and provides an "apply update" button.
Versioning
There are two types of versioning: the versioning for each car folder, and the versioning for the car format.
First, car folder versioning. The data/settings/updates.config file is distributed with each release, and contains the cars that have been included in that release along with their SVN revision numbers. When the game checks for updates, the sourceforge svn browser html is scraped to get the latest revision numbers, and that information ([available_cars] section) along with the current on-disk versions ([cars] section) are stored in an updates.config in the user's folder (~/.vdrift on linux). The game offers to apply updates when the on-disk versions are less than the available versions.
Next, car format versioning. Sometimes, the format of car files changes in a way that breaks compatibility with old data files. To protect against updating cars to a format that the user's executables won't understand, format versions are stored in the updates.config file in the [formats] section. The version of the car format that the executable release understands is set in the data/settings/updates.config file included in the release (and copied to the user's folder). The game retrieves the latest data/settings/update.config via the sourceforge svn website and checks the format version there to make sure it matches the version number in the local update.config. If the format versions are not equal, updates will refuse to apply.
Updating
When the user clicks "apply update", the car format versioning is re-checked per the description above. If the car format versions mismatch, the game refuses to continue. Otherwise, updates are applied by fetching the .tar.gz bundle for a car's folder from sourceforge's http svn browser to a temporary folder (~/.vdrift/tmp on linux). This file then decompressed using libarchive into the settings directory (~/.vdrift on linux) under a "cars" subdir. The game should look here first when loading car files, and fall back to the global data path. The downloaded file is deleted once the update completes successfully, otherwise it leaves the temporary file around for troubleshooting.