bzexe
Compress executables to save disk space
SYNOPSIS
bzexe [-c | -d] [-s salt] [-k] [-f] infile [outfile]
PARAMETERS
-c
Copy/decompress mode: treats infile as prior bzexe output, strips stub, decompresses to executable (outfile defaults to infile.out).
-d
Shortcut for -c: decompress bzexe archive back to original executable.
-s salt
Encrypt output using 16-character salt string for basic protection.
-k
Keep: preserves original infile after creating outfile (default is delete).
-f
Force: overwrites existing outfile without prompting.
DESCRIPTION
bzexe is a utility from the bzip2 package that transforms a standard executable into a self-extracting, compressed archive.
It prepends a small bzip2 decompression stub (about 4-5 KB) to the bzip2-compressed executable data. When run, the stub automatically decompresses the payload in memory or to a temp file and executes it seamlessly, passing along all original arguments.
This is ideal for distributing binaries over space-constrained networks, as it reduces file size by 50-70% typically, while maintaining single-file executability without needing separate decompression tools.
Key workflow:
1. Run bzexe infile outfile → produces compressed outfile.
2. User runs outfile directly → auto-decompresses and executes infile contents.
The tool supports encryption via a salt for basic obfuscation. Decompression mode reverts bzexe files back to originals. Note: works best on position-independent executables or those without hard-coded paths; the stub uses execvp() for flexibility.
Linux/Unix focused, portable across similar systems. Compression ratio excels for text-heavy or repetitive binaries.
CAVEATS
Stub adds ~5KB overhead; ineffective for already-compressed/large data. May fail on executables with argv[0] path dependencies or non-executable payloads. Not for scripts (use makeself). Encrypted files require exact salt to run.
STUB MECHANICS
Stub decompresses to /tmp/bz$$, execs with execvp(), cleans up. Supports ARGV[0] preservation.
EXAMPLE USAGE
bzexe -k myprog myprog.bzexe
Run: ./myprog.bzexe → executes myprog transparently.
Revert: bzexe -c myprog.bzexe myprog
HISTORY
Developed by Julian Seward as part of bzip2 (first release 1996). Included in bzip2 1.0+ distributions for Linux/Unix. Evolved minimally; still in active use for legacy software distribution.


