WebAssembly build of the tar command (libarchive)
npm install @cowasm/tarThis is the BSD version of tar, built to run in WebAssembly via CoWasm, with
support for several compression formats:
``sh``
~/cowasm/packages/libarchive$ cowasm dist/wasm/bin/tar -h
tar(bsdtar): manipulate archive files
First option must be a mode specifier:
-c Create -r Add/Replace -t List -u Update -x Extract
Common Options:
-b # Use # 512-byte records per I/O block
-f
-v Verbose
-w Interactive
Create: tar -c [options] [
-z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma
--format {ustar|pax|cpio|shar} Select archive format
--exclude
-C
@
List: tar -t [options] [
Extract: tar -x [options] [
-k Keep (don't overwrite) existing files
-m Don't restore modification times
-O Write entries to stdout, don't restore to disk
-p Restore permissions (including ACLs, owner, file flags)
bsdtar 3.6.1 - libarchive 3.6.1 zlib/1.2.13 liblzma/5.0.4 bz2lib/1.0.8
There are of course issues, given that WASI makes it impossible to fully
support chmod. For example, if you create a tarball with an executable file
in it, then extract it, the file no longer has the executable bit set.
I tried benchmarks against the version of this code included in MacOS, and
the speed is pretty close. That's impressive.
This seems to fully work, except for the mod issue mentioned above.
I expect there will be a number of system calls that are not implemented, e.g., involving dup'ing file descriptors, etc. This isn't going to work in the browser until that is done, but it is pretty straightforward.