Skip to content

fix: use lexists() for symlink checks in do_adjust_git#123

Open
timblaktu wants to merge 1 commit intoilbers:nextfrom
kyosaku-kai:fix/do-adjust-git-dangling-symlinks
Open

fix: use lexists() for symlink checks in do_adjust_git#123
timblaktu wants to merge 1 commit intoilbers:nextfrom
kyosaku-kai:fix/do-adjust-git-dangling-symlinks

Conversation

@timblaktu
Copy link
Copy Markdown

Fixes FileExistsError in do_adjust_git() when DL_DIR changes between kas-container sessions, leaving a dangling symlink at ${WORKDIR}/git.

os.path.exists() follows symlinks and returns False for dangling ones, so the stale symlink is never cleaned up and os.symlink() fails when it tries to create a replacement.

  • Line 30: os.path.exists()os.path.lexists() (stale link detection)
  • Line 33: os.path.exists()os.path.lexists() (pre-creation check)

os.path.lexists() checks for the symlink entry itself rather than following it to the target, correctly detecting and replacing dangling links.

When DL_DIR is mounted at different paths across kas-container sessions (e.g. host path vs container mount point), the .git-downloads symlink becomes dangling. exists() fails to detect it, so the cleanup branch is skipped and the subsequent symlink() call fails with FileExistsError.

Switch to os.path.lexists() which detects the symlink itself regardless of whether its target exists, allowing proper cleanup and re-creation.

The os.path.exists() on line 66 (alternates file check) is intentionally left unchanged — alternates is a regular file, not a symlink.

Closes #122

os.path.exists() follows symlinks and returns False for dangling
symlinks. When DL_DIR is mounted at different paths across
kas-container sessions (e.g. host path vs container mount point),
the .git-downloads symlink becomes dangling. exists() fails to
detect it, so the cleanup branch is skipped and the subsequent
symlink() call fails with FileExistsError.

Switch to os.path.lexists() which detects the symlink itself
regardless of whether its target exists, allowing proper cleanup
and re-creation.

The os.path.exists() on line 66 (alternates file check) is
intentionally left unchanged — alternates is a regular file,
not a symlink.
timblaktu added a commit to kyosaku-kai/n3x that referenced this pull request Feb 27, 2026
Update mirrors.yml PENDING placeholders with actual upstream tracking:
- Issue: ilbers/isar#122
- PR: ilbers/isar#123
timblaktu added a commit to kyosaku-kai/n3x that referenced this pull request Feb 27, 2026
* docs: rewrite tests/emulation/README.md from 912 to 120 lines

Remove vsim-era content: two mermaid diagrams, session history table,
stale path references (hosts/n100-*, modules/hardware/, modules/roles/,
VSIM-INTEGRATION-PLAN.md, tests/integration/), redundant architecture
sections, oversized platform/troubleshooting/ARM64/resource-control
sections, and "Integrated from vsim project" footer.

Retain: framework purpose with clear "not primary test infra" callout,
platform requirements, directory structure, build/run commands, inner-VM
usage (virsh, OVS, tc profiles), compact ASCII architecture diagram,
traffic control profile table, flake outputs, and references.

* fix: use stable kas-container mount points for DL_DIR/SSTATE_DIR

base.yml used ${HOME}/.cache/yocto/{downloads,sstate} in local_conf_header,
but inside kas-container, kas overrides HOME to an ephemeral tmpdir
(/tmp/tmpXXXXXX). BitBake expanded ${HOME} to that tmpdir, so all downloads
were destroyed when the container exited. Neither devShell nor kas-build
exported DL_DIR/SSTATE_DIR as host environment variables, so kas-container
never mounted a persistent cache directory.

Fix:
- kas-build wrapper (both Darwin and Linux): export DL_DIR and SSTATE_DIR
  with defaults of ~/.cache/yocto/{downloads,sstate}, using ${VAR:-default}
  so CI can override
- base.yml: hardcode /downloads and /sstate (the stable kas-container
  mount points that correspond to the host DL_DIR/SSTATE_DIR)
- Delete ci-cache.yml overlay (existed solely to override the broken ${HOME}
  paths for CI; now redundant)
- Remove ci-cache.yml from build-matrix.nix mkCiKasCommand
- Remove .git-downloads workaround from isar-build-all.sh and CI workflow
  (DL_DIR now resolves to /downloads which is stable across container
  sessions, so .git-downloads symlinks no longer go stale)
- Update CLAUDE.md: replace stale workaround docs with new caching docs

References: siemens/kas#52, siemens/kas#148

* fix: point ISAR repo at kyosaku-kai fork with symlink fix

Switch mirrors.yml from upstream ilbers/isar to our fork at
kyosaku-kai/isar on the fix/do-adjust-git-dangling-symlinks branch.

The fork contains a one-line fix: os.path.exists() → os.path.lexists()
in dpkg-base.bbclass do_adjust_git(), fixing FileExistsError when
DL_DIR mount paths change between kas-container sessions (dangling
.git-downloads symlink not detected by exists() which follows symlinks).

Revert to upstream once ilbers/isar merges the fix.

* fix: add upstream issue/PR references for ISAR symlink fix

Update mirrors.yml PENDING placeholders with actual upstream tracking:
- Issue: ilbers/isar#122
- PR: ilbers/isar#123
@jan-kiszka
Copy link
Copy Markdown
Contributor

Good catch, and the fix looks good. Please just have a look at https://github.com/ilbers/isar/blob/master/CONTRIBUTING.md.

Most critical is the missing DCO ("signed-off", see that doc for its semantic). Reviews happen on the mailing list. So, please submit there if possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants