From nobody@FreeBSD.org  Tue Sep 18 01:33:39 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 86949106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Sep 2012 01:33:39 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 709A38FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Sep 2012 01:33:39 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q8I1Xd45043832
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Sep 2012 01:33:39 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q8I1XdQh043831;
	Tue, 18 Sep 2012 01:33:39 GMT
	(envelope-from nobody)
Message-Id: <201209180133.q8I1XdQh043831@red.freebsd.org>
Date: Tue, 18 Sep 2012 01:33:39 GMT
From: Alberto Villa <avilla@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] sysutils/hal: fix two issues and add dependency on sysutils/hal-info
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         171727
>Category:       ports
>Synopsis:       [patch] sysutils/hal: fix two issues and add dependency on sysutils/hal-info
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnome
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 18 01:40:05 UTC 2012
>Closed-Date:    Sat Sep 29 18:19:12 UTC 2012
>Last-Modified:  Mon Oct  8 07:50:21 UTC 2012
>Originator:     Alberto Villa
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
FreeBSD woodstock.peanuts 10.0-CURRENT FreeBSD 10.0-CURRENT #13 r239665: Sat Aug 25 02:49:34 CEST 2012     root@woodstock.peanuts:/usr/obj/usr/src/sys/HPDV6  amd64
>Description:
1. A new drm entry (nvidia_card) is added on every iteration of osspec_probe(), because no check is done to see if the entry is already there.

2. storage.removable.media_available and storage.removable.media_size are set only for optical drives, while they should be set also for hotpluggable drives.

3. hal-info adds many useful definitions to the HAL device list, but many users don't know about the port.
>How-To-Repeat:
1. Grep `lshal` for "nvidia_card" (on systems mounting an Nvidia, of course): there are multiple entries, with no differences. Systems with removable devices will have many of them, while other systems could have fewer. One is enough, though.

2. Check if those properties are set for hotpluggable devices.
>Fix:
1. Add a check to avoid duplicating the entry.

