%define expat_version           1.95.5
%define glib2_version           2.20.0
%define dbus_version            1.2
%define dbus_glib_version       0.80
%define dbus_python_version     0.80
%define pygtk2_version		2.8.0
%define gnome_python		2.14.0
%define udev_version            145
%define util_linux_ng_version   2.14
%define gettext_version	        0.14.5
%define libusb_version          0.1.10a
%define consolekit_version	0.3.0
%define acl_version		2.2.39
%define policykit_version	0.9
%define pciutils_version	2.2.1
%define dmidecode_version	2.7
%define gperf_version		3.0.1
%define parted_version		1.8.8

%define hal_user_uid           68

%define _localstatedir %{_var}

Summary: Hardware Abstraction Layer
Summary(ja): ハードウエア抽象化レイヤ
Name: hal
Version: 0.5.13
Release: 3%{?_dist_release}
URL: http://www.freedesktop.org/Software/hal
License: AFL/GPL
Group: System Environment/Libraries

Source0: %{name}-%{version}.tar.gz

Patch2: hal-0.5.11-change-priority.patch

# https://bugzilla.redhat.com/show_bug.cgi?id=488177
Patch4: hal-remove-dell-killswitch.patch

# http://lists.freedesktop.org/archives/hal/2009-March/013125.html
Patch9: hal-KVM-evdev.patch

# http://bugs.freedesktop.org/show_bug.cgi?id=22442
Patch11: hal-HDAPS-blacklist.patch

# https://bugzilla.redhat.com/show_bug.cgi?id=507782
Patch12: hal-mdfind.patch

Patch100: hal-use-at-console.patch

Patch200: hal-0.5.13-disable-keyboard-hotplug.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
Requires: chkconfig
BuildRequires: expat-devel >= %{expat_version}
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: dbus-devel  >= %{dbus_version}
BuildRequires: python-devel
BuildRequires: hwdata
BuildRequires: gettext >= %{gettext_version}
%ifnarch s390 s390x
BuildRequires: libusb-devel >= %{libusb_version}
%endif
BuildRequires: desktop-file-utils >= 0.9
BuildRequires: dbus-glib-devel >= %{dbus_glib_version}
BuildRequires: pciutils-devel >= %{pciutils_version}
BuildRequires: gperf >= %{gperf_version}
BuildRequires: parted-devel >= %{parted_version}
BuildRequires: e2fsprogs-devel
BuildRequires: libblkid-devel
BuildRequires: libuuid-devel

Requires: dbus >= %{dbus_version}
Requires: dbus-glib >= %{dbus_glib_version}
Requires: glib2 >= %{glib2_version}
Requires: udev >= %{udev_version} 
Requires: util-linux-ng >= %{util_linux_ng_version} 
%ifnarch s390 s390x
Requires: libusb >= %{libusb_version}
%endif
Requires: ConsoleKit >= %{consolekit_version}
Requires: acl >= %{acl_version}
Requires: hal-info
Obsoletes: hal-gnome

%description
HAL is daemon for collection and maintaining information from several
sources about the hardware on the system. It provdes a live device
list through D-BUS.

%package gnome
Summary: GNOME based device manager for HAL
Group: Applications/System
Requires: %name = %{version}-%{release}
Requires: dbus-python >= %{dbus_python_version}
Requires: pygtk2 >= %{pygtk2_version} 
Requires: pygtk2-libglade >= %{pygtk2_version}
Requires: gnome-python >= %{gnome_python} 

%description gnome
GNOME program for displaying the devices detected by HAL


%package devel
Summary: Libraries and headers for HAL
Group: Development/Libraries
Requires: %name = %{version}-%{release}
Requires: dbus-devel >= %{dbus_version}

%description devel

Headers, static libraries and API docs for HAL.


%prep
%setup -q -n %{name}-%{version}
%patch2 -p1 -b .priority

%patch4 -p1 -b .dell-killswitch
%patch9 -p1 -b .kvm-evdev
%patch11 -p1 -b .hdaps-blacklist
%patch12 -p1 -b .mdfind

%patch100 -p1 -b .drop-polkit

%patch200 -p1 -b .disable-keyboard-hotplug

%build

autoreconf -f -i

