Commit 04b7f737 authored by Michael Droettboom's avatar Michael Droettboom

Clean up the downloaded file if it's corrupted

parent 584c61ed
...@@ -42,10 +42,14 @@ def check_checksum(path, pkg): ...@@ -42,10 +42,14 @@ def check_checksum(path, pkg):
def download_and_extract(buildpath, packagedir, pkg, args): def download_and_extract(buildpath, packagedir, pkg, args):
tarballpath = buildpath / Path(pkg['source']['url']).name tarballpath = buildpath / Path(pkg['source']['url']).name
if not tarballpath.is_file(): if not tarballpath.is_file():
try:
subprocess.run([ subprocess.run([
'wget', '-q', '-O', str(tarballpath), pkg['source']['url'] 'wget', '-q', '-O', str(tarballpath), pkg['source']['url']
], check=True) ], check=True)
check_checksum(tarballpath, pkg) check_checksum(tarballpath, pkg)
except Exception:
tarballpath.unlink()
raise
srcpath = buildpath / packagedir srcpath = buildpath / packagedir
if not srcpath.is_dir(): if not srcpath.is_dir():
shutil.unpack_archive(str(tarballpath), str(buildpath)) shutil.unpack_archive(str(tarballpath), str(buildpath))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment