The Tonido framework contains a flexible patching system for patching the application as well as any installed plugins. A check for new updates is done at startup if a specified time period has passed since the last check for update was done.
Some of the features of the patching system:
- Can patch a application and shared objects in memory
- Doesn't require a new install
- Can patch all plugins and any associated files
- Can detect missing/deleted files in the installation and make them available
- Can detect modified/hacked files and restore them to original condition
- Minimizes download bandwidth by using GZIPed files
- Easy to maintain patch download files
The patching system handles two different sets of packages.
- System Package
- Plugin Package
System package contains the executable files, the bootstrap/core dlls, thirdparty dlls and other data files. It also includes the launcher executable.
Plugin Package is per application plugin and comprises of the main plugin shared library and any required files.
Manifest
- A package is described using a Manifest file.
- A manifest file is a list of all files in that package and the base download URL for that package. Every file in that list also has a MD5 hash of that file.
Patch Maker
- To create a package, given a set of files, one can run the PatchMaker application.
- The patch maker takes an input directory, an output directory and the Base download URL.
- For each file in the input directory, the patchmaker computes the MD5 hash, and then compresses using GZIP compression and saves the file into the output directory. It also saves the Manifest file into the output directory.
System Patching
The following happens when the application comes up:
- The patcher system checks for a file called lastchecked. It then examines the created date of that file. If the file is less than 24 hours old (currently), it will skip patching and exit.
- If the lastchecked file is not present or older than 24 hours, the manifest.xml file is opened and the base URL is examined. (The old lastpatched file is deleted)
- It first downloads the latest version of the manifest.xml from the URL
- Next for every file in the manifest.xml it checks the local file. If the MD5 of the local file matches the hash in the manifest it continues to the next file.
- Otherwise, it will check if there is cached download with the name 'filename.rep'. if the file exists with the correct MD5 it will continue to the next file
- If both conditions fail, it will do a HTTP download of the file from the base download URL. Note that the file is in the GZIP format. Once downloaded, it will be expanded to the filename.rep format.
- After all files are done and if any files were patched, it will create the lastchecked file and also create a 'doupdate' file and it will signal the application to terminate. Before terminating, it will launch the launcher application.
The following happens when the launcher comes up:
- The launcher application is a small executable having no thirdparty dependencies that is meant to update the system files. This is required because an application cannot replace its own dll and exe files when it is running.
- The launcher checks if a 'doupdate' file exists.
- If it exists, it will move the filename.rep files to filename and then launches the p2p app.
- If it doesn't exist, it will simply launch the Tonido app
Plugin Patching
Plugin patching is similar to System patching except that the application will not be restarted if a plugin needs to be updated.