3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #448 from vcunat/p/dbus

dbus: modularize
This commit is contained in:
Vladimír Čunát 2013-04-11 06:20:44 -07:00
commit f9c5bd7a48
10 changed files with 384 additions and 59 deletions

View file

@ -1,18 +1,20 @@
{ stdenv, fetchurl, pkgconfig, expat, gettext, libiconv, dbus, glib }:
stdenv.mkDerivation rec {
name = "dbus-glib-0.98";
name = "dbus-glib-0.100.2";
src = fetchurl {
url = "${meta.homepage}/releases/dbus-glib/${name}.tar.gz";
sha256 = "04fiwld5yaxyggxlvdmbaqkngh4fn8gfkkqckcp3274bpgb82z19";
sha256 = "1ibav91yg70f2l3l18cr0hf4mna1h9d4mrg0c60w4l8zjbd45fx5";
};
nativeBuildInputs = [ pkgconfig gettext ];
buildInputs = [ expat ] ++ stdenv.lib.optional (!stdenv.isLinux) libiconv;
propagatedBuildInputs = [ dbus glib ];
propagatedBuildInputs = [ dbus.libs glib ];
doCheck = true;
passthru = { inherit dbus glib; };

View file

@ -1,4 +1,6 @@
{ stdenv, fetchurl, pkgconfig, expat, libX11, libICE, libSM, useX11 ? true }:
{ stdenv, fetchurl, pkgconfig, autoconf, automake, libtool
, expat, systemd, glib, dbus_glib, python
, libX11, libICE, libSM, useX11 ? true }:
let
version = "1.6.4";
@ -8,64 +10,121 @@ let
sha256 = "1wacqyfkcpayg7f8rvx9awqg275n5pksxq5q7y21lxjx85x6pfjz";
};
patches = [ ./ignore-missing-includedirs.patch ];
patches = [
./ignore-missing-includedirs.patch ./implement-getgrouplist.patch
./ucred-dirty-hack.patch ./no-create-dirs.patch
];
configureFlags = "--localstatedir=/var --sysconfdir=/etc --with-session-socket-dir=/tmp";
# build only the specified subdirs
postPatch = subdirs : "sed '/SUBDIRS/s/=.*/=" + subdirs + "/' -i Makefile.am\n"
# use already packaged libdbus instead of trying to build it again
+ stdenv.lib.optionalString (subdirs != "dbus") ''
for mfile in */Makefile.am; do
sed 's,\$(top_builddir)/dbus/\(libdbus-[0-9]\),${libs}/lib/\1,g' -i "$mfile"
done
'';
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ autoconf automake libtool expat ]; # ToDo: optional selinux?
buildInputsWithX = buildInputs ++ stdenv.lib.optionals useX11 [ libX11 libICE libSM ];
preConfigure = ''
patchShebangs .
substituteInPlace tools/Makefile.am --replace 'install-localstatelibDATA:' 'disabled:'
autoreconf -fi
'';
configureFlags = [
"--localstatedir=/var"
"--sysconfdir=/etc"
"--with-session-socket-dir=/tmp"
"--with-systemdsystemunitdir=$(out)/lib/systemd"
];
# also other parts than "libs" need this statically linked lib
postConfigure = "(cd dbus && make libdbus-internal.la)";
doCheck = true;
installFlags = "sysconfdir=$(out)/etc";
in rec {
libs = stdenv.mkDerivation {
name = "dbus-library-" + version;
nativeBuildInputs = [ pkgconfig ];
inherit src nativeBuildInputs preConfigure configureFlags doCheck installFlags;
buildInputs = [ expat ];
buildInputs = buildInputs ++ [ systemd.headers ];
# FIXME: dbus has optional systemd integration when checking
# at_console policies. How to enable this without introducing a
# circular dependency between dbus and systemd?
patches = patches ++ [ ./systemd.patch ]; # bypass systemd detection
inherit src patches configureFlags;
preConfigure =
''
sed -i '/mkinstalldirs.*localstatedir/d' bus/Makefile.in
sed -i '/SUBDIRS/s/ tools//' Makefile.in
'';
postPatch = postPatch "dbus";
# Enable X11 autolaunch support in libdbus. This doesn't actually
# depend on X11 (it just execs dbus-launch in dbus.tools),
# contrary to what the configure script demands.
NIX_CFLAGS_COMPILE = "-DDBUS_ENABLE_X11_AUTOLAUNCH=1";
installFlags = "sysconfdir=$(out)/etc";
};
tools = stdenv.mkDerivation {
name = "dbus-tools-" + version;
inherit src patches;
inherit src patches nativeBuildInputs preConfigure doCheck installFlags;
configureFlags = "${configureFlags} --with-dbus-daemondir=${daemon}/bin";
configureFlags = configureFlags ++ [ "--with-dbus-daemondir=${daemon}/bin" ];
nativeBuildInputs = [ pkgconfig ];
buildInputs = buildInputsWithX ++ [ libs daemon systemd dbus_glib ];
buildInputs = [ expat libs ]
++ stdenv.lib.optionals useX11 [ libX11 libICE libSM ];
NIX_CFLAGS_LINK = "-Wl,--as-needed -ldbus-1";
NIX_LDFLAGS = "-ldbus-1";
preConfigure =
''
sed -i 's@$(top_builddir)/dbus/libdbus-1.la@@' tools/Makefile.in
substituteInPlace tools/Makefile.in --replace 'install-localstatelibDATA:' 'disabled:'
'';
postConfigure = "cd tools";
installFlags = "localstatedir=$TMPDIR/var";
postPatch = postPatch "tools";
};
# I'm too lazy to separate daemon and libs now.
daemon = libs;
daemon = stdenv.mkDerivation {
name = "dbus-daemon-" + version;
inherit src patches nativeBuildInputs
preConfigure configureFlags postConfigure doCheck installFlags;
buildInputs = buildInputs ++ [ systemd ];
postPatch = postPatch "bus";
};
tests = stdenv.mkDerivation {
name = "dbus-tests-" + version;
inherit src patches nativeBuildInputs
preConfigure configureFlags postConfigure doCheck installFlags;
buildInputs = buildInputsWithX ++ [ systemd libs tools daemon dbus_glib python ];
postPatch = postPatch "test";
NIX_CFLAGS_LINK = "-Wl,--as-needed -ldbus-1";
};
docs = stdenv.mkDerivation {
name = "dbus-docs-" + version;
inherit src patches nativeBuildInputs
preConfigure configureFlags doCheck installFlags;
buildInputs = buildInputs;
postPatch = postPatch "doc";
postInstall = ''rm -r "$out/lib"'';
};
in {
inherit libs daemon tools tests docs;
dbus_libs = libs;
dbus_daemon = daemon;
dbus_tools = tools;
dbus_tests = tests;
dbus_docs = docs;
}

View file

@ -0,0 +1,108 @@
Compatibility patch for Illumos/Solaris and possibly other platforms.
Implements getgrouplist when not provided by OS.
Without it, only the user's primary group is used in authentication!
--- 1970-01-01 00:00:00.000000000 +0000
+++ dbus-1.6.8/dbus/getgrouplist.c 2013-02-28 13:10:51.081792722 +0000
@@ -0,0 +1,89 @@
+/* $OpenBSD: getgrouplist.c,v 1.12 2005/08/08 08:05:34 espie Exp $ */
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* OPENBSD ORIGINAL: lib/libc/gen/getgrouplist.c */
+
+/*
+ * get credential
+ */
+#include <sys/types.h>
+#include <string.h>
+#include <unistd.h>
+#include <grp.h>
+
+int
+getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
+{
+ struct group *grp;
+ int i, ngroups;
+ int ret, maxgroups;
+ int bail;
+
+ ret = 0;
+ ngroups = 0;
+ maxgroups = *grpcnt;
+
+ /*
+ * install primary group
+ */
+ if (ngroups >= maxgroups) {
+ *grpcnt = ngroups;
+ return (-1);
+ }
+ groups[ngroups++] = agroup;
+
+ /*
+ * Scan the group file to find additional groups.
+ */
+ setgrent();
+ while ((grp = getgrent())) {
+ if (grp->gr_gid == agroup)
+ continue;
+ for (bail = 0, i = 0; bail == 0 && i < ngroups; i++)
+ if (groups[i] == grp->gr_gid)
+ bail = 1;
+ if (bail)
+ continue;
+ for (i = 0; grp->gr_mem[i]; i++) {
+ if (!strcmp(grp->gr_mem[i], uname)) {
+ if (ngroups >= maxgroups) {
+ ret = -1;
+ goto out;
+ }
+ groups[ngroups++] = grp->gr_gid;
+ break;
+ }
+ }
+ }
+out:
+ endgrent();
+ *grpcnt = ngroups;
+ return (ret);
+}
--- dbus-1.6.8/dbus/dbus-sysdeps-unix.c.orig 2013-02-28 13:08:52.171215237 +0000
+++ dbus-1.6.8/dbus/dbus-sysdeps-unix.c 2013-02-28 13:13:52.224615146 +0000
@@ -21,6 +21,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
+#ifndef HAVE_GETGROUPLIST
+#include "getgrouplist.c"
+#define HAVE_GETGROUPLIST
+#endif
#include <config.h>

View file

@ -0,0 +1,26 @@
diff --git a/bus/Makefile.am b/bus/Makefile.am
index 6cbc09a..be60bb8 100644
--- a/bus/Makefile.am
+++ b/bus/Makefile.am
@@ -212,7 +212,6 @@ clean-local:
/bin/rm *.bb *.bbg *.da *.gcov || true
install-data-hook:
- $(mkinstalldirs) $(DESTDIR)$(localstatedir)/run/dbus
$(mkinstalldirs) $(DESTDIR)$(configdir)/system.d
$(mkinstalldirs) $(DESTDIR)$(configdir)/session.d
$(mkinstalldirs) $(DESTDIR)$(datadir)/dbus-1/services
diff --git a/tools/Makefile.am b/tools/Makefile.am
index cfd54b8..b6e28f9 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -74,7 +74,7 @@ CLEANFILES = \
# create the /var/lib/dbus directory for dbus-uuidgen
install-data-local:
- $(MKDIR_P) $(DESTDIR)$(localstatedir)/lib/dbus
+ :
installcheck-local:
- test -d $(DESTDIR)$(localstatedir)/lib/dbus
+ :

View file

@ -0,0 +1,14 @@
diff --git a/configure.ac b/configure.ac
index 24fcc9e..98e0459 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1167,7 +1167,8 @@ else
PKG_CHECK_MODULES(SYSTEMD,
[libsystemd-login >= 32, libsystemd-daemon >= 32],
have_systemd=yes,
- have_systemd=no)
+ have_systemd=yes)
+ AC_MSG_NOTICE([NixOS: do not care whether we found systemd or not])
fi
if test x$have_systemd = xyes; then

