4

I am creating a snap package of the Dart language sdk. Here is the snapcraft.yaml

name: dart-sdk
version: 2.0.0
summary: Dart Language SDK
description:  This includes the Dart SDK

confinement: classic
parts:
  dart-sdk:
    plugin: dump
    source: https://storage.googleapis.com/dart-archive/channels/stable/release/2.0.0/sdk/dartsdk-linux-x64-release.zip

    build-packages:
      - wget
      - unzip 

After I install it, it goes into /snap/dart-sdk/current/dart-sdk, but the directory requires root permissions to access. How can I make the snap package so that when I install it, the sdk directory has user permissions instead of root?

richalot
  • 91
  • 2
  • What do you mean by "the directory requires root permissions to access"? What is the actual permission mode and user and group ownership of the problem directory? And what exactly do you mean by "user permissions instead of root" in terms of permission mode and user and group ownership? – Robie Basak Nov 06 '18 at 16:05
  • type: /snap/dart-sdk/current/dart-sdk --> permission denied. – richalot Nov 07 '18 at 03:39
  • As an sdk, I need for other applications to access it. I cannot access the directory without typing sudo first. If it were user permission, you would automatically have access to the file without sudo. The actual permission for the directory is root only. – richalot Nov 07 '18 at 03:45
  • @rchkm By the way could you review the question to make it clear. Like you explained in the comments bellow my answer. May be better to mention the workflow how you want to use snap , because is not standard (at least not what most readers expect). – user.dz Apr 24 '20 at 05:21

1 Answers1

0
  • No, that breaks the purpose of snap. So snap does not allow changing app on the fly.

  • Also, I see no benefit of converting binary archive to snap, as you intended to do.

    Anyway, you can override prepare: and extract that binary archive. So it get snap'ed.

  • The correct way is to build snap from source package. So you can be sure it will work with any platform. By the way snapcraft is not well documented, better to learn from snapd source code and resent snapcraft.yaml in open source repositories.

user.dz
  • 47,137
  • 13
  • 140
  • 258
  • Thank you for your thoughts. I apologize for not being clear in my question. I need the snap application to be – richalot Apr 24 '20 at 04:39
  • Second try: Thank you for your thoughts. I apologize for not being clear in my question. 1. I need the snap application to be readable, not writeable. It cannot be read without root privileges. An app is of no use if it cannot be read. 2. The benefit of snapping a binary is convenience. It is easier to install and update a snap than it is to extract a binary, place it in the desired location, and do this every few weeks as the binary is updated upstream. 3. Can you explain how prepare is used in this situation? – richalot Apr 24 '20 at 04:49
  • @rchkm You welcome 1. The owner will be `root:root` but read permission for all that's the default. May be you have something in you setup. I will give it a try when i have time. see example. 2. So you are using it just as a local store for that package. Then if the first one didn't work, you may put it in another path that is for Data check https://snapcraft.io/docs/snap-layouts , even you can create a script in `apps:` to copy/extract it for you. 3. `prepare: cmd` will run cmd before `stage` step. `prepare:` is a child of part (dart-sdk). I will update the answer after i'm able to try it. – user.dz Apr 24 '20 at 05:11
  • @rchkm example here: https://paste.ubuntu.com/p/ygXS5Td6PN/ (comment was too long) – user.dz Apr 24 '20 at 05:13