lol

dbus: modularize into libs, daemon, tools, tests and docs

+258 -33
+92 -33
pkgs/development/libraries/dbus/default.nix
··· 1 - { stdenv, fetchurl, pkgconfig, expat, libX11, libICE, libSM, useX11 ? true }: 1 + { stdenv, fetchurl, pkgconfig, autoconf, automake, libtool 2 + , expat, systemd, glib, dbus_glib, python 3 + , libX11, libICE, libSM, useX11 ? true }: 2 4 3 5 let 4 6 version = "1.6.4"; ··· 8 10 sha256 = "1wacqyfkcpayg7f8rvx9awqg275n5pksxq5q7y21lxjx85x6pfjz"; 9 11 }; 10 12 11 - patches = [ ./ignore-missing-includedirs.patch ]; 13 + patches = [ 14 + ./ignore-missing-includedirs.patch ./implement-getgrouplist.patch 15 + ./ucred-dirty-hack.patch ./no-create-dirs.patch 16 + ]; 17 + 18 + # build only the specified subdirs 19 + postPatch = subdirs : "sed '/SUBDIRS/s/=.*/=" + subdirs + "/' -i Makefile.am\n" 20 + # use already packaged libdbus instead of trying to build it again 21 + + stdenv.lib.optionalString (subdirs != "dbus") '' 22 + for mfile in */Makefile.am; do 23 + sed 's,\$(top_builddir)/dbus/\(libdbus-[0-9]\),${libs}/lib/\1,g' -i "$mfile" 24 + done 25 + ''; 26 + 27 + nativeBuildInputs = [ pkgconfig ]; 28 + 29 + buildInputs = [ autoconf automake libtool expat ]; # ToDo: optional selinux? 30 + 31 + buildInputsWithX = buildInputs ++ stdenv.lib.optionals useX11 [ libX11 libICE libSM ]; 32 + 33 + preConfigure = '' 34 + patchShebangs . 35 + substituteInPlace tools/Makefile.am --replace 'install-localstatelibDATA:' 'disabled:' 36 + autoreconf -fi 37 + ''; 38 + 39 + configureFlags = [ 40 + "--localstatedir=/var" 41 + "--sysconfdir=/etc" 42 + "--with-session-socket-dir=/tmp" 43 + "--with-systemdsystemunitdir=$(out)/lib/systemd" 44 + ]; 12 45 13 - configureFlags = "--localstatedir=/var --sysconfdir=/etc --with-session-socket-dir=/tmp"; 46 + # also other parts than "libs" need this statically linked lib 47 + postConfigure = "(cd dbus && make libdbus-internal.la)"; 14 48 15 - in rec { 49 + doCheck = true; 50 + 51 + installFlags = "sysconfdir=$(out)/etc"; 52 + 16 53 17 54 libs = stdenv.mkDerivation { 18 55 name = "dbus-library-" + version; 19 56 20 - nativeBuildInputs = [ pkgconfig ]; 57 + inherit src nativeBuildInputs preConfigure configureFlags doCheck installFlags; 21 58 22 - buildInputs = [ expat ]; 59 + buildInputs = buildInputs ++ [ systemd.headers ]; 23 60 24 - # FIXME: dbus has optional systemd integration when checking 25 - # at_console policies. How to enable this without introducing a 26 - # circular dependency between dbus and systemd? 61 + patches = patches ++ [ ./systemd.patch ]; # bypass systemd detection 27 62 28 - inherit src patches configureFlags; 29 - 30 - preConfigure = 31 - '' 32 - sed -i '/mkinstalldirs.*localstatedir/d' bus/Makefile.in 33 - sed -i '/SUBDIRS/s/ tools//' Makefile.in 34 - ''; 63 + postPatch = postPatch "dbus"; 35 64 36 65 # Enable X11 autolaunch support in libdbus. This doesn't actually 37 66 # depend on X11 (it just execs dbus-launch in dbus.tools), 38 67 # contrary to what the configure script demands. 39 68 NIX_CFLAGS_COMPILE = "-DDBUS_ENABLE_X11_AUTOLAUNCH=1"; 40 - 41 - installFlags = "sysconfdir=$(out)/etc"; 42 69 }; 43 70 44 71 tools = stdenv.mkDerivation { 45 72 name = "dbus-tools-" + version; 46 73 47 - inherit src patches; 74 + inherit src patches nativeBuildInputs preConfigure doCheck installFlags; 48 75 49 - configureFlags = "${configureFlags} --with-dbus-daemondir=${daemon}/bin"; 76 + configureFlags = configureFlags ++ [ "--with-dbus-daemondir=${daemon}/bin" ]; 50 77 51 - nativeBuildInputs = [ pkgconfig ]; 78 + buildInputs = buildInputsWithX ++ [ libs daemon systemd dbus_glib ]; 52 79 53 - buildInputs = [ expat libs ] 54 - ++ stdenv.lib.optionals useX11 [ libX11 libICE libSM ]; 80 + NIX_CFLAGS_LINK = "-Wl,--as-needed -ldbus-1"; 55 81 56 - NIX_LDFLAGS = "-ldbus-1"; 82 + postPatch = postPatch "tools"; 83 + }; 57 84 58 - preConfigure = 59 - '' 60 - sed -i 's@$(top_builddir)/dbus/libdbus-1.la@@' tools/Makefile.in 61 - substituteInPlace tools/Makefile.in --replace 'install-localstatelibDATA:' 'disabled:' 62 - ''; 85 + daemon = stdenv.mkDerivation { 86 + name = "dbus-daemon-" + version; 87 + 88 + inherit src patches nativeBuildInputs 89 + preConfigure configureFlags postConfigure doCheck installFlags; 63 90 64 - postConfigure = "cd tools"; 91 + buildInputs = buildInputs ++ [ systemd ]; 65 92 66 - installFlags = "localstatedir=$TMPDIR/var"; 93 + postPatch = postPatch "bus"; 67 94 }; 68 95 69 - # I'm too lazy to separate daemon and libs now. 70 - daemon = libs; 96 + tests = stdenv.mkDerivation { 97 + name = "dbus-tests-" + version; 98 + 99 + inherit src patches nativeBuildInputs 100 + preConfigure configureFlags postConfigure doCheck installFlags; 101 + 102 + buildInputs = buildInputsWithX ++ [ systemd libs tools daemon dbus_glib python ]; 103 + 104 + postPatch = postPatch "test"; 105 + 106 + NIX_CFLAGS_LINK = "-Wl,--as-needed -ldbus-1"; 107 + }; 108 + 109 + docs = stdenv.mkDerivation { 110 + name = "dbus-docs-" + version; 111 + 112 + inherit src patches nativeBuildInputs 113 + preConfigure configureFlags doCheck installFlags; 114 + 115 + buildInputs = buildInputs; 116 + 117 + postPatch = postPatch "doc"; 118 + 119 + postInstall = ''rm -r "$out/lib"''; 120 + }; 121 + 122 + in { 123 + inherit libs daemon tools tests docs; 124 + 125 + dbus_libs = libs; 126 + dbus_daemon = daemon; 127 + dbus_tools = tools; 128 + dbus_tests = tests; 129 + dbus_docs = docs; 71 130 }
+108
pkgs/development/libraries/dbus/implement-getgrouplist.patch
··· 1 + Compatibility patch for Illumos/Solaris and possibly other platforms. 2 + Implements getgrouplist when not provided by OS. 3 + Without it, only the user's primary group is used in authentication! 4 + --- 1970-01-01 00:00:00.000000000 +0000 5 + +++ dbus-1.6.8/dbus/getgrouplist.c 2013-02-28 13:10:51.081792722 +0000 6 + @@ -0,0 +1,89 @@ 7 + +/* $OpenBSD: getgrouplist.c,v 1.12 2005/08/08 08:05:34 espie Exp $ */ 8 + +/* 9 + + * Copyright (c) 1991, 1993 10 + + * The Regents of the University of California. All rights reserved. 11 + + * 12 + + * Redistribution and use in source and binary forms, with or without 13 + + * modification, are permitted provided that the following conditions 14 + + * are met: 15 + + * 1. Redistributions of source code must retain the above copyright 16 + + * notice, this list of conditions and the following disclaimer. 17 + + * 2. Redistributions in binary form must reproduce the above copyright 18 + + * notice, this list of conditions and the following disclaimer in the 19 + + * documentation and/or other materials provided with the distribution. 20 + + * 3. Neither the name of the University nor the names of its contributors 21 + + * may be used to endorse or promote products derived from this software 22 + + * without specific prior written permission. 23 + + * 24 + + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 + + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 + + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 + + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 + + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 + + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 + + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 + + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 + + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 + + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 + + * SUCH DAMAGE. 35 + + */ 36 + + 37 + +/* OPENBSD ORIGINAL: lib/libc/gen/getgrouplist.c */ 38 + + 39 + +/* 40 + + * get credential 41 + + */ 42 + +#include <sys/types.h> 43 + +#include <string.h> 44 + +#include <unistd.h> 45 + +#include <grp.h> 46 + + 47 + +int 48 + +getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt) 49 + +{ 50 + + struct group *grp; 51 + + int i, ngroups; 52 + + int ret, maxgroups; 53 + + int bail; 54 + + 55 + + ret = 0; 56 + + ngroups = 0; 57 + + maxgroups = *grpcnt; 58 + + 59 + + /* 60 + + * install primary group 61 + + */ 62 + + if (ngroups >= maxgroups) { 63 + + *grpcnt = ngroups; 64 + + return (-1); 65 + + } 66 + + groups[ngroups++] = agroup; 67 + + 68 + + /* 69 + + * Scan the group file to find additional groups. 70 + + */ 71 + + setgrent(); 72 + + while ((grp = getgrent())) { 73 + + if (grp->gr_gid == agroup) 74 + + continue; 75 + + for (bail = 0, i = 0; bail == 0 && i < ngroups; i++) 76 + + if (groups[i] == grp->gr_gid) 77 + + bail = 1; 78 + + if (bail) 79 + + continue; 80 + + for (i = 0; grp->gr_mem[i]; i++) { 81 + + if (!strcmp(grp->gr_mem[i], uname)) { 82 + + if (ngroups >= maxgroups) { 83 + + ret = -1; 84 + + goto out; 85 + + } 86 + + groups[ngroups++] = grp->gr_gid; 87 + + break; 88 + + } 89 + + } 90 + + } 91 + +out: 92 + + endgrent(); 93 + + *grpcnt = ngroups; 94 + + return (ret); 95 + +} 96 + --- dbus-1.6.8/dbus/dbus-sysdeps-unix.c.orig 2013-02-28 13:08:52.171215237 +0000 97 + +++ dbus-1.6.8/dbus/dbus-sysdeps-unix.c 2013-02-28 13:13:52.224615146 +0000 98 + @@ -21,6 +21,10 @@ 99 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 100 + * 101 + */ 102 + +#ifndef HAVE_GETGROUPLIST 103 + +#include "getgrouplist.c" 104 + +#define HAVE_GETGROUPLIST 105 + +#endif 106 + 107 + #include <config.h> 108 +
+26
pkgs/development/libraries/dbus/no-create-dirs.patch
··· 1 + diff --git a/bus/Makefile.am b/bus/Makefile.am 2 + index 6cbc09a..be60bb8 100644 3 + --- a/bus/Makefile.am 4 + +++ b/bus/Makefile.am 5 + @@ -212,7 +212,6 @@ clean-local: 6 + /bin/rm *.bb *.bbg *.da *.gcov || true 7 + 8 + install-data-hook: 9 + - $(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus 10 + $(mkinstalldirs) $(DESTDIR)$(configdir)/system.d 11 + $(mkinstalldirs) $(DESTDIR)$(configdir)/session.d 12 + $(mkinstalldirs) $(DESTDIR)$(datadir)/dbus-1/services 13 + diff --git a/tools/Makefile.am b/tools/Makefile.am 14 + index cfd54b8..b6e28f9 100644 15 + --- a/tools/Makefile.am 16 + +++ b/tools/Makefile.am 17 + @@ -74,7 +74,7 @@ CLEANFILES = \ 18 + 19 + # create the /var/lib/dbus directory for dbus-uuidgen 20 + install-data-local: 21 + - $(MKDIR_P) $(DESTDIR)$(localstatedir)/lib/dbus 22 + + : 23 + 24 + installcheck-local: 25 + - test -d $(DESTDIR)$(localstatedir)/lib/dbus 26 + + :
+14
pkgs/development/libraries/dbus/systemd.patch
··· 1 + diff --git a/configure.ac b/configure.ac 2 + index 24fcc9e..98e0459 100644 3 + --- a/configure.ac 4 + +++ b/configure.ac 5 + @@ -1167,7 +1167,8 @@ else 6 + PKG_CHECK_MODULES(SYSTEMD, 7 + [libsystemd-login >= 32, libsystemd-daemon >= 32], 8 + have_systemd=yes, 9 + - have_systemd=no) 10 + + have_systemd=yes) 11 + + AC_MSG_NOTICE([NixOS: do not care whether we found systemd or not]) 12 + fi 13 + 14 + if test x$have_systemd = xyes; then
+18
pkgs/development/libraries/dbus/ucred-dirty-hack.patch
··· 1 + diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c 2 + index b4ecc96..267984a 100644 3 + --- a/dbus/dbus-sysdeps-unix.c 4 + +++ b/dbus/dbus-sysdeps-unix.c 5 + @@ -1635,6 +1635,13 @@ write_credentials_byte (int server_fd, 6 + } 7 + } 8 + 9 + +struct ucred 10 + +{ 11 + + pid_t pid; /* PID of sending process. */ 12 + + uid_t uid; /* UID of sending process. */ 13 + + gid_t gid; /* GID of sending process. */ 14 + +}; 15 + + 16 + /** 17 + * Reads a single byte which must be nul (an error occurs otherwise), 18 + * and reads unix credentials if available. Clears the credentials