%define	pprefver	0.4.3

Summary:       daemon to control the functions of hotkeys found on recent Macs
Summary(ja):   Mac のホットキーを利用可能にするデーモン
Name:          pbbuttonsd
Version:       0.5.8
Release:       0vl1
Copyright:     GPL
Group:         Utilities/System
URL:           http://www.cymes.de/members/joker/projects/pbbuttons/pbbuttons.html
Source0:       http://www.cymes.de/members/joker/projects/pbbuttons/tar/%{name}-%{version}.tar.gz
Source1:       http://www.cymes.de/members/joker/projects/pbbuttons/tar/powerprefs-%{pprefver}.tar.gz
Source10:      pbbuttonsd.init
Patch100:      powerprefs-0.4.2-pbb055.patch
BuildRoot:     %{_tmppath}/%{name}-%{version}-root
Obsoletes:     pbbuttons
BuildRequires: SysVinit >= 2.85, gtk2-devel
Vendor:        Project Vine
Distribution:  Vine Linux
Packager:      MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>


%description
PBButtons is a program which make the special hotkeys of an Apple iBook,
PowerBook or TiBook (or recent PowerMacs' keyboards) working as expected.
With this program the keys for the display brightness, the volume of
speaker and headphone, the mute key and the eject key will do their jobs
as expected.


%description -l ja
PBButtons は Apple iBook, PowerBook, TiBook (或いは最近の PowerMac) の
キーボードの「ホットキー」を期待どおりに動作させるためのものです．
このプログラムを使うと，ディスプレイ照度調節，スピーカーの音量調節，
ミュート，CD-ROM のイジェクトといったホットキーを使用する事が出来ます．


%prep
%setup -q -a 1

pushd powerprefs-%{pprefver}
cp ../libpbbipc/*.h src/
#%patch100 -p1
popd

%build
%configure
make

pushd powerprefs-%{pprefver}
%configure
perl -pi -e 's/#define HAVE_OLDLIBPBB 1//g' config.h
make LIBS="-L%{_builddir}/%{name}-%{version}/libpbbipc -lpbb"
popd

%install
[ -n "${RPM_BUILD_ROOT}" -a "${RPM_BUILD_ROOT}" != / ] \
    && rm -rf ${RPM_BUILD_ROOT}

mkdir -p ${RPM_BUILD_ROOT}/etc/power

%makeinstall

pushd powerprefs-%{pprefver}
%makeinstall
popd

mkdir -p ${RPM_BUILD_ROOT}%{_initdir}
install -m 755 %{SOURCE10} \
    ${RPM_BUILD_ROOT}%{_initdir}/pbbuttonsd

# XXX Fix me
rm -f ${RPM_BUILD_ROOT}/etc/pbbuttonsd.conf
cp pbbuttonsd.conf ${RPM_BUILD_ROOT}/etc/pbbuttonsd.conf

%find_lang %{name}


%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}


%post
/sbin/chkconfig --add pbbuttonsd

if [ -f /var/lock/subsys/pbbuttonsd ] ; then
    %{_initdir}/pbbuttonsd restart
fi


%preun
if [ $1 = 0 ] ; then
   /sbin/chkconfig --del pbbuttonsd

   if [ -f /var/lock/subsys/pbbuttonsd ] ; then
       %{_initdir}/pbbuttonsd stop
   fi
fi


%triggerpostun -- pbbuttons
/sbin/chkconfig --add pbbuttonsd


%triggerpostun -- pbbuttonsd < 0.5.3-0vl1
/sbin/chkconfig --add pbbuttonsd


%files -f %{name}.lang
%defattr(-, root, root)
%doc ABOUT-NLS AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README TODO
%config %{_initdir}/pbbuttonsd
%config %{_sysconfdir}/pbbuttonsd.conf
%{_sysconfdir}/power/*
%{_bindir}/*
%{_datadir}/powerprefs/*
%{_libdir}/*
%{_includedir}/*
%{_mandir}/*/*


%changelog
* Wed Feb 04 2004 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.5.8-0vl1
- updated to pbbuttonsd-0.5.8 and powerprefs-0.4.3

* Wed Dec 10 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 0.5.6-1vl2
- rebuild with kernel-2.4.23-0vl1

* Mon Nov 17 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 0.5.6-0vl1
- source update

* Mon Nov 10 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 0.5.5-0vl1
- source update
- added BuildRequires section
- added powerprefs

* Mon Mar 24 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 0.5.3-0vl1
- source update

* Sun Mar 17 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.4.2a-0vl3
- modified init script to match 0.4.2a's pbbuttonsd retval
  (now non-error returns 0, as expected)

* Fri Mar 15 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.4.2a-0vl2
- modified %preun, added %triggerpostun

* Mon Mar 11 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.4.2a-0vl1
- updated to the upstream bugfix release

* Fri Mar 08 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.4.2-0vl1
- updated to the new upstream release
- now pbbuttonsd and gtkpbbuttons are in separated package (as expected)

* Mon Mar 04 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.4-0vl1
- updated in sync with the new upstream release
- added init script

* Mon Mar 04 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.3.3-0vl2
- added xinit script

* Tue Feb 26 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.3.3-0vl1
- initial rpm package for Vine Linux
