misc: use python builtin tar library when /bin/tar not found

This commit is contained in:
Shen-Ta Hsieh 2020-06-03 21:35:07 +08:00
parent 759f4231d2
commit 9a4059ba39
No known key found for this signature in database
GPG Key ID: DF7FED2B0492FA77
1 changed files with 7 additions and 1 deletions

View File

@ -7,5 +7,11 @@ def untar(tarball_path, parent_path, base):
except FileNotFoundError: except FileNotFoundError:
pass pass
os.makedirs(parent_path, exist_ok=True) os.makedirs(parent_path, exist_ok=True)
subprocess.check_call(['/bin/tar', 'xfC', tarball_path, parent_path]) try:
subprocess.check_call(['/bin/tar', 'xfC', tarball_path, parent_path])
except FileNotFoundError:
import tarfile
tar = tarfile.open(tarball_path)
tar.extractall(path=parent_path)
tar.close()
return path return path