%define major	4
%define	minor	51
%define	teeny	0

%if %{teeny}
%define srcname	%{name}%{major}%{minor}%{teeny}
%else
%define srcname	%{name}%{major}%{minor}
%endif

Summary: a powerful multilingual file viewer
Summary(ja): パワフルな多言語対応ファイルビュウワー
Name: lv
Version: %{major}.%{minor}.%{teeny}
Release: 1%{?_dist_release}
License: GPL
Group: Applications/Text
Source: http://www.ff.iij4u.or.jp/~nrt/freeware/%{srcname}.tar.gz
URL: http://www.ff.iij4u.or.jp/~nrt/lv/
BuildRoot: %{_tmppath}/%{name}-%{version}-root

Provides: pager
Requires(post,preun): alternatives
BuildRequires: ncurses-devel >= 5.6

Vendor: Project Vine
Distribution: Vine Linux

%description
lv is a powerful file viewer like less.  lv can decode and encode
multilingual streams through many coding systems: ISO-8859, ISO-2022,
EUC, SJIS, Big5, HZ, Unicode.  It recognizes multi-bytes patterns as
regular expressions, lv also provides multilingual grep.  In addition,
lv can recognize ANSI escape sequences for text devoration.

%description -l ja
lv は less に似たパワフルなファイルビュウワーです。lv は多言語文字列を
ISO-8859, ISO-2022, EUC, SJIS, Big5, HZ, Unicode といった様々な文字コー
ドにエンコード・デコードできます。また多バイト正規表現をサポートしてお
り、多言語 grep としての機能も備えています。さらに lv は ANSI エスケー
プシーケンスによるテキスト装飾を扱うこともできます。


%prep


%setup -q -c


%build
cd %{srcname}/build
../src/configure %{_target_platform} \
  --prefix=%{_prefix} \
  --exec-prefix=%{_exec_prefix} \
  --bindir=%{_bindir} \
  --sbindir=%{_sbindir} \
  --sysconfdir=%{_sysconfdir} \
  --datadir=%{_datadir} \
  --includedir=%{_includedir} \
  --libdir=%{_libdir} \
  --libexecdir=%{_libexecdir} \
  --localstatedir=%{_localstatedir} \
  --sharedstatedir=%{_sharedstatedir} \
  --mandir=%{_mandir} \
  --infodir=%{_infodir}
make
cd ../..


%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}%{_bindir}
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1

# installing binaries ...
cd %{srcname}/build
%makeinstall
cd ../..

# listing all files in drb-all.files
(find \
  $RPM_BUILD_ROOT%{_bindir} \
  $RPM_BUILD_ROOT%{_mandir} \
      -type f -o -type l) | 
 sort | sed -e "s,^$RPM_BUILD_ROOT,," \
            -e "s,\(/man/man./.*\)$,\1*," > lv-all.files


%clean
rm -rf ${RPM_BUILD_ROOT}
rm -f *.files


#%post -p /sbin/ldconfig -n lv
%post
%{_syssbindir}/update-alternatives --install %{_bindir}/pager pager %{_bindir}/lv 20

%preun
if [ "$1" = "0" ]; then
  %{_syssbindir}/update-alternatives --remove pager %{_bindir}/lv
fi

#%postun -p /sbin/ldconfig -n lv


%files -f lv-all.files
%defattr(-, root, root)
%doc %{srcname}/GPL.txt
%doc %{srcname}/README
%doc %{srcname}/hello.sample
%doc %{srcname}/hello.sample.gif
%doc %{srcname}/index.html
%doc %{srcname}/relnote.html
%{_libdir}/lv


%changelog
* Sun Aug 10 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 4.51.0-1
- new versioning policy
- build with ncurses-5.6

* Fri Apr 13 2007 KANEKO Seiji <giraffe@m2.pbc.ne.jp> 4.51.0-0vl6
- add Provides: pager
- add Requires(post,preun): alternatives

* Mon Apr 09 2007 KANEKO Seiji <giraffe@m2.pbc.ne.jp> 4.51.0-0vl5
- add update-alternatives: pager in %%post and %%preun scriptlet

* Tue Apr 20 2004 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 4.51.0-0vl4
- rebuild on VineSeed

* Tue Apr 20 2004 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 4.51.0-0vl3
- add (Build)Requires: libtermcap(-devel)
- add Vendor/Distribution tag
- add GPL.txt

* Wed Feb 11 2004 KAZUKI SHIMURA <rito@pos.to> 4.51.0-0vl2
- rebuild on VineSeed

* Wed Feb 11 2004 KAZUKI SHIMURA <rito@pos.to> 4.51.0-0vl1
- upstream release
- drop obsolete patch lv-Makefile.in.patch (Patch1)

* Sat Jan 10 2004 KAZUKI SHIMURA <rito@pos.to> 4.50.0-0vl1
- upstream release
- define %%{srcname}
- s/Copyright/License/

* Thu May 15 2003 IWAI Masaharu <iwai@alib.jp> 4.49.5-0vl2
- rebuild on VineSeed

* Thu May 15 2003 IWAI Masaharu <iwai@alib.jp> 4.49.5-0vl1
- SECURITY FIX - upstream release
   - fix CAN-2003-0188: possible local root exploit using config files

* Mon Mar 24 2003 IWAI Masaharu <iwai@alib.jp> 4.49.4-0vl4
- rebuild with new toolchain

* Fri Sep 20 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 4.49.4-0vl3
- URL was incorrect (http was hhttp)... Fixed the typo.

* Sun Jul 21 2002 IWAI Masaharu <iwai@alib.jp> 4.49.4-0vl2
- added the help file for executing with h option

* Wed Jan 10 2001 akira yamada <akira@vinelinux.org>
- Initial packaging.
