Unable to snap Hypnotix

Hello, I’m really struggling to snap Hypnotix. As I’m a new user, I would be happy with getting the snapping process to terminate correctly (even if the snap doesn’t fully work)…

I’ve read the documentation, I’ve checked the forum but I can’t make it work. Can someone help me understand where is the problem? The command seems ok it has not special characters

I can’t fix this error

Failed to generate snap metadata: The specified command ‘/usr/bin/hypnotix’ defined in the app ‘hypnotix’ does not match the pattern expected by snapd. The command must consist only of alphanumeric characters, spaces, and the following special characters: / . _ # : $ -

This is the best yaml file I can get

name: hypnotix
version: '0.3'
summary: IPTV player for M3U playlists
description: |
  Hypnotix is an IPTV streaming application with support for live TV, movies and series.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

base: core20

parts:
  hypnotix:
    source: https://github.com/linuxmint/hypnotix.git
    plugin: python
    stage-packages:
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-plugins-good
      - gstreamer1.0-plugins-ugly
      - gstreamer1.0-libav

apps:
  hypnotix:
    command: /usr/bin/hypnotix
    plugs:
      - desktop
      - home
      - mount-observe
      - network
      - network-bind

the binaries called in command: are always executed relative to the top level of your snap… try removing the first slash :wink:

Thanks for the quick reply, but it still doesn’t work. On Core20 it returns the error above, con Core22 it says that the path doesn’t exists. Snapd is probabily right because I can’t actually find the “hypnotix” binary if i run snapcraft --debug and search in the whole $SNAP path… I thought that I hypnotix was an easy project to snap, but probably I should give up and start from something even easier…

I’ve also tried asking to ChatGPT but it has not been able to make it work, too :slight_smile:

Thanks for your help as usual, I’ll post an update if I can make it work in the future!

My trick for this is to add something like bash to stage-packages then set the app.command to bin/bash. This lets me overcome some issues like you’re seeing with the app.command not being found.

I may be wrong but the python plugin you chose tries to install the source via pip and I didn’t see any setup.py file there so maybe that could be an issue.

It also looks like you’re python app is using gtk3, so you’ll probably want to add gnome to the extensions list (which you’re currently missing).

The community is here to help if you get stuck!

Hello, thank you very much for the reply. I was thinking of changing project because maybe Hypnotix has some “non-standard” configurations. Reading your post it seems that this project actually has them. This is probably the reason why this simple app is not available in either snap or flatpak…

after launching snapcraft --debug i try to search for hypnotix with find $SNAP -name hypnotix but it finds nothing. I’m still still not experienced enough to be able to fix this, so I’ll try to snap some easier project before continuing with Hypnotix.

Your problem is that you are using the python plugin but point to the source of a debian package… it does not have the typical python setup.py and requirements.txt files a normal python source would have… you will need to approach this kind of source tree differently…

You give this a try:

name: hypnotix
version: '3.2'
core: 22
summary: IPTV player for M3U playlists
description: |
  Hypnotix is an IPTV streaming application with support for live TV, movies and series.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

parts:
  hypnotix:
    source: https://github.com/linuxmint/hypnotix.git
    source-tag: $SNAPCRAFT_PROJECT_VERSION
    plugin: make
    stage-packages:
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-plugins-good
      - gstreamer1.0-plugins-ugly
      - gstreamer1.0-libav

apps:
  hypnotix:
    command: usr/bin/hypnotix
    environment:
      PYTHONPATH: $SNAP/usr/lib/hypnotix:$PYTHONPATH
    extensions: [ gnome ]
    plugs:
      - home
      - mount-observe
      - network
      - network-bind
  1. The project here uses Makefile to install the files. The plugin should be the type that is used to build/install the files, not to run.
  2. Added PYTHONPATH so that the files under usr/lib/hypnotix can run using PYTHON
  3. Core: 22, this is what you should always try to use
  4. extensions: [ gnome ] this is the sdk that provides all the files necessary for a gtk based app to build and run.
  5. source-tag can be used to keep the versioning of the project properly and not always build the app from the master branch with latest (may be unstable) changes.

You’ll get every detail in the snapcraft docs. Welcome to this Snap Journey

Thanks

सौम्यदीप घोष(সৌম্যদীপ ঘোষ)

Hello, thank you very much for your explanation. Very useful tips. I started from the docs, but this is (unfortunately) a problematic project I suppose.

Also using your yaml file it still doesn’t work.

