Simple and easy steps to convert a script to snap app

you are missing a plug, please follow my advice from the other thread to use snappy-debug so you get a list of all required plugs.

using snappy-debug is an essential part of developing snaps so you should really familiarize with it …

1 Like

Hi, I’ve followed your advice and snappy-debug has solved almost everything but what I keep getting is Log: apparmor="DENIED" operation="create" profile="snap.daily-quotes.daily-quote" pid=178651 comm="curl" family="inet6" sock_type="dgram" protocol=0 requested_mask="create" denied_mask="create" I believe its denying the command curl and I’m not sure why. I’ve checked everything but I keep getting it

hmm, does it not tell you to add the network-bind plug below this error ?

any type of network based sock syscalls should be covered by this plug … sounds like snappy-debug is missing the hint for this if it did not actually tell you about it …

nope, but it did tell me to add network-control

ah, network-control includes the features of network-bind but needs to be manually connected, try switching that one over to the *-bind one (this one auto-connects) and the message should go away without having to call snap connect ... explicitly :slight_smile:

Let me try that also in the meantime I’m curious to know how do you connect a plug when you want? like do you just put snap connect foo:plug in your script?

no, it is something the user has to do after installing the snap … plugs that do not auto-connect are usually giving access to something the user should be aware of

i.e. using a network socket is simply how you talk to the internet with most apps, so this can automatically connect … using network-control which gives the app full control over the machines network way beyond just creating a socket, is something the user needs to explicitly grant

1 Like

Hi again, so after debugging of one hours I solved all the errors from my app except for the cp $SNAP/daily-quotes.desktop $SNAP_USER_DATA/local/autostart/daily-quote.desktop command. Error:

cp: cannot create regular file '/home/nick/snap/daily-quotes/x1/local/autostart/daily-quotes.desktop': No such file or directory

I tried getting the full path of the desktop file with the command snap run --shell daily-quotes.daily-quote but did not help.

I’m basing this on the latest commit in your repo.

Again:

As per your new snapcraft.yaml, you dump the desktop file straight into the snap. Therefore, your copy command must be:

Make sure to create the target directory first:

mkdir -p "$SNAP_USER_DATA/.config/autostart"

Also, according to the docs, you need to add autostart: daily-quotes.desktop to your app in your snapcraft.yaml.

Refer to this example snap: https://github.com/ppd/syncthing-snap It’s much easier to start out by copying already functional code. I don’t know how you got from the recommendations above, with explicit mentioning of the necessary shell variables, to what you’ve got in your repo, but it’s not exactly rocket science to figure out why it’s not working if you don’t follow the instructions.

1 Like

Alright let me try that, one more question tho what path does $SNAP and $SNAP_USER_DATA return? I keep getting confused between both of them

The env variables are documented here: https://snapcraft.io/docs/environment-variables

1 Like

Thanks a lot, I finally understand the paths and after following your github repo I finally got my script to work! Just one more question, is it possible to remove a published .snap on a latest/beta channel?

Also I’m not sure why but I have -dirty in the end of my .snap file

Congrats!

I believe you can simply close the channel: https://snapcraft.io/docs/channels#Closing%20channels

That happens when you build from a repository that is “dirty”, i.e. it has changes that haven’t been committed yet.

1 Like

ah! sorry to bother you again but one more little thing I’ve been curious about, I have the keyword git in my .snap file name daily-quotes_0+git.ec0f7fc_amd64.snap while others don’t :frowning_face:

You can set the version yourself if you like that better:

An example for the latter, based on the Git hash: https://github.com/FreeCAD/FreeCAD-snap/blob/41fe7038fec0a5261cdb860c1f6d9908c36de746/snap/snapcraft.yaml#L241

1 Like

is it compatible with rh9 ?