Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snap package for hamster #418

Closed
extraymond opened this issue Jun 17, 2019 · 15 comments
Closed

Snap package for hamster #418

extraymond opened this issue Jun 17, 2019 · 15 comments

Comments

@extraymond
Copy link

Hi! Guys, I'm trying to build hamster in snap right now, I believe I'm half way there.

Motivation

My motivation for doing so is as follows:

  1. Snap is a great way to maintain stable run-time environment so app will continue to work regardless of distro versions. It support various build systems too, waf is automatically handled.
  2. Snaps have some nice update mechanisms, we can easily switch between channels as desired. It have some safety mechanisms that perform auto rollback when newer version crashed.
  3. Combining the two, I think it might give hamster a greater chance to reach it's audience.

So here I am trying to reach out and see if anything clicks.


Problems

However there are some problems regarding invoking services with dbus.

For the manual build version, the hamster launch file with automatically invoke the hamster-service and hamster-windows-service if it's not started, but on the snap service I can't find a way to do so. So currently I have to manually start the two service before launching the GUI. Which works!

I would really appreciate any help regarding to setup dbus service so that it can be invoked by dbus name.

Here's the snapcraft.yaml if anyone is interested:

name: hamster-snap # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
version: "0.1" # just for humans, typically '1.2+git' or '1.3.2'
summary: snap for project hamster # 79 char long summary
description: |
  First attempt for creating a snap for project hamster.

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

slots:
  dbus-hamster:
    interface: dbus
    bus: session
    name: org.gnome.Hamster

plugs:
  gnome-3-28-1804:
    interface: content
    target: $SNAP/gnome-platform
    default-provider: gnome-3-28-1804
  gtk-3-themes:
    interface: content
    target: $SNAP/data-dir/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes

apps:
  hamster-service:
    command: desktop-launch ${SNAP}/usr/lib/hamster-time-tracker/hamster-service
    plugs:
      - desktop
      - desktop-legacy
      - gsettings
      - home
    environment:
      PYTHONPATH: $SNAP/usr/lib/python2.7/dist-packages
  hamster-windows-service:
    command: desktop-launch ${SNAP}/usr/lib/hamster-time-tracker/hamster-windows-service
    plugs:
      - desktop
      - desktop-legacy
      - gsettings
      - home
    environment:
      PYTHONPATH: $SNAP/usr/lib/python2.7/dist-packages
  hamster:
    command: desktop-launch ${SNAP}/usr/bin/hamster
    desktop: usr/share/applications/hamster-time-tracker.desktop
    plugs:
      - desktop
      - desktop-legacy
      - gsettings
      - home
      - unity7
    environment:
      PYTHONPATH: $SNAP/usr/lib/python2.7/dist-packages
      LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/share/hamster-time-tracker

parts:
  desktop-gnome-platform:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk3"]
    build-packages:
      - build-essential
      - libgtk-3-dev
    override-build: |
      snapcraftctl build
      mkdir -pv $SNAPCRAFT_PART_INSTALL/gnome-platform
  hamster:
    # See 'snapcraft plugins'
    after: [desktop-gnome-platform]
    build-packages:
      - gettext
      - intltool
      - python-gconf
      - gconf2
    stage-packages:
      - gir1.2-gconf-2.0
      - python3-gi-cairo
      - python3-dbus
      - python3-gi
      - python3-xdg
    source: snap/src
    plugin: waf
    configflags:
      - --prefix=/usr
@ederag
Copy link
Collaborator

ederag commented Jul 30, 2019

Thanks for your interest in hamster !

Sorry my knowledge about dbus is still very limited,
even after fixing the installation process.

Here is the relevant part of the waf script:

hamster/wscript

Lines 71 to 82 in d864d0a

bld.new_task_gen("subst",
source= "org.gnome.hamster.service.in",
target= "org.gnome.hamster.service",
install_path="${DATADIR}/dbus-1/services",
dict = bld.env
)
bld.new_task_gen("subst",
source= "org.gnome.hamster.Windows.service.in",
target= "org.gnome.hamster.Windows.service",
install_path="${DATADIR}/dbus-1/services",
dict = bld.env
)

With --prefix=/usr (currently the only supported installation),
${DATADIR} will expand to /usr/share, and in

Exec=@LIBDIR@/hamster-time-tracker/hamster-service

@LIBDIR@ will expand to /usr/lib.

The snap people might be of better help.

@extraymond
Copy link
Author

extraymond commented Jul 31, 2019

