summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormezz <mezz@df743ca5-7f9a-e211-a948-0013205c9059>2008-08-22 00:04:48 +0800
committermezz <mezz@df743ca5-7f9a-e211-a948-0013205c9059>2008-08-22 00:04:48 +0800
commitaa68e424a63a0467321826d761ea11b42148bf94 (patch)
tree835b11346a5866b5b28470e99a6a48cdd95691d8
parent72cd0bea4f79f81dc72c33fe28421736bd05988e (diff)
downloadmarcuscom-ports-aa68e424a63a0467321826d761ea11b42148bf94.tar
marcuscom-ports-aa68e424a63a0467321826d761ea11b42148bf94.tar.gz
marcuscom-ports-aa68e424a63a0467321826d761ea11b42148bf94.tar.bz2
marcuscom-ports-aa68e424a63a0467321826d761ea11b42148bf94.tar.lz
marcuscom-ports-aa68e424a63a0467321826d761ea11b42148bf94.tar.xz
marcuscom-ports-aa68e424a63a0467321826d761ea11b42148bf94.tar.zst
marcuscom-ports-aa68e424a63a0467321826d761ea11b42148bf94.zip
Fix the ConsoleKit signatures in HAL with ConsoleKit 0.3.x. This fix DVD movie,
HDD and possible more other mount stuff. Bump the PORTREVISION. Obtained from: http://thread.gmane.org/gmane.comp.freedesktop.hal/11940/ Reviewed by: marcus git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@11359 df743ca5-7f9a-e211-a948-0013205c9059
-rw-r--r--sysutils/hal/Makefile121
-rw-r--r--sysutils/hal/distinfo3
-rw-r--r--sysutils/hal/files/10-mouse-sysmouse.fdi8
-rw-r--r--sysutils/hal/files/extra-patch-tools_hal-storage-mount.c25
-rw-r--r--sysutils/hal/files/hald.in80
-rw-r--r--sysutils/hal/files/patch-Makefile.in25
-rw-r--r--sysutils/hal/files/patch-consolekit0387
-rw-r--r--sysutils/hal/files/patch-doc_Makefile.in11
-rw-r--r--sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi18
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in92
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c219
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c238
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_clock111
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_probe-volume.c12
-rw-r--r--sysutils/hal/files/patch-hald_hf-storage.c18
-rw-r--r--sysutils/hal/files/patch-tools_hal-storage-mount.c11
-rw-r--r--sysutils/hal/files/pkg-deinstall.in12
-rw-r--r--sysutils/hal/files/pkg-install.in50
-rw-r--r--sysutils/hal/pkg-descr6
-rw-r--r--sysutils/hal/pkg-plist129
20 files changed, 1276 insertions, 0 deletions
diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile
new file mode 100644
index 000000000..5fbdc3bc9
--- /dev/null
+++ b/sysutils/hal/Makefile
@@ -0,0 +1,121 @@
+# New ports collection makefile for: HAL
+# Date Created: 02 May 2006
+# Whom: Joe Marcus Clarke <marcus@FreeBSD.org>
+#
+# $FreeBSD$
+# $MCom$
+#
+
+PORTNAME= hal
+DISTVERSION= 0.5.11
+PORTREVISION= 2
+CATEGORIES= sysutils
+MASTER_SITES= http://hal.freedesktop.org/releases/
+
+MAINTAINER= gnome@FreeBSD.org
+COMMENT= Hardware Abstraction Layer for simplifying device access
+
+LIB_DEPENDS= polkit.2:${PORTSDIR}/sysutils/policykit \
+ volume_id.0:${PORTSDIR}/devel/libvolume_id \
+ ck-connector.0:${PORTSDIR}/sysutils/consolekit
+RUN_DEPENDS= ${LOCALBASE}/share/pciids/pci.ids:${PORTSDIR}/misc/pciids
+
+USE_GETTEXT= yes
+USE_GMAKE= yes
+USE_GNOME= gnomehack gnometarget intlhack ltverhack
+USE_AUTOTOOLS= libtool:15
+USE_LDCONFIG= yes
+USE_PYTHON= yes
+CONFIGURE_ARGS= --disable-gtk-doc \
+ --with-backend=freebsd \
+ --disable-docbook-docs \
+ --with-pci-ids=${LOCALBASE}/share/pciids \
+ --disable-usb-ids \
+ --without-libpci \
+ --disable-usb \
+ --disable-smbios \
+ --disable-apm \
+ --disable-pmu \
+ --enable-policy-kit \
+ --enable-console-kit \
+ --with-socket-dir=/var/run/hald \
+ --with-eject=/usr/sbin/cdcontrol \
+ --with-pid-file=/var/run/hald/hald.pid \
+ --with-deprecated-keys \
+ --localstatedir=/var
+CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include -DHAVE_CK_0_3" \
+ LDFLAGS="-L${LOCALBASE}/lib" \
+ GTKDOC="false"
+
+#HALVERSION= 0.5.10
+#SNAPVERSION= 20080218
+
+USE_RC_SUBR= hald
+USE_GNOME_SUBR= yes
+DOCSDIR= ${PREFIX}/share/doc/${PORTNAME}-${DISTVERSION}
+PLIST_SUB= VERSION=${DISTVERSION}
+
+RC_FILES= hal.conf:${PREFIX}/etc/dbus-1/system.d
+PLIST_FILES= ${PRIV_FILES:S|^|%%DATADIR%%/dist/|}
+
+SUB_FILES= pkg-install pkg-deinstall
+SUB_LIST= RC_FILES="${RC_FILES}"
+
+MAN1= hal-disable-polling.1 hal-find-by-capability.1 \
+ hal-find-by-property.1 hal-get-property.1 \
+ hal-is-caller-locked-out.1 hal-is-caller-privileged.1 \
+ hal-lock.1 hal-set-property.1 lshal.1
+MAN8= hald.8
+
+OPTIONS= FIXED_MOUNTPOINTS "use fixed mountpoints" off
+
+.include <bsd.port.pre.mk>
+
+.if ${OSVERSION} < 505000
+IGNORE= not supported on FreeBSD prior to 5.5-RELEASE
+.endif
+
+.if (${ARCH}=="i386" || ${ARCH}=="amd64" || ${ARCH}=="ia64")
+RUN_DEPENDS+= dmidecode:${PORTSDIR}/sysutils/dmidecode
+.endif
+
+.if ${OSVERSION} <= 601100
+NEEDS_MEDIA= yes
+PLIST_SUB+= MEDIA=""
+.else
+PLIST_SUB+= MEDIA="@comment "
+.endif
+
+.if defined(WITH_FIXED_MOUNTPOINTS)
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-tools_hal-storage-mount.c
+.endif
+
+post-patch:
+ @${REINPLACE_CMD} -e '/^scriptdir = /s|libdir|libexecdir|' \
+ ${WRKSRC}/tools/Makefile.in \
+ ${WRKSRC}/tools/freebsd/Makefile.in
+ @${REINPLACE_CMD} -e 's|[(]libdir[)]/hal/scripts|(libexecdir)/hal/scripts|' \
+ ${WRKSRC}/hald/Makefile.in
+ @${REINPLACE_CMD} -e 's|user="0"|group="operator"|g' \
+ ${WRKSRC}/hal.conf.in
+
+post-install:
+ ${MKDIR} ${DATADIR}/dist
+ ${INSTALL_DATA} ${WRKSRC}/hal.conf ${DATADIR}/dist
+ ${MKDIR} ${PREFIX}/share/hal/fdi/policy/10osvendor
+ ${INSTALL_DATA} ${FILESDIR}/10-mouse-sysmouse.fdi \
+ ${PREFIX}/share/hal/fdi/policy/10osvendor
+.if !defined(PACKAGE_BUILDING)
+ @${SETENV} PKG_PREFIX=${PREFIX} \
+ ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
+.if defined(NEEDS_MEDIA)
+ ${MKDIR} /media
+.endif
+.endif
+.if !defined(NOPORTDOCS)
+ ${MKDIR} ${DOCSDIR}
+ ${INSTALL_DATA} ${WRKSRC}/hald/freebsd/README \
+ ${DOCSDIR}/README.freebsd
+.endif
+
+.include <bsd.port.post.mk>
diff --git a/sysutils/hal/distinfo b/sysutils/hal/distinfo
new file mode 100644
index 000000000..00f32dd51
--- /dev/null
+++ b/sysutils/hal/distinfo
@@ -0,0 +1,3 @@
+MD5 (hal-0.5.11.tar.gz) = 750cf074e88b6fb7012f26d99cd39b9b
+SHA256 (hal-0.5.11.tar.gz) = 730a9f2340f789677eb0c3b0984bbaca3ede6c12d1e4b16bc7ea91f51d10ba90
+SIZE (hal-0.5.11.tar.gz) = 1672992
diff --git a/sysutils/hal/files/10-mouse-sysmouse.fdi b/sysutils/hal/files/10-mouse-sysmouse.fdi
new file mode 100644
index 000000000..cffd4f624
--- /dev/null
+++ b/sysutils/hal/files/10-mouse-sysmouse.fdi
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deviceinfo version="0.2">
+ <device>
+ <match key="info.capabilities" contains="input.mouse">
+ <append key="info.addons" type="strlist">hald-addon-mouse-sysmouse</append>
+ </match>
+ </device>
+</deviceinfo>
diff --git a/sysutils/hal/files/extra-patch-tools_hal-storage-mount.c b/sysutils/hal/files/extra-patch-tools_hal-storage-mount.c
new file mode 100644
index 000000000..f505709e1
--- /dev/null
+++ b/sysutils/hal/files/extra-patch-tools_hal-storage-mount.c
@@ -0,0 +1,25 @@
+--- tools/hal-storage-mount.c.orig 2008-05-20 13:24:30.000000000 -0400
++++ tools/hal-storage-mount.c 2008-05-20 13:30:14.000000000 -0400
+@@ -585,17 +585,11 @@ handle_mount (LibHalContext *hal_ctx,
+ explicit_mount_point_given = FALSE;
+ if (strlen (mount_point) == 0) {
+ char *p;
+-
+- if (label != NULL) {
+- /* best - use label */
+- g_strlcpy (mount_point, label, sizeof (mount_point));
+-
+- /* TODO: use drive type */
+-
+- } else {
+- /* fallback - use "disk" */
+- g_snprintf (mount_point, sizeof (mount_point), "%s", "disk");
+- }
++ char *basename;
++
++ basename = g_path_get_basename (device);
++ g_strlcpy (mount_point, basename, sizeof (mount_point));
++ g_free (basename);
+
+ /* sanitize computed mount point name, e.g. replace invalid chars with '-' */
+ p = mount_point;
diff --git a/sysutils/hal/files/hald.in b/sysutils/hal/files/hald.in
new file mode 100644
index 000000000..eae1f8320
--- /dev/null
+++ b/sysutils/hal/files/hald.in
@@ -0,0 +1,80 @@
+#!/bin/sh
+#
+# $FreeBSD$
+# $MCom$
+#
+# PROVIDE: hald
+# REQUIRE: DAEMON usbd devd dbus
+#
+# Add the following line to /etc/rc.conf to enable the HAL daemon:
+#
+# hald_enable="YES"
+#
+
+. %%RC_SUBR%%
+. %%GNOME_SUBR%%
+
+hald_enable=${hald_enable-${gnome_enable}}
+hald_flags=${hald_flags-""}
+
+name=hald
+rcvar=`set_rcvar`
+
+command="%%PREFIX%%/sbin/hald"
+pidfile="/var/run/${name}/${name}.pid"
+
+stop_postcmd="hald_postcmd"
+start_precmd="hald_precmd"
+start_cmd="hald_start"
+
+local_force_depend()
+{
+ _depend="$1"
+ if [ -f %%LOCALBASE%%/etc/rc.d/${_depend}.sh ]; then
+ _depend="${_depend}.sh"
+ fi
+
+ if ! %%LOCALBASE%%/etc/rc.d/${_depend} forcestatus 1>/dev/null 2>&1 &&
+ ! %%LOCALBASE%%/etc/rc.d/${_depend} forcestart; then
+ return 1
+ fi
+ return 0
+}
+
+hald_precmd()
+{
+ if ! checkyesno dbus_enable
+ then
+ local_force_depend dbus || return 1
+ fi
+
+ chmod 0755 /var/cache
+
+ mkdir -p $(dirname $pidfile)
+}
+
+hald_postcmd()
+{
+ rm -f $pidfile
+}
+
+hald_start()
+{
+ if ! checkyesno hald_enable ; then
+ return 0
+ fi
+ echo "Starting ${name}."
+
+ ( iter=0
+ while ! ps -axoargs | grep "^/usr/libexec/getty " | grep -qv grep >/dev/null 2>&1; do
+ if [ ${iter} -eq 60 ]; then
+ break
+ fi
+ sleep 1
+ iter=$(expr ${iter} + 1)
+ done
+ ${command} ${hald_flags} ) &
+}
+
+load_rc_config ${name}
+run_rc_command "$1"
diff --git a/sysutils/hal/files/patch-Makefile.in b/sysutils/hal/files/patch-Makefile.in
new file mode 100644
index 000000000..17d23980f
--- /dev/null
+++ b/sysutils/hal/files/patch-Makefile.in
@@ -0,0 +1,25 @@
+--- Makefile.in.orig 2008-01-03 21:28:32.000000000 -0500
++++ Makefile.in 2008-01-03 21:29:15.000000000 -0500
+@@ -311,14 +311,14 @@ clean-libtool:
+ distclean-libtool:
+ -rm -f libtool
+ install-dist_dbusDATA: $(dist_dbus_DATA)
+- @$(NORMAL_INSTALL)
+- test -z "$(dbusdir)" || $(MKDIR_P) "$(DESTDIR)$(dbusdir)"
+- @list='$(dist_dbus_DATA)'; for p in $$list; do \
+- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+- f=$(am__strip_dir) \
+- echo " $(dist_dbusDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(dbusdir)/$$f'"; \
+- $(dist_dbusDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(dbusdir)/$$f"; \
+- done
++# @$(NORMAL_INSTALL)
++# test -z "$(dbusdir)" || $(MKDIR_P) "$(DESTDIR)$(dbusdir)"
++# @list='$(dist_dbus_DATA)'; for p in $$list; do \
++# if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
++# f=$(am__strip_dir) \
++# echo " $(dist_dbusDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(dbusdir)/$$f'"; \
++# $(dist_dbusDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(dbusdir)/$$f"; \
++# done
+
+ uninstall-dist_dbusDATA:
+ @$(NORMAL_UNINSTALL)
diff --git a/sysutils/hal/files/patch-consolekit03 b/sysutils/hal/files/patch-consolekit03
new file mode 100644
index 000000000..a948b189b
--- /dev/null
+++ b/sysutils/hal/files/patch-consolekit03
@@ -0,0 +1,87 @@
+diff -p -up hal-0.5.11/configure.in.ck03 hal-0.5.11/configure.in
+--- hal-0.5.11/configure.in.ck03 2008-05-07 19:24:31.000000000 -0400
++++ configure.in 2008-08-11 06:18:07.000000000 -0400
+@@ -485,6 +485,20 @@ if test "x$enable_console_kit" != "xno";
+ AM_CONDITIONAL(HAVE_CONKIT, true)
+ AC_DEFINE(HAVE_CONKIT, [], [Set if we use ConsoleKit])
+ msg_conkit=yes
++ # yes this is ugly, but there is no other way to get the version of CK
++ AC_MSG_CHECKING([if ConsoleKit version 0.3.0 or newer])
++ if $PKG_CONFIG --atleast-version=0.3.0 ck-connector; then
++ AC_MSG_RESULT([yes])
++ AC_DEFINE(HAVE_CK_0_3, 1, [Define to 1 if ConsoleKit is v0.3.0 or newer])
++ else
++ if $PKG_CONFIG --max-version=0.2.10 ck-connector; then
++ AC_MSG_RESULT([no])
++ else
++ #assume we have the latest version
++ AC_MSG_WARN([Couldn't detect ConsoleKit version, install the devel package, assume for now you use >= 0.3.0])
++ AC_DEFINE(HAVE_CK_0_3, 1, [Define to 1 if ConsoleKit is v0.3.0 or newer])
++ fi
++ fi
+ fi
+
+ AC_PATH_PROG(GPERF, [gperf], [no])
+diff -p -up hal-0.5.11/hald/ck-tracker.c.ck03 hal-0.5.11/hald/ck-tracker.c
+--- hal-0.5.11/hald/ck-tracker.c.ck03 2008-05-07 19:23:48.000000000 -0400
++++ hald/ck-tracker.c 2008-08-12 12:34:47.000000000 -0400
+@@ -256,7 +256,11 @@ ck_session_get_info (CKTracker *tracker,
+ goto error;
+ }
+ if (!dbus_message_get_args (reply, NULL,
++#ifdef HAVE_CK_0_3
++ DBUS_TYPE_UINT32, &(session->user),
++#else
+ DBUS_TYPE_INT32, &(session->user),
++#endif
+ DBUS_TYPE_INVALID)) {
+ HAL_ERROR (("Invalid GetUnixUser reply from CK"));
+ goto error;
+@@ -531,7 +535,11 @@ ck_tracker_process_system_bus_message (C
+ seat_objpath = dbus_message_get_path (message);
+
+ if (!dbus_message_get_args (message, NULL,
++#ifdef HAVE_CK_0_3
++ DBUS_TYPE_OBJECT_PATH, &seat_objpath,
++#else
+ DBUS_TYPE_STRING, &seat_objpath,
++#endif
+ DBUS_TYPE_INVALID)) {
+ HAL_ERROR (("Invalid SeatAdded signal from CK"));
+ goto out;
+@@ -558,7 +566,11 @@ ck_tracker_process_system_bus_message (C
+ seat_objpath = dbus_message_get_path (message);
+
+ if (!dbus_message_get_args (message, NULL,
++#ifdef HAVE_CK_0_3
++ DBUS_TYPE_OBJECT_PATH, &seat_objpath,
++#else
+ DBUS_TYPE_STRING, &seat_objpath,
++#endif
+ DBUS_TYPE_INVALID)) {
+ HAL_ERROR (("Invalid SeatRemoved signal from CK"));
+ goto out;
+@@ -588,7 +600,11 @@ ck_tracker_process_system_bus_message (C
+ seat_objpath = dbus_message_get_path (message);
+
+ if (!dbus_message_get_args (message, NULL,
++#ifdef HAVE_CK_0_3
++ DBUS_TYPE_OBJECT_PATH, &session_objpath,
++#else
+ DBUS_TYPE_STRING, &session_objpath,
++#endif
+ DBUS_TYPE_INVALID)) {
+ HAL_ERROR (("Invalid SessionAdded signal from CK"));
+ goto out;
+@@ -624,7 +640,11 @@ ck_tracker_process_system_bus_message (C
+ seat_objpath = dbus_message_get_path (message);
+
+ if (!dbus_message_get_args (message, NULL,
++#ifdef HAVE_CK_0_3
++ DBUS_TYPE_OBJECT_PATH, &session_objpath,
++#else
+ DBUS_TYPE_STRING, &session_objpath,
++#endif
+ DBUS_TYPE_INVALID)) {
+ HAL_ERROR (("Invalid SessionRemoved signal from CK"));
+ goto out;
diff --git a/sysutils/hal/files/patch-doc_Makefile.in b/sysutils/hal/files/patch-doc_Makefile.in
new file mode 100644
index 000000000..9cd951720
--- /dev/null
+++ b/sysutils/hal/files/patch-doc_Makefile.in
@@ -0,0 +1,11 @@
+--- doc/Makefile.in.orig 2008-01-03 21:41:19.000000000 -0500
++++ doc/Makefile.in 2008-01-03 21:41:31.000000000 -0500
+@@ -203,7 +203,7 @@ target_alias = @target_alias@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ EXTRA_DIST = TODO
+-SUBDIRS = api spec man
++SUBDIRS = spec man
+ MAINTAINERCLEANFILES = \
+ *~ \
+ Makefile.in
diff --git a/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi
new file mode 100644
index 000000000..f7af321c0
--- /dev/null
+++ b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi
@@ -0,0 +1,18 @@
+--- fdi/policy/10osvendor/10-x11-input.fdi.orig 2008-03-27 13:42:31.000000000 -0400
++++ fdi/policy/10osvendor/10-x11-input.fdi 2008-03-27 13:48:06.000000000 -0400
+@@ -1,15 +1,6 @@
+ <?xml version="1.0" encoding="ISO-8859-1"?>
+ <deviceinfo version="0.2">
+ <device>
+- <!-- FIXME: Support tablets too. -->
+- <match key="info.capabilities" contains="input.mouse">
+- <merge key="input.x11_driver" type="string">mouse</merge>
+- <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
+- string="Linux">
+- <merge key="input.x11_driver" type="string">evdev</merge>
+- </match>
+- </match>
+-
+ <match key="info.capabilities" contains="input.keys">
+ <!-- If we're using Linux, we use evdev by default (falling back to
+ keyboard otherwise). -->
diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in b/sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in
new file mode 100644
index 000000000..beb677fa9
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in
@@ -0,0 +1,92 @@
+--- hald/freebsd/addons/Makefile.in.orig 2008-03-27 00:45:50.000000000 -0400
++++ hald/freebsd/addons/Makefile.in 2008-03-27 00:48:15.000000000 -0400
+@@ -33,7 +33,8 @@ POST_UNINSTALL = :
+ build_triplet = @build@
+ host_triplet = @host@
+ @HALD_COMPILE_FREEBSD_TRUE@libexec_PROGRAMS = \
+-@HALD_COMPILE_FREEBSD_TRUE@ hald-addon-storage$(EXEEXT)
++@HALD_COMPILE_FREEBSD_TRUE@ hald-addon-storage$(EXEEXT) \
++@HALD_COMPILE_FREEBSD_TRUE@ hald-addon-mouse-sysmouse$(EXEEXT)
+ subdir = hald/freebsd/addons
+ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+@@ -47,6 +48,15 @@ CONFIG_CLEAN_FILES =
+ am__installdirs = "$(DESTDIR)$(libexecdir)"
+ libexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+ PROGRAMS = $(libexec_PROGRAMS)
++am_hald_addon_mouse_sysmouse_OBJECTS = \
++ hald_addon_mouse_sysmouse-addon-mouse.$(OBJEXT)
++hald_addon_mouse_sysmouse_OBJECTS = \
++ $(am_hald_addon_mouse_sysmouse_OBJECTS)
++hald_addon_mouse_sysmouse_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
++hald_addon_mouse_sysmouse_LINK = $(LIBTOOL) --tag=CC \
++ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
++ $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
++ $(LDFLAGS) -o $@
+ am_hald_addon_storage_OBJECTS = addon-storage.$(OBJEXT)
+ hald_addon_storage_OBJECTS = $(am_hald_addon_storage_OBJECTS)
+ hald_addon_storage_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+@@ -62,8 +72,10 @@ CCLD = $(CC)
+ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+-SOURCES = $(hald_addon_storage_SOURCES)
+-DIST_SOURCES = $(hald_addon_storage_SOURCES)
++SOURCES = $(hald_addon_mouse_sysmouse_SOURCES) \
++ $(hald_addon_storage_SOURCES)
++DIST_SOURCES = $(hald_addon_mouse_sysmouse_SOURCES) \
++ $(hald_addon_storage_SOURCES)
+ ETAGS = etags
+ CTAGS = ctags
+ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+@@ -227,6 +239,11 @@ hald_addon_storage_SOURCES = addon-stora
+ hald_addon_storage_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+
++hald_addon_mouse_sysmouse_SOURCES = addon-mouse.c
++hald_addon_mouse_sysmouse_CFLAGS = $(AM_CPPFLAGS) @GLIB_CFLAGS@
++hald_addon_mouse_sysmouse_LDADD = @GLIB_LIBS@ \
++ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
++
+ all: all-am
+
+ .SUFFIXES:
+@@ -288,6 +305,9 @@ clean-libexecPROGRAMS:
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
++hald-addon-mouse-sysmouse$(EXEEXT): $(hald_addon_mouse_sysmouse_OBJECTS) $(hald_addon_mouse_sysmouse_DEPENDENCIES)
++ @rm -f hald-addon-mouse-sysmouse$(EXEEXT)
++ $(hald_addon_mouse_sysmouse_LINK) $(hald_addon_mouse_sysmouse_OBJECTS) $(hald_addon_mouse_sysmouse_LDADD) $(LIBS)
+ hald-addon-storage$(EXEEXT): $(hald_addon_storage_OBJECTS) $(hald_addon_storage_DEPENDENCIES)
+ @rm -f hald-addon-storage$(EXEEXT)
+ $(LINK) $(hald_addon_storage_OBJECTS) $(hald_addon_storage_LDADD) $(LIBS)
+@@ -299,6 +319,7 @@ distclean-compile:
+ -rm -f *.tab.c
+
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/addon-storage.Po@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Po@am__quote@
+
+ .c.o:
+ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@@ -321,6 +342,20 @@ distclean-compile:
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
++hald_addon_mouse_sysmouse-addon-mouse.o: addon-mouse.c
++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -MT hald_addon_mouse_sysmouse-addon-mouse.o -MD -MP -MF $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo -c -o hald_addon_mouse_sysmouse-addon-mouse.o `test -f 'addon-mouse.c' || echo '$(srcdir)/'`addon-mouse.c
++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='addon-mouse.c' object='hald_addon_mouse_sysmouse-addon-mouse.o' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -c -o hald_addon_mouse_sysmouse-addon-mouse.o `test -f 'addon-mouse.c' || echo '$(srcdir)/'`addon-mouse.c
++
++hald_addon_mouse_sysmouse-addon-mouse.obj: addon-mouse.c
++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -MT hald_addon_mouse_sysmouse-addon-mouse.obj -MD -MP -MF $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo -c -o hald_addon_mouse_sysmouse-addon-mouse.obj `if test -f 'addon-mouse.c'; then $(CYGPATH_W) 'addon-mouse.c'; else $(CYGPATH_W) '$(srcdir)/addon-mouse.c'; fi`
++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='addon-mouse.c' object='hald_addon_mouse_sysmouse-addon-mouse.obj' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -c -o hald_addon_mouse_sysmouse-addon-mouse.obj `if test -f 'addon-mouse.c'; then $(CYGPATH_W) 'addon-mouse.c'; else $(CYGPATH_W) '$(srcdir)/addon-mouse.c'; fi`
++
+ mostlyclean-libtool:
+ -rm -f *.lo
+
diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c b/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c
new file mode 100644
index 000000000..9d0d23300
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c
@@ -0,0 +1,219 @@
+--- hald/freebsd/addons/addon-mouse.c.orig 2008-03-31 04:53:42.000000000 -0400
++++ hald/freebsd/addons/addon-mouse.c 2008-03-31 05:07:19.000000000 -0400
+@@ -0,0 +1,216 @@
++/***************************************************************************
++ * CVSID: $Id: patch-hald_freebsd_addons_addon-mouse.c,v 1.1 2008-08-21 16:04:48 mezz Exp $
++ *
++ * addon-mouse.c : poll mice to disable moused(8) owned devices
++ *
++ * Copyright (C) 2008 Joe Marcus Clarke
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ *
++ **************************************************************************/
++
++#ifdef HAVE_CONFIG_H
++# include <config.h>
++#endif
++
++#include <string.h>
++#include <stdlib.h>
++#include <assert.h>
++#include <unistd.h>
++#include <glib.h>
++
++#include "libhal/libhal.h"
++
++#include "../libprobe/hfp.h"
++
++#define CMD "/usr/bin/fstat %s"
++
++#define MOUSE_DRIVER "mouse"
++#define MOUSED_DEVICE "/dev/sysmouse"
++#define MOUSED_PROC_NAME "moused"
++#define XORG_PROC_NAME "Xorg"
++
++static struct
++{
++ const struct timespec update_interval;
++ char *device_file;
++ struct timespec next_update;
++} addon = { { 2, 0 } };
++
++static gboolean
++device_opened_by_proc (const char *device, const char *proc)
++{
++ char **lines;
++ char *output = NULL;
++ char *cmd;
++ int i;
++ gboolean found = FALSE;
++
++ cmd = g_strdup_printf(CMD, device);
++
++ if (! g_spawn_command_line_sync (cmd, &output, NULL, NULL, NULL))
++ {
++ g_free(cmd);
++ goto done;
++ }
++ g_free(cmd);
++
++ if (! output || strlen(output) == 0)
++ goto done;
++
++ lines = g_strsplit(output, "\n", 0);
++ if (g_strv_length(lines) < 2)
++ {
++ g_strfreev(lines);
++ goto done;
++ }
++
++ for (i = 1; lines[i]; i++)
++ {
++ char **fields;
++ guint len;
++ guint j;
++
++ fields = g_strsplit_set(lines[i], " ", 0);
++ len = g_strv_length(fields);
++ if (len < 2)
++ {
++ g_strfreev(fields);
++ continue;
++ }
++ for (j = 1; j < len && fields[j] && *fields[j] == '\0'; j++)
++ ;
++ if (j < len && fields[j] && ! strcmp(fields[j], proc))
++ {
++ found = TRUE;
++ g_strfreev(fields);
++ break;
++ }
++ g_strfreev(fields);
++ }
++
++ g_strfreev(lines);
++
++done:
++ g_free(output);
++
++ return found;
++}
++
++static const char *
++get_mouse_device (const char *device)
++{
++ if (device_opened_by_proc(device, MOUSED_PROC_NAME))
++ return MOUSED_DEVICE;
++
++ return device;
++}
++
++static void
++poll_for_moused (void)
++{
++ char *driver;
++ char *old_device;
++ const char *device;
++ gboolean found;
++
++ old_device = libhal_device_get_property_string(hfp_ctx, hfp_udi, "input.device", &hfp_error);
++ dbus_error_free(&hfp_error);
++
++ device = get_mouse_device(addon.device_file);
++ if (strcmp(old_device, device))
++ {
++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.device", device, &hfp_error);
++ dbus_error_free(&hfp_error);
++ }
++ g_free(old_device);
++
++ driver = libhal_device_get_property_string(hfp_ctx, hfp_udi, "input.x11_driver", &hfp_error);
++ dbus_error_free(&hfp_error);
++
++ found = (strcmp(device, MOUSED_DEVICE) == 0);
++ if (! found)
++ found = device_opened_by_proc(device, XORG_PROC_NAME);
++
++ if (found && driver)
++ {
++ libhal_device_remove_property(hfp_ctx, hfp_udi, "input.x11_driver", &hfp_error);
++ dbus_error_free(&hfp_error);
++ }
++ else if (! (found || driver))
++ {
++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.x11_driver", MOUSE_DRIVER, &hfp_error);
++ dbus_error_free(&hfp_error);
++ }
++
++ g_free(driver);
++}
++
++int
++main (int argc, char **argv)
++{
++ DBusConnection *connection;
++
++ if (! hfp_init(argc, argv))
++ goto end;
++
++ addon.device_file = getenv("HAL_PROP_FREEBSD_DEVICE_FILE");
++ if (! addon.device_file)
++ goto end;
++
++ setproctitle("%s", addon.device_file);
++
++ if (! libhal_device_addon_is_ready(hfp_ctx, hfp_udi, &hfp_error))
++ goto end;
++ dbus_error_free(&hfp_error);
++
++ connection = libhal_ctx_get_dbus_connection(hfp_ctx);
++ assert(connection != NULL);
++
++ while (TRUE)
++ {
++ /* process dbus traffic until update interval has elapsed */
++ while (TRUE)
++ {
++ struct timespec now;
++
++ hfp_clock_gettime(&now);
++ if (hfp_timespeccmp(&now, &addon.next_update, <))
++ {
++ struct timespec timeout;
++
++ timeout = addon.next_update;
++ hfp_timespecsub(&timeout, &now);
++
++ if (timeout.tv_sec < 0) /* current time went backwards */
++ timeout = addon.update_interval;
++
++ dbus_connection_read_write_dispatch(connection, timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000);
++ if (! dbus_connection_get_is_connected(connection))
++ goto end;
++ }
++ else
++ break;
++ }
++
++ poll_for_moused();
++
++ hfp_clock_gettime(&addon.next_update);
++ hfp_timespecadd(&addon.next_update, &addon.update_interval);
++ }
++
++ end:
++ return 0;
++}
diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c b/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c
new file mode 100644
index 000000000..474658423
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c
@@ -0,0 +1,238 @@
+--- hald/freebsd/addons/addon-storage.c.orig 2008-05-07 19:24:04.000000000 -0400
++++ hald/freebsd/addons/addon-storage.c 2008-05-19 02:18:59.000000000 -0400
+@@ -36,17 +36,23 @@
+ #include "../libprobe/hfp.h"
+ #include "../libprobe/hfp-cdrom.h"
+
++static boolean is_locked_by_hal = FALSE;
++static boolean check_lock_state = TRUE;
++static boolean polling_disabled = FALSE;
++
+ static struct
+ {
+- const struct timeval update_interval;
++ const struct timespec update_interval;
+ char *device_file;
+ char *parent;
+ boolean is_cdrom;
+ boolean is_scsi_removable;
+ boolean had_media;
+- struct timeval next_update;
++ struct timespec next_update;
+ } addon = { { 2, 0 } };
+
++static void update_proc_title (const char *device);
++
+ /* see MMC-3 Working Draft Revision 10 */
+ static boolean
+ hf_addon_storage_cdrom_eject_pressed (HFPCDROM *cdrom)
+@@ -144,18 +150,49 @@ hf_addon_storage_update (void)
+ }
+ }
+
+- hfp_gettimeofday(&addon.next_update);
+- hfp_timevaladd(&addon.next_update, &addon.update_interval);
+-
+ return has_media;
+ }
+
+ static boolean
+-poll_for_media (void)
++poll_for_media (boolean check_only, boolean force)
+ {
+ boolean has_media;
+
++ if (check_lock_state)
++ {
++ boolean should_poll;
++
++ check_lock_state = FALSE;
++
++ hfp_info("Checking whether device %s is locked by HAL", addon.device_file);
++ if (libhal_device_is_locked_by_others(hfp_ctx, hfp_udi, "org.freedesktop.Hal.Device.Storage", &hfp_error))
++ {
++ hfp_info("... device %s is locked by HAL", addon.device_file);
++ dbus_error_free(&hfp_error);
++ is_locked_by_hal = TRUE;
++ update_proc_title(addon.device_file);
++ goto skip_check;
++ }
++ else
++ {
++ hfp_info("... device %s is not locked by HAL", addon.device_file);
++ is_locked_by_hal = FALSE;
++ }
++ dbus_error_free(&hfp_error);
++
++ should_poll = libhal_device_get_property_bool(hfp_ctx, hfp_udi, "storage.media_check_enabled", &hfp_error);
++ dbus_error_free(&hfp_error);
++ polling_disabled = ! should_poll;
++ update_proc_title(addon.device_file);
++ }
++
++ if (! force && polling_disabled)
++ goto skip_check;
++
+ has_media = hf_addon_storage_update();
++ if (check_only)
++ return has_media;
++
+ if (has_media != addon.had_media)
+ {
+ /*
+@@ -175,20 +212,33 @@ poll_for_media (void)
+
+ return TRUE;
+ }
++
++skip_check:
++
+ return FALSE;
+ }
+
+ static void
+-update_proc_title (const char *device, boolean polling_enabled)
++update_proc_title (const char *device)
+ {
+- if (polling_enabled)
+- setproctitle("%s", device);
+- else
++ if (polling_disabled)
+ setproctitle("no polling on %s because it is explicitly disabled", device);
++ else if (is_locked_by_hal)
++ setproctitle("no polling on %s because it is locked by HAL", device);
++ else
++ setproctitle("%s", device);
+ }
+
+ static DBusHandlerResult
+-filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
++dbus_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
++{
++ check_lock_state = TRUE;
++
++ return DBUS_HANDLER_RESULT_HANDLED;
++}
++
++static DBusHandlerResult
++direct_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
+ {
+ if (dbus_message_is_method_call(message,
+ "org.freedesktop.Hal.Device.Storage.Removable",
+@@ -199,7 +249,7 @@ filter_function (DBusConnection *connect
+
+ hfp_info("Forcing poll for media becusse CheckForMedia() was called");
+
+- had_effect = poll_for_media();
++ had_effect = poll_for_media(FALSE, TRUE);
+
+ reply = dbus_message_new_method_return (message);
+ dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &had_effect, DBUS_TYPE_INVALID);
+@@ -217,8 +267,9 @@ main (int argc, char **argv)
+ char *removable;
+ char *bus;
+ char *driver;
+- boolean should_poll;
++ char *filter_str;
+ DBusConnection *connection;
++ DBusConnection *syscon;
+
+ if (! hfp_init(argc, argv))
+ goto end;
+@@ -251,16 +302,41 @@ main (int argc, char **argv)
+ addon.is_scsi_removable = (! strcmp(bus, "scsi") ||
+ (! strcmp(bus, "usb") && (! strcmp(driver, "da") || ! strcmp(driver, "sa") ||
+ ! strcmp(driver, "cd")))) && ! strcmp(removable, "true");
+- addon.had_media = hf_addon_storage_update();
++ addon.had_media = poll_for_media(TRUE, FALSE);
+
+ if (! libhal_device_addon_is_ready(hfp_ctx, hfp_udi, &hfp_error))
+ goto end;
+ dbus_error_free(&hfp_error);
+
++ syscon = dbus_bus_get(DBUS_BUS_SYSTEM, &hfp_error);
++ dbus_error_free(&hfp_error);
++ assert(syscon != NULL);
++ dbus_connection_set_exit_on_disconnect(syscon, 0);
++
++ dbus_bus_add_match(syscon,
++ "type='signal'"
++ ",interface='org.freedesktop.Hal.Manager'"
++ ",sender='org.freedesktop.Hal'",
++ NULL);
++ dbus_bus_add_match(syscon,
++ "type='signal'"
++ ",interface='org.freedesktop.Hal.Manager'"
++ ",sender='org.freedesktop.Hal'",
++ NULL);
++ filter_str = hfp_strdup_printf("type='signal'"
++ ",interface='org.freedesktop.Hal.Device'"
++ ",sender='org.freedesktop.Hal'"
++ ",path='%s'",
++ hfp_udi);
++ dbus_bus_add_match(syscon, filter_str, NULL);
++ hfp_free(filter_str);
++
++ dbus_connection_add_filter(syscon, dbus_filter_function, NULL, NULL);
++
+ connection = libhal_ctx_get_dbus_connection(hfp_ctx);
+ assert(connection != NULL);
+ dbus_connection_set_exit_on_disconnect(connection, 0);
+- dbus_connection_add_filter(connection, filter_function, NULL, NULL);
++ dbus_connection_add_filter(connection, direct_filter_function, NULL, NULL);
+
+ if (! libhal_device_claim_interface(hfp_ctx,
+ hfp_udi,
+@@ -280,40 +356,32 @@ main (int argc, char **argv)
+ /* process dbus traffic until update interval has elapsed */
+ while (TRUE)
+ {
+- struct timeval now;
++ struct timespec now;
+
+- hfp_gettimeofday(&now);
+- if (hfp_timevalcmp(&now, &addon.next_update, <))
++ hfp_clock_gettime(&now);
++ if (hfp_timespeccmp(&now, &addon.next_update, <))
+ {
+- struct timeval timeout;
++ struct timespec timeout;
+
+ timeout = addon.next_update;
+- hfp_timevalsub(&timeout, &now);
++ hfp_timespecsub(&timeout, &now);
+
+ if (timeout.tv_sec < 0) /* current time went backwards */
+ timeout = addon.update_interval;
+
+- dbus_connection_read_write_dispatch(connection, timeout.tv_sec * 1000 + timeout.tv_usec / 1000);
+- if (! dbus_connection_get_is_connected(connection))
++ dbus_connection_read_write_dispatch(connection, (int) ((timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000) / 2));
++ dbus_connection_read_write_dispatch(syscon, (int) ((timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000) / 2));
++ if (! dbus_connection_get_is_connected(connection) ||
++ ! dbus_connection_get_is_connected(syscon))
+ goto end;
+ }
+ else
+ break;
+ }
+
+- should_poll = libhal_device_get_property_bool(hfp_ctx, hfp_udi, "storage.media_check_enabled", &hfp_error);
+- dbus_error_free(&hfp_error);
+- update_proc_title(addon.device_file, should_poll);
+-
+- if (should_poll)
+- {
+- poll_for_media();
+- }
+- else
+- {
+- hfp_gettimeofday(&addon.next_update);
+- hfp_timevaladd(&addon.next_update, &addon.update_interval);
+- }
++ poll_for_media(FALSE, FALSE);
++ hfp_clock_gettime(&addon.next_update);
++ hfp_timespecadd(&addon.next_update, &addon.update_interval);
+ }
+
+ end:
diff --git a/sysutils/hal/files/patch-hald_freebsd_clock b/sysutils/hal/files/patch-hald_freebsd_clock
new file mode 100644
index 000000000..488283e02
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_clock
@@ -0,0 +1,111 @@
+--- hald/freebsd/libprobe/hfp.c.orig 2008-03-17 17:25:17.000000000 -0400
++++ hald/freebsd/libprobe/hfp.c 2008-03-26 12:07:32.000000000 -0400
+@@ -216,55 +216,59 @@ hfp_getenv_bool (const char *variable)
+ }
+
+ void
+-hfp_gettimeofday (struct timeval *t)
++hfp_clock_gettime (struct timespec *t)
+ {
+ int status;
+
+ assert(t != NULL);
+
+- status = gettimeofday(t, NULL);
++#ifdef CLOCK_MONOTONIC_FAST
++ status = clock_gettime(CLOCK_MONOTONIC_FAST, t);
++#else
++ status = clock_gettime(CLOCK_MONOTONIC, t);
++#endif
+ assert(status == 0);
+ }
+
+-/* timeval functions from sys/kern/kern_time.c */
++/* timespec functions from sys/kern/kern_time.c */
+
+ static void
+-hfp_timevalfix (struct timeval *t)
++hfp_timespecfix (struct timespec *t)
+ {
+ assert(t != NULL);
+
+- if (t->tv_usec < 0)
++ if (t->tv_nsec < 0)
+ {
+ t->tv_sec--;
+- t->tv_usec += 1000000;
++ t->tv_nsec += 1000000000;
+ }
+- if (t->tv_usec >= 1000000)
++ if (t->tv_nsec >= 1000000000)
+ {
+ t->tv_sec++;
+- t->tv_usec -= 1000000;
++ t->tv_nsec -= 1000000000;
+ }
+ }
+
+ void
+-hfp_timevaladd (struct timeval *t1, const struct timeval *t2)
++hfp_timespecadd (struct timespec *t1, const struct timespec *t2)
+ {
+ assert(t1 != NULL);
+ assert(t2 != NULL);
+
+ t1->tv_sec += t2->tv_sec;
+- t1->tv_usec += t2->tv_usec;
++ t1->tv_nsec += t2->tv_nsec;
+
+- hfp_timevalfix(t1);
++ hfp_timespecfix(t1);
+ }
+
+ void
+-hfp_timevalsub (struct timeval *t1, const struct timeval *t2)
++hfp_timespecsub (struct timespec *t1, const struct timespec *t2)
+ {
+ assert(t1 != NULL);
+ assert(t2 != NULL);
+
+ t1->tv_sec -= t2->tv_sec;
+- t1->tv_usec -= t2->tv_usec;
++ t1->tv_nsec -= t2->tv_nsec;
+
+- hfp_timevalfix(t1);
++ hfp_timespecfix(t1);
+ }
+--- hald/freebsd/libprobe/hfp.h.orig 2008-03-17 17:25:17.000000000 -0400
++++ hald/freebsd/libprobe/hfp.h 2008-04-02 14:35:50.000000000 -0400
+@@ -29,8 +29,12 @@
+ #endif
+
+ #include <stdarg.h>
++#include <time.h>
+ #include <sys/types.h>
++#include <sys/param.h>
++#if __FreeBSD_version < 600000
+ #include <sys/time.h>
++#endif
+
+ #include "libhal/libhal.h"
+
+@@ -84,14 +88,14 @@ void volume_id_log (const char *format,
+
+ boolean hfp_getenv_bool (const char *variable);
+
+-void hfp_gettimeofday (struct timeval *t);
+-void hfp_timevaladd (struct timeval *t1, const struct timeval *t2);
+-void hfp_timevalsub (struct timeval *t1, const struct timeval *t2);
++void hfp_clock_gettime (struct timespec *t);
++void hfp_timespecadd (struct timespec *t1, const struct timespec *t2);
++void hfp_timespecsub (struct timespec *t1, const struct timespec *t2);
+
+ /* from sys/time.h (_KERNEL) */
+-#define hfp_timevalcmp(t1, t2, cmp) \
++#define hfp_timespeccmp(t1, t2, cmp) \
+ (((t1)->tv_sec == (t2)->tv_sec \
+- ? ((t1)->tv_usec cmp (t2)->tv_usec) \
++ ? ((t1)->tv_nsec cmp (t2)->tv_nsec) \
+ : ((t1)->tv_sec cmp (t2)->tv_sec)))
+
+ #endif /* _HFP_H */
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_probe-volume.c b/sysutils/hal/files/patch-hald_freebsd_probing_probe-volume.c
new file mode 100644
index 000000000..b9dc099e6
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_probe-volume.c
@@ -0,0 +1,12 @@
+--- hald/freebsd/probing/probe-volume.c.orig 2008-04-07 00:41:22.000000000 -0400
++++ hald/freebsd/probing/probe-volume.c 2008-04-07 00:43:32.000000000 -0400
+@@ -502,7 +502,8 @@ main (int argc, char **argv)
+ hfp_cdrom_free(cdrom);
+ }
+
+- if (has_data)
++ if (has_data && vid && (! strcmp(vid->type, "iso9660") ||
++ ! strcmp(vid->type, "udf")))
+ hf_probe_volume_advanced_disc_detect(fd);
+ }
+ else
diff --git a/sysutils/hal/files/patch-hald_hf-storage.c b/sysutils/hal/files/patch-hald_hf-storage.c
new file mode 100644
index 000000000..7f504c6c9
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_hf-storage.c
@@ -0,0 +1,18 @@
+--- hald/freebsd/hf-storage.c.orig 2008-04-07 00:40:06.000000000 -0400
++++ hald/freebsd/hf-storage.c 2008-04-07 00:40:37.000000000 -0400
+@@ -117,6 +117,7 @@ hf_storage_geom_has_partitions (const Ge
+ if (g_node_n_children(node) > 0)
+ return TRUE;
+
++ /*
+ if (hf_storage_class_is_partitionable(geom_obj->class) &&
+ g_node_next_sibling(node) != NULL)
+ {
+@@ -135,6 +136,7 @@ hf_storage_geom_has_partitions (const Ge
+ return TRUE;
+ }
+ }
++ */
+
+ return FALSE;
+ }
diff --git a/sysutils/hal/files/patch-tools_hal-storage-mount.c b/sysutils/hal/files/patch-tools_hal-storage-mount.c
new file mode 100644
index 000000000..c270893c2
--- /dev/null
+++ b/sysutils/hal/files/patch-tools_hal-storage-mount.c
@@ -0,0 +1,11 @@
+--- tools/hal-storage-mount.c.orig 2008-04-29 20:05:38.000000000 -0400
++++ tools/hal-storage-mount.c 2008-04-29 20:05:44.000000000 -0400
+@@ -56,7 +56,7 @@
+
+ #ifdef __FreeBSD__
+ #define MOUNT "/sbin/mount"
+-#define MOUNT_OPTIONS "noexec,nosuid"
++#define MOUNT_OPTIONS "nosuid"
+ #define MOUNT_TYPE_OPT "-t"
+ #elif sun
+ #define MOUNT "/sbin/mount"
diff --git a/sysutils/hal/files/pkg-deinstall.in b/sysutils/hal/files/pkg-deinstall.in
new file mode 100644
index 000000000..96f8e9f91
--- /dev/null
+++ b/sysutils/hal/files/pkg-deinstall.in
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+[ "$2" != DEINSTALL ] && exit 0
+
+for pair in %%RC_FILES%%; do
+ file=`echo $pair | cut -f 1 -d :`
+ destdir=`echo $pair | cut -f 2 -d :`
+
+ if cmp -s %%DATADIR%%/dist/$file $destdir/$file; then
+ rm -f $destdir/$file
+ fi
+done
diff --git a/sysutils/hal/files/pkg-install.in b/sysutils/hal/files/pkg-install.in
new file mode 100644
index 000000000..0935c06e1
--- /dev/null
+++ b/sysutils/hal/files/pkg-install.in
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+case $2 in
+POST-INSTALL)
+ USER=haldaemon
+ GROUP=${USER}
+ UID=560
+ GID=${UID}
+ PW=/usr/sbin/pw
+
+ if ${PW} group show "${GROUP}" 2>/dev/null; then
+ echo "You already have a group \"${GROUP}\", so I will use it."
+ else
+ if ${PW} groupadd ${GROUP} -g ${GID}; then
+ echo "Added group \"${GROUP}\"."
+ else
+ echo "Adding group \"${GROUP}\" failed..."
+ exit 1
+ fi
+ fi
+
+ if ${PW} user show "${USER}" 2>/dev/null; then
+ echo "You already have a user \"${USER}\", so I will use it."
+ else
+ if ${PW} useradd ${USER} -u ${UID} -g ${GROUP} -h - \
+ -d "/nonexistent" -s /sbin/nologin -c "HAL Daemon User"
+ then
+ echo "Added user \"${USER}\"."
+ else
+ echo "Adding user \"${USER}\" failed..."
+ exit 1
+ fi
+ fi
+
+ /usr/bin/install -d -o ${USER} -g ${GROUP} /var/run/hald
+ /usr/bin/install -d -o ${USER} -g ${GROUP} /var/cache/hald
+ /usr/bin/install -d -o ${USER} -g ${GROUP} /var/lib/hal
+
+ for pair in %%RC_FILES%%; do
+ file=`echo $pair | cut -f 1 -d :`
+ destdir=`echo $pair | cut -f 2 -d :`
+
+ if [ ! -f $destdir/$file ]; then
+ mkdir -p $destdir
+ cp -p %%DATADIR%%/dist/$file $destdir/$file
+ fi
+ done
+ exit 0
+ ;;
+esac
diff --git a/sysutils/hal/pkg-descr b/sysutils/hal/pkg-descr
new file mode 100644
index 000000000..c94358513
--- /dev/null
+++ b/sysutils/hal/pkg-descr
@@ -0,0 +1,6 @@
+HAL is a hardware abstraction layer whose goal is to merge information from
+various sources such that desktop applications can locate and use hardware
+devices. The point is that the exact set of information to merge varies by
+device and bus type.
+
+WWW: http://www.freedesktop.org/Software/hal
diff --git a/sysutils/hal/pkg-plist b/sysutils/hal/pkg-plist
new file mode 100644
index 000000000..1c75cccbe
--- /dev/null
+++ b/sysutils/hal/pkg-plist
@@ -0,0 +1,129 @@
+@unexec %D/etc/rc.d/hald stop > /dev/null 2>&1 || true
+%%MEDIA%%@exec mkdir -p /media
+bin/hal-device
+bin/hal-disable-polling
+bin/hal-find-by-capability
+bin/hal-find-by-property
+bin/hal-get-property
+bin/hal-is-caller-locked-out
+bin/hal-is-caller-privileged
+bin/hal-lock
+bin/hal-set-property
+bin/lshal
+@exec mkdir -p %D/etc/hal/fdi/preprobe
+@exec mkdir -p %D/etc/hal/fdi/policy
+@exec mkdir -p %D/etc/hal/fdi/information
+include/hal/libhal-storage.h
+include/hal/libhal.h
+lib/libhal-storage.a
+lib/libhal-storage.la
+lib/libhal-storage.so
+lib/libhal-storage.so.1
+lib/libhal.a
+lib/libhal.la
+lib/libhal.so
+lib/libhal.so.1
+lib/libhald_freebsd_probe.a
+lib/libhald_freebsd_probe.la
+lib/libhald_freebsd_probe.so
+lib/libhald_freebsd_probe.so.0
+libdata/pkgconfig/hal-storage.pc
+libdata/pkgconfig/hal.pc
+libexec/hal-storage-cleanup-all-mountpoints
+libexec/hal-storage-cleanup-mountpoint
+libexec/hal-storage-closetray
+libexec/hal-storage-eject
+libexec/hal-storage-mount
+libexec/hal-storage-unmount
+libexec/hal-system-power-pm-is-supported
+libexec/hal-system-setserial
+libexec/hal/scripts/freebsd/hal-system-lcd-get-brightness-freebsd
+libexec/hal/scripts/freebsd/hal-system-lcd-set-brightness-freebsd
+libexec/hal/scripts/freebsd/hal-system-power-reboot-freebsd
+libexec/hal/scripts/freebsd/hal-system-power-set-power-save-freebsd
+libexec/hal/scripts/freebsd/hal-system-power-shutdown-freebsd
+libexec/hal/scripts/freebsd/hal-system-power-suspend-freebsd
+libexec/hal/scripts/hal-dockstation-undock
+libexec/hal/scripts/hal-functions
+libexec/hal/scripts/hal-luks-remove
+libexec/hal/scripts/hal-luks-setup
+libexec/hal/scripts/hal-luks-teardown
+libexec/hal/scripts/hal-system-killswitch-get-power
+libexec/hal/scripts/hal-system-killswitch-set-power
+libexec/hal/scripts/hal-system-lcd-get-brightness
+libexec/hal/scripts/hal-system-lcd-set-brightness
+libexec/hal/scripts/hal-system-power-hibernate
+libexec/hal/scripts/hal-system-power-reboot
+libexec/hal/scripts/hal-system-power-set-power-save
+libexec/hal/scripts/hal-system-power-shutdown
+libexec/hal/scripts/hal-system-power-suspend
+libexec/hal/scripts/hal-system-power-suspend-hybrid
+libexec/hal/scripts/hal-system-wol-enable
+libexec/hal/scripts/hal-system-wol-enabled
+libexec/hal/scripts/hal-system-wol-supported
+libexec/hald-addon-mouse-sysmouse
+libexec/hald-addon-storage
+libexec/hald-generate-fdi-cache
+libexec/hald-probe-hiddev
+libexec/hald-probe-scsi
+libexec/hald-probe-smbios
+libexec/hald-probe-storage
+libexec/hald-probe-volume
+libexec/hald-runner
+sbin/hald
+%%PORTDOCS%%%%DOCSDIR%%/README.freebsd
+%%DATADIR%%/dist/hal.conf
+%%DATADIR%%/fdi/fdi.dtd
+%%DATADIR%%/fdi/information/10freedesktop/01-deprecated-keys.fdi
+@exec mkdir -p %D/%%DATADIR%%/fdi/information/20thirdparty
+%%DATADIR%%/fdi/policy/10osvendor/10-dockstation.fdi
+%%DATADIR%%/fdi/policy/10osvendor/10-input-policy.fdi
+%%DATADIR%%/fdi/policy/10osvendor/10-laptop-panel-mgmt-policy.fdi
+%%DATADIR%%/fdi/policy/10osvendor/10-mouse-sysmouse.fdi
+%%DATADIR%%/fdi/policy/10osvendor/10-power-mgmt-policy.fdi
+%%DATADIR%%/fdi/policy/10osvendor/10-rfkill-switch.fdi
+%%DATADIR%%/fdi/policy/10osvendor/10-tabletPCs.fdi
+%%DATADIR%%/fdi/policy/10osvendor/10-x11-input.fdi
+%%DATADIR%%/fdi/policy/10osvendor/15-storage-luks.fdi
+%%DATADIR%%/fdi/policy/10osvendor/20-storage-methods.fdi
+%%DATADIR%%/fdi/policy/10osvendor/30-wol.fdi
+share/PolicyKit/policy/org.freedesktop.hal.dockstation.policy
+share/PolicyKit/policy/org.freedesktop.hal.killswitch.policy
+share/PolicyKit/policy/org.freedesktop.hal.policy
+share/PolicyKit/policy/org.freedesktop.hal.power-management.policy
+share/PolicyKit/policy/org.freedesktop.hal.storage.policy
+share/PolicyKit/policy/org.freedesktop.hal.wol.policy
+@exec mkdir -p %D/%%DATADIR%%/fdi/policy/20thirdparty
+@exec mkdir -p %D/%%DATADIR%%/fdi/preprobe/10osvendor
+@exec mkdir -p %D/%%DATADIR%%/fdi/preprobe/20thirdparty
+@dirrm %%DATADIR%%/fdi/preprobe/20thirdparty
+@dirrm %%DATADIR%%/fdi/preprobe/10osvendor
+@dirrm %%DATADIR%%/fdi/preprobe
+@dirrm %%DATADIR%%/fdi/policy/20thirdparty
+@dirrm %%DATADIR%%/fdi/policy/10osvendor
+@dirrm %%DATADIR%%/fdi/policy
+@dirrm %%DATADIR%%/fdi/information/20thirdparty
+@dirrm %%DATADIR%%/fdi/information/10freedesktop
+@dirrm %%DATADIR%%/fdi/information
+@dirrm %%DATADIR%%/fdi
+@dirrm %%DATADIR%%/dist
+@dirrm %%DATADIR%%
+@dirrm %%DOCSDIR%%
+@dirrm libexec/hal/scripts/freebsd
+@dirrm libexec/hal/scripts
+@dirrm libexec/hal
+@dirrm include/hal
+@dirrm etc/hal/fdi/preprobe
+@dirrm etc/hal/fdi/policy
+@dirrm etc/hal/fdi/information
+@dirrm etc/hal/fdi
+@dirrm etc/hal
+@unexec rm -f /var/run/hald/hald.pid 2>/dev/null || true
+@unexec rm -rf /var/run/hald/hald-local 2>/dev/null || true
+@unexec rm -rf /var/run/hald/hald-runner 2>/dev/null || true
+@unexec rmdir /var/run/hald 2>/dev/null || true
+@unexec rmdir /var/cache/hald 2>/dev/null || true
+@unexec rmdir /var/cache 2>/dev/null || true
+@unexec /var/lib/hal 2>/dev/null || true
+@unexec /var/lib 2>/dev/null || true
+%%MEDIA%%@unexec rmdir /media 2>/dev/null || true