## -*- coding: utf-8-unix -*-
%define tex_destdir	%{_datadir}
%define texmf           %{_prefix}/share/texmf
%define texlive_src	%{tex_destdir}/texlive-sources
%define build_tex_destdir	%{buildroot}%{tex_destdir}
%define build_texmf     %{buildroot}%{texmf}
%define build_texlive_src	%{buildroot}%{tex_destdir}-sources

%define knjfonts	kanjifonts-3.1
%define jsclasses_ver	110510
%define jlisting_ver	0.2
%define bkmk2uni	convert-bkmk2uni

%define list_macros \
	jsclasses-%{jsclasses_ver} \
	jlisting-%{jlisting_ver}

## use some macros for %post, %posttrans
%define touch_run(%1)	%{expand:( %__mkdir_p /var/run/texlive; touch /var/run/texlive/run-%1; )
}
%define exec_upddeffont	[ -x %{_sbindir}/update-defaultfont ] && \\\
    %{_sbindir}/update-defaultfont 2> /dev/null
%define exec_texhash	[ -e /var/run/texlive/run-texhash ] && ( \\\
    [ -x %{_bindir}/texhash ] && \\\
    echo -n "    "; echo -n "Running texhash... "; \\\
    %{_bindir}/texhash 2> /dev/null; \\\
    echo "done." ) && %__rm -f /var/run/texlive/run-texhash;
%define exec_mtxrun	[ -e /var/run/texlive/run-mtxrun ] && ( \\\
    [ -x %{_bindir}/mtxrun ] && \\\
    echo -n "    "; echo -n "Running mtxrun... "; \\\
    export TEXMF=%{texmf}-dist TEXMFCNF=%{texmf}/web2c TEXMFCACHE=%{texmfsysvar}; \\\
    %{_bindir}/mtxrun --generate &> /dev/null; \\\
    echo "done." ) && %__rm -f /var/run/texlive/run-mtxrun; 
%define exec_fmtutil	[ -e /var/run/texlive/run-fmtutil ] && ( \\\
    [ -x %{_bindir}/fmtutil-sys ] && \\\
    echo -n "    "; echo -n "Running fmtutil-sys... "; \\\
    %{_bindir}/fmtutil-sys --all &> /dev/null; \\\
    echo "done." ) && %__rm -f /var/run/texlive/run-fmtutil; 
%define exec_updmap	[ -e /var/run/texlive/run-updmap ] && ( \\\
    [ -x %{_bindir}/updmap-sys ] && \\\
    echo -n "    "; echo -n "Running updmap-sys... "; \\\
    %{_bindir}/updmap-sys --nohash --quiet &> /dev/null; \\\
    echo "done." ) && %__rm -f /var/run/texlive/run-updmap; 

Summary:	A collection of useful macro packages for texlive package
Summary(ja):	texlive パッケージで使うマクロパッケージ集
Name:		texlive-macros
Version:	2012
Release:	1%{?_dist_release}
License:	distributable
Group:		Applications/Publishing

## Vine Linux
Source0:	%{knjfonts}.tar.bz2
Source1:	sample.tex

## jsclasses
Source10:	http://oku.edu.mie-u.ac.jp/~okumura/jsclasses/jsclasses-%{jsclasses_ver}.zip
Source11:	http://oku.edu.mie-u.ac.jp/~okumura/jsclasses/index.html

## jlisting
Source20:	http://prdownloads.sourceforge.jp/mytexpert/26068/jlisting.sty.bz2


Requires:	perl
Requires:	texlive-common = %{version}
BuildRequires:	texlive-common = %{version}
BuildRequires:	nkf unzip

Buildroot: %{_tmppath}/%{name}-%{version}-root
BuildArch: noarch

Obsoletes:	tetex-macros
Obsoletes:	pLaTeX2e_Macros

Distribution:	Vine Linux
Vendor:		Project Vine
Packager:	munepi


%description
A collection of useful macro packages for texlive package, including 
	kanjifonts-3.1 (for Ricoh Fonts/DynaLab Fonts and JIS font metric)
%{list_macros}

# This package contained a perl script 
#   http://www.rmatsumoto.org/tex-ps-pdf/convert-euc.txt

