java.lang.Object
net.i2p.router.tasks.InstallUpdate

public class InstallUpdateextends Object
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 Details

  • Constructor Details

    • InstallUpdate

      private InstallUpdate()
      Utility class, not intended for instantiation.
  • Method Details

    • installUpdates

      public static void installUpdates(Router r)
      Install updates from i2pupdate.zip file if present.
      Parameters:
      r - the router instance, must have a valid context
    • deleteJbigiFiles

      private static void deleteJbigiFiles(RouterContext context)
      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

      private static void deleteNativeLib(File jbigiJar, File lib)
      Delete a native library if the jbigi.jar is newer. Copies to .bak first, then deletes.
      Parameters:
      jbigiJar - the jar whose modification time is compared with the library's
      lib - the native library file to back up and delete
    • deleteListedFiles

      private static void deleteListedFiles(RouterContext context)
      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

      private static boolean deleteDir(File dir)
      Recursive directory delete.
      Parameters:
      dir - the directory to delete along with everything inside it
      Returns:
      true if the directory was deleted