dylanaraps / neofetch

🖼️ A command-line system information tool written in bash 3.2+
MIT License
22.18k stars 1.66k forks source link

Snappy package #645

Closed Ads20000 closed 6 years ago

Ads20000 commented 7 years ago

I'm trying to make a snappy package, I'm not a developer but want to give this a go anyway and any help is appreciated.

The snapcraft.yaml I have made is as follows (you save this file in a folder, then run snapcraft prime in the folder, then sudo snap try prime/ --devmode to test Devmode or sudo snap try prime/ to test Strict. Then use sudo snap connect neofetch:hardware-observe core:hardware-observe so that the Model entry works. You can then use neofetch in Terminal or snap run neofetch to ensure you're running the snap you just built. To update, just change the source to the new release and run snapcraft again, or you can even point the URL to the GitHub repo (and change grade to devel) and you can update it every now and then so it's using the new master code):

name: neofetch
version: 3.1.0
summary: Neofetch
description: A fast, highly customizable system info script
confinement: strict
grade: stable
apps:
  neofetch:
#  Export LC_ALL to workaround [LP: #1576411] (still get an error with this workaround though)
    command: env LC_ALL=C.UTF-8 $SNAP/neofetch
    plugs:
      - hardware-observe

parts:
  neofetch:
    plugin: dump
    source: https://github.com/dylanaraps/neofetch.git
    source-tag: 3.1.0
    stage-packages:
      - w3m
      - imagemagick
      - cmus
      - feh
      - mpc
      - nitrogen
      - scrot
      - x11-utils
      - moc
    after:
#     wimpress said this would help with Themes and Fonts but it doesn't seem to do so
      - desktop-glib-only

We may not need all the stage-packages, they are just the suggests from the Debian package which I thought I'd add to see if it would get more of Neofetch working, we should probably remove them one-by-one and see if doing that removes any functionality (I'm assuming we don't need to install Bash?!). I think the dependencies are included in the snap, so doing so would bring down the file size (with those stage-packages it is 63.7 MB, without them it is 65.5 KB). Also note that we need to confine the snap. If I don't give it any interfaces, we get the following from snap run neofetch: strict with stage-packages

In devmode, where the snap isn't confined: With stage-packages: devmode with stage-packages Without stage-packages: devmode without stage-packages

We're losing Model, Theme and Icons when we confine the snap.

We can also see from this that we're losing Resolution and WM without stage-packages.

However, when I use usr/bin/neofetch to load the PPA package version of Neofetch...: ppa package

We get Packages, WM Theme and GPU. The most important of these is probably GPU (since this is a snap, do we need to know how many Debs are installed? Or maybe we need a new feature which can detect Deb and snap packages when snapd is on the system).

Also, it's meant to say what the wallpaper is and what music is playing? That doesn't seem to work for the PPA Deb package either for me (not when playing music in Rhythmbox), so that's not a fault in the snap I don't think. What other features in Neofetch are there which should be supported by the snap? I've only tried running neofetch so far, with the Deb and with the snap.

Any thoughts?

Btw, justification for making a snap package, it's like a PPA in that it can be updated to the latest version on any Ubuntu system, except there's no risk of dependency hell because dependencies can be included if Ubuntu Core doesn't provide the necessary versions. It's confined (more secure) and simpler (once we've made the first working snap anyway) and you can install it with just one command (once we've uploaded it to the store). It also works on any distro with snapd installed.

Thanks @dylanaraps for trying to get your program working on as many platforms as possible and for encouraging me to open this issue!

Ubuntu 16.10

dylanaraps commented 7 years ago

Thanks for working on this!

Do we need to know how many Debs are installed?

Yes, this is the expected behavior.

Or maybe we need a new feature which can detect Deb and Snap packages when Snapd is on the system).

The packages function already works this way, all we need to do is add snapd detection. :+1:

Also, it's meant to say what the wallpaper...

Neofetch doesn't tell the user what wallpaper they're using, the wallpaper is used in the image display modes. https://github.com/dylanaraps/neofetch/wiki/Image-Backends

what music is playing?

The song function isn't enabled by default, you have to enable it in your config file. If you have enabled it and it's still not working than this might be an issue with the snap.

dylanaraps commented 7 years ago

I'll have to read up about how much of the system a snap package can access so that we can figure out the dependency situation. I'm currently setting up snapd + snapcraft so that I can test your snap package.