%configure \
	--with-os-type=redhat \
        --docdir=%{_docdir}/%{name}-%{version} \
        --with-udev-prefix=/etc \
	--disable-docbook-docs \
	--enable-pcmcia-support \
	--enable-umount-helper \
	--disable-console-kit \
	--disable-policy-kit \
	--disable-acpi-ibm \
	--disable-smbios \
	--enable-parted \
	--enable-acpi-toshiba \
	--without-usb-csr \
	--without-cpufreq \
	--with-eject=/usr/sbin/eject

%__make %{?_smp_mflags}


%install
rm -rf %{buildroot}
make install DESTDIR=$RPM_BUILD_ROOT

rm -f $RPM_BUILD_ROOT%{_libdir}/*.{a,la}


%clean
rm -rf %{buildroot}


%pre
# Add the "haldaemon" user
/usr/sbin/useradd -c 'HAL daemon' -u %{hal_user_uid} \
	-s /sbin/nologin -r -d '/' haldaemon 2> /dev/null || :

# User haldaemon needs to be able to read authorizations
/usr/bin/polkit-auth --user haldaemon --grant org.freedesktop.policykit.read >& /dev/null || :


%post
/sbin/ldconfig
/sbin/chkconfig --add haldaemon


%preun
if [ $1 = 0 ]; then
    service haldaemon stop > /dev/null 2>&1
    /sbin/chkconfig --del haldaemon
fi


%postun
/sbin/ldconfig
#if [ "$1" -ge "1" ]; then
#  service haldaemon condrestart > /dev/null 2>&1
#fi


%triggerpostun -- hal < 0.5.7
#remove lingering fstab-sync entries from /etc/fstab
/bin/cp -f /etc/fstab /etc/fstab.hal-save
(IFS="
"; while read line; do echo $line | awk '{print $4}' | grep -q managed || echo $line | grep -q "^#.*fstab-sync" || echo $line; done < /etc/fstab > fstab.replace)

if [ -s fstab.replace ]; then
  /bin/cp -f fstab.replace /etc/fstab
fi

%triggerpostun -- hal < 0.5.11-3
# reset priorities
if [ -f /etc/rc3.d/S98haldaemon ]; then
  /sbin/chkconfig haldaemon resetpriorities
fi


%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING ChangeLog HACKING INSTALL README NEWS
%doc examples

%dir %{_sysconfdir}/dbus-1/system.d
%{_sysconfdir}/dbus-1/system.d/*

%config %{_sysconfdir}/rc.d/init.d/haldaemon

%dir %{_sysconfdir}/hal
%{_sysconfdir}/hal/*

/sbin/umount.hal
%{_sbindir}/hald
%{_bindir}/*

%{_libexecdir}/*

%{_libdir}/*hal*.so.*

%dir %{_datadir}/hal
%dir %{_datadir}/hal/fdi
%{_datadir}/hal/fdi/*

%{_mandir}/man1/*
%{_mandir}/man8/*

%{_sysconfdir}/udev/rules.d/90-hal.rules


%attr(0700,haldaemon,haldaemon) %dir %{_localstatedir}/cache/hald
%attr(0700,haldaemon,haldaemon) %dir %{_localstatedir}/run/hald


%files devel
%defattr(-,root,root)
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*
%{_includedir}/*
%{_datadir}/gtk-doc/html/*

#%files gnome
#%defattr(-,root,root)
#%dir %{_datadir}/hal/device-manager
#%{_datadir}/hal/device-manager/*
#%{_bindir}/hal-device-manager
#%{_datadir}/applications/*.desktop


%changelog
* Mon Feb 08 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.5.13-3
- add BuildRequires: libuuid-devel

* Fri Feb 05 2010 Shu KONNO <owa@bg.wakwak.com> 0.5.13-2
- rebuilt with python-2.6.4-3

* Wed Oct 14 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.13-1
- new upstream release
- merge patches from fedora
- disable ConsoleKit and PolicyKit support
- disable acl management, this is now handled by udev
- disable csr,ibm and cpufreq which is obsolete.

* Sat Oct 03 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.5.12-2.rc1
- add patch11 to disable acl for unpartitioned volumes (such as audio CDs)
  ([vine-users:079605])

* Sat Jul 04 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 0.5.12-1.rc1
- added BuildRequires: e2fsprogs-devel

* Fri Mar 27 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.12-0.rc1
- update to 0.5.12rc1
- add patch5 to allow introspection and Device.KillSwitch access
  https://bugs.freedesktop.org/show_bug.cgi?id=18985

* Wed Dec 03 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.11-6
- rebuild with udev-135-1

* Wed Oct 22 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.11-5
- add 10-x11-input.fdi again
- add patch10 to disable x11 keyaboard hotplugging

* Tue Aug 19 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.11-4
- rebuild with parted-1.8.8
- add BuildRequires: util-linux-ng instead of util-linux

* Mon Aug 04 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.11-3
- rebuild with new ConsoleKit/PolicyKit
- change start/stop priority earlier

* Mon Jun 30 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.5.11-2
- spec in UTF-8
- Drop 99-redhat-storage-policy-fixed-drives.fdi; this is now
  controlled by PolicyKit
- Remove /usr/share/hal/fdi/policy/10osvendor/10-x11-input.fdi which
  effectively disables xorg input hotplugging again: this is only a
  temporary workaround until a better solution is available
  (see: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=447666)

* Sat May 24 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.5.11-1
- updated to 0.5.11
- drop gnome subpackage - obsoleted in the upstream
  (but separated into gnome-desktop-manager)
- drop use of find_lang - all translations dropped in the upstream

* Sat Mar 08 2008 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.5.9-0vl5
- add Patch1001 to get proper LCD max brightness with pcc-acpi.

* Wed Feb 20 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 0.5.9-0vl4
- rebuild with expat-2.0.1
- add BuildRequires: dbus-glib-devel >= %%{dbus_glib_version}
- update %%{SOURCE2} (drop extension from Icon entry)

* Thu Oct 11 2007 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.5.9-0vl3
- add Patch600 to fix severe memory leak on the system with apm
  initially discussed at:
    https://bugzilla.redhat.com/show_bug.cgi?id=244995
  then more comprehensive fixes posted at:
    http://lists.freedesktop.org/archives/hal/2007-September/009642.html

* Sat Apr 28 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.9-0vl2
- add Requires: hal-info

* Fri Apr 27 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.9-0vl1
- new upstream release
- add Patch1000 to revert kernel-2.6.17 specific changes

* Thu Apr 26 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.7.1-0vl4
- rebuild with dbus-1.0

* Sat Nov 25 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.5.7.1-0vl3
- changed hal-gnome Group to Applications/System

* Wed Sep 13 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.7.1-0vl2
- add Patch10 to detecting usb optical drives
  (https://bugs.freedesktop.org/show_bug.cgi?id=5558)

* Fri Jul 28 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.7.1-0vl1
- new upstream release
- add Patch1 to fix confusing lid state. (<BTS:0091>)

* Wed Mar 15 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.7-0vl3
- add Source1 for workaround policy file to ignore fixed
  (non-hotpluggable) disk from FC.

* Mon Mar 13 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.7-0vl2
- do not restart haldaemon in %%postun script

* Mon Mar 06 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.7-0vl1
- new upstream release
- disable fstab-sync, clear fstab-sync entries from fstab
- import changes from FC

* Mon Oct 17 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.4-0vl2
- remove Requires: gnome-python-* from hal-gnome
  gnome-python sub packages are obsoleted.

* Wed Oct 05 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.4-0vl1
- new upstream release

* Wed Jul 13 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.3-0vl1
- new upstream release
- add Requires: pygtk2-libglade for hal-gnome

* Sun Jul 10 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.2-0vl1
- new upstream release
- import patches from FC

* Sun Mar 20 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 0.4.7-2vl1
- initiual build for Vine Linux based on FC package.

* Thu Jan 27 2005 David Zeuthen <davidz@redhat.com> 0.4.7-2
- Add patch that should close #146316

* Mon Jan 24 2005 David Zeuthen <davidz@redhat.com> 0.4.7-1
- New upstream release.
- Should close #145921, #145750, #145293, #145256

* Mon Jan 24 2005 John (J5) Palmieri <johnp@redhat.com> 0.4.6-3
- Update required dbus version to 0.23 

* Thu Jan 20 2005 David Zeuthen <davidz@redhat.com> 0.4.6-2
- Fix parameters to configure

* Thu Jan 20 2005 David Zeuthen <davidz@redhat.com> 0.4.6-1
- New upstream release
- Should close #145099, #144600, #140150, #145223, #137672

* Wed Jan 12 2005 David Zeuthen <davidz@redhat.com> 0.4.5-1
- New upstream release.
- Should close #142834, #141771, #142183

* Fri Dec 12 2004 David Zeuthen <davidz@redhat.com> 0.4.2.cvs20041210-1
- Snapshot from stable branch of upstream CVS

* Tue Oct 26 2004 David Zeuthen <davidz@redhat.com> 0.4.0-8
- Forgot to add some diffs in hal-0.4.0-pcmcia-net-support.patch

* Tue Oct 26 2004 David Zeuthen <davidz@redhat.com> 0.4.0-7
- Change default policy such that non-hotpluggable fixed disks are not
  added to the /etc/fstab file because a) ATARAID detection in hal is
  incomplete (e.g. RAID members from ATARAID controllers might be added
  to /etc/fstab); and b) default install wont corrupt multiboot 
  systems on fixed drives (#137072)

* Tue Oct 26 2004 David Zeuthen <davidz@redhat.com> 0.4.0-6
- Fix hotplug timeout handling (#136626)
- Detect ATARAID devices and do not add /etc/fstab entry for them
- Probe for ext3 before ntfs (#136966)
- Use fstype 'auto' for optical drives instead of 'iso9660,udf'
- Properly detect wireless ethernet devices  (#136591)
- Support 16-bit PCMCIA networking devices (by Dan Williams) (#136658)

* Tue Oct 19 2004 David Zeuthen <davidz@redhat.com> 0.4.0-5
- Make hal work with PCMCIA IDE hotpluggable devices (#133943)
- Fixup URL listed from rpm -qi (#136396)
- Add Portuguese translations for hal
- Fix addition of Russian and Hungarian translations

* Mon Oct 18 2004 David Zeuthen <davidz@redhat.com> 0.4.0-4
- Make hald cope with missing hotplug events from buggy drivers (#135202)
- Fix the order of mount options in fstab-sync (#136191)
- Allow x86 legacy floppy drives in default policy (#133777)
- Fix fstab-sync crashing without any options and not run from hald (#136214)
- man page for fstab-sync references non-existing files (#136026)
- Add Russian translations for hal (#135853)
- Add Hungarian translations for hal

* Fri Oct 15 2004 David Zeuthen <davidz@redhat.com> 0.4.0-3
- Fix bad use of O_NONBLOCK as the 2.6.8-1.624 kernel exposes this (#135886)
- Never use the UUID as mount point candidate in the default policy 
  as it is unfriendly (#135907)
- Fix a trivial bug in fstab-sync so the syslog messages actually expose
  the device name instead of just the word foo

* Thu Oct 14 2004 David Zeuthen <davidz@redhat.com> 0.4.0-2
- Fix issue with fstab-sync not cleaning /etc/fstab on startup

* Thu Oct 14 2004 David Zeuthen <davidz@redhat.com> 0.4.0-1
- Update to upstream stable version 0.4.0
- Remove patch for libhal shutdown since that is now upstream
- fstab-sync: man page, adds comment in /etc/fstab pointing to man page

* Fri Oct 01 2004 David Zeuthen <davidz@redhat.com> 0.2.98.cvs20040929-3
- Fix a bug so libhal actually invoke callback functions when needed

* Fri Oct 01 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.98.cvs20040929-2
- Use "user" mount flag for now until "pamconsole" flag gets into mount

* Wed Sep 29 2004 David Zeuthen <davidz@redhat.com> 0.2.98.cvs20040929-1
- Update to upstream CVS version
- Enable libselinux again

* Mon Sep 27 2004 David Zeuthen <davidz@redhat.com> 0.2.98.cvs20040927-1
- Update to upstream CVS version

* Fri Sep 24 2004 David Zeuthen <davidz@redhat.com> 0.2.98.cvs20040923-1
- Update to upstream CVS release
- Include libhal-storage library
- Should close bug #132876

* Mon Sep 20 2004 David Zeuthen <davidz@redhat.com> 0.2.98-4
- Rebuilt

* Mon Sep 20 2004 David Zeuthen <davidz@redhat.com> 0.2.98-3
- Rebuilt

* Mon Sep 20 2004 David Zeuthen <davidz@redhat.com> 0.2.98-2
- Temporarily disable explicit requirement for libselinux

* Mon Sep 20 2004 David Zeuthen <davidz@redhat.com> 0.2.98-1
- Update to upstream release 0.2.98. 
- Use --with-pid-file so we don't depend on /etc/redhat-release

* Wed Sep 01 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040901-1
- Update to upstream CVS HEAD

* Tue Aug 31 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040831-3
- Add UID for haldaemon user

* Tue Aug 31 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040831-2
- Rebuilt with a newer snapshot.

* Fri Aug 27 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040827-3
- Rebuilt

* Fri Aug 27 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040827-2
- Rebuilt
- Closes RH Bug #130971

* Fri Aug 27 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040827-1
- Update to upstream CVS HEAD. 
- Should close RH Bug #130588

* Wed Aug 25 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040823-3
- Rebuilt

* Wed Aug 25 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040823-2
- Apply a patch so hald doesn't hang on startup.

* Mon Aug 23 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040823-1
- Update to upstream CVS HEAD
- Remove symlinking of fstab-sync from specfile since this is now being
  done in the package

* Mon Aug 23 2004 Florian La Roche <Florian.LaRoche@redhat.de>
- change the %%define names to not use "-"

* Thu Aug 19 2004 David Zeuthen <davidz@redhat.com> 0.2.97.cvs20040819-1
- Update to upstream CVS HEAD
- Remove suid patch as it is fixed upstream
- Fix some dependency issues (RH Bug #130202)

* Wed Aug 18 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.97-2
- Add stopgap patch to remove suid from mount flags (RH Bug #130290)

* Mon Aug 16 2004 David Zeuthen <davidz@redhat.com> 0.2.97-1
- update to upstream release 0.2.97
- use kudzu option in fstab-sync since updfstab is now disabled

* Thu Aug 12 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.96-2
- fixed Requires lines to use %{} instead of ${}
- made dbus related requires lines use the = condition instead of =<
  because the dbus API is still in flux

* Thu Aug 12 2004 David Zeuthen <davidz@redhat.com> 0.2.96
- Update to upstream release 0.2.96
- Symlink fstab-sync into /etc/hal/device.d on install

* Fri Aug 06 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.95.cvs20040802-2
- Base hal package no longer requires python

* Mon Aug 02 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.95.cvs20040802-1
- Update to CVS head
- Remove Dan's patches as they were commited to CVS

* Fri Jul 30 2004 Dan Williams <dcbw@redhat.com> 0.2.93.cvs.20040712-2
- Fix netlink sockets pointer arithmetic bug

* Mon Jul 12 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.93.cvs.20040712-1
- Update to new CVS version as of 7-12-2004

* Fri Jun 25 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.92.cvs.20040611-2
- take out fstab-update.sh from install
- add to rawhide
 
* Fri Jun 11 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.92.cvs.20040611-1 
- update to CVS head as of 6-11-2004 which contains dcbw's 
  network link status fix 

* Wed Jun 9 2004 Ray Strode <rstrode@redhat.com> 0.2.91.cvs20040527-2
- added dependency on udev

* Wed May 12 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.91.cvs20040527-1
- update to CVS head as of 5-27-2004 which contains fixes for PCMCIA
  and wireless network devices.

* Wed May 12 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.90.cvs20040511-3
- added hal-0.2.90.cvs20040511.callbackscripts.patch which installs 
  the file system mounting script in /etc/hal/device.d

* Wed May 12 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.90.cvs20040511-2
- added the %{_sysconfigdir}/hal directory tree to %files 

* Tue May 11 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.90.cvs20040511-1
- update to CVS head as of 5-11-2004

* Wed May 5 2004 Christopher Blizzard <blizzard@redhat.com> 0.2.90-2
- Install hal.dev from /etc/dev.d/default/

* Mon Apr 19 2004 John (J5) Palmieri <johnp@redhat.com> 0.2.90-1
- upstream update

* Mon Apr 19 2004 John (J5) Palmieri <johnp@redhat.com> 0.2-1 
- initial checkin to package repository
- added dependency to the dbus-python package
- added %{_libexecdir}/hal.dev to teh %files section