Snapcraft doesn't ignore already-built snaps when `source` is the folder containing the `snapcraft.yaml`
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snapcraft |
Fix Released
|
Medium
|
Sergio Schvezov | ||
snapcraft (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Xenial |
Fix Released
|
Undecided
|
Unassigned | ||
Yakkety |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[Impact]
* Many plugins support sources. When the `source` keyword points to the directory containing the `snapcraft.yaml`, Snapcraft creates a copy of that entire directory, including any snaps that have already been built (which can be very large).
[Test Case]
1. Download and run `snapcraft` on http://
2. Run `snapcraft clean`. This shouldn't remove the .snap.
3. Run `snapcraft` again.
4. Notice that the .snap that was already built was copied into `parts/foo/build/`.
5. Apply the fix for this bug.
6. Run steps 2 and 3 again.
7. Notice that the .snap that was already built was NOT copied into `parts/foo/build/`.
[Regression Potential]
* When copying the source folder, Snapcraft-specific data is excluded (e.g. parts/ stage/ snap/ snapcraft.yaml, etc.). That data may no longer be excluded correctly.
description: | updated |
Changed in snapcraft: | |
milestone: | none → 2.9 |
summary: |
- "copy" plugin symlinks whole snap folder when no source is given + Snapcraft doesn't ignore already-built snaps when `source` is the folder + containing the `snapcraft.yaml` |
description: | updated |
Changed in snapcraft: | |
milestone: | 2.9 → 2.10 |
Changed in snapcraft: | |
status: | New → In Progress |
importance: | Undecided → High |
assignee: | nobody → Sergio Schvezov (sergiusens) |
Changed in snapcraft: | |
status: | In Progress → Fix Committed |
Changed in snapcraft (Ubuntu Xenial): | |
milestone: | none → xenial-updates |
Changed in snapcraft: | |
status: | Fix Committed → Fix Released |
Some clarification.
The biggest problem I have with the current approach is that anything, apart from blacklisted files/folders, will be copied to the build folder of every part which uses the copy plugin. If one keeps the built snaps in the root folder of the project, they will all end up in the part' s build folders. Same thing if you keep archives in various src/part folders.
I fail to see a real use case for copying the whole project folder to the build folder, apart for some very minimalistic projects which don't use a src folder, so even if snaps end up being blacklisted, the whole recursively copying the top folder bugs me as an approach. Similar issue if '.' is moved to 'src' as a default.
If you look at the snippet I've posted, it's very simple and should only copy one file. You could argue that adding an extra line of configuration doesn't make it less elegant and I would agree, but the problem is that others may make the same mistake I did and end up with GBs of extra data in their project until they realise what's happening, like I did.
Since "source" is used in more than just the copy plugin, there may be problems with changing the approach, so maybe it's simply a documentation (or user :P) issue.