fix update
This commit is contained in:
parent
0ff98f616b
commit
33327094e3
2 changed files with 14 additions and 7 deletions
6
ctl
6
ctl
|
@ -87,8 +87,8 @@ if [ "$1" == "ui" ]; then
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
if [ "$1" == "update" ]; then
|
if [ "$1" == "update" ]; then
|
||||||
if [ -e $BASE/$NAME/.git ]; then
|
cd "$BASE/$NAME"
|
||||||
cd "$BASE/$NAME"
|
if [ -d "$BASE/$NAME/.git" ]; then
|
||||||
OLD=`"$0" version`
|
OLD=`"$0" version`
|
||||||
cd "$BASE/platform"
|
cd "$BASE/platform"
|
||||||
echo Update platform..
|
echo Update platform..
|
||||||
|
@ -101,10 +101,10 @@ if [ "$1" == "update" ]; then
|
||||||
$0 update_static > /dev/null
|
$0 update_static > /dev/null
|
||||||
NEW=`"$0" version`
|
NEW=`"$0" version`
|
||||||
$0 postupdate -o $OLD -n $NEW
|
$0 postupdate -o $OLD -n $NEW
|
||||||
exit
|
|
||||||
else
|
else
|
||||||
python2 oml update
|
python2 oml update
|
||||||
fi
|
fi
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
if [ "$1" == "python" ]; then
|
if [ "$1" == "python" ]; then
|
||||||
cd "$BASE/$NAME"
|
cd "$BASE/$NAME"
|
||||||
|
|
|
@ -32,7 +32,8 @@ def verify(release):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def download(self, url, filename):
|
def download(url, filename):
|
||||||
|
print url, filename
|
||||||
dirname = os.path.dirname(filename)
|
dirname = os.path.dirname(filename)
|
||||||
if dirname and not os.path.exists(dirname):
|
if dirname and not os.path.exists(dirname):
|
||||||
os.makedirs(dirname)
|
os.makedirs(dirname)
|
||||||
|
@ -59,20 +60,26 @@ def update():
|
||||||
old = settings.release['modules']['openmedialibrary']['version']
|
old = settings.release['modules']['openmedialibrary']['version']
|
||||||
new = release['modules']['openmedialibrary']['version']
|
new = release['modules']['openmedialibrary']['version']
|
||||||
if verify(release) and old < new:
|
if verify(release) and old < new:
|
||||||
|
ox.makedirs(settings.updates_path)
|
||||||
with open(os.path.join(settings.updates_path, 'release.json'), 'w') as fd:
|
with open(os.path.join(settings.updates_path, 'release.json'), 'w') as fd:
|
||||||
fd.write(release_data)
|
fd.write(release_data)
|
||||||
os.chdir(settings.base_dir)
|
os.chdir(os.path.dirname(settings.base_dir))
|
||||||
for module in release['modules']:
|
for module in release['modules']:
|
||||||
if release['modules'][module]['version'] > settings.release['modules'][module]['version']:
|
if release['modules'][module]['version'] > settings.release['modules'][module]['version']:
|
||||||
package_tar = os.path.join(settings.updates_path, release['modules'][module]['name'])
|
package_tar = os.path.join(settings.updates_path, release['modules'][module]['name'])
|
||||||
url = RELEASE_URL.replace('release.json', package_tar)
|
url = RELEASE_URL.replace('release.json', release['modules'][module]['name'])
|
||||||
download(url, package_tar)
|
download(url, package_tar)
|
||||||
if ox.sha1sum(package_tar) == release['modules'][module]['sha1']:
|
if ox.sha1sum(package_tar) == release['modules'][module]['sha1']:
|
||||||
shutil.move(module, '%s_old' % module)
|
ox.makedirs('new')
|
||||||
|
os.chdir('new')
|
||||||
tar = tarfile.open(package_tar)
|
tar = tarfile.open(package_tar)
|
||||||
tar.extractall()
|
tar.extractall()
|
||||||
tar.close()
|
tar.close()
|
||||||
|
os.chdir(os.path.dirname(settings.base_dir))
|
||||||
|
shutil.move(module, '%s_old' % module)
|
||||||
|
shutil.move(os.path.join('new', module), module)
|
||||||
shutil.rmtree('%s_old' % module)
|
shutil.rmtree('%s_old' % module)
|
||||||
|
shutil.rmtree('new')
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
os.unlink(package_tar)
|
os.unlink(package_tar)
|
||||||
|
|
Loading…
Reference in a new issue