[[PageOutline]]
= tlpdb2rpmspec =

texlive-collection-* の spec ファイルを生成するツールを作成しました。

[browser:projects/texlive-vtlpkg/trunk]

tlpdb2rpmspec は texlive-vtlpkg パッケージに同梱されています。

{{{
  $ sudo apt-get install texlive-vtlpkg
}}}

== 初期設定 ==

/usr/share/texlive-vtlpkg/dot.vtlpkg.conf を ${HOME}/.vtlpkg.conf へコピーして、必要な設定をします。
{{{
## 
## texlive-vtlpkg configuration file
## 
## This configuration is read at the startup of texlive-vtlpkg. 

## set spec suffix
## default: RPM_SPEC_SUFFIX=vl
RPM_SPEC_SUFFIX=vl

## set your vendor
## default: RPM_VENDOR="Project Vine"
RPM_VENDOR="Project Vine"

## set your distribution
## default: RPM_DISTRIBUTION="Vine Linux"
RPM_DISTRIBUTION="Vine Linux"

## set your name and your e-mail address
## default: RPM_GPG_NAME="YOUR NAME <your@email.address>"
RPM_GPG_NAME=""

## set your packager id
## default: RPM_PACKAGER=your_id
RPM_PACKAGER=

## set the top of your rpm directory
## default: RPM_TOPDIR=${HOME}/rpm
RPM_TOPDIR=${HOME}/rpm

## set local tlnet
## default: TLNETROOT=/var/local/tlnet
TLNETROOT=/var/local/tlnet
## default: TLPDB=/var/local/tlnet/tlpkg/texlive.tlpdb
TLPDB=/var/local/tlnet/tlpkg/texlive.tlpdb

## set external dependencies (optional)
## default: ASYMPTOTE_PACKAGE=
#ASYMPTOTE_PACKAGE=asymptote
## default: DETEX_PACKAGE=
#DETEX_PACKAGE=detex
## default: DVIPNG_PACKAGE=
#DVIPNG_PACKAGE=dvipng
## default: LATEXMK_PACKAGE=
#LATEXMK_PACKAGE=latexmk
## default: LCDF_TYPETOOLS_PACKAGE=
#LCDF_TYPETOOLS_PACKAGE=lcdf-typetools
## default: PSUTILS_PACKAGE=
#PSUTILS_PACKAGE=psutils
## default: T1UTILS_PACKAGE=
#T1UTILS_PACKAGE=t1utils

## customize some commands if you need (optional)
#__echo=/bin/echo

## end of file
}}}


== ヘルプ ==

{{{
$ tlpdb2rpmspec 
Usage:	tlpdb2rpmspec [option] [pkgname]

This script generates a rpm spec file for CTAN and collection-* packages of TeX Live. 

Options:
	--name:			return [pkgname]
	--category:		return the category of [pkgname]
	--revision:		return the revision of [pkgname]
	--depend:		return dependencies of [pkgname]
	--shortdesc:		return the short description of [pkgname]
	--longdesc:		return the description of [pkgname]
	--execute:		return post processe of [pkgname]
	--catalogue-ctan:	return the locate of [pkgname]
	--catalogue-date:	return the last update of [pkgname]
	--catalogue-license:	return the license of [pkgname]
	--catalogue-version:	return the version of [pkgname]
	--filelist:		return the filelist of [pkgname]
	--help:			show this help

Supoort collections-* packages: 
collection-basic
collection-bibtexextra
collection-binextra
(snip)
collection-xetex
}}}


== 使い方 ==

=== 1. TLNET を構築 ===

