support platform specific modules
This commit is contained in:
parent
ea7e01ec3d
commit
c844aae72e
1 changed files with 19 additions and 3 deletions
|
@ -104,16 +104,30 @@ def get_latest_release():
|
|||
fd.write(release_data)
|
||||
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():
|
||||
if not os.path.exists(os.path.join(settings.data_path, 'release.json')):
|
||||
return True
|
||||
release = get_latest_release()
|
||||
platform = get_platform()
|
||||
if release:
|
||||
ox.makedirs(settings.updates_path)
|
||||
os.chdir(os.path.dirname(settings.base_dir))
|
||||
current_files = {'release.json'}
|
||||
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'])
|
||||
base_url = settings.server.get('release_url').rsplit('/', 1)[0]
|
||||
url = '/'.join([base_url, release['modules'][module]['name']])
|
||||
|
@ -124,7 +138,7 @@ def download():
|
|||
logger.debug('invalid checksum %s', os.path.basename(module_tar))
|
||||
os.unlink(module_tar)
|
||||
return False
|
||||
current_files.add(os.path.basename(module_tar))
|
||||
current_files.add(os.path.basename(module_tar))
|
||||
for f in set(next(os.walk(settings.updates_path))[2])-current_files:
|
||||
os.unlink(os.path.join(settings.updates_path, f))
|
||||
return True
|
||||
|
@ -141,8 +155,10 @@ def install(stop=True):
|
|||
new_version = release['modules']['openmedialibrary']['version']
|
||||
if verify(release) and old_version < new_version:
|
||||
os.chdir(os.path.dirname(settings.base_dir))
|
||||
platform = get_platform()
|
||||
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'])
|
||||
if os.path.exists(module_tar) and ox.sha1sum(module_tar) == release['modules'][module]['sha1']:
|
||||
#tar fails if old platform is moved before extract
|
||||
|
|
Loading…
Reference in a new issue