It has been requested often that once a snap is in the store, in the case of open source snaps, there is no easy way to rebuild that snap. During different conversations with the security team, it was also mentioned that it is not as easy to track CVEs that would concern the owners of such snaps.
For a while now we’ve been working on the plumbing layers for richer syntax for stage-packages
, build-packages
and source
entries.
Additionally, during the hooks
implementation workflow implementation in snapcraft we came to the agreement of snapcraft owning a directory withing the snap under snap
and snapcraft projects would load their configuration from snap/snapcraft.yaml
as a default.
Add all these things up and the proposal is to:
- record all assets used in every part
- recreate the
snapcraft.yaml
with annotated assets insnap/snapcraft.yaml
What does this allow is for someone to download the snap and:
- extract the
snap
directory from the snap to rebuild - track versions of assets used (for whatever reasons) along the lifetime of the snap
The answer to why to go with the format of a snapcraft.yaml
for this recording task is that it is already understood by anyone already working on snapcraft and (given the environment) a way to rebuild.
So how does this look? Well here is a first pass for it (of an existing implementation):
name: godd
version: 1.0
summary: Simple dd like tool
description: Written in go with support for device auto-detection via libgudev, you
would need to use hw-assign to access devices.
grade: stable
architectures: [amd64]
confinement: strict
apps:
godd:
command: command-godd.wrapper
plugs: [mount-observe]
parts:
godd:
build-packages: ['gcc=4:6.3.0-2ubuntu1', 'libgudev-1.0-dev=1:230-3']
go-importpath: github.com/mvo5/godd
plugin: go
prime: []
snap: []
source: https://github.com/mvo5/godd
source-branch: ''
source-checksum: ''
source-commit: 5c75ebcdca9d17cec693af13a7adebdccb8ae639
source-source: https://github.com/mvo5/godd
source-tag: ''
source-type: git
stage: []
stage-packages: []
There is some cleanup work here:
- we need to move to
OrderedDict
so the yaml looks nice. - (maybe) remove empty entries, they are mostly noise.
- fix the
command
entry to be transparent. - have a keyword to identify the
remote
when using local sources.
With that said, a final implementation, from something like:
name: godd
version: 1.0
summary: Simple dd like tool
description: |
Written in go with support for device auto-detection via libgudev,
you would need to use hw-assign to access devices.
confinement: strict
apps:
godd:
command: bin/godd
plugs: [mount-observe]
parts:
godd:
source: https://github.com/mvo5/godd
source-type: git
plugin: go
go-importpath: github.com/mvo5/godd
build-packages: [gcc, libgudev-1.0-dev]
You will get
name: godd
architectures: [amd64]
version: 1.0
summary: Simple dd like tool
description: |
Written in go with support for device auto-detection via libgudev, you
would need to use hw-assign to access devices.
grade: stable
confinement: strict
apps:
godd:
command: godd
plugs: [mount-observe]
parts:
godd:
source: https://github.com/mvo5/godd
source-type: git
source-commit: 5c75ebcdca9d17cec693af13a7adebdccb8ae639
plugin: go
go-importpath: github.com/mvo5/godd
build-packages: ['gcc=4:6.3.0-2ubuntu1', 'libgudev-1.0-dev=1:230-3']