%define name	spicctrl
%define version	1.8
%define release	1%{?_dist_release}

Summary:	Sony Vaio SPIC Control Program
Summary(ja):	Sony Vaio ノート用ユーティリティ
Name:		%{name}
Version:	%{version}
Release:	%{release}
Source0:	http://popies.net/sonypi/%{name}-%{version}.tar.bz2
License:	GPL
Group:		Applications/System
URL:		http://popies.net/sonypi/

BuildRoot: %{_tmppath}/%{name}-%{version}-root


%description
This utility allows one to query and set a variety of parameters on your
Sony Vaio laptop computer, including:

 * AC Power status
 * Battery status 
 * Screen brightness
 * Bluetooth device power status

%description -l ja
このユーティリティにより Sony Vaio ノートの以下の情報を取得/設定
することができます。
 * AC電源の状態
 * バッテリーの状態
 * 画面の輝度
 * ブルートゥースデバイスの状態


%prep

%setup

%build
%__make


%install
%__rm -rf ${RPM_BUILD_ROOT}
%__install -d ${RPM_BUILD_ROOT}/%{_sbindir}
%__install -m755 %{_builddir}/%{name}-%{version}/spicctrl ${RPM_BUILD_ROOT}/%{_sbindir}
%__install -d ${RPM_BUILD_ROOT}/%{_mandir}/man1
%__install -m644 %{_builddir}/%{name}-%{version}/spicctrl.1 ${RPM_BUILD_ROOT}/%{_mandir}/man1/


%clean
%__rm -rf ${RPM_BUILD_ROOT}


%post
if [ ! -c /dev/sonypi ]; then
	rm -f /dev/sonypi
	mknod /dev/sonypi c 10 250
fi
if [ -e /etc/modules.conf ]; then
	grep 'alias char-major-10-250 sonypi' /etc/modules.conf > /dev/null
	RETVAL=$?
	if [ $RETVAL -ne 0 ]; then
		echo 'alias char-major-10-250 sonypi' >> /etc/modules.conf
		echo 'options sonypi minor=250' >> /etc/modules.conf
	fi
fi
if [ -e /etc/modprobe.conf ]; then
	grep 'alias char-major-10-250 sonypi' /etc/modprobe.conf > /dev/null
	RETVAL=$?
	if [ $RETVAL -ne 0 ]; then
		echo 'alias char-major-10-250 sonypi' >> /etc/modprobe.conf
		echo 'options sonypi minor=250' >> /etc/modprobe.conf
	fi
fi

if [ -e /etc/security/console.perms ]; then
    if ! grep -q '<sonypi>=/dev/sonypi' /etc/security/console.perms; then
        echo -e '\n# following 2 lines are added by spicctrl package.' >> /etc/security/console.perms
        echo '<sonypi>=/dev/sonypi' >> /etc/security/console.perms
        echo '<console>  0600 <sonypi>     0600 root' >> /etc/security/console.perms
    fi
fi


%files
%defattr(-,root,root)
%doc AUTHORS LICENSE CHANGES
%{_sbindir}/spicctrl
%{_mandir}/man1/spicctrl.1*

%changelog
* Sat Oct 11 2008 Shu KONNO <owa@bg.wakwak.com> 1.8-1vl5
- applied new versioning policy, spec in utf-8

* Sun Apr 17 2005 Kazutaka HAHARA <kazutaka@dc4.so-net.ne.jp> 1.8-0vl3
- allow console user to access sonypi device.(by console.perms)

* Sun Apr 03 2005 Kazutaka HAHARA <kazutaka@dc4.so-net.ne.jp> 1.8-0vl0
- build for Vine Plus.

* Wed Mar 30 2005 Kazutaka HAHARA <kazutaka@dc4.so-net.ne.jp> 1.8-0vl1
- initial build for VineSeed Plus.
