env: set XDG_DATA_DIRS for wayland et.al. #3398

Merged
merged 8 commits into from Aug 30, 2017

Conversation

Projects
None yet
10 participants
Contributor

sergiusens commented May 24, 2017

Currently XDG_DATA_DIRS is only setup for an X session, there
is currently no specific location to set this up for anything
using the wayland protocol. The profile.d mechanism seems like
the next best choice.

LP: #1681547

Signed-off-by: Sergio Schvezov sergio.schvezov@ubuntu.com

env: set XDG_DATA_DIRS for wayland et.al.
Currently XDG_DATA_DIRS is only setup for an X session, there
is currently no specific location to set this up for anything
using the wayland protocol. The profile.d mechanism seems like
the next best choice.

LP: #1681547

Signed-off-by: Sergio Schvezov <sergio.schvezov@ubuntu.com>

mvo5 approved these changes Jun 7, 2017

Thanks, nice catch!

+1 on the effort but I think this needs to be managed better across distributions and other files that serve the same purpose (though get sourced in different ways)

CC @morphis

etc/profile.d/snapd.sh
@@ -0,0 +1,6 @@
+# set XDG_DATA_DIRS for snapd provisioned desktop files.
+if [ "${XDG_DATA_DIRS#*snapd}" = "${XDG_DATA_DIRS}" ]; then
@zyga

zyga Jun 8, 2017

Contributor

Is this valid sh (not bash) syntax?

@ogra1

ogra1 Jun 8, 2017

Contributor

yes, thats appropriate to split variable content

Contributor

morphis commented Jun 8, 2017

This very much looks like a copy of https://github.com/snapcore/snapd/blob/master/etc/X11/Xsession.d/65snappy

Can't we link both somehow?

Member

chipaca commented Jul 10, 2017

What's the status of this PR?

ogra1 approved these changes Aug 4, 2017

since this currently blocks snap usage in wayland altogether and since wayland wont ever parse /etx/X11/Xsession.d (i was told) ... i'm approving this as interim solution

+1 on the contents of the file, but -1 on the name of the file.

'snapd.sh' is actually referenced in ./packaging/opensuse-42.2/snapd.spec and ./packaging/arch/PKGBUILD.

I suggest renaming the file 'snapd-xdg-data-dirs.sh'.

Also, can you update ./packaging/opensuse-42.2/snapd.spec and ./packaging/arch/PKGBUILD to do for this file what they are doing for apps-bin-path.sh?

Member

chipaca commented Aug 25, 2017

Unless anybody objects I'm going to take over this PR, and unify all this into a single file. Ubuntu and Debian would ship it as /etc/profile.d/apps-bin-path.sh (because that's what we ship today, it's picked up by Xsession, and it's a conffile, and renaming conf files is AFAIK LOLNO territory), and it'd replace what's currently in snapd.spec and arch/snapd.sh (although tbh it might look alarmingly light the latter)

/etc/profile.d is not picked up by Xsession, it only applies to shells under X11 (but due to a hack is read for wayland sessions)...
for plain X11 the existing /etc/X11/Xsession.d/65snappy still needs to persist

Member

chipaca commented Aug 25, 2017

are you sure profile.d isn't picked up by X? I moved 65snappy to /etc/profile.d/snapd.sh and started unity, xfce and jwm (heh) and in all cases ps eww of the toplevel process showed XDG_DATA_DIRS having snapd in it

"ps eww of the toplevel process" is surely a shell in this case ... apps are usually not executed under a shell but directly, you would have to dump the env out of a C app that is launched from a .desktop file to find out ...

Member

chipaca commented Aug 25, 2017

I mean I do this:

~$ ps fx
  PID TTY      STAT   TIME COMMAND
16758 ?        Ss     0:00 /sbin/upstart --user
16845 ?        S      0:00  \_ upstart-udev-bridge --daemon --user
16852 ?        Ss     0:04  \_ dbus-daemon --fork --session --address=unix:abstract=/tmp/dbus-qFtZh3OQOM
16885 ?        S      0:00  \_ upstart-dbus-bridge --daemon --system --user --bus-name system
...

so then

~$ ps eww 16758 | egrep -o 'XDG_DATA_DIRS=[^ ]*'
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop

@pedronis pedronis added the Blocked label Aug 29, 2017

Contributor

pedronis commented Aug 29, 2017

@chipaca is working on adjusting this

chipaca added some commits Aug 29, 2017

packaging: unify PATH and XDG_DATA_DIRS handling cross-distro
All distributions need to add the snappy bin directory (/snap/bin or
/var/lib/snapd/snap/bin, depending) to the user's PATH, and to add
/var/lib/snapd/desktop to XDG_DATA_DIRS (which might be unset, meaning
it needs adding to the defaults).

Up to now all distros were doing this separately, so we had a bunch of
duplication. Also, as things move to Wayland, on debian-based distros
XDG_DATA_DIRS was only being set in X sessions which mean that
switching to wayland lost you your snappy desktop files.

