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

redshift/geoclue/localtime: progress in fixing agent confusion #44820

Merged
merged 4 commits into from Aug 14, 2018

Conversation

michaelpj
Copy link
Contributor

Motivation for this change

Partially fixes #44725.

geoclue recently started requiring an authorization agent in order for clients to get data. For example, they provide a demo agent that asks the user via a notification if they want to allow the application access to their location.

DEs are supposed to provide their own agent, but only GNOME does so. However, we can use the demo agent provided by geoclue. AFAICT, this needs to run as a user service, because it is associated with the user who makes the requests.

This makes redshift work again (albeit with an annoying notification prompt), after a bit more wrangling because the agent also expects a valid .desktop file and appears to check that the executable exists.

However, I couldn't make localtime work, because it runs as a system service, and there isn't an agent for it's UID. I think the thing to do would be to make it run as a user service, but my preliminary hacking was not enough to make this work.

cc @garbas @yegortimoshenko as maintainers of relevant packages.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@michaelpj
Copy link
Contributor Author

Oh, and FWIW I think the breaking commit in geoclue is this one, which appears in 4.9. We recently upgraded from 4.8 -> 4.10, which is presumably when this started.

@@ -1,24 +1,29 @@
{ fetchurl, stdenv, intltool, pkgconfig, gtk-doc, docbook_xsl, docbook_xml_dtd_412, glib, json-glib, libsoup, libnotify, gdk_pixbuf
, modemmanager, avahi, glib-networking, wrapGAppsHook, gobjectIntrospection
, withDemoAgent ? false
# doc build currently seems to be broken
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide more details? The docs build for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I set this to true I get the following:

> nix build -f . pkgs.geoclue
builder for '/nix/store/mgyaj5vnzg1fy2yvx16xqk11r6kiqq9v-geoclue-2.4.11.drv' failed with exit code 2; last 10 log lines:
  ../libgeoclue-docs.xml:77: element include: XInclude error : could not load ../xml/gclue-client-proxy.xml, and no fallback was found
  warning: failed to load external entity "../xml/gclue-location-proxy.xml"
  ../libgeoclue-docs.xml:83: element include: XInclude error : could not load ../xml/gclue-location-proxy.xml, and no fallback was found
  make[3]: *** [Makefile:750: html-build.stamp] Error 6
  make[3]: Leaving directory '/build/geoclue-2.4.11/docs/lib'
  make[2]: *** [Makefile:577: all-recursive] Error 1
  make[2]: Leaving directory '/build/geoclue-2.4.11/docs'
  make[1]: *** [Makefile:517: all-recursive] Error 1
  make[1]: Leaving directory '/build/geoclue-2.4.11'
  make: *** [Makefile:449: all] Error 2
[0 built (1 failed), 0.0 MiB DL]
error: build of '/nix/store/mgyaj5vnzg1fy2yvx16xqk11r6kiqq9v-geoclue-2.4.11.drv' failed

This is with sandboxing on. I don't get this in the previous version, but I couldn't figure out what the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recent master seems to have a bunch of build-related commits, so I suspect they may still be fixing things up.

, withDemoAgent ? false
# doc build currently seems to be broken
, enableDocs ? false
, withDemoAgent ? true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Demo agent should not be build by default, since the default use is for libraries. Override the value in the module when needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that, but then we'll build it twice. As is presumably libraries can just depend on geoclue2.dev, so I don' think this should affect closure size?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

geoclue2.dev is only used for build, the library is still in out. Maybe we could split lib to a separate output. Though building such a small program twice should not really matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, fine with me.

@@ -4,6 +4,10 @@

with lib;

let
# the demo agent isn't built by default, but we need it here
package = pkgs.geoclue2.override { withDemoAgent = true; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be set to config.services.geoclue2.enableDemoAgent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@michaelpj
Copy link
Contributor Author

If you can work out how to fix the docs I'm up for it, but I'd really like to get redshift working again.

@jtojnar
Copy link
Contributor

jtojnar commented Aug 9, 2018

Will try to bisect it later.

@michaelpj
Copy link
Contributor Author

You have more patience than me :D

@jtojnar
Copy link
Contributor

jtojnar commented Aug 9, 2018

Builds fine from git:

{ fetchFromGitLab, stdenv, autoconf, automake, libtool, intltool, pkgconfig, gtk-doc, docbook_xsl, docbook_xml_dtd_412, glib, json-glib, libsoup, libnotify, gdk_pixbuf
, modemmanager, avahi, glib-networking, wrapGAppsHook, gobjectIntrospection
, withDemoAgent ? false
}:

with stdenv.lib;

stdenv.mkDerivation rec {
  name = "geoclue-${version}";
  version = "2.4.11";

  src = fetchFromGitLab {
    domain = "gitlab.freedesktop.org";
    owner = "geoclue";
    repo = "geoclue";
    rev = version;
    sha256 = "11pvw7cif1jp305qag85br9pwda5h9in9377cwzy82wfb0inyrf2";
  };

  outputs = [ "out" "dev" "devdoc" ];

  nativeBuildInputs = [
    autoconf automake libtool pkgconfig intltool gtk-doc docbook_xsl docbook_xml_dtd_412 wrapGAppsHook gobjectIntrospection
  ];

  buildInputs = [
    glib json-glib libsoup avahi
  ] ++ optionals withDemoAgent [
    libnotify gdk_pixbuf
  ] ++ optionals (!stdenv.isDarwin) [ modemmanager ];

  propagatedBuildInputs = [ glib glib-networking ];

  configureFlags = [
    "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
    "--enable-introspection"
    "--enable-gtk-doc"
    "--enable-demo-agent=${if withDemoAgent then "yes" else "no"}"
  ] ++ optionals stdenv.isDarwin [
    "--disable-silent-rules"
    "--disable-3g-source"
    "--disable-cdma-source"
    "--disable-modem-gps-source"
    "--disable-nmea-source"
  ];

  postPatch = ''
    sed -i '/git submodule/d' autogen.sh
  '';

  preConfigure = "NOCONFIGURE=1 ./autogen.sh";

  # https://gitlab.freedesktop.org/geoclue/geoclue/issues/73
  postInstall = ''
    sed -i $dev/lib/pkgconfig/libgeoclue-2.0.pc -e "s|includedir=.*|includedir=$dev/include|"
  '';

  meta = with stdenv.lib; {
    description = "Geolocation framework and some data providers";
    homepage = https://gitlab.freedesktop.org/geoclue/geoclue/wikis/home;
    maintainers = with maintainers; [ raskin garbas ];
    platforms = with platforms; linux ++ darwin;
    license = licenses.lgpl2;
  };
}

Could you maybe report a bug upstream?

@michaelpj
Copy link
Contributor Author

I'm not sure I know what the issue is - do you think there's something missing in the release tarball?

@jtojnar
Copy link
Contributor

jtojnar commented Aug 9, 2018

No idea. But maybe upstream will be wiser.

@michaelpj
Copy link
Contributor Author

I diffed the release tarball and the source checkout - it looks like the tarball has had some generation steps done, and is generally a bit different. I think perhaps we're not meant to build the docs from the release tarball - I think we should probably just switch to building this from git, but that can be in a different PR.

@jtojnar
Copy link
Contributor

jtojnar commented Aug 9, 2018

I do not see why would not devdoc be supposed to be built from tarball. Anyway, opened https://gitlab.freedesktop.org/geoclue/geoclue/issues/77

@michaelpj
Copy link
Contributor Author

I think this is ready to go, any other comments?

@jtojnar
Copy link
Contributor

jtojnar commented Aug 12, 2018

I would still prefer building from git to disabling the docs.

@michaelpj
Copy link
Contributor Author

Updated to build from git following your patch.

@michaelpj
Copy link
Contributor Author

(This will probably be a bit nicer once they're done moving to meson)

};

outputs = [ "out" "dev" "devdoc" ];
outputs = [ "out" "dev" "devdoc"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spacing should be consistent.

sed -i '/git submodule/d' autogen.sh
'';

# configure will happen durng the configure phase anyway
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo durng

# user who is making the requests
systemd.user.services = mkIf config.services.geoclue2.enableDemoAgent {
"geoclue-agent" = {
description = "Geoclue agent";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space

@michaelpj
Copy link
Contributor Author

Nits fixed.

@michaelpj
Copy link
Contributor Author

gentle prod

@jtojnar
Copy link
Contributor

jtojnar commented Aug 14, 2018

2.4.12 was released and it fixes the devdoc. Could you update to it?


# configure will happen during the configure phase anyway
preConfigure = "NOCONFIGURE=1 ./autogen.sh";

# https://gitlab.freedesktop.org/geoclue/geoclue/issues/73
postInstall = ''
sed -i $dev/lib/pkgconfig/libgeoclue-2.0.pc -e "s|includedir=.*|includedir=$dev/include|"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed in 2.4.12

@michaelpj michaelpj force-pushed the fix/redshift-geoclue-agents branch 2 times, most recently from 130f6a3 to 3891415 Compare August 14, 2018 14:30
@michaelpj
Copy link
Contributor Author

Thanks for chasing that up - I've removed the commit changing it to build from git, and changed the version upgrade commit to go to 2.4.12.

Copy link
Contributor

@jtojnar jtojnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few more final nits. Also could you squash bae4fa2130bba6f1020c31790ab583c31fe9e388 and 38914154ced3e2f5ba4b74901d406dd54befd7f4 into ca8bda4252214ec6d0cc0bf3ab8bd8ed7c4bc9ec:

@@ -31,7 +32,7 @@ stdenv.mkDerivation rec {
configureFlags = [
"--with-systemdsystemunitdir=$(out)/etc/systemd/system"
"--enable-introspection"
"--enable-gtk-doc"
"--enable-gtk-doc=yes"
Copy link
Contributor

@jtojnar jtojnar Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you drop this change.

];
pkgconfig intltool wrapGAppsHook gobjectIntrospection
# devdoc
gtk-doc docbook_xsl docbook_xml_dtd_412 ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the closing paren to the next line (like fetchurl does)?

@michaelpj
Copy link
Contributor Author

Last nits done.

@jtojnar
Copy link
Contributor

jtojnar commented Aug 14, 2018

Actually, services.geoclue2.enableDemoAgent = false should probably also be added to noxlibs module.

@michaelpj
Copy link
Contributor Author

Is it not enough that it's false by default?

@jtojnar
Copy link
Contributor

jtojnar commented Aug 14, 2018

Yeah, that will probably be enough.

@jtojnar
Copy link
Contributor

jtojnar commented Aug 14, 2018

@GrahamcOfBorg build geoclue2

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: geoclue2

Partial log (click to expand)

checking for references to /build in /nix/store/lpgimzzvf0xkn2pancp4pgpr7lgw3xyq-geoclue-2.4.12...
shrinking RPATHs of ELF executables and libraries in /nix/store/hvl2z9j3q7kjnf0z8pl44q36y9vlc0q4-geoclue-2.4.12-dev
strip is /nix/store/gpc2wld1s0c6qzx9326cwn1wcx29xzsj-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/hvl2z9j3q7kjnf0z8pl44q36y9vlc0q4-geoclue-2.4.12-dev/lib
patching script interpreter paths in /nix/store/hvl2z9j3q7kjnf0z8pl44q36y9vlc0q4-geoclue-2.4.12-dev
checking for references to /build in /nix/store/hvl2z9j3q7kjnf0z8pl44q36y9vlc0q4-geoclue-2.4.12-dev...
shrinking RPATHs of ELF executables and libraries in /nix/store/8h8dfd5pxwp6avjfn0y9gbj3m472afjj-geoclue-2.4.12-devdoc
strip is /nix/store/gpc2wld1s0c6qzx9326cwn1wcx29xzsj-binutils-2.30/bin/strip
patching script interpreter paths in /nix/store/8h8dfd5pxwp6avjfn0y9gbj3m472afjj-geoclue-2.4.12-devdoc
checking for references to /build in /nix/store/8h8dfd5pxwp6avjfn0y9gbj3m472afjj-geoclue-2.4.12-devdoc...

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: geoclue2

Partial log (click to expand)

Wrapping program /nix/store/r2459i9fdj1l1f91fjhlygrgi0bzdabq-geoclue-2.4.12/libexec/geoclue-2.0/demos/where-am-i
strip is /nix/store/251fvx4mx9q4zarbca5cciasmn66p668-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/r2459i9fdj1l1f91fjhlygrgi0bzdabq-geoclue-2.4.12/lib  /nix/store/r2459i9fdj1l1f91fjhlygrgi0bzdabq-geoclue-2.4.12/libexec
patching script interpreter paths in /nix/store/r2459i9fdj1l1f91fjhlygrgi0bzdabq-geoclue-2.4.12
strip is /nix/store/251fvx4mx9q4zarbca5cciasmn66p668-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/qy0yy4hdiqgl30ffs1z5cia3hgxqn4b5-geoclue-2.4.12-dev/lib
patching script interpreter paths in /nix/store/qy0yy4hdiqgl30ffs1z5cia3hgxqn4b5-geoclue-2.4.12-dev
strip is /nix/store/251fvx4mx9q4zarbca5cciasmn66p668-cctools-binutils-darwin/bin/strip
patching script interpreter paths in /nix/store/gqm8prlc21jfk5pvawzqywpgal582sld-geoclue-2.4.12-devdoc
/nix/store/r2459i9fdj1l1f91fjhlygrgi0bzdabq-geoclue-2.4.12

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: geoclue2

Partial log (click to expand)

shrinking RPATHs of ELF executables and libraries in /nix/store/bl389i8232wd9z242xjjgpnpv2bh3j6j-geoclue-2.4.12-dev
strip is /nix/store/ah0va6j4cnwj9nx4j6rwcfc8nh785jwm-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/bl389i8232wd9z242xjjgpnpv2bh3j6j-geoclue-2.4.12-dev/lib
patching script interpreter paths in /nix/store/bl389i8232wd9z242xjjgpnpv2bh3j6j-geoclue-2.4.12-dev
checking for references to /build in /nix/store/bl389i8232wd9z242xjjgpnpv2bh3j6j-geoclue-2.4.12-dev...
shrinking RPATHs of ELF executables and libraries in /nix/store/vn3khi9sf1i20zbwgwi5gq3v38dgmz6r-geoclue-2.4.12-devdoc
strip is /nix/store/ah0va6j4cnwj9nx4j6rwcfc8nh785jwm-binutils-2.30/bin/strip
patching script interpreter paths in /nix/store/vn3khi9sf1i20zbwgwi5gq3v38dgmz6r-geoclue-2.4.12-devdoc
checking for references to /build in /nix/store/vn3khi9sf1i20zbwgwi5gq3v38dgmz6r-geoclue-2.4.12-devdoc...
/nix/store/qa8jd3dm8qci5p4yjgn36ndm4z8yk63p-geoclue-2.4.12

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

Successfully merging this pull request may close these issues.

Redshift, localtime can't talk to geoclue
3 participants