Thx for the reply! I've tried contacting the snap team via snap forum.
With the response I've got over there, it seems that while dbus is working fine within a snap, it's not possible to activate other .desktop file by invoking their dbus path currently. That feature is being worked on and was promised to land sometime later.

After digging into the hamster code base, it seems that the hamster app is separated into hamster-service and hamster-windows-service and the CLI client.

The launch script that was managed by the CLI client will check whether the two other dependent service is started via dbus, and activate it if it's not found.

I think I can bypass this by creating an alternative launch script that will always start the two depending service before the main CLI is ever invoked.

@ederag
Copy link
Collaborator

ederag commented Jul 31, 2019

I think I can bypass this by creating an alternative launch script that will always start the two depending service before the main CLI is ever invoked.

Sound good !

@tchama
Copy link

tchama commented Dec 20, 2019

Have you managed to build a hamster snap package ?

I've been using hamster for years, recently I installed ubuntu 19.10, but in this version there are no more hamster packages.

Not knowing python, and not finding clear instructions, I can't install it.

@extraymond
Copy link
Author

extraymond commented Dec 20, 2019

Have you managed to build a hamster snap package ?

I've been using hamster for years, recently I installed ubuntu 19.10, but in this version there are no more hamster packages.

Not knowing python, and not finding clear instructions, I can't install it.

I would say partially. I get it working if I manually start the services before the client.

The hamster client requires three(or two) dbus services to be launch before the app instance.
In traditional desktop environment, if a service is called but not activated beforehand, it is activated if stated in the .service file.

But since snap confined the app more strictly, it's not possible to use dbus-activation for user services.
So the init sequence would need us to manually started the services before the client instance, else the app instance will not launch.

If we were to make it work today, we can simply add a custom launch script to call the app. I know it's possible.

The reason I didn't work on it afterwards is that I believe the maintainers has some plan to update the build and launch script. #421. And lots of stuff are improving as well. So I might work on it in the next release.

If you are interested you can copy my snapcraft.yaml above and play with it. Would love to see if someone can solve that issue with a better method.

@extraymond
Copy link
Author

#496 An naive attempt to start snap packaging. Would love to hear how it can be improved.

Proof that this works.

2019-12-24 00-04-20 的螢幕擷圖

@extraymond
Copy link
Author

extraymond commented Dec 23, 2019

Updated:

It's now in a dedicated repo, and fully confined.
It's currently under review, I will release after approved by the reviewers.
Forum link

To be able to confine this, I have to use the unmerged gsettings branch, due to Gconf not being provided by snap interfaces.

Would be able to tracker master after #470

@ederag
Copy link
Collaborator

ederag commented Dec 24, 2019

Good, please tell here when hamster appears on https://snapcraft.io/store, to advertise it in the README.

@mbnoimi
Copy link

mbnoimi commented Jan 4, 2020

Thanks a lot @extraymond

Snap packing is a really interesting step forward because hamster and xfce4-hamster-plugin projects are out of debian/ubuntu repositories so we forced the build them from the source code (it's really an awful process)

I wish to create a snap package for xfce4-hamster-plugin too.

@ederag
Copy link
Collaborator

ederag commented Jan 4, 2020

The installation process has been improved a lot lately,
and should work perfectly if the instructions are followed exactly.

Admittedly, in the future, ./waf could give hints to prevent the most common overlooks
such as not killing the old services (#503).

@extraymond
Copy link
Author

snap landing page

Hi! The snapcraft team has approved the usage of hamster-service and hamster-window-service plug so it's now able to publish to all channels.

I've taken the suggestion and registered the name hamster instead of hamster-snap. However it's still under review so I'll update the page if anything happens.

Right now it's possible to install the snap via "snap install hamster-snap" or via software stores with snap plugin enabled.

The caveat of this snap that when upgrading versions. The services launched with the older version has to be manually killed, so that the gui process has the correct service it can access to. Otherwise it apparmor is gonna blame us for being naughty.

@ederag
Copy link
Collaborator

ederag commented Jan 12, 2020

Good, thanks !
#509 is a proposition for a README update; please comment there if you feel it should be improved.

@extraymond
Copy link
Author

Thx!! Should I close this?

@ederag
Copy link
Collaborator

ederag commented Jan 12, 2020

Should I close this?

Yes, thanks !
And I count on you to edit README.md when the name is updated on snapcraft.io (that will create a PR).

@extraymond
Copy link
Author

Will do when I get approved with the new name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants