RustForge

foundry

Foundry OS: the operating system built on the Rustbelt kernel

foundry / ports / busybox / bzip2-shim.py
401 bytes ยท raw
1
2
3
4
5
6
7
8
9
#!/usr/bin/env python3
# Stand-in for the bzip2 program, used only by build.sh when the host has
# none: busybox's build runs `bzip2 -1` as a filter (stdin -> stdout).
import bz2, sys
args = sys.argv[1:]
level = next((int(a[1:]) for a in args if a[1:].isdigit()), 9)
data = sys.stdin.buffer.read()
out = bz2.decompress(data) if "-d" in args else bz2.compress(data, level)
sys.stdout.buffer.write(out)