zstd-sfx is a project to compress data into a self-extracting executable with zstd compression algorithm. This project is composed of two components: archiver and unarchiver, the archiver would compress the data and combine with the unarchiver, into a single executable.
The usage of the archiver is shown below
Usage: archiver <target> <unarchiver> [-l <level>] [-o <output>] [-r] [-t <temp>]
Positional Arguments:
target what to compress
unarchiver path to unarchiver executable
Options:
-l, --level zstd compress level, range from 0~23, default is 3
-o, --output path to output sfx file, default is target name
-r, --root the root directory with be included or not
-t, --temp where temp files should be store, default depends on os
--help display usage information
To use zstd-sfx, you can download the pre-compiled binaries here. Or you can compile by yourself, make sure you have rust toolchain and git installed first, you'll need to download the source code with git
git clone https://github.com/phoxwupsh/zstd-sfx.gitThen build unarchiver first
cd zstd-sfx
cargo build --bin=unarchiver --releaseAfter you build the unarchiver, the executable file would be target/release/unarchiver in the project directory (for Windows is /target/release/unarchiver.exe)
So you can compress the data like this
Unix
cargo run --bin=archiver --release -- some/path/to/data target/release/unarchiver -o sfx-executableWindows
cargo run --bin=archiver --release -- some/path/to/data target/release/unarchiver.exe -o sfx-executable.exeIf the executable file size of unarchiver is a concern for you, you can do some trick to shrink it.
First you would need rust nightly
rustup install nightlyThen you can compile it with
Unix
# Find your host's target
rustc -vV
RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-unknown-linux-gnu --bin=unarchiver --releaseWindows
$env:RUSTFLAG="-Zlocation-detail=none -Zfmt-debug=none"
cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-pc-windows-msvc --bin=unarchiver --releaseFor more information, refer to johnthagen/min-sized-rust