-
Couldn't load subscription status.
- Fork 214
try to empty install dir if removing it fails #4932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
8c4dd29
90e62ce
9501a71
9a936f5
919d5eb
0aa808b
df8d04c
2397aeb
2c70d86
0b8331b
0519d9f
49fd013
66ae73d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,13 +90,14 @@ | |
| from easybuild.tools.config import DATA, SOFTWARE | ||
| from easybuild.tools.environment import restore_env, sanitize_env | ||
| from easybuild.tools.filetools import CHECKSUM_TYPE_SHA256 | ||
| from easybuild.tools.filetools import adjust_permissions, apply_patch, back_up_file, change_dir, check_lock | ||
| from easybuild.tools.filetools import adjust_permissions, apply_patch, back_up_file, change_dir, check_lock, clean_dir | ||
| from easybuild.tools.filetools import compute_checksum, convert_name, copy_dir, copy_file, create_lock | ||
| from easybuild.tools.filetools import create_non_existing_paths, create_patch_info, derive_alt_pypi_url, diff_files | ||
| from easybuild.tools.filetools import download_file, encode_class_name, extract_file, find_backup_name_candidate | ||
| from easybuild.tools.filetools import get_cwd, get_source_tarball_from_git, is_alt_pypi_url, is_binary, is_parent_path | ||
| from easybuild.tools.filetools import is_sha256_checksum, mkdir, move_file, move_logs, read_file, remove_dir | ||
| from easybuild.tools.filetools import remove_file, remove_lock, symlink, verify_checksum, weld_paths, write_file | ||
| from easybuild.tools.filetools import download_file, encode_class_name, extract_file | ||
| from easybuild.tools.filetools import find_backup_name_candidate, get_cwd, get_source_tarball_from_git, is_alt_pypi_url | ||
| from easybuild.tools.filetools import is_binary, is_parent_path, is_sha256_checksum, mkdir, move_file, move_logs | ||
| from easybuild.tools.filetools import read_file, remove_dir, remove_file, remove_lock, symlink, verify_checksum | ||
| from easybuild.tools.filetools import weld_paths, write_file | ||
| from easybuild.tools.hooks import ( | ||
| BUILD_STEP, CLEANUP_STEP, CONFIGURE_STEP, EASYBLOCK, EXTENSIONS_STEP, EXTRACT_STEP, FETCH_STEP, INSTALL_STEP, | ||
| MODULE_STEP, MODULE_WRITE, PACKAGE_STEP, PATCH_STEP, PERMISSIONS_STEP, POSTITER_STEP, POSTPROC_STEP, PREPARE_STEP, | ||
|
|
@@ -1171,10 +1172,13 @@ def make_builddir(self): | |
| # unless we're building in installation directory and we iterating over a list of (pre)config/build/installopts, | ||
| # otherwise we wipe the already partially populated installation directory, | ||
| # see https://github.com/easybuilders/easybuild-framework/issues/2556 | ||
| if not (self.build_in_installdir and self.iter_idx > 0): | ||
| # make sure we no longer sit in the build directory before cleaning it. | ||
| if self.build_in_installdir and self.iter_idx > 0: | ||
| pass | ||
| else: | ||
| # make sure we no longer sit in the build directory before removing it. | ||
| change_dir(self.orig_workdir) | ||
| self.make_dir(self.builddir, self.cfg['cleanupoldbuild']) | ||
| # if we’re building in installation directory, clean it | ||
| self.make_dir(self.builddir, self.cfg['cleanupoldbuild'], clean_instead_of_remove=self.build_in_installdir) | ||
|
|
||
| trace_msg("build dir: %s" % self.builddir) | ||
|
|
||
|
|
@@ -1220,9 +1224,10 @@ def make_installdir(self, dontcreate=None): | |
| if self.build_in_installdir: | ||
| self.cfg['keeppreviousinstall'] = True | ||
| dontcreate = (dontcreate is None and self.cfg['dontcreateinstalldir']) or dontcreate | ||
| self.make_dir(self.installdir, self.cfg['cleanupoldinstall'], dontcreateinstalldir=dontcreate) | ||
| self.make_dir(self.installdir, self.cfg['cleanupoldinstall'], dontcreateinstalldir=dontcreate, | ||
| clean_instead_of_remove=True) | ||
|
|
||
| def make_dir(self, dir_name, clean, dontcreateinstalldir=False): | ||
| def make_dir(self, dir_name, clean, dontcreateinstalldir=False, clean_instead_of_remove=False): | ||
| """ | ||
| Create the directory. | ||
| """ | ||
|
|
@@ -1233,15 +1238,24 @@ def make_dir(self, dir_name, clean, dontcreateinstalldir=False): | |
| return | ||
| elif build_option('module_only') or self.cfg['module_only']: | ||
| self.log.info("Not touching existing directory %s in module-only mode...", dir_name) | ||
| elif clean: | ||
| remove_dir(dir_name) | ||
| self.log.info("Removed old directory %s", dir_name) | ||
| else: | ||
| self.log.info("Moving existing directory %s out of the way...", dir_name) | ||
| timestamp = time.strftime("%Y%m%d-%H%M%S") | ||
| backupdir = "%s.%s" % (dir_name, timestamp) | ||
| move_file(dir_name, backupdir) | ||
| self.log.info("Moved old directory %s to %s", dir_name, backupdir) | ||
| if not clean: | ||
| self.log.info("Creating backup of directory %s...", dir_name) | ||
| timestamp = time.strftime("%Y%m%d-%H%M%S") | ||
| backupdir = "%s.%s" % (dir_name, timestamp) | ||
| if clean_instead_of_remove: | ||
| copy_dir(dir_name, backupdir) | ||
| self.log.info(f"Copied old directory {dir_name} to {backupdir}") | ||
| else: | ||
| move_file(dir_name, backupdir) | ||
| self.log.info(f"Moved old directory {dir_name} to {backupdir}") | ||
| if clean_instead_of_remove: | ||
| # clean the installation directory: first try to remove it; if that fails, empty it | ||
| clean_dir(dir_name) | ||
| self.log.info(f"Cleaned old directory {dir_name}") | ||
| else: | ||
| remove_dir(dir_name) | ||
| self.log.info(f"Removed old directory {dir_name}") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this whole block be under an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, only the last else block can go under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 66ae73d |
||
|
|
||
| if dontcreateinstalldir: | ||
| olddir = dir_name | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.