Skip to content

Commit 6943ccc

Browse files
committed
use clean_dir instead of remove_dir on installation directory for Binary easyblock
1 parent d9dec7f commit 6943ccc

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

easybuild/easyblocks/generic/binary.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@
3232
@author: Jens Timmerman (Ghent University)
3333
"""
3434

35-
import shutil
3635
import os
3736
import stat
3837

3938
from easybuild.framework.easyblock import EasyBlock
4039
from easybuild.framework.easyconfig import CUSTOM
4140
from easybuild.tools.build_log import EasyBuildError
42-
from easybuild.tools.filetools import adjust_permissions, copy_file, mkdir, remove_dir
41+
from easybuild.tools.filetools import adjust_permissions, clean_dir, copy_dir, copy_file, mkdir
4342
from easybuild.tools.run import run_shell_cmd
4443

4544

@@ -116,8 +115,8 @@ def install_step(self):
116115
if install_cmd is None and install_cmds is None:
117116
try:
118117
# shutil.copytree doesn't allow the target directory to exist already
119-
remove_dir(self.installdir)
120-
shutil.copytree(self.cfg['start_dir'], self.installdir, symlinks=self.cfg['keepsymlinks'])
118+
clean_dir(self.installdir)
119+
copy_dir(self.cfg['start_dir'], self.installdir, symlinks=self.cfg['keepsymlinks'], dirs_exist_ok=True)
121120
except OSError as err:
122121
raise EasyBuildError("Failed to copy %s to %s: %s", self.cfg['start_dir'], self.installdir, err)
123122
else:
@@ -142,14 +141,8 @@ def post_processing_step(self):
142141
if self.cfg.get('staged_install', False):
143142
staged_installdir = self.installdir
144143
self.installdir = self.actual_installdir
145-
try:
146-
# copytree expects target directory to not exist yet
147-
if os.path.exists(self.installdir):
148-
remove_dir(self.installdir)
149-
shutil.copytree(staged_installdir, self.installdir)
150-
except OSError as err:
151-
raise EasyBuildError("Failed to move staged install from %s to %s: %s",
152-
staged_installdir, self.installdir, err)
144+
clean_dir(self.installdir)
145+
copy_dir(staged_installdir, self.installdir, dirs_exist_ok=True)
153146

154147
super().post_processing_step()
155148

0 commit comments

Comments
 (0)