sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.
https://yazi-rs.github.io
MIT License
16.3k stars 377 forks source link

Add snap to snapcraft.io #1631

Closed DevelSSN closed 1 month ago

DevelSSN commented 1 month ago

yazi --debug output

---

Please describe the problem you're trying to solve

Currently, builds of yazi are published standalone. Updating to the latest release will be difficult

Would you be willing to contribute this feature?

Describe the solution you'd like

Publish snaps to snapcraft.io Link to that in the docs

Additional context

No response

Validations

sxyazi commented 1 month ago

I have submitted the snap registration request to snapcraft.io, and now we need to wait for their approval.

screenshot-002008

sxyazi commented 1 month ago

Today I tried to use snapcraft push to publish, but failed with:

❯ snapcraft push yazi_0.3.3_amd64.snap
Issues while processing snap:ew
- (NEEDS REVIEW) confinement 'classic' not allowed. If your snap needs classic confinement to function, please make a request for this snap to use classic by creating a new topic in the forum using the'store-requests' category and detail the technical reasons why classic is required.

It seems that the classic confinement Yazi is using isn't allowed. Unfortunately, I'm not sure how to fix it since I've never used Snap myself — it was added by the community contributor.

I'll keep this issue open for a while to see if anyone can help fix it.

DevelSSN commented 1 month ago

Hey I am an end user of this, primarily due to its rust leanings. So is it ok if I publish to the store with relevant policies concerned? I love the file manager btw...

DevelSSN commented 1 month ago

Seems the snapcraft people need this:

Process

  • the publisher makes the request for classic confinement in the forum using the store-requests category
  • the technical reasons for why the snap uses classic confinement are gathered in the forum post and captured for potential >future snapd improvements. The technical requirements will be reviewed by the security team and/or an architect
  • the advocacy team, reviewers team and/or architects participate in vetting the snap/publisher
  • once the publisher has been vetted, the technical reasons are captured and the request is approved, a store reviewer will issue a snap declaration for the snap and add a comment to the store, giving the URL to the forum post

At the least, needs you to run some thread on the site

sxyazi commented 1 month ago

So is it ok if I publish to the store with relevant policies concerned?

Sure, go for it!

the technical reasons for why the snap uses classic confinement are gathered in the forum post and captured for potential >future snapd improvements. The technical requirements will be reviewed by the security team and/or an architect

This is something I don't know about - I'm not sure of the reason behind using classic or if it can be changed. Maybe @gapplef can give some pointers?

gnpaone commented 1 month ago

It seems that the classic confinement Yazi is using isn't allowed. Unfortunately, I'm not sure how to fix it since I've never used Snap myself — it was added by the community contributor.

Using strict confinement won't cause this error, classic confinement usually needs snap moderators approval due to package needing to access and modify system files while testing by snap sandbox environment. Checking this condition is required

sxyazi commented 1 month ago

So is it ok if I publish to the store with relevant policies concerned?

Hey @DevelSSN, any news about this? Do you still need our official support for it? If so, I'll add it to the tracker issue

DevelSSN commented 1 month ago

Yeah I started my college this week. Hectic one. Will check and do it by the weekend

DevelSSN commented 1 month ago

Hey I checked with docs I believe we can use the strict confinement after all

Add to snapcraft.yaml the line confinement: strict

Please branch it out, test this before merging back in

sxyazi commented 1 month ago

Hi @DevelSSN, I changed it to strict in https://github.com/sxyazi/yazi/commit/eca97fb6f12074ac39b715bdeadcaea7362286fa, and I've rebuilt the snap. Please download and test it at https://github.com/sxyazi/yazi/releases/tag/nightly to see if everything works fine.

DevelSSN commented 1 month ago

Will check and confirm to you by tomorrow

DevelSSN commented 1 month ago

Actually, I tried it now, and it failed to open even my Downloads folder, so no go. Will start with our snapcraft raise.

sxyazi commented 1 month ago

Thanks for the test!

it failed to open even my Downloads folder

Can it not start? Or does it start but can't load the directory? Any error messages?

gnpaone commented 1 month ago

Actually strict confinement by default cannot access any files or directories. But there's a way to request access to files and folders by the package: https://snapcraft.io/docs/snap-confinement#interfaces

sxyazi commented 1 month ago

I didn't understand this document - do these permissions need to be specified in snap's snapcraft.yaml?

gnpaone commented 1 month ago

