support platform specific modules

This commit is contained in:
j 2016-01-31 15:08:16 +05:30
parent ea7e01ec3d
commit c844aae72e

View file

@ -104,16 +104,30 @@ def get_latest_release():
fd.write(release_data) fd.write(release_data)
return release return release
def get_platform():
name = sys.platform
if name.startswith('darwin'):
name = 'darwin64'
elif name.startswith('linux'):
import platform
if platform.architecture()[0] == '64bit':
name = 'linux64'
else:
name = 'linux32'
return name
def download(): def download():
if not os.path.exists(os.path.join(settings.data_path, 'release.json')): if not os.path.exists(os.path.join(settings.data_path, 'release.json')):
return True return True
release = get_latest_release() release = get_latest_release()
platform = get_platform()
if release: if release:
ox.makedirs(settings.updates_path) ox.makedirs(settings.updates_path)
os.chdir(os.path.dirname(settings.base_dir)) os.chdir(os.path.dirname(settings.base_dir))
current_files = {'release.json'} current_files = {'release.json'}
for module in release['modules']: for module in release['modules']:
if release['modules'][module]['version'] > current_version(module): if release['modules'][module].get('platform', platform) == platform and \
release['modules'][module]['version'] > current_version(module):
module_tar = os.path.join(settings.updates_path, release['modules'][module]['name']) module_tar = os.path.join(settings.updates_path, release['modules'][module]['name'])
base_url = settings.server.get('release_url').rsplit('/', 1)[0] base_url = settings.server.get('release_url').rsplit('/', 1)[0]
url = '/'.join([base_url, release['modules'][module]['name']]) url = '/'.join([base_url, release['modules'][module]['name']])
@ -141,8 +155,10 @@ def install(stop=True):
new_version = release['modules']['openmedialibrary']['version'] new_version = release['modules']['openmedialibrary']['version']
if verify(release) and old_version < new_version: if verify(release) and old_version < new_version:
os.chdir(os.path.dirname(settings.base_dir)) os.chdir(os.path.dirname(settings.base_dir))
platform = get_platform()
for module in release['modules']: for module in release['modules']:
if release['modules'][module]['version'] > current_version(module): if release['modules'][module].get('platform', platform) == platform and \
release['modules'][module]['version'] > current_version(module):
module_tar = os.path.join(settings.updates_path, release['modules'][module]['name']) module_tar = os.path.join(settings.updates_path, release['modules'][module]['name'])
if os.path.exists(module_tar) and ox.sha1sum(module_tar) == release['modules'][module]['sha1']: if os.path.exists(module_tar) and ox.sha1sum(module_tar) == release['modules'][module]['sha1']:
#tar fails if old platform is moved before extract #tar fails if old platform is moved before extract