39 lines
1.6 KiB
Markdown
39 lines
1.6 KiB
Markdown
# Archive tools
|
|
|
|
These Rust commands use standard WASI files and streams.
|
|
|
|
```sh
|
|
tar -czf archive.tgz -C /repos project
|
|
tar -xzf archive.tgz -C /work --strip-components 1
|
|
tar -tf archive.tar
|
|
tar -cf - project | gzip -c > project.tgz
|
|
gzip -k file
|
|
gunzip -fk file.gz
|
|
zcat file.gz
|
|
```
|
|
|
|
The tar parser accepts short combined flags, `-C`, `-f -`, and `--strip-components`.
|
|
Extraction supports regular files and directories. It rejects special files and paths outside the destination.
|
|
Creation uses portable modes because WASI does not expose Unix mode bits.
|
|
It includes symbolic links in archives, but world extraction does not create symbolic links or hardlinks.
|
|
The selected `-C` applies to all input paths.
|
|
With `-v`, creation prints names to stdout for named archives and to stderr for `-f -`.
|
|
|
|
Gzip supports `-d`, `-c`, `-k`, and `-f`.
|
|
Gunzip defaults to decompression. Zcat defaults to decompression to stdout.
|
|
Files use the `.gz` suffix. Decompression accepts concatenated gzip members.
|
|
Existing output files require `-f`. A successful file operation removes its input unless `-k` is set.
|
|
|
|
From `userland/`, with the executor's `CARGO_TARGET_DIR`:
|
|
|
|
```sh
|
|
nix develop -c cargo build -p sausage-archive-tools --release --locked
|
|
nix develop -c nu archive-tools/test.nu
|
|
nix develop -c cargo test -p sausage-archive-tools --target aarch64-unknown-linux-gnu --locked
|
|
```
|
|
|
|
The test script compares cross-format tar and gzip transfers with native tools.
|
|
It also compares common GoAWK one-liners and checks the pinned QuickJS command.
|
|
The real-world tests live in `fs-tools/world-test.nu`.
|
|
Nix packaging remains deferred until T17 merges.
|