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