← Back to issue list

Give `organize` access to variables set during the build step

View original Github issue

Metadata

Project
snapcraft
Number
#5241
Type
issue
State
open
Author
dilyn-corner
Labels
Status: Triaged Type: Enhancement
Created
Updated
Closed
—

Current evaluation

Enhancement: let `organize` expand variables defined in build-environment or computed during the build step. Triaged as valid; maintainer mr-cal filed upstream craft-parts#1076 (open), so it awaits work in craft-parts.

Suggested action: keep open

Reason: Labelled 'Status: Triaged'/'Type: Enhancement' and explicitly endorsed by maintainer mr-cal ("I think this is a good idea"), who filed the upstream bug craft-parts#1076 (still open). No fix exists in this repo: craft_parts/executor/part_handler.py calls organize_files() with the raw spec.organize_files dict and there is no expandvars/environment-substitution call anywhere in craft-parts, so the behaviour is unimplemented. Impact is moderate convenience (override-build mv workaround exists), and complexity is nontrivial because shell-local variables computed inside override-build (e.g. kver) cannot simply be read from the parent environment — craftctl set/project-variable plumbing or new semantics are needed.

Evaluated by: mr-cal-bot

Impact: 32 Quick Win: 10 Complexity: 60 Confidence: 86 Actionability: 80

Issue body

### What needs to get done When snapcraft performs the build step for a part, keys in `build-environment` or variables set during the build should exist for the `organize` portion of the build step to use. ### Why it needs to get done Suppose something like the below: ``` parts: foo: build-environment: NAME: bar VERSION: baz ``` If some piece of `foo` needs to be in a specifically named directory, this must currently be done manually: ``` override-build: | craftctl default mv -f "${CRAFT_PART_INSTALL}/my/file" "${CRAFT_PART_INSTALL}/$NAME/$VERSION/my/file" ``` The `organize` part of the build step is a more natural use-case: ``` organize: my/file: $NAME/$VERSION/my/file ``` The utility becomes more obvious just in case `$NAME` or `$VERSION` are generated and only known *during the build* (i.e. in the case of kernel snaps): ``` override-build: | craftctl default kver="$(basename "${CRAFT_PART_INSTALL}/lib/modules/"*)" organize: modules/**/kernel/drivers/net/wireless/rtw88: (component/wlan)/modules/$kver/kernel/drivers/net/wireless/rtw88 ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 32
Quick Win: 10
Complexity: 60
Confidence: 86
Actionability: 80
keep open Enhancement: let `organize` expand variables defined in build-environment or computed during the build step. Triaged as valid; maintainer mr-cal filed upstream craft-parts#1076 (open), so it awaits work in craft-parts.
qwen/qwen3.6-35b-a3b
Impact: 65
Quick Win: 23
Complexity: 55
Confidence: 75
Actionability: 80
keep open Enhancement to allow organize keyword to reference variables set during build step. Triaged and tracked upstream in craft-parts#1076, both open with no progress.
qwen/qwen3.8-27b
Impact: 50
Quick Win: 20
Staleness: 55
Complexity: 60
Confidence: 75
Support Request: 5
keep open Enhancement request to allow the organize keyword to access build-environment variables and variables set during the build step. Triaged by a maintainer and tracked upstream in craft-parts#1076, which remains open with no progress.
qwen/qwen3.6-35b-a3b
Staleness: 70
Complexity: 40
Confidence: 85
Support Request: 10
keep open Enhancement request to allow organize directives to access variables defined in build-environment or set during override-build. Triaged, with maintainer support and an upstream craft-parts issue created.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 40
Confidence: 80
Support Request: 10
keep open Feature request to let organize directives access build-environment or override-build variables. Triaged, escalated upstream, and awaiting resolution despite over a year of inactivity.

Update history

No update history recorded yet.

Related work

  • Blocked By: craft-parts#1076 (confidence 95%)

    mr-cal created this upstream issue; organize is implemented in craft_parts/executor/organize.py, so snapcraft cannot fix it alone.

Related issues

Issue Project State Summary Similarity
#1076 Give organize access to variables set during the build step #5241 craft-parts open Enhancement to let organize reference variables populated during the build step, enabling paths known only at build time; triaged and still open with no implementation evidence.
78%