aboutsummaryrefslogtreecommitdiffstats
path: root/python/build/tar.py
blob: 15bbfca6bc49b2dac21629d827245eb40ff9f226 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
import os, shutil, subprocess

def untar(tarball_path, parent_path, base):
    path = os.path.join(parent_path, base)
    try:
        shutil.rmtree(path)
    except FileNotFoundError:
        pass
    os.makedirs(parent_path, exist_ok=True)
    subprocess.check_call(['/bin/tar', 'xfC', tarball_path, parent_path])
    return path