mirror of
https://github.com/ZDoom/zdoom-macos-deps.git
synced 2024-11-29 07:02:27 +00:00
build script: print message when downloading source code
This commit is contained in:
parent
23470315f3
commit
efb613729e
1 changed files with 16 additions and 13 deletions
29
build.py
29
build.py
|
@ -1400,23 +1400,26 @@ class Builder(object):
|
||||||
source_path = self.source_path
|
source_path = self.source_path
|
||||||
os.makedirs(source_path, exist_ok=True)
|
os.makedirs(source_path, exist_ok=True)
|
||||||
|
|
||||||
filename = source_path + url.rsplit(os.sep, 1)[1]
|
filename = url.rsplit(os.sep, 1)[1]
|
||||||
|
filepath = source_path + filename
|
||||||
|
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filepath):
|
||||||
# Read existing source package
|
# Read existing source package
|
||||||
with open(filename, 'rb') as f:
|
with open(filepath, 'rb') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
else:
|
else:
|
||||||
# Download package with source code
|
# Download package with source code
|
||||||
|
print(f'Downloading {filename}')
|
||||||
|
|
||||||
response = urllib.request.urlopen(url)
|
response = urllib.request.urlopen(url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(filename, 'wb') as f:
|
with open(filepath, 'wb') as f:
|
||||||
data = response.read()
|
data = response.read()
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
except IOError:
|
except IOError:
|
||||||
os.unlink(filename)
|
os.unlink(filepath)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Verify package checksum
|
# Verify package checksum
|
||||||
|
@ -1425,28 +1428,28 @@ class Builder(object):
|
||||||
file_checksum = file_hasher.hexdigest()
|
file_checksum = file_hasher.hexdigest()
|
||||||
|
|
||||||
if file_checksum != checksum:
|
if file_checksum != checksum:
|
||||||
os.unlink(filename)
|
os.unlink(filepath)
|
||||||
raise Exception(f'Checksum of {filename} does not match, expected: {checksum}, actual: {file_checksum}')
|
raise Exception(f'Checksum of {filepath} does not match, expected: {checksum}, actual: {file_checksum}')
|
||||||
|
|
||||||
# Figure out path to extracted source code
|
# Figure out path to extracted source code
|
||||||
filepaths = subprocess.check_output(['tar', '-tf', filename]).decode("utf-8")
|
filepaths = subprocess.check_output(['tar', '-tf', filepath]).decode("utf-8")
|
||||||
filepaths = filepaths.split('\n')
|
filepaths = filepaths.split('\n')
|
||||||
first_path_component = None
|
first_path_component = None
|
||||||
|
|
||||||
for filepath in filepaths:
|
for path in filepaths:
|
||||||
if os.sep in filepath:
|
if os.sep in path:
|
||||||
first_path_component = filepath[:filepath.find(os.sep)]
|
first_path_component = path[:path.find(os.sep)]
|
||||||
break
|
break
|
||||||
|
|
||||||
if not first_path_component:
|
if not first_path_component:
|
||||||
raise Exception("Failed to figure out source code path for " + filename)
|
raise Exception("Failed to figure out source code path for " + filepath)
|
||||||
|
|
||||||
extract_path = source_path + first_path_component + os.sep
|
extract_path = source_path + first_path_component + os.sep
|
||||||
|
|
||||||
if not os.path.exists(extract_path):
|
if not os.path.exists(extract_path):
|
||||||
# Extract source code package
|
# Extract source code package
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['tar', '-xf', filename], cwd=source_path)
|
subprocess.check_call(['tar', '-xf', filepath], cwd=source_path)
|
||||||
except (IOError, subprocess.CalledProcessError):
|
except (IOError, subprocess.CalledProcessError):
|
||||||
shutil.rmtree(extract_path, ignore_errors=True)
|
shutil.rmtree(extract_path, ignore_errors=True)
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in a new issue