View file

@ -0,0 +1,18 @@
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index b4ecc96..267984a 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -1635,6 +1635,13 @@ write_credentials_byte (int server_fd,
}
}
+struct ucred
+{
+ pid_t pid; /* PID of sending process. */
+ uid_t uid; /* UID of sending process. */
+ gid_t gid; /* GID of sending process. */
+};
+
/**
* Reads a single byte which must be nul (an error occurs otherwise),
* and reads unix credentials if available. Clears the credentials

View file

@ -6,7 +6,8 @@
assert stdenv.gcc.libc or null != null;
stdenv.mkDerivation rec {
name = "systemd-200";
version = "200";
name = "systemd-${version}";
src = fetchurl {
url = "http://www.freedesktop.org/software/systemd/${name}.tar.xz";
@ -24,7 +25,7 @@ stdenv.mkDerivation rec {
] ++ stdenv.lib.optional stdenv.isArm ./libc-bug-accept4-arm.patch;
buildInputs =
[ pkgconfig intltool gperf libcap dbus kmod xz pam acl
[ pkgconfig intltool gperf libcap dbus.libs kmod xz pam acl
/* cryptsetup */ libuuid m4 glib libxslt libgcrypt docbook_xsl
];
@ -116,6 +117,19 @@ stdenv.mkDerivation rec {
# runtime; otherwise we can't and we need to reboot.
passthru.interfaceVersion = 2;
passthru.headers = stdenv.mkDerivation {
name = "systemd-headers-${version}";
inherit src;
phases = [ "unpackPhase" "installPhase" ];
# some are needed by dbus.libs, which is needed for systemd :-)
installPhase = ''
mkdir -p "$out/include/systemd"
mv src/systemd/*.h "$out/include/systemd"
'';
};
meta = {
homepage = "http://www.freedesktop.org/wiki/Software/systemd";
description = "A system and service manager for Linux";

View file

@ -0,0 +1,68 @@
Signed-off-by: Ramkumar Ramachandra <artag...@gmail.com>
---
Ramkumar Ramachandra wrote:
> $ ./test-id128
> random: a08ea8ed34594d4bbd953dd182ec86f9
> Assertion 'sd_id128_get_machine(&id) == 0' failed at
> src/test/test-id128.c:41, function main(). Aborting.
> [1] 8017 abort (core dumped) ./test-id128
Okay, this test fails because I don't have a /etc/machine-id -- I
thought systemd is supposed to create it? However, from the logic in
src/core/machine-id-setup.c, it looks like although open() is called
with O_CREAT on /etc/machine-id, systemd barfs if the file isn't
present. How about changing this?
src/core/machine-id-setup.c | 12 +++++-------
src/test/test-id128.c | 6 ++++--
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index 7f4c23b..3f21d58 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -168,12 +168,8 @@ int machine_id_setup(void) {
writable = true;
else {
fd = open("/etc/machine-id", O_RDONLY|O_CLOEXEC|O_NOCTTY);
- if (fd < 0) {
- umask(m);
- log_error("Cannot open /etc/machine-id: %m");
- return -errno;
- }
-
+ if (fd < 0)
+ goto generate;
writable = false;
}
@@ -192,7 +188,9 @@ int machine_id_setup(void) {
}
}
- /* Hmm, so, the id currently stored is not useful, then let's
+generate:
+ /* Hmm, so, either /etc/machine-id doesn't exist, the id
+ * currently stored is not useful, then let's
* generate one */
r = generate(id);
diff --git a/src/test/test-id128.c b/src/test/test-id128.c
index bfd743e..60902d0 100644
--- a/src/test/test-id128.c
+++ b/src/test/test-id128.c
@@ -38,8 +38,10 @@ int main(int argc, char *argv[]) {
assert_se(sd_id128_from_string(t, &id2) == 0);
assert_se(sd_id128_equal(id, id2));
- assert_se(sd_id128_get_machine(&id) == 0);
- printf("machine: %s\n", sd_id128_to_string(id, t));
+ if (sd_id128_get_machine(&id) < 0)
+ printf("machine: run systemd-machine-id-setup first\n");
+ else
+ printf("machine: %s\n", sd_id128_to_string(id, t));
assert_se(sd_id128_get_boot(&id) == 0);
printf("boot: %s\n", sd_id128_to_string(id, t));
--
1.7.8.1.362.g5d6df.dirty

View file

@ -0,0 +1,26 @@
diff --git a/Makefile.am b/Makefile.am
index 05bf582..aa16a7c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2568,11 +2568,6 @@ endif
# "adm" and "wheel".
libsystemd-journal-install-hook:
libname=libsystemd-journal.so && $(move-to-rootlibdir)
- $(MKDIR_P) $(DESTDIR)/var/log/journal
- -chown 0:0 $(DESTDIR)/var/log/journal
- -chmod 755 $(DESTDIR)/var/log/journal
- -setfacl -nm g:adm:rx,d:g:adm:rx $(DESTDIR)/var/log/journal/
- -setfacl -nm g:wheel:rx,d:g:wheel:rx $(DESTDIR)/var/log/journal/
libsystemd-journal-uninstall-hook:
rm -f $(DESTDIR)$(rootlibdir)/libsystemd-journal.so*
@@ -3676,9 +3671,6 @@ if HAVE_SYSV_COMPAT
sysvinit_DATA = \
docs/sysvinit/README
-varlog_DATA = \
- docs/var-log/README
-
docs/sysvinit/README: docs/sysvinit/README.in
$(SED_PROCESS)

View file

@ -1452,7 +1452,7 @@ let
pystringtemplate = callPackage ../development/python-modules/stringtemplate { };
pythonDBus = callPackage ../development/python-modules/dbus { };
pythonDBus = dbus_python;
pythonIRClib = builderDefsPackage (import ../development/python-modules/irclib) {
inherit python;
@ -3582,23 +3582,13 @@ let
db48 = callPackage ../development/libraries/db4/db4-4.8.nix { };
dbus = pkgs.dbus_all.libs // { inherit (pkgs.dbus_all) libs; };
dbus_daemon = pkgs.dbus_all.daemon;
dbus_tools = pkgs.dbus_all.tools;
dbus_libs = pkgs.dbus_all.libs;
dbus_all = callPackage ../development/libraries/dbus {
useX11 = true;
};
dbus_cplusplus = callPackage ../development/libraries/dbus-cplusplus { };
dbus_glib = callPackage ../development/libraries/dbus-glib { };
dbus_java = callPackage ../development/libraries/java/dbus-java { };
dbus = dbus_all;
dbus_all = callPackage ../development/libraries/dbus { };
inherit (dbus_all) dbus_libs dbus_daemon dbus_tools dbus_tests dbus_docs;
dbus_cplusplus = callPackage ../development/libraries/dbus-cplusplus { };
dbus_glib = callPackage ../development/libraries/dbus-glib { };
dbus_java = callPackage ../development/libraries/java/dbus-java { };
dbus_python = callPackage ../development/python-modules/dbus { };
dclib = callPackage ../development/libraries/dclib { };