ローカルに [http://www.ctan.org/tex-archive/systems/texlive/tlnet TLNET] を構築するための一例を、
{{{ /usr/share/texlive-vtlpkg/_sync-tlnet.sh }}} に作っておきました。
この {{{ _sync-tlnet.sh }}} を実行すると、
TLNET の国内ミラーサーバの一つである JAIST の TLNET ftp://ftp.jaist.ac.jp/pub/CTAN/systems/texlive/tlnet/ と {{{ rsync }}} コマンドにより同期をとって、
ローカルに TLNET を構築できます。
{{{
  $ bash /usr/share/texlive-vtlpkg/_sync-tlnet.sh 
}}}

=== 2. spec ファイルを生成 ===

例えば、collection-basic の texlive-collection-basic-vl.spec を生成したい場合は、以下を実行します。

{{{
$ tlpdb2rpmspec collection-basic > texlive-collection-basic-vl.spec
}}}

{{{rpmbuild -ba texlive-collection-basic-vl.spec}}} を実行すると、
texlive-collection-basic-YYYY-NNvlVV.{noarch,src}.rpm, 
texlive-collection-basic-doc-YYYY-NNvlVV.src.rpm 
がビルドされます。

=== 3. rpm を作成 ===

1 で構築した TLNET 内の {{{ archive }}} ディレクトリを {{{ %_sourcedir }}} として、{{{ rpmbuild }}} コマンドを実行します。
{{{
$ rpmbuild -ba --define="%_sourcedir /var/local/tlnet/archive" texlive-collection-basic-vl.spec
}}}

各カテゴリ別に texlive-collection-* を生成したい場合は、以下を実行することにより、rpmbuild まで実行します。
{{{
最小(main)：$ tlpdb2rpmspec --minimal-collections
標準(plus)：$ tlpdb2rpmspec --standard-collections
最大(plus)：$ tlpdb2rpmspec --full-collections
}}}

また、大量にパッケージを生成する場合は、tee を利用してログを出しておくことが望ましいです。
{{{
$ tlpdb2rpmspec --full-collections 2>&1 | tee 00full-collections.log
}}}


== macros.texlive ==

TeX Live 関連の RPM パッケージを作成する上でよく使われるものを {{{ /etc/rpm/macros.texlive }}} にまとめました。

{{{
#
# RPM macros for our TeX Live
#

# default TeX Live directories
%_tl_texmfroot		%{_datadir}

%_tl_texmfconfig	~/.texmf-config
%_tl_texmfvar		~/.texmf-var
%_tl_texmfhome		~/texmf
%_tl_texmfsysconfig	%{_sysconfdir}/texmf
%_tl_texmfsysvar	%{_var}/lib/texmf
%_tl_texmflocal		%{_prefix}/local/share/texmf
%_tl_texmfvine		%{_tl_texmfroot}/texmf
%_tl_texmfdist		%{_tl_texmfroot}/texmf-dist
%_tl_vartexfonts	%{_tl_texmfsysvar}/fonts

%_tl_aliasttfdir	%{_tl_texmfsysvar}/fonts/truetype/vine
%_tl_varrundir		%{_var}/run/texlive

# some useful functions/macros
%_tl_touch_run()	%{expand:( %__mkdir_p %{_tl_varrundir}; touch %{_tl_varrundir}/run-%1; )
}

%_tl_exec_upddeffont	[ -x %{_sbindir}/update-defaultfont ] && \\\
    %{_sbindir}/update-defaultfont 2> /dev/null

%_tl_exec_texhash	[ -e %{_tl_varrundir}/run-texhash ] && ( \\\
    [ -x %{_bindir}/texhash ] && \\\
    echo -n "    "; echo -n "Running texhash... "; \\\
    %{_bindir}/texhash 2> /dev/null; \\\
    echo "done." ) && %__rm -f %{_tl_varrundir}/run-texhash;

%_tl_exec_mtxrun	[ -e %{_tl_varrundir}/run-mtxrun ] && ( \\\
    [ -x %{_bindir}/mtxrun ] && \\\
    echo -n "    "; echo -n "Running mtxrun... "; \\\
    export TEXMF=%{_tl_texmfdist} TEXMFCNF=%{_tl_texmfdist}/web2c TEXMFCACHE=%{_tl_texmfsysvar}; \\\
    %{_bindir}/mtxrun --generate &> /dev/null; \\\
    echo "done." ) && %__rm -f %{_tl_varrundir}/run-mtxrun; 

%_tl_exec_fmtutil	[ -e %{_tl_varrundir}/run-fmtutil ] && ( \\\
    [ -x %{_bindir}/fmtutil-sys ] && \\\
    echo -n "    "; echo -n "Running fmtutil-sys... "; \\\
    %{_bindir}/fmtutil-sys --all &> /dev/null; \\\
    echo "done." ) && %__rm -f %{_tl_varrundir}/run-fmtutil; 

%_tl_exec_updmap	[ -e %{_tl_varrundir}/run-updmap ] && ( \\\
    [ -x %{_bindir}/updmap-sys ] && \\\
    echo -n "    "; echo -n "Running updmap-sys... "; \\\
    yes | %{_bindir}/updmap-sys --syncwithtrees --nohash --quiet &>/dev/null; \\\
    %{_bindir}/updmap-sys --nohash --quiet &> /dev/null; \\\
    echo "done." ) && %__rm -f %{_tl_varrundir}/run-updmap; 


# %_tl_enable_map [maptype] [map]
%_tl_enable_map()	%{expand: %{_bindir}/updmap-sys --nomkmap --nohash --quiet --enable %1 %2 >/dev/null 2>&1 && %_tl_touch_run updmap
}

# %_tl_disable_map [map]
%_tl_disable_map()	%{expand: %{_bindir}/updmap-sys --nomkmap --nohash --quiet --disable %1 >/dev/null 2>&1 && %_tl_touch_run updmap
}

# end of file
}}}




== テスト事項 ==

=== パッケージングの検証 ===

1. {{{$ tlpdb2rpmspec --full-collections}}} で生成されたすべての rpm パッケージをインストールする。
1. TeX Live の scheme-full からインストールされる {{{ $TEXLIVE/texmf-dist }}} と {{{ /usr/share/texmf-dist }}} との差分比較して確認する。


== 資料 ==

=== texlive.tlpdb のフィールド一覧 ===

{{{
$ sed -e "s/^\([-A-z0-9]*\) .*$/\1/g" /var/local/tlnet/tlpkg/texlive.tlpdb | sort | uniq

binfiles
catalogue
catalogue-ctan
catalogue-date
catalogue-license
catalogue-version
category
containermd5
containersize
depend
doccontainermd5
doccontainersize
docfiles
execute
longdesc
name
postaction
relocated
revision
runfiles
shortdesc
srccontainermd5
srccontainersize
srcfiles
}}}

=== ライセンスのリスト ===
{{{
$ egrep "^catalogue-license" /var/local/tlnet/tlpkg/texlive.tlpdb | sed -e "s,catalogue-license[[:blank:]]*,," | sort | uniq
apache2
artistic
bsd
collection
fdl
gfl
gfsl
gpl
gpl2
gpl3
knuth
lgpl
lgpl2.1
lppl
lppl1
lppl1.2
lppl1.3
noinfo
nosource
ofl
opl
other-free
other-nonfree
pd
}}}




== texlive-vtlpkg の主な更新履歴 ==

=== TeX Live 2014 ===
[browser:projects/texlive-vtlpkg/trunk]

次期 Vine Linux 7 に対応する予定。

=== TeX Live 2013 ===
[browser:projects/texlive-vtlpkg/2013]

TeX Live 2012 以前の texlive-vtlpkg では、
リリースされたバージョンのソースアーカイブスをまとめた texlive-sources パッケージから texlive-collection-* を生成していた。

TeX Live 2013 以降の texlive-vtlpkg は、TLNET のパッケージから texlive-collection-* を生成するようにした。
この変更により、TeX Live の current へ追従しやすくなった。

=== TeX Live 2012 ===
[browser:projects/texlive-vtlpkg/2012]

=== TeX Live 2011 ===
[browser:projects/texlive-vtlpkg/tags/2011]

rpm-4.8.1 を利用するため、
{{{_use_internal_dependency_generator 0}}} を用いれば、簡単に制御できた。
{{{
%global _use_internal_dependency_generator 0
%global __find_provides %{nil}
%global __find_requires %{nil}
}}}

=== TeX Live 2009 ===
[browser:projects/texlive-vtlpkg/branches/2009]

Vine Linux 6 および Vine Linux 5 に対応しているため、
spec ファイルがやや煩雑になっている。
{{{
%define __find_provides %{nil}
%define __find_requires %{nil}
%define __perl_provides %{nil}
%define __perl_requires %{nil}

Autoreq: 0
}}}