Skip to content
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

prepare_build_dirs: handle copytree FileExistsError #761

Merged
merged 1 commit into from
Oct 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/portage/package/ebuild/prepare_build_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,21 @@ def _ensure_log_subdirs(logdir, subdir):
ensure_dirs(current, uid=uid, gid=gid, mode=grp_mode, mask=0)


def _copytree(src, dst, **kwargs):
try:
shutil.copytree(src, dst, **kwargs)
except FileExistsError:
shutil.rmtree(dst)
shutil.copytree(src, dst, **kwargs)


def _prepare_fake_filesdir(settings):
real_filesdir = settings["O"] + "/files"
filesdir = settings["FILESDIR"]

# Copy files from real directory to ebuild directory (without metadata).
if os.path.isdir(real_filesdir):
shutil.copytree(real_filesdir, filesdir, copy_function=copyfile)
_copytree(real_filesdir, filesdir, copy_function=copyfile)
apply_recursive_permissions(
filesdir,
uid=portage_uid,
Expand Down