%global srcver 4.51
%global shortsrcver %(echo %{srcver} | sed -e 's/\\.//')
%global _configure ../configure

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

# from https://github.com/k-takata/lv-mod
Patch1: lv-mod-4.51.d.patch

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 -n lv%{shortsrcver}

%patch1 -p1
autoreconf -ivf

%build
pushd build
%configure
make %{_smp_mflags}
popd


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

# installing binaries ...
pushd build
%makeinstall
popd

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


%clean
rm -rf %{buildroot}
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)
%license GPL.txt
%doc README
%doc hello.sample
%doc hello.sample.gif
%doc index.html
%doc relnote.html
%{_libdir}/lv


%changelog
* Mon Mar 09 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.51.d-1
- added Patch1: from https://github.com/k-takata/lv-mod

* Sun Jan 26 2014 IWAI, Masaharu <iwaim.sub@gmail.com> 4.51.0-3
- rebuild with current VineSeed

* Tue Apr 05 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 4.51.0-2
- rebuild for Vine 6

* 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.
