%define ruby     /usr/bin/ruby
%define rlibdir  %(%{ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]')

Summary: Ruby based WEB Application server
Name: walrus
Version: 0.8.1
Release: 1%{?_dist_release}
License: GPL
Group: Development/Languages
Source0: http://www.brain-tokyo.jp/~research/koutetu/walrus/%{name}-%{version}.tar.gz
Patch0: walrus-0.8.1-ruby186.diff
URL: http://www.brain-tokyo.jp/~research/koutetu/
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: ruby ruby-devel
Requires: ruby >= 1.8.1, obaq >= 0.6.1-0vl3

%description
Walrus provides some features:
  * template
  * contents generation helper
  * application server

%prep

%setup -q -c
pushd %{name}-%{version}
%patch0 -p0
popd

[ -d tmp ] && rm -rf tmp
mkdir tmp
tar cf - %{name}-%{version} | (cd tmp && tar xf -)

cd tmp/%{name}-%{version}
for f in `find sample -type f`
do
  sed -e '1s/^#!.*//' < $f > $f.tmp; \
  mv -f $f.tmp $f; \
done
rm -f lib/walrus/walrusver.rb walrusmain.rb
cd ../..

%build

%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}%{rlibdir}

# installing binaries ...
cd tmp/%{name}-%{version}
make install \
  WALRUS_CURRENT_VER=%{version} \
  PREFIX=${RPM_BUILD_ROOT}%{_prefix} \
  SITE_DIR=${RPM_BUILD_ROOT}%{rlibdir}
cd ../..

%clean
rm -rf ${RPM_BUILD_ROOT}
rm -rf tmp

%files
%defattr(-, root, root)
%{_bindir}/walrus
%{rlibdir}/walrus/*.rb
%doc tmp/%{name}-%{version}/ChangeLog
%doc tmp/%{name}-%{version}/README
%doc tmp/%{name}-%{version}/manual
%doc tmp/%{name}-%{version}/test
%doc tmp/%{name}-%{version}/sample

%changelog
* Tue Oct 14 2008 Shu KONNO <owa@bg.wakwak.com> 0.8.1-1vl5
- applied new versioning policy

* Sun Apr 01 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 0.8.1-0vl3
- add patch0 to support ruby-1.8.6

* Sun Feb 15 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 0.8.1-0vl2
- rebuild on ruby 1.8.1

* Sun Jun 16 2002 akira yamada <akira@vinelinux.org> 0.8.1-0vl1
- Initial packaging.
