-
Notifications
You must be signed in to change notification settings - Fork 83
do_adjust_git: FileExistsError on dangling symlinks when DL_DIR path changes #122
Copy link
Copy link
Open
Description
Summary
do_adjust_git() in meta/classes-recipe/dpkg-base.bbclass fails with
FileExistsError when DL_DIR changes between kas-container sessions,
leaving a dangling symlink at ${WORKDIR}/git.
Root Cause
Lines 30 and 33 use os.path.exists(), which follows symlinks. When the
symlink target no longer exists (dangling), os.path.exists() returns
False — even though the symlink itself still exists on disk.
This causes:
- Line 30: The stale symlink check (
if os.path.exists(git_link) and ...)
evaluates toFalse, so the dangling symlink is not removed. - Line 33: The creation check (
if not os.path.exists(git_link)) evaluates
toTrue, soos.symlink()attempts to create a new symlink — but
the old one still exists, raisingFileExistsError.
Reproduction
- Run an ISAR build with
DL_DIR=/path/a - Change
DL_DIRto/path/b(e.g., kas-container mounts change between sessions) - Run the build again —
do_adjust_gitfails with:FileExistsError: [Errno 17] File exists: '/path/b/git' -> '${WORKDIR}/git'
Fix
Replace os.path.exists() with os.path.lexists() on both lines.
os.path.lexists() checks for the existence of the path itself (the symlink
entry) rather than following the symlink to its target.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels