pluginhandler: organize in build instead of stage
Metadata
Current evaluation
Merged PR #2047 moved organize handling from stage to build, fixing repeat staging and ensuring collision detection sees organized files.
Resolution: closed resolved
Reason: PR #2047 was approved and merged as commit be5982a1d, moving organization to the end of the build step so staging and collision detection use the final file layout.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh unit`?
-----
Currently, Snapcraft organizes during the stage step. This is terrible for two reasons:
1. The organization actually occurs in the installdir, which belongs to the build step. As a result, a snap that uses the `organize` keyword cannot in some cases be staged twice (i.e. have the stage step cleaned, and then staged again) because the organization cannot always happen twice.
2. Since organization only happens in the stage step, and collision detection runs before any parts are staged, collision detection doesn't take the organization into account. As a result, one cannot use the `organize` keyword to get around file collisions between parts, even though we recommend it for exactly that use.
This PR fixes #2031 and LP: [#1628098](https://bugs.launchpad.net/snapcraft/+bug/1628098) by completing the organization at the tail end of the build step, so the part is already organized when it comes time to check for collisions and stage.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #2047 moved organize handling from stage to build, fixing repeat staging and ensuring collision detection sees organized files. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #2047 moved the organize keyword from staging to the build step, fixing rebuild failures and making collision detection account for organized files. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged. Relocates file organization from the stage step to the build step in Snapcraft, resolving double-staging failures and ensuring collision detection accounts for organized files. Approved by reviewer. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Relocates organize keyword execution from the stage step to the end of the build step. This resolves re-staging failures and enables collision detection to account for file relocations, fixing issues #2031 and LP: #1628098. |
Update history
No update history recorded yet.
Related work
-
Related To:
snapcraft#2031
(confidence 100%)
Underlying inconsistent-rebuild issue explicitly identified as fixed by PR #2047.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2290 pluginhandler: update build should overwrite organize | snapcraft | merged | Merged PR #2290 at commit 2cef6c3f6 made organize overwrite previously organized files and directories, allowing build updates without cleaning and resolving LP #1794083. | |
| #2305 [legacy] pluginhandler: update build should overwrite organize | snapcraft | merged | Merged legacy backport PR #2305 of #2290, fixing LP #1794083 so update builds can overwrite files arranged by organize. | |
| #1628098 organize needs to run after build in stage | snapcraft (launchpad) | closed | Organize was moved from stage to build by merged PR snapcore/snapcraft#2047 (commit be5982a1d), so files are organized right after build; rebuilds and collision checks now see organized names. | |
| #2450 pluginhandler: handle removal of inconsistent files | snapcraft | merged | Merged PR #2450 in commit 9fdd3bdc7, making cleanup tolerate manually removed stage/prime files and warn instead of failing. | |
| #920 pluginhandler: ensure staged files are included in the prime step. | snapcraft | merged | Merged PR #920 as commit 5a253c13a, including staged files in prime when prime uses wildcards or only exclusions and fixing missing staged artifacts. | |
| #1592 Refactor and integrate organize from build | craft-parts | closed | Reintroduced organize-from-build in merged PR #1598 (commit cc02958b), with (build) as a source partition whose files are copied rather than moved. | |
| #1618 fix: handle dependencies when organizing to overlay | craft-parts | merged | Merged PR #1618 (commit 18239b07) fixes dependency scheduling when organizing to overlay, prioritizing BUILD/organize over dependency STAGE steps and closing #1611. |