Check for version when downloading external binaries.

This commit is contained in:
Cheng Zhao 2014-05-18 23:42:47 +08:00
parent 9754050598
commit c1e2348695
2 changed files with 22 additions and 9 deletions

2
.gitignore vendored
View file

@ -1,7 +1,7 @@
.DS_Store
/build/
/dist/
/frameworks/
/external_binaries/
/out/
/vendor/brightray/vendor/download/
/vendor/python_26/

View file

@ -7,20 +7,22 @@ import os
from lib.util import safe_mkdir, extract_zip, tempdir, download
VERSION = 'v0.0.3'
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
FRAMEWORKS_URL = 'https://github.com/atom/atom-shell-frameworks/releases' \
'/download/v0.0.3'
'/download/' + VERSION
def main():
os.chdir(SOURCE_ROOT)
try:
os.makedirs('external_binaries')
except OSError as e:
if e.errno != errno.EEXIST:
raise
else:
return
version_file = os.path.join(SOURCE_ROOT, 'external_binaries', '.version')
safe_mkdir('external_binaries')
if (is_updated(version_file, VERSION)):
return
with open(version_file, 'w') as f:
f.write(VERSION)
if sys.platform == 'darwin':
download_and_unzip('Mantle')
@ -30,6 +32,17 @@ def main():
download_and_unzip('directxsdk')
def is_updated(version_file, version):
existing_version = ''
try:
with open(version_file, 'r') as f:
existing_version = f.readline().strip()
except IOError as e:
if e.errno != errno.ENOENT:
raise
return existing_version == version
def download_and_unzip(framework):
zip_path = download_framework(framework)
if zip_path: