pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/50075: Making dbus actually work on FreeBSD, DragonFly, and probably more



>Number:         50075
>Category:       pkg
>Synopsis:       Making dbus actually work on FreeBSD, DragonFly, and probably more
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 22 01:05:00 +0000 2015
>Originator:     David Shao
>Release:        pkgsrc current
>Organization:
>Environment:
DragonFly  4.3-DEVELOPMENT DragonFly v4.2.2.81.g7432b-DEVELOPMENT #4: Tue Jul 21 13:55:40 PDT 2015     xxxxx@:/usr/obj/usr/src/sys/X86_64_GENERIC  x86_64

>Description:
I have found the following patches to be essential for getting dbus to finally work on DragonFly, FreeBSD, and possibly other OSes.  The functionality has been verified on DragonFly 4.3 DEVELOPMENT and FreeBSD 10.1 release to enable the latest Xfce4 desktop to start and be usable.  As my experience has been dbus as it is builds but does not function even on NetBSD, I argue the following patches should be committed so that dbus works on something and enables an up-to-date desktop on DragonFly and FreeBSD.

That being said I acknowledge it is possible I have made an error and broken working dbus on Darwin or in the smf code, so please reply with corrections.

The following changes are to mk/defaults/mk.conf.

1) The pid file for dbus in /var/run/dbus can have different names, anything from messagebus.pid to dbus.pid on DragonFly and FreeBSD to the default name of pid.  DBUS_SYSTEM_PID_FILE allows the installer to customize this pid file name.

2) The new mk.conf also notes that in practice DBUS_USER and DBUS_GROUP are the same value.

The script dbus that starts the dbus daemon is generated using FILE_SUBST from files/dbus.sh and from smf/files/dbus.sh. 

3) For newer DragonFly and FreeBSD the rcvar name used to invoke dbus in /etc/rc.conf has incorrect default of dbus, whereas it should be dbus_enable.  Therefore @DBUS_RCVAR@ is introduced to pass the correct name.  

4) The pid file name is passed through @DBUS_SYSTEM_PID_FILE_SH@.  I did not want to use FILE_SUBST directly on variables such as DBUS_SYSTEM_PID_FILE because the source code for dbus seems to originally have its own @DBUS_USER@ patterns. Thus the _SH extension for DBUS_SYSTEM_PID_FILE_SH.

5) The original dbus.sh neither removes the pid file when dbus is stopped nor checks if a stale one exists before it starts.  I added a check for both, including adding a dbus_poststop() command similar to the one that DragonFly dports uses.

6) Older dbus seems to have expected the /var/run/dbus directory to have ownership ${DBUS_USER}:${DBUS_GROUP}.  That is no longer the case for current dbus that happily accepts defaults from /var/run such as root:root or root:wheel on newer Linux, DragonFly, or FreeBSD.  I therefore commented out the code setting ownership and permissions for /var/run/dbus but at least left it behind as a hint.

7) The code now checks for the existence of both /var/run/dbus and /var/db/dbus and creates them if they do not exist. 

8) I added the _SH extension to the FILE_SUBST variables in files/smf/dbus.sh for the new line:

		@CHOWN@ @DBUS_USER_SH@:@DBUS_GROUP_SH@ $dir

Now for the changes to sysutils/dbus/Makefile

9) I added DBUS_USER, DBUS_GROUP, and DBUS_SYSTEM_PID_FILE to BUILD_DEFS to at least give installers a hint what to set in their etc/mk.conf if they want other than the defaults.  And as mentioned above, I changed the FILE_SUBST to variables with a _SH extension so that there was no chance of a clash with source code patterns of the same form.

10) I commented out the setting of a home directory for the DBUS_USER as it is nonexistent on newer systems.  I also added a call to create DBUS_USER and DBUS_GROUP before configure but that may not have been necessary.

11) I got rid of a construct playing with CONFIGURE_ARGS.var that grepping seemed to indicate exists nowhere else in pkgsrc.   Instead I rewrote everything to the usual
CONFIGURE_ARGS+=
format.

