%bcond_with check

%global cache /var/cache/man

# Basic Information
Name:		man-db
Version:	2.8.5
Release:	2%{?_dist_release}
License:	GPL
Group:		System Environment/Base
Source0:        http://download.savannah.gnu.org/releases/%{name}/%{name}-%{version}.tar.xz
Source1:	man-db.crondaily
Source2:	man-db.sysconfig
Patch0: man-db-2.8.3-change-owner-of-man-cache.patch
# http://lists.nongnu.org/archive/html/man-db-devel/2017-01/msg00013.html
Patch1: man-db-2.7.6.1-fix-override-dir-handling.patch

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

Vendor:		Project Vine
Distribution:	Vine Linux
Packager:	yasumichi

Summary:	the man-db manual pager suite
Summary(ja):	man-dbマニュアルページャスイート

# Dependency
Requires:     	groff >= 1.20.1
BuildRequires:	groff >= 1.20.1
Requires:	gdbm
BuildRequires:	gdbm-devel
BuildRequires:	libpipeline-devel >= 1.1.0
BuildRequires:	zlib-devel
BuildRequires:  po4a

Obsoletes:	man
Provides:	man

%description
This package provides the man command. This utility is the primary way of
examining the on-line help files (manual pages). Other utilities provided
include the whatis and apropos commands for searching the manual page
database, the manpath utility for determining the manual page search path,
and the maintenance utilities mandb, catman, and zsoelim. This package uses
the groff suite of programs to format and display the manual pages. 

%description -l ja
このパッケージは、man コマンドを提供します。このユーティリティの主な用途は
ヘルプファイル(マニュアルページ)を調べることです。他のユーティリティとして
マニュアルページデータベースを検索するための whatis と apropos コマンド、
マニュアルページの検索パスを決定する manpath ユーティリティ、および
メンテナンスユーティリティである mandb、catman および zsoelim を提供します。
このパッケージは、マニュアルページを整形および表示するために groff プログラム
スイートを利用しています。

%prep
%autosetup -p1

%build
%configure \
	--disable-setuid --disable-cache-owner \
	--with-browser=elinks --with-lzip=lzip \
	--with-override-dir=overrides

%{__make} %{?_smp_mflags}

%install
%{__rm} -rf ${RPM_BUILD_ROOT}
make install DESTDIR=$RPM_BUILD_ROOT prefix=%{_prefix} INSTALL='install -p'

# move the documentation to the relevant place
mv $RPM_BUILD_ROOT%{_datadir}/doc/man-db/* ./

# remove zsoelim man page - part of groff package
rm $RPM_BUILD_ROOT%{_datadir}/man/man1/zsoelim.1

# remove libtool archives
rm $RPM_BUILD_ROOT%{_libdir}/man-db/*.la

# install cron script for man-db creation/update
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily
install -D -p -m 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/man-db.cron

# config for cron script
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
install -D -p -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/man-db

# install cache directory
install -d -m 0755  $RPM_BUILD_ROOT%{cache}

%find_lang %{name}
%find_lang %{name}-gnulib

# drop files for systemd
rm -rf %{buildroot}/lib/systemd
rm -rf %{buildroot}%{_prefix}/lib/tmpfiles.d

%if %{with check}
%check
make check
%endif

%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

# clear the old cache
%post
%{__rm} -rf %{cache}/*

%files -f %{name}.lang -f %{name}-gnulib.lang
%defattr(-,root,root)
%doc ChangeLog NEWS README
%config(noreplace) %{_sysconfdir}/man_db.conf
%config(noreplace) %{_sysconfdir}/sysconfig/man-db
%{_sysconfdir}/cron.daily/man-db.cron
%{_bindir}/apropos
%{_bindir}/catman
%{_bindir}/lexgrog
%{_bindir}/man
%{_bindir}/mandb
%{_bindir}/manpath
%{_bindir}/whatis
%{_libdir}/man-db
%{_libexecdir}/man-db
%{_sbindir}/accessdb
%{_defaultdocdir}/man-db
%attr(0755,root,root)   %dir %{cache}
%lang(da) %{_mandir}/da/man*/*
%lang(de) %{_mandir}/de/man*/*
%lang(es) %{_mandir}/es/man*/*
%lang(fr) %{_mandir}/fr/man*/*
%lang(id) %{_mandir}/id/man*/*
%lang(it) %{_mandir}/it/man*/*
%lang(ja) %{_mandir}/ja/man*/*
%lang(nl) %{_mandir}/nl/man*/*
%lang(pl) %{_mandir}/pl/man*/*
%lang(pt) %{_mandir}/pt/man*/*
%lang(pt_BR) %{_mandir}/pt_BR/man*/*
%lang(ru) %{_mandir}/ru/man*/*
%lang(sr) %{_mandir}/sr/man*/*
%lang(sv) %{_mandir}/sv/man*/*
%lang(tr) %{_mandir}/tr/man*/*
%lang(zh_CN) %{_mandir}/zh_CN/man*/*
%{_mandir}/man1/apropos.1.*
%{_mandir}/man1/lexgrog.1.*
%{_mandir}/man1/man.1.*
%{_mandir}/man1/manconv.1.*
%{_mandir}/man1/manpath.1.*
%{_mandir}/man1/whatis.1.*
%{_mandir}/man5/manpath.5.*
%{_mandir}/man8/accessdb.8.*
%{_mandir}/man8/catman.8.*
%{_mandir}/man8/mandb.8.*


%changelog
* Wed May 15 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.8.5-2
- fixed options for configure.
- imported Patch1 and 1 from rawhide.

* Mon May 13 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.8.5-1
- new upstream release.
- added BR:zlib-devel.

* Sat Jan 25 2014 Yasumichi Akahoshi <yasumichi@vinelinux.org> 2.6.6-1
- new upstream release

* Thu Nov 29 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 2.6.3-1
- new upstream release
- add BR: libpipeline-devel instead of libpipeline
- add BR: po4a

* Fri Sep 23 2011 Yasumichi Akahoshi <yasumichi@vinelinux.org> 2.6.0.2-1
- new upstream release.
- remove Patch0.

* Wed Mar 30 2011 Yasumichi Akahoshi <yasumichi@vinelinux.org> 2.5.9-1
- new upstream release.
- add Source1,Source2 and Patch0 from fedora.

* Tue Nov 16 2010 Yasumichi Akahoshi <yasumichi@vinelinux.org> 2.5.8-1
- initial build for Vine Linux