Reading the makefile, it seems to only build the mo files (https://github.com/linuxmint/hypnotix/blob/master/Makefile) is that fine?

your snapcraft returns the following (I also did some tests changing some arguments but I was not able to make it work)

2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.343 Failed to run the build script for part ‘hypnotix’.

2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352 Traceback (most recent call last):
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_parts/executor/step_handler.py", line 144, in _builtin_build
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     subprocess.run(
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/usr/lib/python3.8/subprocess.py", line 516, in run
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     raise CalledProcessError(retcode, process.args,
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352 subprocess.CalledProcessError: Command '['/root/parts/hypnotix/run/build.sh']' returned non-zero exit status 2.
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352 The above exception was the direct cause of the following exception:
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352 Traceback (most recent call last):
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 171, in run
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     aex.execute(action, stdout=stream, stderr=stream)
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_parts/executor/executor.py", line 304, in execute
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     self._executor.execute(actions, stdout=stdout, stderr=stderr)
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_parts/executor/executor.py", line 128, in execute
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     self._run_action(act, stdout=stdout, stderr=stderr)
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_parts/executor/executor.py", line 193, in _run_action
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     handler.run_action(action, stdout=stdout, stderr=stderr)
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_parts/executor/part_handler.py", line 168, in run_action
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     state = handler(step_info, stdout=stdout, stderr=stderr)
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_parts/executor/part_handler.py", line 305, in _run_build
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     self._run_step(
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_parts/executor/part_handler.py", line 489, in _run_step
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     return step_handler.run_builtin()
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_parts/executor/step_handler.py", line 106, in run_builtin
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     return handler()
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352   File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_parts/executor/step_handler.py", line 152, in _builtin_build
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352     raise errors.PluginBuildError(part_name=self._part.name) from process_error
2023-04-29 11:40:11.965 :: 2023-04-29 09:40:11.352 craft_parts.errors.PluginBuildError: Failed to run the build script for part 'hypnotix'.

:frowning_face:

Yes, you’re right, I didn’t checked that Makefile, cause it’s not a very normal scenario. Anyways, you need to manually install those files. BTW, yes that project is a little tough. It need to be added with wayland support, cause Ubuntu is wayland by default now. I will create one then, if you love to use the app. A small tip, use AUR also for your help.

If you look inside the Makefile you will notice it is only used to create translations for the app, it wont help…

to build it properly you will instead have to follow what what is inside the debian/rules file…

name: hypnotix
version: '3.2'
base: core22
summary: IPTV player for M3U playlists
description: |
  Hypnotix is an IPTV streaming application with support for live TV, movies and series.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

parts:
  hypnotix:
    source: https://github.com/linuxmint/hypnotix.git
    plugin: make
    stage-packages:
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-plugins-good
      - gstreamer1.0-plugins-ugly
      - gstreamer1.0-libav
      - libxapp1
      - python3-imdbpy
      - libmpv1
    override-pull: |
      craftctl default
      sed -i '2d' usr/bin/hypnotix
      sh -c "echo 'if [ \$WAYLAND_DISPLAY=wayland-0 ]
      then
      GDK_BACKEND=x11 /usr/lib/hypnotix/hypnotix.py &
      else
      /usr/lib/hypnotix/hypnotix.py &
      fi'" >> usr/bin/hypnotix
      sed -i '1438a \        options["vo"] = "x11"' usr/lib/hypnotix/hypnotix.py
      cp -a $CRAFT_PART_SRC/usr $CRAFT_PRIME/
       
apps:
  hypnotix:
    command: usr/bin/hypnotix
    extensions: [ gnome ]
    desktop: usr/share/applications/hypnotix.desktop
    plugs:
      - home
      - mount-observe
      - network
      - network-bind

Test this. Make changes over this.

That app is actually prebuilt, we just need to install it properly.

then you should stop using the python plugin like i said above … or develop a proper setup.py and create a requirements.txt based on debian/control … else you wont get anywhere …

Sorry, that’s actually a typo. I have edited it to use make. :sweat_smile:

Anyway that `snapcraft.yaml` I provided is working.

Thank you very much. I confirm it creates the snap correctly.

It doesn’t launch because it returns /snap/hypnotix/x1/usr/bin/hypnotix: 4: /usr/lib/hypnotix/hypnotix.py: not found but it’s a big step forward. Thank you very much for your help, I’ll try to fully understand what your “override-pull” does and then try to fix this issue.

Thanks again

change the override-pull to this

    override-pull: |
      craftctl default
      sed -i '2d' usr/bin/hypnotix
      sh -c "echo 'if [ \$WAYLAND_DISPLAY=wayland-0 ]
      then
      GDK_BACKEND=x11 /snap/hypnotix/current/usr/lib/hypnotix/hypnotix.py &
      else
      /snap/hypnotix/current/usr/lib/hypnotix/hypnotix.py &
      fi'" >> usr/bin/hypnotix
      sed -i '1438a \        options["vo"] = "x11"' usr/lib/hypnotix/hypnotix.py
      cp -a $CRAFT_PART_SRC/usr $CRAFT_PRIME/

Again, make will try to use the makefile… which only creates translation files for the deb… you want to use the dump plugin and simply stage the usr/ dir from the checked out source while throwing away all the rest…

Also, if you use the gnome extension simply tell it to not use wayland from the apps environment so you don’t need any hackery to force x11

(This can be a really clean snapcraft.yaml without any override statements beyond changing the icon path in the desktop file)

You’re right actually, okay I’m trying that. But, what’ll happen to the translation if we use the dump plugin? Will they stage? I don’t know though.

You can indeed call make additionally in case you find they are actually missing … if you use the make plugin instead of dump you will end up only having the translations and nothing else though…

Also make sure you stage everything from debian/control, else you will surely run into runtime problems

I am actually copying them from the source folder to the $CRAFT_PRIME.

I didn’t understand the debian packaging very well, but now you said, I’ll check it out and create a modified one tonight.