Finally I patched options.mk.

12) I added the option enable_in_rcvar so that dbus_enable could be set as the correct rcvar in dbus.sh.  It is the suggested option for newer DragonFly and FreeBSD, yet the flexibility is there to choose otherwise for older versions.

13) I again removed the unique CONFIGURE_ARGS.var constructs.


>How-To-Repeat:

>Fix:

--- mk/defaults/mk.conf.orig	2015-07-07 02:03:40.000000000 -0700
+++ mk/defaults/mk.conf	2015-07-21 16:32:47.084413000 -0700
@@ -787,16 +787,21 @@
 # Possible: any user name
 # Default: cyrus
 
-DBUS_GROUP?=	dbus
-# Used in the dbus package to specify the group to run dbus as
-# Possible: any group name
-# Default: dbus
-
 DBUS_USER?=	dbus
 # Used in the dbus package to specify the user to run dbus as
 # Possible: any user name
 # Default: dbus
 
+DBUS_GROUP?=	dbus
+# Used in the dbus package to specify the group to run dbus as
+# Possible: any group name but in practice equals ${DBUS_USER}
+# Default: dbus
+
+DBUS_SYSTEM_PID_FILE?=	pid	
+# Used in the dbus package to specify the name of the pid file 
+# Possible: any pid file name such as pid, messagebus.pid, or dbus.pid
+# Default: pid 
+
 DEFANG_GROUP?=	defang
 # Used in the mimedefang package to specify the group to run commands as
 # Possible: any group name

The remaining patches are to sysutils/dbus.

--- files/dbus.sh.orig	2015-07-20 22:18:07.000000000 -0700
+++ files/dbus.sh	2015-07-21 10:52:31.000000000 -0700
@@ -9,21 +9,33 @@
 . /etc/rc.subr
 
 name="dbus"
-rcvar=$name
+rcvar="@DBUS_RCVAR@"
 command="@PREFIX@/bin/dbus-daemon"
 command_args="--system"
-pidfile="@VARBASE@/run/dbus/pid"
-start_precmd=dbus_prestart
+pidfile="@VARBASE@/run/dbus/@DBUS_SYSTEM_PID_FILE_SH@"
+start_precmd="dbus_prestart"
+stop_postcmd="dbus_poststop"
 
 dbus_prestart() {
+	dbdir="@VARBASE@/db/dbus"
+	if @TEST@ ! -d $dbdir; then
+		@MKDIR@ $dbdir
+	fi
 	dir="@VARBASE@/run/dbus"
 	if @TEST@ ! -d $dir; then
 		@MKDIR@ $dir
-		@CHMOD@ 0755 $dir
-		@CHOWN@ @DBUS_USER@:@DBUS_GROUP@ $dir
+# On other systems /var/run/dbus root:wheel works fine
+#		@CHMOD@ 0755 $dir
+#		@CHOWN@ @DBUS_USER_SH@:@DBUS_GROUP_SH@ $dir
+	elif @TEST@ -f $pidfile; then
+		@RM@ -f $pidfile
 	fi
 	@PREFIX@/bin/dbus-uuidgen --ensure
 }
 
+dbus_poststop() {
+	@RM@ -f $pidfile
+}
+
 load_rc_config $name
 run_rc_command "$1"

--- Makefile.orig	2015-07-20 22:38:16.000000000 -0700
+++ Makefile	2015-07-21 12:21:44.000000000 -0700
@@ -19,7 +19,7 @@
 
 PKGCONFIG_OVERRIDE=	dbus-1.pc.in
 
-BUILD_DEFS+=		VARBASE
+BUILD_DEFS+=		VARBASE DBUS_USER DBUS_GROUP DBUS_SYSTEM_PID_FILE
 
 OWN_DIRS_PERMS+=	${VARBASE}/db/dbus ${DBUS_USER} ${DBUS_GROUP} 0755
 SPECIAL_PERMS+=		libexec/dbus-daemon-launch-helper ${REAL_ROOT_USER} ${DBUS_GROUP} 4511