Edit: One of the dependencies for snapcraft in the aur is broken so I can't cleanly install snapcraft.

Ads20000 commented 7 years ago

@dylanaraps Can you link to the broken dependency so we can keep an eye on it? Does the maintainer know it's broken? Also, if the maintainer is part of the Ubuntu community, I/you could mention this on the #snapcraft Ubuntu Rocket chat, they'd probably be interested on making sure Snapcraft works on Arch!

Also I don't know how building Snaps with stage-packages works on Arch, since it pulls in packages in the Ubuntu repos using Apt for me, but will be interesting to find out!

ghost commented 7 years ago

@dylanaraps Do you mean python-apt? I was able to build it by just changing the pkgver to 1.1.0~beta5.

dylanaraps commented 7 years ago

Yes @mstraube, I'll try that and see if it builds. :+1:

@Ads20000, this is the package: https://aur.archlinux.org/packages/python-apt/

Ads20000 commented 7 years ago

@dylanaraps Unfortunately since I'm not an Arch user I can't ask the Arch-specific security question required to make an account to comment on AUR, could you comment to ask them to update to 1.1.0~beta5 to fix the issue properly, or contact the maintainer/packager directly if that's possible? Or should I ask someone else? :-) Thanks for trying this out btw!

dylanaraps commented 7 years ago

I've left a comment @Ads20000

Edit: I've got snapcraft installed now, thanks guys.

Edit2: I'm getting this error whenever I run snapcraft:

ModuleNotFoundError: No module named 'debian'

Any ideas @mstraube?

ghost commented 7 years ago

I would try to install https://aur.archlinux.org/packages/python-debian/

dylanaraps commented 7 years ago

Snapcraft works for me now, thanks @mstraube. :)

dylanaraps commented 7 years ago

I finally got the snap package to build properly!

2017-01-29-165236_290x171_scrot

Apart from these issues it all seems to work OK.

Bugs