%description -l ja
texlive パッケージで使うマクロパッケージ集です。
以下のマクロを収録しています。
	kanjifonts-3.1 (Vine Linux 3.1R 付属のリコーフォント/ダイナフォントやJISフォントメトリックを使う)
%{list_macros}

# このパッケージには prosper, powerdot 用に 
# PDF ブックマークの文字化けを修正するための perl スクリプト
#   http://www.rmatsumoto.org/tex-ps-pdf/convert-euc.txt
# を同梱しています．

%prep
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && %__rm -rf $RPM_BUILD_ROOT
%setup -q -c -n %{name}-%{version}

%__mkdir_p jsclasses
(cd jsclasses
    %__mkdir_p jsclasses
    %__unzip -a -qq %{SOURCE10}
    %__cp -p %{SOURCE11} ./jsclasses/README.html
)

# get rid of unwanted files
find . -type d -name CVS | xargs -r %__rm -frv
find . -type f -name .cvsignore | xargs -r %__rm -fv

(cd jsclasses
    %__mkdir_p tmp
    for i in *.*; do nkf $i > tmp/$i; done
    %__mv tmp/* .
    %__rm -rf tmp
)


%build

(cd jsclasses
    for i in jsclasses okumacro okuverb morisawa; do 
	platex ${i}.dtx && platex ${i}.dtx || exit 1
    done
    for i in jsclasses okumacro okuverb; do 
	dvipdfmx $i || exit 1
    done
    %__cp *.dvi *.pdf jsclasses
)

%install
%__rm -rf %{buildroot}

%__mkdir_p %{build_texmf}/packages/

## install kanjifonts
%__mkdir_p %{build_texmf}/tex/platex/kanjifonts
%__mv %{knjfonts}/*.sty %{build_texmf}/tex/platex/kanjifonts
%__mv %{knjfonts}/*.def %{build_texmf}/tex/platex/kanjifonts

# nkf --utf8 %{SOURCE25} | \
#     sed -e "s@^#!/usr/local/bin/perl5 -w@#!/usr/bin/perl -w@" > \
#     %{buildroot}%{_bindir}/%{bkmk2uni}
# chmod 755 %{buildroot}%{_bindir}/%{bkmk2uni}

## install jsclasses
(cd jsclasses
    %__mkdir_p %{build_texmf}/tex/platex/jsclasses
    %__cp -fp *.dtx *.ins *.cls *.sty %{build_texmf}/tex/platex/jsclasses/
)

## install jlisting
%__mkdir_p %{build_texmf}/tex/latex/jlisting
%__install -m 644 %{SOURCE20} %{build_texmf}/tex/latex/jlisting/
bunzip2 %{build_texmf}/tex/latex/jlisting/jlisting.sty.bz2


%post
%touch_run texhash
exit 0

%postun
if [ "$1" = 0 ]; then
   %touch_run texhash
fi
exit 0

%posttrans
%{exec_texhash}
exit 0

%clean
%__rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%doc %{knjfonts}
%doc jsclasses/jsclasses
#%{_bindir}/%{bkmk2uni}
%{texmf}/tex/platex/kanjifonts/kanjifonts.sty
%{texmf}/tex/platex/kanjifonts/*.def
%{texmf}/tex/platex/jsclasses
%{texmf}/tex/latex/jlisting


%changelog
* Sat Nov 24 2012 Munehiro Yamamoto <munepi@vinelinux.org> 2012-1
- TeX Live 2012

* Thu Feb  9 2012 Munehiro Yamamoto <munepi@vinelinux.org> 2011-3
- move jlisting package to %%{texmf}/tex/latex/jlisting

* Thu Dec  1 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2011-2
- updated jsclasses to 110510
  - mistook to change %%jsclasses_ver at 2011-1

* Sun Nov 27 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2011-1
- TeX Live 2011
- updated jsclasses to 110510

* Fri Dec 31 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2009-3
- dropped BuildRequires: jvf
- for vl5, added Conflicts: tetex-macros

* Tue Aug 10 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2009-2
- removed %%{exec_updmap} in %%post and %%postun

* Tue May 17 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2009-1
- ported from tetex-macros-3.0-7
- TeX Live 2009

* Mon Oct 12 2009 Munehiro Yamamoto <munepi@vinelinux.org> 3.0-7
- added BuildRequires: unzip
- updated jsclasses to 090826
- updated pict2e to 0.2x

* Sun May 17 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 3.0-6
- dropped epsbox.sty, eclepsf.sty 
  (bacause there style files for platex209 are obsolete)

* Fri May 15 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 3.0-5
- added jlisting v0.2
- defined list_macros
  - used %%{list_macros} in %%description and %%description -l ja

* Thu May 14 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 3.0-4
- dropped convert-euc.txt

* Sat May 09 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 3.0-3
- updated prosper
  - added some contrib themes from CTAN
  - added prosper.cls v1.6 from CVS HEAD
  - added a perl script: convert-euc.txt
- added powerdot v1.3
  - added xkeyval v2.5d
- added beamer v3.07
  - added pgf v2.00
- added pict2e v0.2w

* Sat May 09 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 3.0-2
- updated jsclasses to 20090222
- updated jsclasses/index.html to 2009-02-22
- removed /usr/share/texmf/dvips/config/extmap/morisawa.map (See [BTS:524])

* Wed Sep 03 2008 Shu KONNO <owa@bg.wakwak.com> 3.0-1vl5
- applied new versioning policy, spec in utf-8

* Mon Oct 08 2007 KOBAYASHI Taizo <tkoba@vinelinux.org> 3.0-0vl3
- update jsclasses/index.html to 2006-11-06.

* Fri May 19 2006 KOBAYASHI Taizo <tkoba@vinelinux.org> 3.0-0vl2
- update jsclasses/index.html to 2006-02-12.

* Sun Nov 06 2005 KOBAYASHI Taizo <tkoba@vinelinux.org> 3.0-0vl1
- update jsclasses/index.html to 2005-10-26.

* Sat Jun 18 2005 KOBAYASHI Taizo <tkoba@vinelinux.org> 3.0-0vl0.1
- update jsclasses/index.html to 2005-4-30.
- added breqn

* Tue Jan 18 2005 KOBAYASHI Taizo <tkoba@vinelinux.org> 2.0-0vl7
- update jsclasses/index.html to 2004-12-29.

* Mon Jan 17 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0-0vl6
- add missing files in kanjifonts-3.0

* Sun Jan 16 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 2.0-0vl6
- update to kanjifonts.sty-3.0.

* Mon Nov 29 2004 KOBAYASHI Taizo <tkoba@vinelinux.org> 2.0-0vl4
- update jsclasses/index.html to 2004-11-03.

* Sat Oct 16 2004 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 2.0-0vl3
- update jsclasses/index.html to 2004-09-27.

* Sat Apr 17 2004 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 2.0-0vl2
- update jsclasses/index.html to 2004-02-25.
- added eclepsf.sty.
- removed epsf.sty (symlink to epsbox.sty).
- removed geometry, which is in tetex-2.0.

* Fri Apr 18 2003 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 2.0-0vl1
- update jsclasses/index.html to 2003-04-18.
- added morisawa.dvi.

* Fri Mar 14 2003 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 2.0-0t2
- update jsclasses/index.html to 2003-03-06

* Mon Feb  3 2003 Nobuyuki Tsuchimura <tutimura@nn.iij4u.or.jp> 2.0-0t1
- remove natbib, which is in tetex-2.0
- let version number same as tetex
- added Requires: tetex

* Sat Jan 18 2003 KAZUKI SHIMURA <rito@pos.to> 1.1-0vl9
- update jsclasses/index.html to 2003-01-16

* Mon Jan 13 2003 KAZUKI SHIMURA <rito@pos.to> 1.1-0vl8
- update jsclasses to 2003-01-05
- update index.html to 2003-01-12

* Thu Nov 28 2002 KAZUKI SHIMURA <rito@pos.to> 1.1-0vl7
- update jsclasses and index.html to 2002-11-27

* Sun Nov 03 2002 KAZUKI SHIMURA <rito@pos.to> 1.1-0vl6
- update jsclasses and index.html to 2002-11-01

* Thu Oct 17 2002 KAZUKI SHIMURA <rito@pos.to> 1.1-0vl5
- oops, packager was incorrect

* Mon Jul 15 2002 KAZUKI SHIMURA <rito@pos.to> 1.1-0vl4
- update jsclasses to 2002-06-29
- update index.html to 2002-07-03

* Sun Apr 28 2002 KAZUKI SHIMURA <rito@pos.to> 1.1-0vl3
- update jsclasses to 2002-04-21
- update index.html to 2002-04-09

* Tue Apr 16 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.1-0vl2
- added MORISAWA basic 5 fonts

* Mon Mar 25 2002 Jun Nishii <jun@vinelinux.org> 1.1-0vl1
- update to kanjifonts-1.1

* Thu Feb 07 2002 KAZUKI SHIMURA <rito@pos.to> 1.0-0vl11
- update jsclasses and index.html to 2002-02-07

* Tue Jan 31 2002 KAZUKI SHIMURA <rito@pos.to> 1.0-0vl10
- update jsclasses and index.html to 2002-01-27
- fix typo in changelog

* Fri Jan 25 2002 KAZUKI SHIMURA <rito@pos.to> 1.0-0vl9
- update jsclasses and index.html to 2002-01-18

* Tue Dec 18 2001 KAZUKI SHIMURA <rito@pos.to> 1.0-0vl8
- update index.html (jsclasses)

* Sat Dec 15 2001 KAZUKI SHIMURA <rito@pos.to> 1.0-0vl7
- update jsclasses to 2001-11-29

* Sun Sep 16 2001 IWAI Masaharu <iwaim@cc.mbn.or.jp> 1.0-0vl6
- fixed spec file for Prosper and jsclasses
- use RPM macro in %files
- added BuildPrereq: jvf

* Mon Sep 10 2001 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.0-0vl5
- move revtex4 to texmacro-aps package

* Sun Sep  9 2001 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.0-0vl4
- added prosper jsclasses

* Mon Sep  6 2001 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.0-0vl3
- added revtex4 natbib

* Mon Sep  3 2001 Jun Nishii <jun@vinelinux.org> 1.0-0vl2
- remove prereq tetex to avoid dependency-loop

* Wed Aug  1 2001 Jun Nishii <jun@vinelinux.org>
- tetex-macros-1.0-0vl1

* Fri Jan 21 2000 Jun Nishii <jun@vinelinux.org>
- 2.0-2
- added kanjifonts-1.0 and removed jisfontsmetric

* Sun Jan  9 2000 Jun Nishii <jun@vinelinux.org>
- 2.0-1
- install ldf in babel

* Sat Jan  8 2000 Jun Nishii <jun@vinelinux.org>
- added jisfontmetric.tex

* Fri Oct 29 1999 Norihito Ohmori <ohmori@flatout.org>
- change group.

* Sun Oct 17 1999 Jun Nishii <jun@flatout.org>
- added babel

* Fri Aug 27 1999 Jun Nishii <jun@flatout.org>
- added hoekwater

* Mon Aug 3 1999 Jun Nishii <jun@flatout.org>
- added psfrag

* Mon Jun 21 1999 Jun Nishii <jun@flatout.org>
- added psnfss
- Change directory tree according to the suggestion by Dr.Okumura.
- remove many files from packages directory except documentations
- disable mktexlsr and erase ls-R

* Tue Feb 16 1999 Jun Nishii <jun@flatout.org>
- added url.sty

* Thu Dec 3 1998 Jun Nishii <jun@flatout.org>
- pLaTeX2e_Macros-1-2
- added fancyhdr.sty, boxedminipage.sty
- added graphics.cfg, color.cfg (use dvips as default)
- symlink from epsbox to epsf

* Mon Nov 9 1998 Jun Nishii <jun@flatout.org>
- pLaTeX2e_Macros-1-1
  (rename as pLaTeX2e_Macros from pLaTeX-Classes)
- added def files of graphics
- added tools and hyperref
- check the existence of mktexlsr

* Tue Oct 5 1998 Jun Nishii <jun@flatout.org>
- buildarch: noarch
- added requires

* Tue Sep 29 1998 Jun Nishii <jun@flatout.org>
- tiny bug fix and add %defattr

* Wed Sep 23 1998 Jun Nishii <jun@flatout.org>
- first version fo platex-19980901
