You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
3.1 KiB
73 lines
3.1 KiB
# `sfexec` - Self Extracting Executable
|
|
|
|
`sfexec` is a simple tool to create archive-like native binaries that extract contents from their static memory to temporary files when ran.
|
|
It is useful for packaging a bunch of binaries into a single one.
|
|
Temporary files are cleaned up after the post-extraction script hook.
|
|
|
|
## Example
|
|
|
|
``` shell
|
|
$ echo "Hello world!" > file.txt
|
|
$ sfexec-create -e 'cat %location/file.txt' - file.txt
|
|
Writing to /home/avril/work/sfexec/file.h...
|
|
+ test.txt OK
|
|
Adding lengths...
|
|
Adding names...
|
|
- "test.txt" OK
|
|
Compiling binary...
|
|
Complete.
|
|
$ ./sfexec
|
|
Extracting 1 files to "/tmp/eda0bd22-9565-7e3c-e1d0-f7cdff96770e"...
|
|
<- test.txt (13)
|
|
exec: cat /tmp/eda0bd22-9565-7e3c-e1d0-f7cdff96770e/test.txt
|
|
Hello world!
|
|
```
|
|
|
|
## Usage
|
|
|
|
It comes with 2 scripts, `sfexec-create` and `sfexec-create-compress`. Both take the same arguments:
|
|
| Argument | Description |
|
|
|---------------|-----------------------------------------------------|
|
|
| `-s` | Silent mode. Do not output anything when extracting |
|
|
| `-e <string>` | Post-extraction hook. See below for details. |
|
|
| `-u` | Do not check data integrity (skip hashing) |
|
|
| `-` | Stop reading argument flags |
|
|
|
|
`sfexec-create-compress` compresses the binary with `gzip`, and decompresses when executed.
|
|
|
|
### Post-extraction hook
|
|
|
|
The post extraction hook is passed to `/bin/sh`, with some input changes:
|
|
| Argument | Usage |
|
|
|-------------|-------------------------------------------------------------------------------------------------------|
|
|
| `%location` | The directory root that the files are extracted to |
|
|
| `%argc` | The number of command line arguments passed to `sfexec` |
|
|
| `%args` | A list of all args passed to `sfexec` |
|
|
| `%arg[n]` | The `n`th argument passed to `sfexec`, if `n` is outside the range of arguments, nothing is replaced. |
|
|
|
|
## Building
|
|
To build the `sfexec` binary, `g++` is used, along with [sha256_literal] for verifying the data (unless `-u` is specified) and post-extraction hook.
|
|
To clone `sha256_literal` run:
|
|
``` shell
|
|
$ make deps
|
|
```
|
|
Included in the repo is a pre-built generator binary, signed with [my PGP key] at `generator-v<version>.gpg` with a checksum in `generator-v<version>.sha256`. Alternatively you can build it yourself like so:
|
|
|
|
[sha256_literal]: https://github.com/aguinet/sha256_literal
|
|
[my pgp key]: https://flanchan.moe/flanchan.asc
|
|
|
|
### Building the generator
|
|
To build the generator yourself, Rust and Cargo are needed.
|
|
``` shell
|
|
$ make clean && make generator
|
|
```
|
|
Will remove the pre-built generator binaries, build the generator, and symlink accordingly.
|
|
You can also compile without `sha2` crate dependancy (for data hash integrity checks), this will in effect force the `-u` option always.
|
|
``` shell
|
|
$ make clean && make generator-no-hash
|
|
```
|
|
|
|
## License
|
|
GPL'd with love <3
|
|
|