2. Set the properties for any storage device, as the Linux backend does. It's not wrong to do that only for optical drives, as they are the only true "removable" devices (along with tape and floppy drives), as USB sticks should only be marked as "hotpluggable", but since our backend does the same wrong assumption as the Linux one, it's better to pursue that road (it's a bit late to change). This means that the properties will also be set for non-hotpluggable devices (hard disks), but that's not a problem, as the properties should not be checked if storage.removable is false. This also mimics Linux backend behaviour, and, to be fair, HAL spec is not at all complete in the definition of the properties.

3. Adding a dependency on hal-info ensures that everyone gets the best possible "HAL experience" (sounds a bit too much :). For instance, I now have my iPod detected as such in KDE, with a nice icon shown in place of the plain USB stick one.

Patch attached with submission follows:

Index: Makefile
===================================================================
--- Makefile	(revision 304374)
+++ Makefile	(working copy)
@@ -8,7 +8,7 @@
 
 PORTNAME=	hal
 DISTVERSION=	0.5.14
-PORTREVISION=	19
+PORTREVISION=	20
 CATEGORIES=	sysutils
 MASTER_SITES=	http://hal.freedesktop.org/releases/
 
@@ -19,7 +19,8 @@
 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
+RUN_DEPENDS=	${LOCALBASE}/share/pciids/pci.ids:${PORTSDIR}/misc/pciids \
+		${LOCALBASE}/share/hal/fdi/information/10freedesktop/30-keymap-misc.fdi:${PORTSDIR}/sysutils/hal-info
 
 USE_GETTEXT=	yes
 USE_GMAKE=	yes
--- hald/freebsd/hf-drm.c.orig	2012-09-12 01:45:35.665050510 +0200
+++ hald/freebsd/hf-drm.c	2012-09-12 01:25:28.125106626 +0200
@@ -234,6 +234,12 @@
   {
     HalDevice *parent = HAL_DEVICE(l->data);
 
+    if (hf_device_store_match(hald_get_gdl(),
+			      "info.parent", HAL_PROPERTY_TYPE_STRING, hal_device_get_udi(parent),
+			      "info.subsystem", HAL_PROPERTY_TYPE_STRING, "drm",
+			      NULL))
+      continue;
+
     if (! hal_device_property_get_bool(parent, "info.ignore"))
       {
         Card *card;
--- hald/freebsd/probing/probe-storage.c.orig	2012-09-12 01:46:34.554977683 +0200
+++ hald/freebsd/probing/probe-storage.c	2012-09-12 01:38:45.000000000 +0200
@@ -236,7 +236,27 @@
 
       hfp_cdrom_free(cdrom);
     }
-  else if (! has_children) /* by definition, if it has children it has no fs */
+  else
+    {
+      int fd;
+      off_t size;
+
+      fd = open(device_file, O_RDONLY | O_NONBLOCK);
+      if (fd > -1)
+	{
+	  libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", TRUE, &hfp_error);
+	  if (ioctl (fd, DIOCGMEDIASIZE, &size) == 0)
+	    {
+	      libhal_device_set_property_uint64(hfp_ctx, hfp_udi, "storage.removable.media_size", size, &hfp_error);
+	    }
+	  close(fd);
+	}
+      else
+	{
+	  libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", FALSE, &hfp_error);
+	}
+
+      if (! has_children) /* by definition, if it has children it has no fs */
     {
       struct volume_id *vid;
 
@@ -249,6 +269,7 @@
 
       volume_id_close(vid);
     }
+    }
 
  end:
   return ret;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->gnome 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Tue Sep 18 01:40:16 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=171727 
State-Changed-From-To: open->closed 
State-Changed-By: kwm 
State-Changed-When: Sat Sep 29 18:19:01 UTC 2012 
State-Changed-Why:  
Committed thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=171727 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/171727: commit references a PR
Date: Sat, 29 Sep 2012 18:18:14 +0000 (UTC)

 Author: kwm
 Date: Sat Sep 29 18:17:59 2012
 New Revision: 305045
 URL: http://svn.freebsd.org/changeset/ports/305045
 
 Log:
   Make sure /var is populated correctly before hal is started, like dbus does
   already in its rc.d script. [1]
   Don't list entries twice, set some more details about storage devices like
   the linux backend does. [2]
   
   PR:		ports/171568 [1]
   PR:		ports/171727 [2]
   Submitted by:	Norbert Koch <nkoch@demig.de> [1], avilla@ [2]
   Reviewed by:	marcus@
 
 Added:
   head/sysutils/hal/files/patch-hald_freebsd_hf-drm.c   (contents, props changed)
   head/sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c   (contents, props changed)
 Modified:
   head/sysutils/hal/Makefile   (contents, props changed)
   head/sysutils/hal/files/hald.in   (contents, props changed)
 
 Modified: head/sysutils/hal/Makefile
 ==============================================================================
 --- head/sysutils/hal/Makefile	Sat Sep 29 18:10:12 2012	(r305044)
 +++ head/sysutils/hal/Makefile	Sat Sep 29 18:17:59 2012	(r305045)
 @@ -8,7 +8,7 @@
  
  PORTNAME=	hal
  DISTVERSION=	0.5.14
 -PORTREVISION=	19
 +PORTREVISION=	20
  CATEGORIES=	sysutils
  MASTER_SITES=	http://hal.freedesktop.org/releases/
  
 
 Modified: head/sysutils/hal/files/hald.in
 ==============================================================================
 --- head/sysutils/hal/files/hald.in	Sat Sep 29 18:10:12 2012	(r305044)
 +++ head/sysutils/hal/files/hald.in	Sat Sep 29 18:17:59 2012	(r305045)
 @@ -41,6 +41,43 @@ local_force_depend()
     return 0
  }
  
 +init_var_policykit()
 +{
 +  local USER=polkit
 +  local GROUP=${USER}
 +  local PREFIX=/usr/local
 +
 +  /usr/bin/install -d -o root -m 0770 -g ${GROUP} /var/run/PolicyKit
 +  /usr/bin/install -d -o root -m 0770 -g ${GROUP} /var/lib/PolicyKit
 +  /usr/bin/install -d -o ${USER} -m 0755 -g wheel /var/lib/PolicyKit-public
 +  /bin/mkdir -p /var/lib/misc
 +  /usr/bin/touch -f /var/lib/misc/PolicyKit.reload
 +  /usr/sbin/chown ${USER}:${GROUP} /var/lib/misc/PolicyKit.reload
 +  /bin/chmod 0664 /var/lib/misc/PolicyKit.reload
 +}
 +
 +init_var_polkit()
 +{
 +  mkdir -p /var/lib/polkit-1/localauthority
 +  for i in 10-vendor.d 20-org.d 30-site.d 50-local.d 90-mandatory.d
 +  do
 +    mkdir -p /var/lib/polkit-1/localauthority/${i}
 +  done
 +  chmod 0700 /var/lib/polkit-1
 +}
 +
 +init_var_hal()
 +{
 +  local USER=haldaemon
 +  local GROUP=${USER}
 +
 +  /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
 +  /usr/local/bin/polkit-auth --user ${USER} --grant \
 +          org.freedesktop.policykit.read 1> /dev/null 2>&1
 +}
 +
  hald_precmd()
  {
      if ! checkyesno dbus_enable
 @@ -48,6 +85,10 @@ hald_precmd()
  	local_force_depend dbus || return 1
      fi
  
 +    init_var_policykit
 +    init_var_polkit
 +    init_var_hal
 +
      chmod 0755 /var/cache
  
      mkdir -p $(dirname $pidfile)
 
 Added: head/sysutils/hal/files/patch-hald_freebsd_hf-drm.c
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/sysutils/hal/files/patch-hald_freebsd_hf-drm.c	Sat Sep 29 18:17:59 2012	(r305045)
 @@ -0,0 +1,15 @@
 +--- hald/freebsd/hf-drm.c.orig	2008-08-10 15:50:10.000000000 +0200
 ++++ hald/freebsd/hf-drm.c	2012-09-27 12:04:28.000000000 +0200
 +@@ -234,6 +234,12 @@
 +   {
 +     HalDevice *parent = HAL_DEVICE(l->data);
 + 
 ++    if (hf_device_store_match(hald_get_gdl(),
 ++			      "info.parent", HAL_PROPERTY_TYPE_STRING, hal_device_get_udi(parent),
 ++			      "info.subsystem", HAL_PROPERTY_TYPE_STRING, "drm",
 ++			      NULL))
 ++      continue;
 ++
 +     if (! hal_device_property_get_bool(parent, "info.ignore"))
 +       {
 +         Card *card;
 
 Added: head/sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/sysutils/hal/files/patch-hald_freebsd_probing_probe-storage.c	Sat Sep 29 18:17:59 2012	(r305045)
 @@ -0,0 +1,39 @@
 +--- hald/freebsd/probing/probe-storage.c.orig	2009-08-24 14:42:29.000000000 +0200
 ++++ hald/freebsd/probing/probe-storage.c	2012-09-27 12:03:02.000000000 +0200
 +@@ -236,7 +236,27 @@
 + 
 +       hfp_cdrom_free(cdrom);
 +     }
 +-  else if (! has_children) /* by definition, if it has children it has no fs */
 ++  else
 ++    {
 ++      int fd;
 ++      off_t size;
 ++
 ++      fd = open(device_file, O_RDONLY | O_NONBLOCK);
 ++      if (fd > -1)
 ++	{
 ++	  libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", TRUE, &hfp_error);
 ++	  if (ioctl (fd, DIOCGMEDIASIZE, &size) == 0)
 ++	    {
 ++	      libhal_device_set_property_uint64(hfp_ctx, hfp_udi, "storage.removable.media_size", size, &hfp_error);
 ++	    }
 ++	  close(fd);
 ++	}
 ++      else
 ++	{
 ++	  libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", FALSE, &hfp_error);
 ++	}
 ++
 ++      if (! has_children) /* by definition, if it has children it has no fs */
 +     {
 +       struct volume_id *vid;
 + 
 +@@ -249,6 +269,7 @@
 + 
 +       volume_id_close(vid);
 +     }
 ++    }
 + 
 +  end:
 +   return ret;
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 

From: arrowdodger <6yearold@gmail.com>
To: bug-followup@freebsd.org, avilla@freebsd.org
Cc:  
Subject: Re: ports/171727: [patch] sysutils/hal: fix two issues and add
 dependency on sysutils/hal-info
Date: Mon, 8 Oct 2012 09:48:55 +0400

 --f46d04016d1fcadfc404cb85c829
 Content-Type: text/plain; charset=UTF-8
 
 Haven't you forgot to commit the RUN_DEPENDS+=hal-info hunk?
 
 --f46d04016d1fcadfc404cb85c829
 Content-Type: text/html; charset=UTF-8
 
 Haven&#39;t you forgot to commit the RUN_DEPENDS+=hal-info hunk?<br>
 
 --f46d04016d1fcadfc404cb85c829--

From: Alberto Villa <avilla@FreeBSD.org>
To: arrowdodger <6yearold@gmail.com>
Cc: bug-followup@freebsd.org
Subject: Re: ports/171727: [patch] sysutils/hal: fix two issues and add
 dependency on sysutils/hal-info
Date: Mon, 8 Oct 2012 09:40:29 +0200

 On Mon, Oct 8, 2012 at 7:48 AM, arrowdodger <6yearold@gmail.com> wrote:
 > Haven't you forgot to commit the RUN_DEPENDS+=hal-info hunk?
 
 hal-info depends on hal. That was quite a stupid mistake of mine. :)
 -- 
 Alberto Villa, FreeBSD committer <avilla@FreeBSD.org>
 http://people.FreeBSD.org/~avilla

From: arrowdodger <6yearold@gmail.com>
To: Alberto Villa <avilla@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: ports/171727: [patch] sysutils/hal: fix two issues and add
 dependency on sysutils/hal-info
Date: Mon, 8 Oct 2012 11:48:02 +0400

 --f46d040716e3b691cd04cb8772cf
 Content-Type: text/plain; charset=UTF-8
 
 Ah, right. Maybe it should be mentioned in hal's pkg-message then?
 
 On Mon, Oct 8, 2012 at 11:40 AM, Alberto Villa <avilla@freebsd.org> wrote:
 
 > On Mon, Oct 8, 2012 at 7:48 AM, arrowdodger <6yearold@gmail.com> wrote:
 > > Haven't you forgot to commit the RUN_DEPENDS+=hal-info hunk?
 >
 > hal-info depends on hal. That was quite a stupid mistake of mine. :)
 > --
 > Alberto Villa, FreeBSD committer <avilla@FreeBSD.org>
 > http://people.FreeBSD.org/~avilla
 >
 
 --f46d040716e3b691cd04cb8772cf
 Content-Type: text/html; charset=UTF-8
 Content-Transfer-Encoding: quoted-printable
 
 Ah, right. Maybe it should be mentioned in hal&#39;s pkg-message then?<br><=
 br><div class=3D"gmail_quote">On Mon, Oct 8, 2012 at 11:40 AM, Alberto Vill=
 a <span dir=3D"ltr">&lt;<a href=3D"mailto:avilla@freebsd.org" target=3D"_bl=
 ank">avilla@freebsd.org</a>&gt;</span> wrote:<br>
 
 <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
 x #ccc solid;padding-left:1ex"><div class=3D"im">On Mon, Oct 8, 2012 at 7:4=
 8 AM, arrowdodger &lt;<a href=3D"mailto:6yearold@gmail.com">6yearold@gmail.=
 com</a>&gt; wrote:<br>
 
 
 &gt; Haven&#39;t you forgot to commit the RUN_DEPENDS+=3Dhal-info hunk?<br>
 <br>
 </div>hal-info depends on hal. That was quite a stupid mistake of mine. :)<=
 br>
 <span class=3D"HOEnZb"><font color=3D"#888888">--<br>
 Alberto Villa, FreeBSD committer &lt;avilla@FreeBSD.org&gt;<br>
 <a href=3D"http://people.FreeBSD.org/~avilla" target=3D"_blank">http://peop=
 le.FreeBSD.org/~avilla</a><br>
 </font></span></blockquote></div><br>
 
 --f46d040716e3b691cd04cb8772cf--
>Unformatted:
