[FIX] runbot: make checkout safer wrt addons layout

Avoid errors/crash when the server/addons directory in the build branch
contains symlinks.

Exhibited by e.g. odoo/odoo#16720
This commit is contained in:
Olivier Dony 2017-05-02 13:03:21 +02:00
parent f889f2095c
commit 63b997a4ed

View File

@ -851,12 +851,16 @@ class runbot_build(osv.osv):
# move all addons to server addons path # move all addons to server addons path
for module in uniq_list(glob.glob(build._path('addons/*')) + modules_to_move): for module in uniq_list(glob.glob(build._path('addons/*')) + modules_to_move):
basename = os.path.basename(module) basename = os.path.basename(module)
if os.path.exists(build._server('addons', basename)): addon_path = build._server('addons', basename)
if os.path.exists(addon_path):
build._log( build._log(
'Building environment', 'Building environment',
'You have duplicate modules in your branches "%s"' % basename 'You have duplicate modules in your branches "%s"' % basename
) )
shutil.rmtree(build._server('addons', basename)) if os.path.islink(addon_path) or os.path.isfile(addon_path):
os.remove(addon_path)
else:
shutil.rmtree(addon_path)
shutil.move(module, build._server('addons')) shutil.move(module, build._server('addons'))
available_modules = [ available_modules = [