/snap/neofetch/x1/neofetch: line 2031: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)`\
/usr/bin/env: 'bash': No such file or directory
/snap/neofetch/x1/neofetch: line 3504: uname: command not found

Quirks

Ads20000 commented 7 years ago

Yeah I get the locale error on Ubuntu too. snap run neofetch (and even just neofetch, if I don't have the Deb installed) works fine for me on Ubuntu (I know, the idea with Snappy is that Snaps run the same on any distribution, we need to find out what's going wrong here and tell the Snappy developers if we can find what it is), how did you get it to run to produce your screenshot? Detects distro fine on Ubuntu 16.10, strange...

Disk seems to report the size of the snap mount instead of the system disks.

This isn't a bug in Snappy then?

What do you think should be reported as bugs to the Snappy team?

Also, do you have any idea which dependencies, if any, we can drop from stage-packages?

dylanaraps commented 7 years ago

Yeah I get the locale error on Ubuntu too.

We can silence the locale error, the only issue is that neofetch will be up to 2x slower when run from the snap. We set the locale to C (disabling unicode) since it speeds up the script quiet a bit.

how did you get it to run to produce your screenshot?

I ran neofetch with snap run neofetch, the issue still occurs if I just run neofetch with neofetch though.

This isn't a bug in Snappy then?

Since the snap package is sandboxed it seems like this is all the disk information it can get. We get the same behavior on Windows 10 with WSL.

What do you think should be reported as bugs to the Snappy team?

I'm not sure if these are issues with my system or with the snap I've built. I'll setup a VM tomorrow and see if I can reproduce this. It could very well be the snap not building correctly on my machine.

Ads20000 commented 7 years ago

@dylanaraps The maintainer doesn't seem to be doing anything about the python-apt AUR package, and it's been out-of-date for a while, can you file an Orphan Request please (that's the right action here, right)? :)

dylanaraps commented 7 years ago

I'm going to contact the maintainer via email first, if he still fails to respond then I'll make an orphan request.

Ads20000 commented 7 years ago

@dylanaraps Also, could you upload the Snap you built to a Beta channel (I think that's most appropriate? You can choose between Release, RC, Beta and Edge - I think Beta is probably the best one for the stage this is at) so it's really easy to install (anyone will be able to install it with sudo snap install --beta neofetch)? It's rather easy

Presumably you could integrate this with Travis? You could also add an Edge build which has the GitHub repo as its source, you'll just want to make sure that's rebuilt every now and then, ideally on every commit to the GitHub repo (more realistically, maybe daily or something).

dylanaraps commented 7 years ago

I no longer have the snap I built.

When I've got some more time I'll setup an Ubuntu VM and start again. I had too many issues with building it on Arch.

Ads20000 commented 7 years ago

Ah fairs, would be nice if it 'just worked' on Arch, but seems like things aren't that way yet :( Also I made a mistake in my original post, I was installing with --devmode for strict confinement, which is why there was no difference between running Neofetch in devmode and running it in strict. Presumably it does therefore need some interfaces if we're going to get it in strict confinement and thus releasable to Release and RC channels.

dylanaraps commented 7 years ago

I'm now the maintainer of python-apt on the aur. :+1:

Ads20000 commented 7 years ago

@dylanaraps Nice! That's a really big favour for Snapcraft (and any other projects that depend on it) thank you! :D

Ads20000 commented 7 years ago

@dylanaraps Can you test the 3.1.0 snapcraft.yaml (which I put in the Issue description) for the bug with the snap not displaying the distribution version correctly? Hopefully snapd + snapcraft isn't too hard to reinstall if you've removed them...

sudo pacman -S snapd
sudo systemctl enable --now snapd.socket

Then install snapcraft from the AUR. Then sudo snap refresh to ensure the core snap is up-to-date. Then follow the instructions in the Issue description to install the snap.

Ads20000 commented 7 years ago

For me it says 'Ubuntu Core 16 x86_64' I don't know about you, would be good if you could test so I know what it says on Arch. If it says what it says on mine then presumably I need to forward this to the snapd team because that shouldn't really be calling the core snap 'Ubuntu Core', and also this is annoying because it means the Neofetch snap won't be able to determine what the actual OS is.

dylanaraps commented 7 years ago

I can't run snapcraft prime on Arch Linux, it says it's unsupported.

What was the other way of installing snaps that worked earlier? I've forgotton.

Ads20000 commented 7 years ago

@dylanaraps Ah sorry, that's just a marginally faster way of doing it since that way you don't have to actually create the package to test it. You can use snapcraft then sudo snap install neofetch_3.1.0_amd64.snap --dangerous --devmode.

dylanaraps commented 7 years ago

I get the same error when I run just snapcraft.

Currently only `cleanbuild` will work on this system ('arch')

Any ideas?

Ads20000 commented 7 years ago

Try the command snapcraft cleanbuild then. I think it builds it in an LXD container (so it can get Ubuntu dependencies).

dylanaraps commented 7 years ago

Still getting errors, hm.

sudo snapcraft cleanbuild
Currently only `cleanbuild` will work on this system ('arch')
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 32, in <module>
    obj=dict(project=snapcraft.ProjectOptions()))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 206, in cleanbuild
    lifecycle.cleanbuild(project_options, remote)
  File "/usr/lib/python3.6/site-packages/snapcraft/internal/lifecycle.py", line 343, in cleanbuild
    metadata=config.get_metadata(), remote=remote).execute()
  File "/usr/lib/python3.6/site-packages/snapcraft/internal/lxd.py", line 170, in __init__
    container_name=container_name, remote=remote)
  File "/usr/lib/python3.6/site-packages/snapcraft/internal/lxd.py", line 54, in __init__
    remote = _get_default_remote()
  File "/usr/lib/python3.6/site-packages/snapcraft/internal/lxd.py", line 239, in _get_default_remote
    default_remote = check_output(['lxc', 'remote', 'get-default'])
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'lxc'
Ads20000 commented 7 years ago

I'm guessing you tried it without sudo too?

dylanaraps commented 7 years ago

Yeah, I'll dig around and see if I can fix it.

Ads20000 commented 7 years ago

FileNotFoundError: [Errno 2] No such file or directory: 'lxc'

Use snapcraft cleanbuild --help, it says you need an LXD installation. Not too hard, I can give you the commands if you don't have the time to read the link in that help command? :) (though having said that, I haven't done it in Arch before...)

Ads20000 commented 7 years ago

The Arch Wiki says you need a different kernel for it to work or you can use security.privileged=true at the lxc launch step, which sounds much easier! Assuming that does work and I've understood that correctly...

LXD is great btw, lets you use an Ubuntu command-line on your system without damaging anything or using as much resources as a VM...

dylanaraps commented 6 years ago

Closing this as Neofetch won't really work with the sand-boxing of snaps etc. Re-open this if I'm wrong here.

NatoBoram commented 5 years ago

@dylanaraps Have you tried with the --classic confinement?