@@ -34,21 +34,19 @@
 CONFIGURE_ARGS+=	--localstatedir=${VARBASE:Q}
 CONFIGURE_ARGS+=	--sysconfdir=${PKG_SYSCONFDIR:Q}
 
-CONFIGURE_ARGS_GROUPS=	enable disable with without
-
-.if ${OPSYS} == "Darwin"
+.if ${OPSYS} == "Darwin" || ${OPSYS} == "DragonFly" || ${OPSYS} == "FreeBSD"
 # Prevent the configure script from picking up a per-user tmp
 # directory. See the commit message on revision 1.35
-CONFIGURE_ARGS.with+=	session-socket-dir=/tmp
+CONFIGURE_ARGS+=	--with-session-socket-dir=/tmp
 .endif
 
-CONFIGURE_ARGS.Linux=	abstract-sockets selinux
+CONFIGURE_ARGS+=	--without-init-scripts
+CONFIGURE_ARGS+=	--disable-ansi
+CONFIGURE_ARGS+=	--disable-console-owner-file
+CONFIGURE_ARGS+=	--disable-doxygen-docs
+CONFIGURE_ARGS+=	--enable-checks
+CONFIGURE_ARGS+=	--enable-static
 
-CONFIGURE_ARGS.without+=	init-scripts
-CONFIGURE_ARGS.disable+=	ansi
-CONFIGURE_ARGS.disable+=	console-owner-file
-CONFIGURE_ARGS.disable+=	doxygen-docs
-CONFIGURE_ARGS.enable+=		checks static
 ###
 ### XXX the spawn test hangs, and some of these tests may be bogus
 ###
@@ -57,27 +55,21 @@
 #TEST_TARGET=			check
 #.endif
 
-CONFIGURE_ARGS.with+=	dbus-user=${DBUS_USER}
-CONFIGURE_ARGS.with+=	test-socket-dir=${WRKDIR:Q}
+CONFIGURE_ARGS+=	--with-dbus-user=${DBUS_USER}
+CONFIGURE_ARGS+=	--with-test-socket-dir=${WRKDIR:Q}
+CONFIGURE_ARGS+=	--with-system-pid-file=${VARBASE}/run/dbus/${DBUS_SYSTEM_PID_FILE}
 
 PTHREAD_AUTO_VARS=	yes
 
 .if ${OPSYS} == "Linux"
 PLIST.linux=		yes
 .else
-CONFIGURE_ARGS.disable+=\
-			${CONFIGURE_ARGS.Linux}
+CONFIGURE_ARGS+=	--disable-abstract-sockets
+CONFIGURE_ARGS+=	--disable-selinux
 .endif
 
 PLIST_VARS+=    	linux launchd
 
-CONFIGURE_ARGS+=\
-	${CONFIGURE_ARGS_GROUPS:@.g.@			\
-		${CONFIGURE_ARGS.${.g.}:@.a.@		\
-			--${.g.}-${.a.}			\
-		@}					\
-	@:M*}
-
 MAKE_DIRS=		${PKG_SYSCONFDIR}/dbus-1/event.d
 MAKE_DIRS+=		${PKG_SYSCONFDIR}/dbus-1/system.d
 MAKE_DIRS+=		${PKG_SYSCONFDIR}/dbus-1/session.d
@@ -94,10 +86,14 @@
 PKG_GROUPS=		${DBUS_GROUP}
 PKG_USERS=		${DBUS_USER}:${DBUS_GROUP}
 PKG_GECOS.${DBUS_USER}=	System message bus
-PKG_HOME.${DBUS_USER}=	${VARBASE}/run/dbus
+# Modern dbus does not need a home directory for its user
+# PKG_HOME.${DBUS_USER}=	${VARBASE}/run/dbus
+
+USERGROUP_PHASE=	configure
 
