Sunday, May 31, 2009

Building the BleachBit installer for Windows

Building BleachBit 0.5.0 for Windows is relatively easy. The biggest challenge is installing the many dependencies. The end result is a single-file, redistributable installer which contains all dependencies: GTK+, PyGTK, etc. Some other projects with the same dependencies install the dependencies with a sub-installer, but BleachBit's approach is seamless.

Dependencies

Install these dependencies:

  • Python 2.5.4. Do not use Python 2.6.2 because it causes the error
    "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem"
    related to a MSVCR90.DLL issue.)
  • NSIS 2.44
  • py2exe 0.6.9
  • PyCairo 1.4
  • PyGObject 2.14
  • PyGTK 2.12
  • GTK+ 2.12

This GTK+ runtime is old. Newer versions may work but haven't been tested yet.

Build process

After installing the dependencies, build and package BleachBit like this:

  1. Extract BleachBit source tarball or retrieve the source by SVN.
  2. Change to the directory with setup.py.
  3. Optionally, unzip upx.exe from UPX 3.03 to this directory. UPX compresses the executables and DLLs. While UPX may increase the size of the installer slightly (because of the double compression), it saves disk space by reducing the final installation footprint.
  4. If you repeat the installer build process often, run this command to save time:
    upx --best c:\gtk\bin\*.*
    
  5. Compile the gettext localization files from .po to .mo format with this command:
    make -C po local 
    
    Microsoft Windows doesn't have make, so you may need a Cygwin environment; I use a Linux machine with file sharing setup between Windows and Linux.
  6. If you are using BleachBit version 0.5.0 exactly, replace setup_py2exe.bat with revision 426. (This revision will be included in BleachBit 0.5.1.)
  7. Run setup_py2exe.bat to clean any old builds, invoke setup.py and py2exe, copy remaining files from the GTK+ runtime (py2exe misses some necessary GTK+ files), compress executables with UPX, purge several megabytes of unnecessary GTK+ locales, and invoke NSIS to build the installer.

You're done. Now test the installer on a fresh machine (without any of these dependencies installed.)

Other uses

Installing these dependencies has other uses than building a redistributable package. The environment is useful for developing BleachBit. Also, you can run new versions of BleachBit without having to re-download and re-install the large GTK+ runtime for each BleachBit release: this saves about 98% of the download size—not that it matters so much these days with high-speed Internet.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.