RustForge

foundry

Foundry OS: the operating system built on the Rustbelt kernel

foundry / ports / busybox / untar.py
362 bytes ยท raw
1
2
3
4
5
6
7
8
9
#!/usr/bin/env python3
# Unpack a .tar.bz2 with Python, so the build doesn't need the bzip2 program.
# Usage: untar.py TARBALL DEST_DIR
import sys, tarfile
with tarfile.open(sys.argv[1], "r:*") as t:
    if hasattr(tarfile, "data_filter"):
        t.extractall(sys.argv[2], filter="data")   # refuse odd paths/devices
    else:
        t.extractall(sys.argv[2])