-FILES_SUBST+=		DBUS_USER=${DBUS_USER}
-FILES_SUBST+=		DBUS_GROUP=${DBUS_GROUP}
+FILES_SUBST+=		DBUS_USER_SH=${DBUS_USER}
+FILES_SUBST+=		DBUS_GROUP_SH=${DBUS_GROUP}
+FILES_SUBST+=		DBUS_SYSTEM_PID_FILE_SH=${DBUS_SYSTEM_PID_FILE}
 
 BUILDLINK_TRANSFORM+=	rm:-Wl,--gc-sections
 # Package tries to use these if gcc accepts them, but that doesn't

Finally option.mk:

--- options.mk.orig	2015-07-20 22:45:00.000000000 -0700
+++ options.mk	2015-07-21 09:11:37.000000000 -0700
@@ -1,9 +1,13 @@
 # $NetBSD: options.mk,v 1.8 2015/01/21 13:45:18 pho Exp $
 
 PKG_OPTIONS_VAR=	PKG_OPTIONS.dbus
-PKG_SUPPORTED_OPTIONS+=	debug x11
+PKG_SUPPORTED_OPTIONS+=	debug x11 enable_in_rcvar
 PKG_SUGGESTED_OPTIONS=	x11
 
+.if ${OPSYS} == "FreeBSD" || ${OPSYS} == "DragonFly"
+PKG_SUGGESTED_OPTIONS+= enable_in_rcvar	
+.endif
+
 .if (${OPSYS} == "NetBSD"  ||	\
      ${OPSYS} == "FreeBSD" ||	\
      ${OPSYS} == "OpenBSD" ||	\
@@ -22,31 +26,41 @@
 .include "../../mk/bsd.options.mk"
 
 .if !empty(PKG_OPTIONS:Mdebug)
-CONFIGURE_ARGS.enable+=	asserts verbose-mode
+CONFIGURE_ARGS+=	--enable-asserts
+CONFIGURE_ARGS+=	--enable-verbose-mode
 .else
-CONFIGURE_ARGS.disable+= asserts verbose-mode
+CONFIGURE_ARGS+=	--disable-asserts
+CONFIGURE_ARGS+=	--disable-verbose-mode
 .endif
 
 .if !empty(PKG_OPTIONS:Mkqueue)
-CONFIGURE_ARGS.enable+= 	kqueue
+CONFIGURE_ARGS+= 	--enable-kqueue
 .else
-CONFIGURE_ARGS.disable+=	kqueue
+CONFIGURE_ARGS+=	--disable-kqueue
 .endif
 
 .if !empty(PKG_OPTIONS:Mx11)
-CONFIGURE_ARGS.with+=	x
+CONFIGURE_ARGS+=	--with-x
 .  include "../../x11/libX11/buildlink3.mk"
 BUILDLINK_DEPMETHOD.libXt=	build
 .  include "../../x11/libXt/buildlink3.mk"
 .else
-CONFIGURE_ARGS.without=	x
+CONFIGURE_ARGS=		--without-x
 .endif
 
 .if !empty(PKG_OPTIONS:Mlaunchd)
 MESSAGE_SRC+=			MESSAGE.launchd
 PLIST.launchd=			yes
-CONFIGURE_ARGS.enable+=		launchd
-CONFIGURE_ARGS.with+=		launchd-agent-dir=${PREFIX}/Library/LaunchAgents
+CONFIGURE_ARGS+=		--enable-launchd
+CONFIGURE_ARGS+=		--with-launchd-agent-dir=${PREFIX}/Library/LaunchAgents
+.else
+CONFIGURE_ARGS+=		--disable-launchd
+.endif
+
+.if !empty(PKG_OPTIONS:Menable_in_rcvar)
+DBUS_RCVAR=		dbus_enable
 .else
-CONFIGURE_ARGS.disable+=	launchd
+DBUS_RCVAR=		dbus
 .endif
+
+FILES_SUBST+=		DBUS_RCVAR=${DBUS_RCVAR}




Home | Main Index | Thread Index | Old Index