Yes, it should be mentioned in snapcraft.yaml under yazi

Example:

apps:
  yazi:
    command: yazi
    environment:
      PATH: $SNAP/bin:$PATH
    plugs:
      - home
      - removable-media

All the available plugs can be found here: https://snapcraft.io/docs/supported-interfaces

Then in postinstall script you have to

sudo snap connect yazi:home
sudo snap connect yazi:removable-media

etc all the mentioned plugs in snapcraft.yaml

gnpaone commented 1 month ago

Yes, it should be mentioned in snapcraft.yaml under yazi

Example:

apps:
  yazi:
    command: yazi
    environment:
      PATH: $SNAP/bin:$PATH
    plugs:
      - home
      - removable-media

All the available plugs can be found here: https://snapcraft.io/docs/supported-interfaces

Then in postinstall script you have to

sudo snap connect yazi:home
sudo snap connect yazi:removable-media

etc all the mentioned plugs in snapcraft.yaml

You can verify if connected or not using snap connections yazi command

sxyazi commented 1 month ago

Then in postinstall script you have to

What does the "postinstall script" refer to? It seems like snap doesn't have this hook. The only thing I found is the pre-refresh hook, but it doesn't seem relevant.

Does this mean we need to create a separate installation script, download the snap from GitHub in that script, and then run sudo snap connect in it?

gnpaone commented 1 month ago

postinstall script must be present in yazi package, there are no hooks for this in snap. Actually sudo snap connect command must be run manually by the user after installing yazi, instead I recommend to add a postinstall script in yazi itself that will run the snap connect instead of user worrying about it. VLC and other apps does the same thing

gnpaone commented 1 month ago

Actually there is post install hook in snap, but it can only execute commands that doesn't affect the system such as echo command due to sandboxed environment of strict confinement. User must do snap connect in new shell or can be done by the package as a postinstall script as a workaround.

You can try the hooks. create a folder called hooks inside snap directory where snapcraft.yaml is present, then create a shell script with file name install inside hooks directory, you can put all the shell commands of post install in this file. Make the hook executable chmod +x snap/hooks/install

DevelSSN commented 1 month ago

The output was weird actually. Yazi opened, but got stuck in the loading part. What was even weird was that it was able to get the parent directory sturcture. Ex: in ~/Downloads then can see the / subdirectory, but not inside /usr/

gnpaone commented 1 month ago

The output was weird actually. Yazi opened, but got stuck in the loading part. What was even weird was that it was able to get the parent directory sturcture. Ex: in ~/Downloads then can see the / subdirectory, but not inside /usr/

Did you try the plugs? The home plug can only see what current user can control, not root files, there must be some other plug for that

DevelSSN commented 1 month ago

I am thinking of a flatpak option, because this is becoming quite ridiculous. Also, no offence, flatpak is quite universal over snap. Yet please try out. Please keep this open while I try flatpak builder out

On Tue, 1 Oct 2024, 08:41 Naveen Prashanth, @.***> wrote:

The output was weird actually. Yazi opened, but got stuck in the loading part. What was even weird was that it was able to get the parent directory sturcture. Ex: in ~/Downloads then can see the / subdirectory, but not inside /usr/

Did you try the plugs? The home plug can only see what current user can control, not root files, there's some other plug for that

— Reply to this email directly, view it on GitHub https://github.com/sxyazi/yazi/issues/1631#issuecomment-2384693111, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBRJ3Y633CHQ4PWVT5W6BDLZZIHGVAVCNFSM6AAAAABN67BTS6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBUGY4TGMJRGE . You are receiving this because you were mentioned.Message ID: @.***>

gnpaone commented 1 month ago

Yeah, it's better to go with classic confinement or other package manager than fiddling with strict confinement

sxyazi commented 1 month ago

I reverted back to classic in https://github.com/sxyazi/yazi/commit/e1773b11f1fcd545b5afac8d9cb460ec2a9bedc0 for now to avoid interruptions for nightly users

DevelSSN commented 1 month ago

Yeah, I checked the flatpak docs, seems meson or cmake is required, so no go. Forward with snap only for now.

sxyazi commented 1 month ago

I see, add it to the tracker for now - I'll try it again when I find some time.

To set expectations: I've never used snap myself, so I'll need some time to figure out how it works, but I might fail.

github-actions[bot] commented 5 days ago

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please file a new issue and complete the issue template so we can capture all the details necessary to investigate further.