This tries to fix all that, hopefully in a sane way.

@chipaca chipaca removed the Blocked label Aug 29, 2017

mvo5 approved these changes Aug 29, 2017

Thanks for your work on this, this looks much nicer than before.

packaging/ubuntu-14.04/rules
@@ -117,6 +117,7 @@ endif
# XXX: hacky
$(MAKE) -C cmd distclean || true
$(MAKE) -C data/systemd clean
+ $(MAKE) -C data/env clean
@mvo5

mvo5 Aug 29, 2017

Collaborator

Hm, could we have a single make -C data clean here?

packaging/ubuntu-14.04/rules
@@ -130,6 +131,9 @@ override_dh_auto_build:
cd cmd && ( ./configure --prefix=/usr --libexecdir=/usr/lib/snapd $(VENDOR_ARGS))
$(MAKE) -C cmd all
+ # Generate the env snippet
+ $(MAKE) -C data/env all
@mvo5

mvo5 Aug 29, 2017

Collaborator

Could we have a single "$(MAKE) -C data all" here?

@chipaca

chipaca Aug 29, 2017

Member

14.04 wasn't making dbus. Is that a bug?

@mvo5

mvo5 Aug 29, 2017

Collaborator

Probably :/

packaging/ubuntu-16.04/rules
@@ -106,6 +106,7 @@ endif
# XXX: hacky
$(MAKE) -C cmd distclean || true
$(MAKE) -C data/systemd clean
@mvo5

mvo5 Aug 29, 2017

Collaborator

Same question as for the 14.04 branch

Collaborator

mvo5 commented Aug 29, 2017

Fwiw, both lightdm and gdm3 load /etc/profile which in turn will load /etc/profile.d (in gdm3-3.24.1/data/Xsession.in and lightdm-1.22.0/debian/lightdm-session).

I like the direction of this PR much more. Thanks for addressing my concerns (and more!) :)

Fix 14.04 (thank you spread), address review feedback (thank you mvo)
Also do some work to keep the diffs between 14.04 and 16.04 small.
Pre-Depends: dpkg (>= 1.15.7.2)
-Description: Transitional package for snap-confine
+Description: Transitional package for snapd
@mvo5

mvo5 Aug 29, 2017

Collaborator

❤️

mvo5 approved these changes Aug 29, 2017

@mvo5 mvo5 added this to the 2.28 milestone Aug 29, 2017

Contributor

niemeyer commented Aug 29, 2017

@chipaca Thanks for working on this. The current error looks related:

+ echo 'Ensure sudo works without a password inside classic'
Ensure sudo works without a password inside classic
++ tr -d '\r'
++ classic sudo id -u
+ '[' '/etc/profile: line 23: .: /etc/profile.d/apps-bin-path.sh: is a directory
0' '!=' 0 ']'
+ echo 'sudo inside classic did not work as expected'
sudo inside classic did not work as expected

Once tests pass...

Member

chipaca commented Aug 29, 2017

@niemeyer yes, looking into why we're getting a directory there. Probably some silly error on my end.

fixed issue where I was misusing snapd.install
It turns out I didn't need to use it at all, as we now have 'make
install' -- all it needs a rename after the fact, and everything's
happy.

Codecov Report

Merging #3398 into master will increase coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3398      +/-   ##
=========================================
+ Coverage   75.63%   75.7%   +0.06%     
=========================================
  Files         407     407              
  Lines       35028   35268     +240     
=========================================
+ Hits        26494   26698     +204     
- Misses       6654    6687      +33     
- Partials     1880    1883       +3
Impacted Files Coverage Δ
interfaces/builtin/i2c.go 65.95% <0%> (-1.39%) ⬇️
interfaces/builtin/iio.go 69.64% <0%> (-0.54%) ⬇️
interfaces/builtin/framebuffer.go 100% <0%> (ø) ⬆️
interfaces/builtin/account_control.go 100% <0%> (ø) ⬆️
interfaces/builtin/udisks2.go 100% <0%> (ø) ⬆️
interfaces/builtin/tpm.go 100% <0%> (ø) ⬆️
interfaces/builtin/kernel_module_control.go 100% <0%> (ø) ⬆️
interfaces/builtin/bluetooth_control.go 100% <0%> (ø) ⬆️
interfaces/builtin/broadcom_asic_control.go 100% <0%> (ø) ⬆️
interfaces/builtin/optical_drive.go 100% <0%> (ø) ⬆️
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1182f06...4217778. Read the comment docs.

@mvo5 mvo5 merged commit 189efaa into snapcore:master Aug 30, 2017

7 checks passed

artful-amd64 autopkgtest finished (success)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
xenial-ppc64el autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details
zesty-amd64 autopkgtest finished (success)
Details

@sergiusens sergiusens deleted the sergiusens:xdg-for-more-than-x branch Sep 12, 2017

@ramonsuarez ramonsuarez referenced this pull request in snapcrafters/atom Oct 27, 2017

Closed

Atom snap not findable in Ubuntu 17.10 #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment