← Back to issue list

usrmerge handling is not dealing with subdirectories

View original Github issue

Metadata

Project
rockcraft
Number
#187
Type
issue
State
closed
Author
tigarmo
Labels
—
Created
Updated
Closed

Current evaluation

Fixed by PR #200 (commit 3f43e30e, "oci: fix handling of subdirs in usrmerge"); files and subdirs under base-layer usrmerge symlinks (e.g. lib) are now archived at the symlink target path. Closed by maintainer tigarmo.

Resolution: closed resolved

Reason: Maintainer tigarmo closed the issue with the comment "fixed by #200"; PR #200 was merged as commit 3f43e30e "oci: fix handling of subdirs in usrmerge", which changes _archive_layer in rockcraft/oci.py so subdirectories under a base-layer usrmerge symlink are written to the symlink target. Later follow-up commits (1783fa2a, c3382fc2) refined the same usrmerge directory handling.

Evaluated by: mr-cal-bot

No scores available.

Issue body

Our [code](https://github.com/canonical/rockcraft/blob/main/rockcraft/oci.py#L347) that archives the lifecycle payload as a new layer is taking the usrmerge into account when handling files, but *not* when handling subdirectories; So for example, if a part primes two files: ``` - bin/f1 - lib/subdir/f2 ``` `bin/f1` will be correctly archived as `usr/bin/f1`, *but* `lib/subdir/f2` will stay as `lib/subdir/f2`, possibly breaking the usrmerge symlink (depends on the version of... something). Here's a rockcraft.yaml that repros this: ``` name: usrmerge-dir-bug base: ubuntu:22.04 version: '0.1' summary: usrmerge-dir-bug description: usrmerge-dir-bug license: GPL-3.0 platforms: amd64: parts: p1: plugin: nil override-build: | cd ${CRAFT_PART_INSTALL} mkdir bin touch bin/f1 mkdir -p lib/subdir touch lib/subdir/f2 ``` Building it and then loading it in dive shows the issue; see on the right the `lib` entry has no permissions - that's the tell that it's broken: ![image](https://user-images.githubusercontent.com/1951299/217341142-1819a7a1-7665-4040-bfa7-9c77dfdee6a8.png) The build log shows it too: ``` 2023-02-07 16:02:11.359 :: 2023-02-07 19:02:10.607 Creating new layer 2023-02-07 16:02:11.359 :: 2023-02-07 19:02:10.608 Skipping /root/prime/bin because it exists as a symlink on the lower layer 2023-02-07 16:02:11.359 :: 2023-02-07 19:02:10.608 Adding to layer: /root/prime/bin/f1 as 'usr/bin/f1' 2023-02-07 16:02:11.359 :: 2023-02-07 19:02:10.614 Skipping /root/prime/lib because it exists as a symlink on the lower layer 2023-02-07 16:02:11.359 :: 2023-02-07 19:02:10.614 Adding to layer: /root/prime/lib/subdir 2023-02-07 16:02:11.359 :: 2023-02-07 19:02:10.615 Adding to layer: /root/prime/lib/subdir/f2 as 'lib/subdir/f2' ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed by PR #200 (commit 3f43e30e, "oci: fix handling of subdirs in usrmerge"); files and subdirs under base-layer usrmerge symlinks (e.g. lib) are now archived at the symlink target path. Closed by maintainer tigarmo.
stealth/space-bunny-alpha — closed resolved Fixed by merged PR canonical/rockcraft#200 (commit 3f43e30e), correcting OCI subdirectory archiving when the payload is usrmerged.
qwen/qwen3.6-35b-a3b — — Rockcraft's usrmerge handling incorrectly processed subdirectories, breaking symlinks. The bug was fixed and closed by pull request #200.
qwen/qwen3.6-35b-a3b — — Fixed by PR #200. Updated rockcraft's layer archiving logic to correctly apply usrmerge transformations to subdirectories, preventing broken symlinks and permission errors in the resulting container image.
qwen/qwen3.6-35b-a3b — — Fixed usrmerge handling for subdirectories in rockcraft's OCI layer archiving. Subdirectories under lib were previously archived without merging, breaking symlinks. Resolved by merging PR #200.
qwen3.6-35b-a3b-mtp-q6 — — Rockcraft's usrmerge logic incorrectly preserved subdirectory paths instead of mapping them to usr/ during OCI layer creation. Resolved by merge of pull request #200.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/rockcraft#200 (confidence 98%)

    Merged PR fixing usrmerge subdir handling; commit 3f43e30e, cited in the closing comment.

  • Related To: canonical/rockcraft#211 (confidence 70%)

    Follow-up commit 1783fa2a "oci: fix handling of symlink subdirs" refining the same code path.

  • Related To: canonical/rockcraft#163 (confidence 55%)

    Prior commit 501e6eae handling opaque whiteouts in new layer (usrmerge) that #200 builds on.

Related issues

Issue Project State Summary Similarity
#200 oci: fix handling of subdirs in usrmerge rockcraft merged Merged in PR #200 as commit 3f43e30e, fixing OCI usrmerge so subdirectories beneath base-layer symlinks are written to the symlink target.
85%
#154 first pass at handling usrmerge rockcraft merged Merged PR #154 (commit 607d934f, "oci: handle symlinks in base layer (usrmerge)"). add_layer() now takes the extracted base, so files primed under /lib or /bin are written to the usrmerge symlink target (/usr/lib, /usr/bin) instead of breaking Ubuntu-based rocks; lifecycle passes the base forward.
79%
#204 oci: handle duplicate directories because of usrmerge rockcraft merged Merged #204 as c3382fc2, fixing OCI failures from usrmerge-aliased duplicate directories with matching attributes; mismatched attributes and file conflicts still error.
73%