Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full integration of snapcraft #914

Closed
ghost opened this issue Jan 8, 2019 · 12 comments
Closed

Full integration of snapcraft #914

ghost opened this issue Jan 8, 2019 · 12 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@ghost
Copy link

ghost commented Jan 8, 2019

Snapcraft 3.0 introduces new functionality that is currently not supported in goreleaser. It would be really useful to reflect these changes in goreleaser and allow full compatibility with snapcraft.

Example: base:core18

The base keyword specifies a special kind of snap that provides a minimal set of libraries common to most applications, and it is mounted as the root filesystem for application.

Proposed enhancement

Allow developers to import entire snapcraft.yaml into .goreleaser.yml as is, and then selectively replace specific fields, e.g. name, description using variables (to allow integration and automatic builds), but then pass other declarations to snapcraft without additional syntactic checks (in these are not explicitly supported in goreleaser).

@caarlos0
Copy link
Member

caarlos0 commented Jan 8, 2019

which fields are missing? (besides base)?

@caarlos0 caarlos0 added the enhancement New feature or request label Jan 8, 2019
@caarlos0
Copy link
Member

caarlos0 commented Jan 8, 2019

If you have a documentation link it will also be helpful.

I tried looking into https://docs.snapcraft.io/snapcraft-yaml-reference/4276, but couldn't find anything related to core18 and the base and core links does not work...

Another question I have is: can I declare dependencies? For example, if I have an app that depends on git... how can I make it work?

@ghost
Copy link
Author

ghost commented Jan 9, 2019

Hi Carlos,

So here's what I was thinking (apart from the fields you already support):

Parts

For example, this include:

parts:
appname:
plugin: go
source: https://github.com/something.git
go-importpath: github.com/something

But this could look different for other languages, like python for instance - this isn't the scope of go, but the idea is that there are keywords you might not necessarily use in a given scenario, but they could exist, and someone may try them.

parts:
appname:
plugin: python
python-version: python2
source: https://github.com/something.git

Anyway, these are two examples where you also use plugins to build, with language-specific overrides.

There could also be stage packages and build packages:

parts:
something:
plugin: go
source: https://github.com/something/something.git
go-importpath: github.com/something
build-packages:
- build-essential
- libpcap-dev
- libnetfilter-queue-dev
stage-packages:
- libpcap0.8
- libnfnetlink0
- libnetfilter-queue1

BTW, we have language guide wizards here: https://snapcraft.io/first-snap

This is the more relevant documentation:
https://docs.snapcraft.io/the-snapcraft-format/8337
https://docs.snapcraft.io/snapcraft-parts-metadata/8336
https://docs.snapcraft.io/snapcraft-app-and-service-metadata/8335

Hooks

Conditional triggers:
https://docs.snapcraft.io/supported-snap-hooks/3795

I agree that the current documentation can be improved, and I'll take your feedback as another pointer on this.

My suggestion would be - if there's a declaration that you don't support it at the moment, ignore it and pass it on to snapcraft as is, and worse case, there will be an error in snapcraft but the build won't be blocked by goreleaser.

Hopefully, this makes sense.

Thanks.

Snapcraft
Snaps are containerised software packages that are simple to create and install. They auto-update and are safe to run. And because they bundle their dependencies, they work on all major Linux systems without modification.

@guilhem
Copy link
Contributor

guilhem commented Jan 25, 2019

Since snapcore/snapd#5845 is solved, we can set files permitted to be edited by software. (without having to be native confinement)

plugs:
  personal-files:
    read:
      - $HOME/.kube/config
      - $HOME/.minikube/client.key
      - $HOME/.minikube/client.crt
      - $HOME/.minikube/ca.crt

This is not in apps.plugs

aliases is also really important when your repository have multiple binaries.

Here is a complete list of yaml parameters: https://github.com/snapcore/snapd/blob/master/snap/info_snap_yaml.go#L35

GitHub
The snapd and snap tools enable systems to work with .snap files. - snapcore/snapd

@caarlos0
Copy link
Member

if I understand correctly, the parts thing is used to build the snap, right? If so, it doesn't make sense for goreleaser, as the binary will be already compiled...

@ghost
Copy link
Author

ghost commented Jan 25, 2019

You can use parts with the dump plugin - so you don't compile, you just grab the source. But then, if you compiled with different libraries than snapcraft has (in its base), you will need to specify them as stage packages.

https://docs.snapcraft.io/the-dump-plugin/8007

But if you support all parts/plugins, developers have the options to choose what they need.

Thanks!

@stale
Copy link

stale bot commented Feb 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Feb 8, 2019
@stale stale bot closed this as completed Feb 15, 2019
@jimafisk
Copy link

jimafisk commented Jun 4, 2020

This feature would be really great to have! We're building a static site generator with a Go CLI that requires running npm and node to compile svelte components. Unfortunately we aren't able to execute npm/node outside of our snap: plentico/plenti#31

I was able to add home and network-bind plugs to allow writing to the filesystem and serving a local website while still using strict confinement. However, it would require classic confinement to execute the user's system npm/node, which under manual review it was suggested to use stage-packages/stage-snaps instead: https://forum.snapcraft.io/t/classic-confinement-request-for-plenti/17803/9?u=jimafisk

@caarlos0
Copy link
Member

caarlos0 commented Jun 4, 2020

happy to review a PR on that. :)

FWIW there is one opened that adds some stuff #1553

@jimafisk
Copy link

jimafisk commented Jun 4, 2020

Thanks and sorry if I came across as demanding. Goreleaser is amazing, I def appreciate all the hard work the team is doing :).

@caarlos0
Copy link
Member

caarlos0 commented Jun 4, 2020

No problem at all, just that I don't have time to work on this right now, so if someone can work on a PR it would be awesome :)

sorry if I sounded defensive or something, was not the intent

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants