%define  _mandir		%{_datadir}/man

Summary:      A set of documentation tools:  man, apropos and whatis.
Summary(ja):  ドキュメンテーション・ツール: man, apropos, whatis

Name:         man
Version:      1.5o
Release:      7%{?_dist_release}

Group:        System Environment/Base
License:      GPLv2

Source0:      http://www.kernel.org/pub/linux/utils/man/man-%{version}.tar.bz2
Source1:      makewhatis.cronweekly
Source2:      makewhatis.crondaily
Patch1:       man-1.5m2-confpath.patch
Patch5:       man-1.5i-nonascii.patch
Patch6:       man-1.5m2-security.patch
Patch7:       man-1.5m2-mandirs.patch
Patch8:       man-1.5h1-bug11621.patch
Patch9:       man-1.5m2-sofix.patch
Patch10:      man-1.5m2-buildroot.patch
Patch12:      man-1.5m2-ro-usr.patch
Patch15:      man-1.5h1-lookon.patch
Patch17:      man-1.5m2-utf8.patch

# Vine Source(s)/Patch(es)
Patch101:     man-1.5h1-gencat.patch
Patch106:     man-man2html_aux_path.patch
Patch107:     man-1.5m2-hman-use-w3m.patch
Patch108:     man-1.5m2-no-mansearch.patch
Patch110:     man-1.5o-tmpcache.patch
Patch120:     man-1.5o-convert-manpage-to-utf8.patch
Patch130:     man-1.5o-utf8-msgs.patch
Patch140:     man-1.5o-utf8-makewhatis.patch
Patch141:     man-1.5o-man1man.patch

Buildroot:    %{_tmppath}/%{name}-%{version}-root
BuildRequires: bzip2
BuildRequires: gzip
Requires:      bzip2
Requires:      coreutils
Requires:      findutils
Requires:      gawk
Requires:      grep
Requires:      groff
Requires:      gzip
Requires:      nkf
# pager
%if %{?_dist_release} == "vl5"
Requires:      lv
%else
Requires:      less
%endif
Requires(post): coreutils

Vendor:       Project Vine
Distribution: Vine Linux
Packager:     shaolin, daisuke


%description
The man package includes three tools for finding information and/or
documentation about your Linux system: man, apropos and whatis.  The
man system formats and displays on-line manual pages about commands or
functions on your system.  Apropos searches the whatis database
(containing short descriptions of system commands) for a string.
Whatis searches its own database for a complete word.

The man package should be installed on your system because it is the
primary way to find documentation on a Linux system.

%description -l ja
マニュアルページを表示するためのプログラム man の日本語対応版です．
日本語対応の groff パッケージが必要です．特定のキーワードに関連する文書
を探すための whatis や apropos も含んでいます．
環境変数 LANG=ja_JP.* の時には、

    1.JMANプロジェクトまたはオリジナルソースに付随する日本語マニュアル
    2.オリジナル・ソースに付随する英語マニュアル

という順でマニュアルの検索がなされます．英語マニュアルを見る場合は、
LANG=C man などとして利用してください．

%package -n man2html
Summary:	manroff to HTML converter
Summary(ja):	manroff から HTML への変換器
Group:		Applications/System
Requires:	%{name} = %{version}-%{release}

%description -n man2html
This package contains manroff to HTML converter.

%description -n man2html -l ja
このパッケージには、manroff から HTML へのコンバータが含まれています．

%prep
%setup -q
%patch1 -p1 -b .confpath
%patch6 -p1 -b .security
%patch7 -p1 -b .mandirs
%patch9 -p1 -b .sofix
%patch10 -p1 -b .less
%patch12 -p1 -b .usr

%patch101 -p1

%patch17 -p1 -b .utf8

%patch106 -p1 -b .aux
%patch107 -p1 -b .w3m
%if ! 0%{?mansearch}
%patch108 -p1 -b .search
%endif
%patch110 -p1 -b .tmpcache
%patch120 -p1 -b .convert-man-to-utf8
%patch130 -p1 -b .utf8-msgs
%patch140 -p1 -b .utf8-makewhatis
%patch141 -p1 -b .man1

pushd msgs
%__mv mess.ja mess.ja_JP.eucJP
%__mv mess.ja.codeset mess.ja_JP.eucJP.codeset
iconv -f euc-jp -t utf-8 mess.ja_JP.eucJP > mess.ja
echo "$ codeset=utf-8" > mess.ja.codeset
popd

%build
./configure -default +fhs +lang en,ja,ja_JP.eucJP -confdir %{_sysconfdir}
make CC="gcc $RPM_OPT_FLAGS -D_GNU_SOURCE"

pushd src
mv man.conf man.conf.orig
%if %{?_dist_release} == "vl5"
sed -e 's/less -is/lv -c/g' man.conf.orig > man.conf
%else
sed -e 's/less -is/less -isMr/g' man.conf.orig > man.conf
%endif
popd

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.{daily,weekly}
make install PREFIX=$RPM_BUILD_ROOT
%__mv $RPM_BUILD_ROOT%{_mandir}/man5/man.conf.5 $RPM_BUILD_ROOT%{_mandir}/man5/man.config.5
%__mv $RPM_BUILD_ROOT%{_mandir}/ja/man5/man.conf.5 $RPM_BUILD_ROOT%{_mandir}/ja/man5/man.config.5

install -m755 %{_sourcedir}/makewhatis.cronweekly $RPM_BUILD_ROOT%{_sysconfdir}/cron.weekly/makewhatis.cron
install -m755 %{_sourcedir}/makewhatis.crondaily $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/makewhatis.cron

mkdir -p $RPM_BUILD_ROOT/var/cache
mkdir -p $RPM_BUILD_ROOT/var/cache/man/local
mkdir -p $RPM_BUILD_ROOT/var/cache/man/X11R6

mkdir -p $RPM_BUILD_ROOT/var/cache/ja
mkdir -p $RPM_BUILD_ROOT/var/cache/man/local/ja
mkdir -p $RPM_BUILD_ROOT/var/cache/man/X11R6/ja
for i in 1 2 3 4 5 6 7 8 9 n; do
	mkdir -p $RPM_BUILD_ROOT/var/cache/man/cat$i
	mkdir -p $RPM_BUILD_ROOT/var/cache/man/local/cat$i
	mkdir -p $RPM_BUILD_ROOT/var/cache/man/X11R6/cat$i

	mkdir -p $RPM_BUILD_ROOT/var/cache/man/ja/cat$i
	mkdir -p $RPM_BUILD_ROOT/var/cache/man/local/ja/cat$i
	mkdir -p $RPM_BUILD_ROOT/var/cache/man/X11R6/ja/cat$i
done

# added man2html stuff
cd man2html
make install PREFIX=$RPM_BUILD_ROOT

# symlinks for manpath
( cd $RPM_BUILD_ROOT
  ln -s man ./usr/bin/manpath
  ln -s man.1.gz .%{_mandir}/man1/manpath.1.gz
  ln -s man.1.gz .%{_mandir}/ja/man1/manpath.1.gz
)

# symlinks for compatibility
ln -s man $RPM_BUILD_ROOT/usr/bin/jman

%preun
# Clean up accumulated cat litter.
rm -f /var/cache/man/cat[123456789n]/*
rm -f /var/cache/man/local/cat[123456789n]/*
rm -f /var/cache/man/X11R6/cat[123456789n]/*

rm -f /var/cache/man/ja/cat[123456789n]/*
rm -f /var/cache/man/local/ja/cat[123456789n]/*
rm -f /var/cache/man/X11R6/ja/cat[123456789n]/*


%post
rm -f /var/cache/man/cat[123456789n]/*
rm -f /var/cache/man/local/cat[123456789n]/*
rm -f /var/cache/man/X11R6/cat[123456789n]/*

rm -f /var/cache/man/ja/cat[123456789n]/*
rm -f /var/cache/man/local/ja/cat[123456789n]/*
rm -f /var/cache/man/X11R6/ja/cat[123456789n]/*


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%doc README* COPYING HISTORY INSTALL LSM TODO
%config(noreplace) %{_sysconfdir}/cron.weekly/makewhatis.cron
%config(noreplace) %{_sysconfdir}/cron.daily/makewhatis.cron
%attr(2755,root,man)	/usr/bin/man
/usr/bin/jman
/usr/bin/manpath
/usr/bin/apropos
/usr/bin/whatis
/usr/sbin/makewhatis
%config(noreplace) %{_sysconfdir}/man.config
#%config(noreplace) %{_sysconfdir}/man-j.config
%{_mandir}/man1/man.1*
%{_mandir}/man1/manpath.1*
%{_mandir}/man1/apropos.1*
%{_mandir}/man1/whatis.1*
%{_mandir}/man5/man.config.5*
%{_mandir}/man8/makewhatis.8*
%{_mandir}/ja/man1/man.1*
%{_mandir}/ja/man1/manpath.1*
%{_mandir}/ja/man1/apropos.1*
%{_mandir}/ja/man1/whatis.1*
%{_mandir}/ja/man5/man.config.5*

/usr/share/locale/*/man

%attr(0775,root,man)	%dir /var/cache/man
%attr(0775,root,man)	%dir /var/cache/man/cat[123456789n]
%attr(0775,root,man)	%dir /var/cache/man/local
%attr(0775,root,man)	%dir /var/cache/man/local/cat[123456789n]
%attr(0775,root,man)	%dir /var/cache/man/X11R6
%attr(0775,root,man)	%dir /var/cache/man/X11R6/cat[123456789n]

%attr(0775,root,man)	%dir /var/cache/man/ja
%attr(0775,root,man)	%dir /var/cache/man/ja/cat[123456789n]
%attr(0775,root,man)	%dir /var/cache/man/local/ja
%attr(0775,root,man)	%dir /var/cache/man/local/ja/cat[123456789n]
%attr(0775,root,man)	%dir /var/cache/man/X11R6/ja
%attr(0775,root,man)	%dir /var/cache/man/X11R6/ja/cat[123456789n]

%files -n man2html
%defattr(-,root,root)
%doc man2html/README man2html/TODO
/usr/bin/man2html
%{_mandir}/man1/man2html.1*

%if 0%{?mansearch}
/home/httpd/cgi-bin/man/mansearch
/home/httpd/cgi-bin/man/mansearchhelp
%{_datadir}/man2html/mansearch.aux
%{_datadir}/man2html/mansearchhelp.aux
/var/man2html/.glimpse_filters
%endif

%changelog
* Fri Apr 22 2011 IWAI, Masaharu <iwai@alib.jp> 1.5o-7
- add man(1) patch: fix <BTS:VineLinux:824>

* Sun Sep 26 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.5o-6
- added Patch140 to convert /var/cache/man/whatis encodings to UTF-8 <BTS:846>
- added Requires: gawk, grep (used at apropos, makewhatis)

* Fri Sep 24 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.5o-5
- used less as pager again
- fixed SOURCE1, 2 <BTS:846>

* Sun Aug 16 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5o-4
- remove Patch120(run-groff-in-eucjp)
- add new Patch120 to convert manpage to utf8 before formatting.
- add Requires: nkf

* Wed Jul 29 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5o-3
- remove jman and man-j.config

* Mon Apr 13 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5o-2
- spec in utf-8
- drop man2html cgi script

* Sat May 10 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5o-1
- add Patch120 to run groff in eucJP locale if current locale
  is eucJP or not.
- add Patch130 to add utf8 messages
- use lv as pager
- add lv to Requires, remove less.

* Sun Dec  2 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.5o-0vl5
- update man[-j].config (using -r option instead of -R on less)

* Sun Sep 23 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.5o-0vl4
- update man[-j].config (less option @ PAGER)

* Wed Dec 20 2006 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 1.5o-0vl3
- update makewhatis.cronweekly: always use -w option. <BTS:VineLinux:336>

* Sat Dec 16 2006 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 1.5o-0vl2
- update Source1 & 2: set LANG variable for makewhatis. <BTS:VineLinux:336>
- add patch110 to make makewhatis -u works correctly. <BTS:VineLinux:336>

* Mon Aug 30 2004 NISHIMURA Daisuke <nishi@graco.c.u-tokyo.ac.jp> 1.5o-0vl1
- update to 1.5o
- remove patches reflected in base: 105(mansec-loop), 109(man-ja-typo).
- remove patch104(msgs): resolved by adding codeset to gencat.

* Fri Jun 18 2004 NISHIMURA Daisuke <nishi@graco.c.u-tokyo.ac.jp> 1.5m2-0vl2
- separate man2html package for man2html and CGI scripts,
  and make it depends on apache.
- change owner of /var/man2html from nobody to apache
- Patch107: hman use w3m by default
- Patch108: remove mansearch CGI because it does not work without glimpse
- Patch106: move cgi-aux directory to %{_datadir}/man2html (from PLD Linux)
- Patch105: fix a fatal bug in mansec CGI
- Patch109: fix typo in Japanese man.1 man page
- re-enable Patch17(utf) not to output latin-1 to euc-jp terminal
- add Japanese manpath.1 man page
- add docs
- add dependencies to bzip2 and gzip

* Wed May 26 2004 NISHIMURA Daisuke <nishi@graco.c.u-tokyo.ac.jp> 1.5m2-0vl1
- update to 1.5m2
- remove patches reflected in base:
  2(i18n) 14(newline) 18(root) 19(overflow)
  20(quote) 21(fixcache) 22(nocache) 100(ja)
- default config change to create cache
- makewhatis now does not read Japanese man pages by default
- noreplace config files
- drop Patch5(nonascii): grep -a is not needed for most non-ASCII text
- drop Patch8(bug11621): less -r is not needed and rather dangerous
- drop Patch15(lookon): incorporated but disabled because of its disadvantage
- drop Patch17(utf8) and Patch103(configure.nroff): they canceled each other
- modify patches (1,6,7,9,10,12) to apply to 1.5m2
- rename man page of man.config by mv, not patch(3,4)
- give owner/group of buildroot/var/man2html as parameters instead of patch102
- gencat now requires LC_CTYPE is set properly
- add Patch104(msgs): only make catalogs of specified languages

* Mon Dec 31 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.5i-0vl5
- Oh my /usr/share/locale/{en,ja}/man were missing. Fixed.

* Thu Oct 18 2001 Jun Nishii <jun@vinelinux.org> 1.5i-0vl4
- added PATH in makewhatis.cron*

* Mon Sep 03 2001 Toru Sagami <sagami@vinelinux.org>
- 1.5i-0vl3: fix grammatical error in makewhatis

* Sat Sep  1 2001 Jun Nishii <jun@vinelinux.org>
- build for VineSeed

* Sat Sep  1 2001 Jun Nishii <jun@vinelinux.org> 1.5i-0vl1
- follow up with rawhide for security fix

* Thu Jul 19 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- added makewhatis (8) man.
- modified security patch for cache path.

* Wed Jul 13 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- renew SPEC from rawhide.
- removed /home/httpd/cgi-{bin|aux}/man* from %files that does not exist.
- modified ja patch to recognize "/jman/" dir as Japanese manual.
- remove unnecessary SGID from jman command.

* Mon Jun 12 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- gzip the man pages manually - since file doesn't recognize them as
  man pages, the build root policy doesn't do it (Bug #12015)

* Tue May 16 2000 Preston Brown <pbrown@redhat.com>
- default man path is now /usr/share/man.  /usr/man maintained for compat.
- remove +sgid option to allow builds as a normal user.  SPEC file maintains
  proper permissions.

* Tue May  9 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- modified man-ja patch to fix my stupid mistake of makewhatis.sh.

* Tue Apr 18 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- modified jman-vine.sh to set ja_JP.eucJP locale.

* Tue Apr 18 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- updated to 1.5h1
- modified man-j.config to sync with man-1.5h1 default.
- renew SPEC from RH6.2

* Wed Mar  3 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Add kerberos man paths to man.config (Bug #11168 + extra fixes)

* Tue Feb 29 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 1.5h1 - this has a better fix for the security problems.
- remove manpath patch (now in base)
- remove loop patch (now in base)

* Mon Feb 28 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Fix security problems related to buffer overruns caused by oversized
  enviroment variables

* Thu Feb  3 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- deal with rpm gziping man pages
- fix file locking (Bug #8947)

* Thu Dec 23 1999 Yasuyuki Furukawa <furukawa@vinelinux.org>
- replace jman script to keep orignal man binary.
- renew man-ja patch

* Fri Nov 12 1999 Jun Nishii <jun@flatout.org>
- ported for Vine Linux

* Mon Sep 13 1999 Bill Nottingham <notting@redhat.com>
- strip man2html

* Fri Sep 10 1999 Cristian Gafton <gafton@redhat.com>
- revert to latin1 instead of ascii

* Wed Jun 16 1999 Cristian Gafton <gafton@redhat.com>
- fixed man2html loop on terminfo.5 (patrch from the author; #3316)

* Mon May 10 1999 Michael K. Johnson <johnsonm@redhat.com>
- fixed #2532 by adding /usr/local/sbin as a MANPATH_MAP

* Fri Apr 09 1999 Michael K. Johnson <johnsonm@redhat.com>
- cron.weekly rebuilds, cron.daily updates in minimal time

* Fri Apr 09 1999 Preston Brown <pbrown@redhat.com>
- man 1.5g bugfix release

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 5)

* Thu Feb 18 1999 Jeff Johnson <jbj@redhat.com>
- add manpath symlinks (#1138).

* Fri Feb 12 1999 Michael Maher <mike@redhat.com>
- fixed bug #792
- added man2html files

* Tue Dec 29 1998 Cristian Gafton <gafton@redhat.com>
- build for 6.0
- upgraded to 1.5e
- properly buildrooted

* Thu Aug 13 1998 Jeff Johnson <jbj@redhat.com>
- enable fsstnd organization
- change /var/catman/X11 to X11R6
- %post/%preun to clean up cat litter

* Tue Jun 02 1998 Prospector System <bugs@redhat.com>
- translations modified for de

* Tue Jun 02 1998 Erik Troan <ewt@redhat.com>
- you can't do free(malloc(10) + 4) <sigh>

* Wed May 06 1998 Cristian Gafton <gafton@redhat.com>
- upgraded to 1.5d

* Fri Apr 24 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Fri Apr 10 1998 Cristian Gafton <gafton@redhat.com>
- updated to 1.5a

* Sun Oct 19 1997 Erik Troan <ewt@redhat.com>
- uses a build root

* Mon Sep 22 1997 Erik Troan <ewt@redhat.com>
- updated to man-1.4j, which fixes some security problems; release 1 is
  for RH 4.2, release 2 is for glibc
 
* Mon Jun 02 1997 Erik Troan <ewt@redhat.com>
- built against glibc

* Tue Mar 25 1997 Erik Troan <ewt@redhat.com>
- Added /usr/lib/perl5/man to default manpath
