java.lang.Object
net.i2p.router.tasks.InstallUpdate
Automatic I2P router update installer and processor.
This class handles the complete update process when an i2pupdate.zip file is present in the router or base directory. It performs a comprehensive update including verification, extraction, cleanup, and restart procedures.
Update Process:
- Searches for i2pupdate.zip in router dir or base dir
- Verifies write permissions to target directory
- Validates ZIP file integrity and structure
- Updates router configuration with version information
- Extracts update files to base directory
- Processes deletelist.txt for obsolete file removal
- Cleans up native libraries (jbigi, jcpuid)
- Removes update file and restarts JVM
Error Handling:
- Renames failed updates to "BAD-i2pupdate.zip"
- Summarizes file deletions at end of process
- Handles permission issues gracefully
- Performs cleanup even on partial failures
Restart Behavior:
- With wrapper: Automatic restart after update
- Without wrapper: Manual restart required
- Exit code: Router.EXIT_HARD_RESTART
If no update file is found, performs routine maintenance including native library cleanup and deletion list processing.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringFile listing what the previous update installed.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate static booleanRecursive directory delete.private static voiddeleteJbigiFiles(RouterContext context) Remove extracted libjbigi.so and libjcpuid.so files if we have a newer jbigi.jar, so the new ones will be extracted.private static voiddeleteListedFiles(RouterContext context) Delete all files listed in the delete file.private static voiddeleteNativeLib(File jbigiJar, File lib) Delete a native library if the jbigi.jar is newer.static voidInstall updates from i2pupdate.zip file if present.
Field Details
DELETE_FILE
File listing what the previous update installed.- See Also:
Constructor Details
InstallUpdate
private InstallUpdate()Utility class, not intended for instantiation.
Method Details
installUpdates
Install updates from i2pupdate.zip file if present.- Parameters:
r- the router instance, must have a valid context
deleteJbigiFiles
Remove extracted libjbigi.so and libjcpuid.so files if we have a newer jbigi.jar, so the new ones will be extracted. We do this after the restart, not after the extract, because it's safer, and because people may upgrade their jbigi.jar file manually.Copied from NativeBigInteger, which we can't access here or the libs will get loaded.
- Parameters:
context- provides the lib directory holding jbigi.jar and the base directory holding the extracted native libraries
deleteNativeLib
deleteListedFiles
Delete all files listed in the delete file. Format: One file name per line, comment lines start with '#'. All file names must be relative to $I2P, absolute file names not allowed. Summarizes deletions at the end. Use no new I2P classes here so it may be called after zip extraction.- Parameters:
context- provides the base directory holding the delete file
deleteDir
Recursive directory delete.- Parameters:
dir- the directory to delete along with everything inside it- Returns:
- true if the directory was deleted