source: projects/texlive-vtlpkg/trunk/tlpdb2rpmspec.sh.in @ 5075

Revision 5075, 24.0 KB checked in by munepi, 13 years ago (diff)

[experimental] supported TeX Live 2011

  • Property svn:executable set to *
Line 
1#!/bin/bash
2# tlpdb2rpmspec
3#
4# Copyright 2010 Munehiro Yamamoto <munepi@vinelinux.org>
5# This file is licensed under the GNU General Public License version 2
6# or any later version.
7
8Usage(){
9    cat<<EOF
10$(basename $0) @@VTLPKG_VERSION@@
11Usage:  $(basename $0) [option] [pkgname]
12
13TeX Live Package Database (a file named texlive.tlpdb) to RPM spec converter
14This script generates a RPM spec file of CTAN and collection-* packages
15contained in TeX Live @@VTLPKG_VERSION@@.
16
17Options:
18        --name:                 return [pkgname]
19        --category:             return the category of [pkgname]
20        --revision:             return the revision of [pkgname]
21        --depend:               return dependencies of [pkgname]
22        --shortdesc:            return the short description of [pkgname]
23        --longdesc:             return the description of [pkgname]
24        --execute:              return post processe of [pkgname]
25        --catalogue-ctan:       return the locate of [pkgname]
26        --catalogue-date:       return the last update of [pkgname]
27        --catalogue-license:    return the license of [pkgname]
28        --catalogue-version:    return the version of [pkgname]
29        --filelist:             return the filelist of [pkgname]
30        --help:                 show this help
31
32Supoort collections-* packages:
33$(egrep "^name collection-" $TLPDB | sed -e "s,name ,,g")
34EOF
35}
36
37check-parameter(){
38    [ -z "$*" ] && Usage && return 1
39
40    while [ ! -z "$*" ]; do
41        case $1 in
42            --name|--category|--revision|--depend|--shortdesc|--longdesc|--execute|--catalogue-ctan|--catalogue-date|--catalogue-license|--catalogue-version|--filelist)
43                [ $with_option -eq 1 ] && \
44                    $__echo "E: you only give one option" && return 1
45                with_option=1
46                ;;
47            --help)
48                Usage
49                return 1
50                ;;
51            --minimal-collections|--standard-collections|--full-collections)
52                [ ! -f /etc/vine-release ] && \
53                    $__echo "E: support Vine Linux only" && return 1
54                ;;
55            *)
56                [ -z "$(egrep -n "^name $1$" $TLPDB)" ] && \
57                    $__echo "E: unknown option or package: $1" && return 1
58                ;;
59        esac
60        shift
61    done
62
63    return 0
64}
65
66
67## tlpkg4a [--name|--category|--revision|--depend|--shortdesc|--longdesc|--execute|--catalogue-ctan|--catalogue-date|--catalogue-license|--catalogue-version|--filelist] [pkgname]
68tlpkg4a(){
69    [ $# -eq 2 ] || return 1
70    local opt=$1
71    local pkg=$2
72    local fieldname=$($__echo $opt | sed -e "s,--,,")
73
74    ## check param
75    case $opt in
76        --name|--category|--revision|--depend|--shortdesc|--longdesc|--execute|--catalogue-ctan|--catalogue-date|--catalogue-license|--catalogue-version|--filelist)
77            ;;
78        *)
79            $__echo "E: unknown option: $opt"
80            exit 1
81            ;;
82    esac
83
84    ## get the head line of $pkg record
85    pkg_LINE=$(egrep -n "^name $pkg$" $TLPDB | cut -d":" -f 1)
86
87    ## read tlpdb
88    is_pkg=0
89    (
90        [ "$opt" = "--filelist" ] && \
91            tail -n $(( $TLPDB_MAXLINE - $pkg_LINE + 1 )) $TLPDB || \
92            tail -n $(( $TLPDB_MAXLINE - $pkg_LINE + 1 )) $TLPDB | egrep -v -e "^ "
93    ) | \
94        while read field; do
95            ## find the record of $pkg
96            $__echo "$field" | egrep -q "^name $pkg" && is_pkg=1
97            [ $is_pkg -eq 0 ] && continue
98           
99            ## return the values of its field name
100            if [ "$opt" = "--filelist" ]; then
101            ## NOTE: we only need texmf-dist directories
102            ##       we replace RELOC with texmf-dist
103                $__echo "$field" | \
104                    egrep -e "^texmf-dist" -e "^RELOC" | \
105                    sed -e "s,^RELOC,texmf-dist," \
106                        -e "s, details=.*,," -e "s, language=.*,,"
107            else
108                $__echo "$field" | \
109                    egrep "^${fieldname} " | \
110                    sed -e "s,${fieldname} ,,"
111            fi
112           
113            ## end of the record of $pkg
114            $__echo "$field" | egrep -q "^[[:blank:]]*$" && break
115        done
116   
117    return 0
118}
119
120## tlpkg2speclicense [pkgname]
121tlpkg2speclicense(){
122    [ $# -eq 1 ] || return 1
123    local pkg=$1
124
125    case $(tlpkg4a --catalogue-license $pkg) in
126        gpl3) $__echo "GPLv3+";;
127        gpl2) $__echo "GPLv2+";;
128        gpl) $__echo "GPL+";;
129        lppl|lppl1.2|lppl1.3) $__echo "LPPL";;
130        other-free) $__echo "Freely redistributable without restriction";;
131        pd) $__echo "Public Domain";;
132        noinfo) $__echo "No Info";;
133        lgpl|lgpl2.1) $__echo "LGPLv2+";;
134        gfsl) $__echo "LPPL";;
135        bsd) $__echo "BSD";;
136        knuth) $__echo "Knuth";;
137        unknown) $__echo "Unknown";;
138        gfl) $__echo "LPPL";;
139        artistic2) $__echo "Artistic 2.0";;
140        fdl) $__echo "GFDL";;
141        collection) $__echo "Public Domain";;
142        artistic) $__echo "Artistic";;
143        other-nonfree) $__echo "Other";;
144        other) $__echo "Other";;
145        ofl) $__echo "OFSFLD";;
146        apache2) $__echo "ASL 2.0";;
147        nosource) $__echo "No Source";;
148        nosell) $__echo "No Sell";;
149        nocommercial) $__echo "Non-commercial";;
150        *) return 1;;
151    esac
152    return 0
153}
154
155## tlpkg2manifest [pkgname]
156tlpkg2manifest(){
157    [ $# -eq 1 ] || return 1
158    local pkg=$1
159    local pkgdeps="$(tlpkg4a --depend $pkg)"
160    local i=
161
162    tlpkg4a --filelist $pkg || return 1
163
164    ## if $pkg is not collection-*, only return the filelist of $pkg
165    $__echo $pkg | egrep -q "^collection-" || return 0
166
167    ##!! we need pure filelist of $pkg; remove collection-*
168    pkgdeps=$($__echo $pkgdeps | sed -e "s,collection-[-A-Za-z0-9]*,,g")
169
170    [ -z "$pkgdeps" ] && return 0
171    for i in $pkgdeps; do
172        tlpkg4a --filelist $i || return 1
173    done
174
175    return 0
176}
177
178## tlpkg2maplist [pkgname]
179tlpkg2maplist(){
180    [ $# -eq 1 ] || return 1
181    local pkg=$1
182    local pkgdeps="$(tlpkg4a --depend $pkg)"
183    local i=
184
185    tlpkg4a --execute $pkg | grep -e "Map" | sed -e "s,^add,,g"
186
187    ##!! we need pure filelist of $pkg; remove collection-*
188    pkgdeps=$($__echo $pkgdeps | sed -e "s,collection-[-A-Za-z0-9]*,,g")
189
190    [ -z "$pkgdeps" ] && return 0
191    for i in $pkgdeps; do
192        tlpkg4a --execute $i | grep -e "Map" | sed -e "s,^add,,g"
193    done
194
195    return 0
196}
197
198## tlpkg2inilist [pkgname]
199tlpkg2inilist(){
200    [ $# -eq 1 ] || return 1
201    local pkg=$1
202    local pkgdeps="$(tlpkg4a --depend $pkg)"
203    local i=
204
205    ## search AddFormat, AddHypen
206    tlpkg4a --execute $pkg | grep -e "Add"
207
208    ##!! we need pure filelist of $pkg; remove collection-*
209    pkgdeps=$($__echo $pkgdeps | sed -e "s,collection-[-A-Za-z0-9]*,,g")
210
211    [ -z "$pkgdeps" ] && return 0
212    for i in $pkgdeps; do
213        tlpkg4a --execute $i | grep -e "Add"
214    done
215
216    return 0
217}
218
219## mkrpmspec [pkgname]
220mkrpmspec(){
221    [ $# -eq 1 ] || return 1
222    local pkg=$1
223    local i=
224
225    RPM_SUMMARY="TeX Live: $(tlpkg4a --shortdesc $pkg)"
226
227    ## Requires tag for texlive
228    RPM_REQUIRES=$(for i in $(tlpkg4a --depend $pkg | egrep "^collection-" | egrep -v "^collection-documentation"); do $__echo "Requires: texlive-$i = %{version}"; done)
229
230    ## License tag
231    RPM_LICENSE="$(tlpkg2speclicense $pkg),"
232    for i in $(tlpkg4a --depend $pkg | egrep -v "^collection-"); do
233        tmp=$(tlpkg2speclicense $i)
234        $__echo "$RPM_LICENSE" | grep -q "${tmp},"
235        [ $? -eq 1 ] && RPM_LICENSE="${RPM_LICENSE} ${tmp},"
236    done
237    RPM_LICENSE=$($__echo "$RPM_LICENSE" | sed -e "s/,$//" | sed -e "s/^, //")
238    [ -z "$RPM_LICENSE" ] && RPM_LICENSE=distributable
239
240    PKG_SHORTDESC=$(tlpkg4a --shortdesc $pkg)
241    PKG_LONGDESC=$(tlpkg4a --longdesc $pkg)
242
243    PKG_CTANPKGSLIST=$(for i in $(tlpkg4a --depend $pkg); do \
244        if [ -z "$($__echo "$i" | grep "collection-")" ]; then \
245            $__echo -n "$i: "; \
246            tmp=$(tlpkg4a --shortdesc $i); \
247            [ -z "${tmp}" ] && $__echo || $__echo "$tmp"; \
248        fi
249        done)
250
251    PKG_MANIFEST=$(tlpkg2manifest $pkg)
252    [ -z "${PKG_MANIFEST}" ] && \
253        $__echo "W: empty manifest: $pkg" && return 1
254
255    with_docpkg=0
256    [ -z "$($__echo $pkg | grep "collection-documentation")" ] && \
257        [ ! -z "$($__echo "${PKG_MANIFEST}" | grep texmf-dist/doc/)" ] && \
258        with_docpkg=1
259
260    with_maplist=0
261    MAPLIST="$(tlpkg2maplist $pkg)"
262    [ ! -z "$MAPLIST" ] && with_maplist=1
263    ##$__echo $with_maplist && $__echo "$MAPLIST" && exit
264
265    with_inilist=0
266    INILIST="$(tlpkg2inilist $pkg)"
267    [ ! -z "$INILIST" ] && with_inilist=1
268    ##$__echo $with_inilist && $__echo "$INILIST" && exit
269
270cat<<EOF
271## -*- coding: utf-8-unix -*-
272## NOTE: This spec file is generated by $(basename $0) ${VERSION}-${RELEASE}:
273## $(basename $0) $pkg
274
275%global _use_internal_dependency_generator 0
276%global __find_provides %{nil}
277%global __find_requires %{nil}
278
279%bcond_with firstbuild
280
281%define tex_destdir     %{_datadir}
282%define texmf           %{tex_destdir}/texmf
283%define texlive_src     %{tex_destdir}/texlive-sources
284%define build_tex_destdir       %{buildroot}%{tex_destdir}
285%define build_texmf     %{buildroot}%{texmf}
286
287%define exec_mktexlsr  [ -x %{_bindir}/texconfig-sys ] && PATH=%{_bindir}:\$PATH %{_bindir}/texconfig-sys rehash
288%define exec_texhash  [ -x %{_bindir}/texhash ] && PATH=%{_bindir}:\$PATH %{_bindir}/texhash
289%define exec_updmap   [ -x %{_bindir}/updmap-sys ] && PATH=%{_bindir}:\$PATH %{_bindir}/updmap-sys --nostop
290%define exec_fmtutil  [ -x %{_bindir}/fmtutil-sys ] && PATH=%{_bindir}:\$PATH %{_bindir}/fmtutil-sys --all >/dev/null 2>&1
291%define exec_upddeffont    [ -x %{_sbindir}/update-defaultfont ] && %{_sbindir}/update-defaultfont 2> /dev/null
292%define vartexfonts %{_var}/lib/texmf
293
294Summary: ${RPM_SUMMARY}
295Summary(ja): ${RPM_SUMMARY}
296Name: texlive-$pkg
297Version: ${VERSION}
298Release: ${RELEASE}%{?_dist_release}
299License: ${RPM_LICENSE}
300Group: Applications/Publishing
301URL:http://www.tug.org/texlive/
302
303Requires: texlive = %{version}
304$RPM_REQUIRES
305
306Requires(post):         texlive = %{version}
307Requires(postun):       texlive = %{version}
308BuildRequires:          texlive-sources = %{version}
309
310BuildArch:      noarch
311Buildroot:      %{_tmppath}/%{name}-%{version}-root
312
313Vendor:         ${RPM_VENDOR}
314Distribution:   ${RPM_DISTRIBUTION}
315Packager:       ${RPM_PACKAGER}
316
317%description
318The TeX Live software distribution offers a complete TeX system for a
319variety of Unix, Macintosh, Windows and other platforms. It
320encompasses programs for editing, typesetting, previewing and printing
321of TeX documents in many different languages, and a large collection
322of TeX macros and font libraries.
323
324The distribution includes extensive general documentation about TeX,
325as well as the documentation for the included software packages.
326
327This package is a collection of ${PKG_SHORTDESC}:
328${PKG_LONGDESC}
329
330This package contains the following CTAN packages:
331${PKG_CTANPKGSLIST}
332
333%description -l ja
334TeX Live ソフトウェアディストリビューションは、
335さまざまな Unix, Macintosh, Windows、および
336他のプラットホームに対して完全な TeX システムを提供します。
337多くの異なった言語を含む TeX ドキュメントの
338編集、組版、閲覧、印刷するためのプログラム、
339そして、TeX マクロやフォントライブラリの大きなコレクションを
340同梱しています。
341
342このディストリビューションは
343同梱しているソフトウェアパッケージのためのドキュメントばかりでなく、
344TeX に関するたくさんの一般的なドキュメントを含んでいます。
345
346このパッケージは以下のようなパッケージ集です。
347${PKG_SHORTDESC}:
348${PKG_LONGDESC}
349
350このパッケージは以下の CTAN パッケージを含んでいます:
351${PKG_CTANPKGSLIST}
352
353EOF
354
355## subpackage: %{name}-doc
356if [ $with_docpkg -eq 1 ]; then
357    cat<<EOF
358%package doc
359Summary: TeX Live: Documentation files of %{name}
360Group: Applications/Publishing
361Requires: %{name} = %{version}-%{release}
362
363%description doc
364This package contains documentation files of %{name}.
365
366EOF
367fi
368
369cat<<EOF
370%prep
371
372%build
373
374%install
375[ -n "%{buildroot}" -a "%{buildroot}" != / ] && %__rm -rf %{buildroot}
376
377PREF=%{buildroot}%{tex_destdir}
378
379manifest=(
380${PKG_MANIFEST}
381)
382
383%__mkdir_p \${PREF}/texmf-dist
384for i in "\${manifest[@]}"; do
385    %__install -m \$(stat -c %a %{texlive_src}/\$i) -p -D %{texlive_src}/\$i \${PREF}/\$i
386done
387EOF
388
389# cat<<EOF
390# ## make symlinks of core script utils
391# mk_symlinks=(
392# texlive-collection-binextra,/usr/bin/dviasm,/usr/share/texmf-dist/scripts/dviasm/dviasm.py
393# texlive-collection-binextra,/usr/bin/findhyph,/usr/share/texmf-dist/scripts/findhyph/findhyph
394# texlive-collection-binextra,/usr/bin/fragmaster,/usr/share/texmf-dist/scripts/fragmaster/fragmaster.pl
395# texlive-collection-binextra,/usr/bin/latex2man,/usr/share/texmf-dist/scripts/latex2man/latex2man
396# texlive-collection-binextra,/usr/bin/latexmk,/usr/share/texmf-dist/scripts/latexmk/latexmk.pl
397# texlive-collection-binextra,/usr/bin/listings-ext.sh,/usr/share/texmf-dist/scripts/listings-ext/listings-ext.sh
398# texlive-collection-binextra,/usr/bin/mkjobtexmf,/usr/share/texmf-dist/scripts/mkjobtexmf/mkjobtexmf.pl
399# texlive-collection-binextra,/usr/bin/pdfcrop,/usr/share/texmf-dist/scripts/pdfcrop/pdfcrop.pl
400# texlive-collection-binextra,/usr/bin/pkfix,/usr/share/texmf-dist/scripts/pkfix/pkfix.pl
401# texlive-collection-binextra,/usr/bin/pkfix-helper,/usr/share/texmf-dist/scripts/pkfix-helper/pkfix-helper
402# texlive-collection-binextra,/usr/bin/purifyeps,/usr/share/texmf-dist/scripts/purifyeps/purifyeps
403# texlive-collection-binextra,/usr/bin/texcount,/usr/share/texmf-dist/scripts/texcount/texcount.pl
404# texlive-collection-binextra,/usr/bin/texdiff,/usr/share/texmf-dist/scripts/texdiff/texdiff
405# texlive-collection-binextra,/usr/bin/texdirflatten,/usr/share/texmf-dist/scripts/texdirflatten/texdirflatten
406# texlive-collection-binextra,/usr/bin/texloganalyser,/usr/share/texmf-dist/scripts/texloganalyser/texloganalyser
407# texlive-collection-context,/usr/bin/context,/usr/share/texmf-dist/scripts/context/stubs/unix/context
408# texlive-collection-context,/usr/bin/ctxtools,/usr/share/texmf-dist/scripts/context/stubs/unix/ctxtools
409# texlive-collection-context,/usr/bin/luatools,/usr/share/texmf-dist/scripts/context/lua/luatools.lua
410# texlive-collection-context,/usr/bin/makempy,/usr/share/texmf-dist/scripts/context/stubs/unix/makempy
411# texlive-collection-context,/usr/bin/mpstools,/usr/share/texmf-dist/scripts/context/stubs/unix/mpstools
412# texlive-collection-context,/usr/bin/mptopdf,/usr/share/texmf-dist/scripts/context/stubs/unix/mptopdf
413# texlive-collection-context,/usr/bin/mtxrun,/usr/share/texmf-dist/scripts/context/lua/mtxrun.lua
414# texlive-collection-context,/usr/bin/mtxtools,/usr/share/texmf-dist/scripts/context/stubs/unix/mtxtools
415# texlive-collection-context,/usr/bin/pdftools,/usr/share/texmf-dist/scripts/context/stubs/unix/pdftools
416# texlive-collection-context,/usr/bin/pstopdf,/usr/share/texmf-dist/scripts/context/stubs/unix/pstopdf
417# texlive-collection-context,/usr/bin/rlxtools,/usr/share/texmf-dist/scripts/context/stubs/unix/rlxtools
418# texlive-collection-context,/usr/bin/runtools,/usr/share/texmf-dist/scripts/context/stubs/unix/runtools
419# texlive-collection-context,/usr/bin/texexec,/usr/share/texmf-dist/scripts/context/stubs/unix/texexec
420# texlive-collection-context,/usr/bin/texfont,/usr/share/texmf-dist/scripts/context/stubs/unix/texfont
421# texlive-collection-context,/usr/bin/texmfstart,/usr/share/texmf-dist/scripts/context/ruby/texmfstart.rb
422# texlive-collection-context,/usr/bin/textools,/usr/share/texmf-dist/scripts/context/stubs/unix/textools
423# texlive-collection-context,/usr/bin/texutil,/usr/share/texmf-dist/scripts/context/stubs/unix/texutil
424# texlive-collection-context,/usr/bin/tmftools,/usr/share/texmf-dist/scripts/context/stubs/unix/tmftools
425# texlive-collection-context,/usr/bin/xmltools,/usr/share/texmf-dist/scripts/context/stubs/unix/xmltools
426# texlive-collection-fontutils,/usr/bin/afm2afm,/usr/share/texmf-dist/scripts/fontools/afm2afm
427# texlive-collection-fontutils,/usr/bin/autoinst,/usr/share/texmf-dist/scripts/fontools/autoinst
428# texlive-collection-fontutils,/usr/bin/cmap2enc,/usr/share/texmf-dist/scripts/fontools/cmap2enc
429# texlive-collection-fontutils,/usr/bin/epstopdf,/usr/share/texmf-dist/scripts/epstopdf/epstopdf.pl
430# texlive-collection-fontutils,/usr/bin/font2afm,/usr/share/texmf-dist/scripts/fontools/font2afm
431# texlive-collection-fontutils,/usr/bin/mkt1font,/usr/share/texmf-dist/scripts/accfonts/mkt1font
432# texlive-collection-fontutils,/usr/bin/ot2kpx,/usr/share/texmf-dist/scripts/fontools/ot2kpx
433# texlive-collection-fontutils,/usr/bin/pfm2kpx,/usr/share/texmf-dist/scripts/fontools/pfm2kpx
434# texlive-collection-fontutils,/usr/bin/showglyphs,/usr/share/texmf-dist/scripts/fontools/showglyphs
435# texlive-collection-fontutils,/usr/bin/vpl2ovp,/usr/share/texmf-dist/scripts/accfonts/vpl2ovp
436# texlive-collection-fontutils,/usr/bin/vpl2vpl,/usr/share/texmf-dist/scripts/accfonts/vpl2vpl
437# texlive-collection-langgreek,/usr/bin/mkgrkindex,/usr/share/texmf-dist/scripts/mkgrkindex/mkgrkindex
438# texlive-collection-langindic,/usr/bin/ebong,/usr/share/texmf-dist/scripts/bengali/ebong.py
439# texlive-collection-latex,/usr/bin/pdfatfi,/usr/share/texmf-dist/scripts/oberdiek/pdfatfi.pl
440# texlive-collection-latexextra,/usr/bin/makeglossaries,/usr/share/texmf-dist/scripts/glossaries/makeglossaries
441# texlive-collection-latexextra,/usr/bin/pdfannotextractor,/usr/share/texmf-dist/scripts/pax/pdfannotextractor.pl
442# texlive-collection-latexextra,/usr/bin/pdfthumb,/usr/share/texmf-dist/scripts/ppower4/pdfthumb.tlu
443# texlive-collection-latexextra,/usr/bin/perltex,/usr/share/texmf-dist/scripts/perltex/perltex
444# texlive-collection-latexextra,/usr/bin/ppower4,/usr/share/texmf-dist/scripts/ppower4/ppower4.tlu
445# texlive-collection-latexextra,/usr/bin/ps4pdf,/usr/share/texmf-dist/scripts/pst-pdf/ps4pdf
446# texlive-collection-latexextra,/usr/bin/splitindex,/usr/share/texmf-dist/scripts/splitindex/perl/splitindex.pl
447# texlive-collection-latexextra,/usr/bin/svn-multi,/usr/share/texmf-dist/scripts/svn-multi/svn-multi.pl
448# texlive-collection-latexextra,/usr/bin/vpe,/usr/share/texmf-dist/scripts/vpe/vpe.pl
449# texlive-collection-latexrecommended,/usr/bin/thumbpdf,/usr/share/texmf-dist/scripts/thumbpdf/thumbpdf.pl
450# texlive-collection-pictures,/usr/bin/cachepic,/usr/share/texmf-dist/scripts/cachepic/cachepic.tlu
451# texlive-collection-pictures,/usr/bin/epspdf,/usr/share/texmf-dist/scripts/epspdf/epspdf
452# texlive-collection-pictures,/usr/bin/epspdftk,/usr/share/texmf-dist/scripts/epspdf/epspdftk
453# texlive-collection-pictures,/usr/bin/fig4latex,/usr/share/texmf-dist/scripts/fig4latex/fig4latex
454# texlive-collection-pstricks,/usr/bin/pst2pdf,/usr/share/texmf-dist/scripts/pst2pdf/pst2pdf.pl
455# texlive-collection-science,/usr/bin/ulqda,/usr/share/texmf-dist/scripts/ulqda/ulqda.pl
456# )
457# %__mkdir_p %{buildroot}%{_bindir}
458# pushd %{buildroot}%{_bindir}
459#     for i in "\${mk_symlinks[@]}"; do
460#         tlc=\$(echo \$i | cut -f 1 -d",")
461#         lnk=\$(echo \$i | cut -f 2 -d"," | %__sed -e "s|/usr/bin/||")
462#         rlnk=\$(echo \$i | cut -f 3 -d"," | %__sed -e "s|/usr/|../|")
463
464#         [ "%{name}" = "\$tlc" ] || continue
465#         [ -f \$rlnk ] || exit 1
466#         %__ln_s \$rlnk \$lnk || exit 1
467#     done
468# popd
469# EOF
470
471cat<<EOF
472## remove asymptote directries, which provides asymptote package
473find %{buildroot} -regex ".*asymptote.*" | xargs %__rm -rf
474
475## Files list
476find %{buildroot} -type f -or -type l | \\
477    %__sed -e "s|%{buildroot}||g" > filelist.full
478
479find %{buildroot}%{texmf}-dist -type d | \\
480    %__sed -e "s|^%{buildroot}|%dir |" \\
481           -e "s|\$|/|"             >> filelist.full
482
483EOF
484
485## subpackage: %{name}-doc
486if [ $with_docpkg -eq 1 ]; then
487    cat<<EOF
488## subpackages
489grep "/texmf-dist/doc/" filelist.full > filelist.doc
490cat filelist.doc filelist.full | sort | uniq -u > filelist.tmp
491%__mv -f filelist.tmp filelist.full
492
493EOF
494fi
495
496cat<<EOF
497%clean
498%__rm -rf %{buildroot}
499
500%post
501%{exec_texhash}
502
503EOF
504
505## Running updmap
506if [ $with_maplist -eq 1 ]; then
507    cat<<EOF
508[ -f %{texmf}/web2c/updmap.cfg ] || exit 0
509
510updmap_lock=%{texmf}/updmap.lock
511$($__echo "$MAPLIST" | while read maptype map; do \
512    cat<<EOT
513%{exec_updmap} --listmaps 2>/dev/null | egrep -q "^#! ${maptype} ${map}" && \\
514    echo -n "    " && \\
515    echo -n "Running updmap: enable ${map} ... " && \\
516    %{exec_updmap} --nomkmap --enable ${maptype} ${map} >/dev/null 2>&1 && \\
517    echo "done." && \\
518    touch \${updmap_lock}
519EOT
520done)
521
522rpm -q --quiet texlive-common || exit 0
523
524[ -f \${updmap_lock} ] && \\
525    echo -n "    " && \\
526    echo -n "Running updmap: recreate map files ... " && \\
527    %{exec_updmap} >/dev/null 2>&1 && \\
528    echo "done." && \\
529    rm -f \${updmap_lock}
530
531EOF
532fi
533
534## Running fmtutil
535if [ $with_inilist -eq 1 ]; then
536    cat<<EOF
537rpm -q --quiet texlive-common || exit 0
538
539echo -n "    "
540echo -n "Running fmtutil ... " && %{exec_fmtutil} && echo "done."
541
542EOF
543fi
544
545cat<<EOF
546exit 0
547
548
549%postun
550if [ "\$1" = 0 ]; then
551    %{exec_texhash}
552
553EOF
554
555## Running updmap
556if [ $with_maplist -eq 1 ]; then
557    cat<<EOF
558    [ -f %{texmf}/web2c/updmap.cfg ] || exit 0
559
560$($__echo "$MAPLIST" | while read maptype map; do \
561    cat<<EOT
562    %{exec_updmap} --listmaps 2>/dev/null | egrep -q "^${maptype} ${map}" && \\
563        echo -n "    " && \\
564        echo -n "Running updmap: disable ${map} ... " && \\
565        %{exec_updmap} --nomkmap --disable ${map} >/dev/null 2>&1 && \\
566        echo "done."
567EOT
568done)
569    echo -n "    " && \\
570        echo -n "Running updmap: recreate map files ... " && \\
571        %{exec_updmap} >/dev/null 2>&1 && \\
572        echo "done."
573
574EOF
575fi
576
577cat<<EOF
578fi
579
580exit 0
581
582%files -f filelist.full
583%defattr(-,root,root,-)
584
585EOF
586## subpackage: %{name}-doc
587if [ $with_docpkg -eq 1 ]; then
588    cat<<EOF
589%files -f filelist.doc doc
590%defattr(-,root,root,-)
591
592EOF
593fi
594
595cat<<EOF
596%changelog
597* Sun Oct 30 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2011-1
598- generated by $(basename $0) 2011-1: $(basename $0) $($__echo $*)
599
600* Mon Mar 23 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2009-4
601- generated by $(basename $0) 2009-4: $(basename $0) $($__echo $*)
602- make symlinks of core script utils (texlive-collection-binextra,
603  texlive-collection-context, texlive-collection-fontutils,
604  texlive-collection-langgreek, texlive-collection-langindic,
605  texlive-collection-latex, texlive-collection-latexextra,
606  texlive-collection-latexrecommended, texlive-collection-pictures,
607  texlive-collection-pstricks, texlive-collection-science)
608
609* Fri Jan 14 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2009-3
610- generated by $(basename $0) 2009-3: $(basename $0) $($__echo $*)
611- improved %%post
612
613* Fri Oct 01 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2009-2
614- generated by $(basename $0) 2009-2: $(basename $0) $($__echo $*)
615- removed arch dependent binaries (texlive-collection-latexextra)
616- fixed perl path
617- improved updmap process in %%post and %%postun
618
619* Sat Aug 07 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2009-1
620- generated by $(basename $0) 2009-1: $(basename $0) $($__echo $*)
621EOF
622
623    return 0
624}
625
626## mkrpmcollection [--minimal-collections|--standard-collections|--full-collections]
627mkrpmcollection(){
628    local category=$($__echo $1 | sed -e "s/--\([a-z]*\)-collections/\1/")
629    local category_pkglist=
630    local i=
631
632    case $category in
633        minimal|standard)
634            category_pkglist=$(grep -e "${category}," $CATEGORYLIST | sed -e "s/${category},//g" | sed -e "s/,$//g")
635            ;;
636        full)
637            category_pkglist=$(Usage | egrep "^collection-")
638            ;;
639        *)
640            $__echo "E: unknown category: $category"
641            return 1
642            ;;
643    esac
644
645    for i in ${category_pkglist}; do
646        mkrpmspec $i > texlive-${i}-vl.spec
647        if [ $? -eq 1 ]; then
648            $__echo "texlive-${i}-vl.spec: "
649            cat texlive-${i}-vl.spec
650            rm -f texlive-${i}-vl.spec
651            continue
652        fi
653        rpmbuild -ba texlive-${i}-vl.spec || return 1
654    done
655
656    return 0
657}
658
659setup-tlpdb2rpmspec(){
660    __echo=$(which echo 2>/dev/null)
661    [ ! -f $__echo ] && return 1
662
663    ## load your .vtlpkg.conf
664    if [ -f ${HOME}/.vtlpkg.conf ]; then
665        . ${HOME}/.vtlpkg.conf
666    else
667        $__echo "E: ${HOME}/.vtlpkg.conf: No such file"
668        return 1
669    fi
670
671    [ -z "$RPM_VENDOR" ] && \
672        $__echo "E: \$RPM_VENDOR is empty" && return 1
673    [ -z "$RPM_DISTRIBUTION" ] && \
674        $__echo "E: \$RPM_DISTRIBUTION is empty" && return 1
675    [ -z "$RPM_GPG_NAME" ] && \
676        $__echo "E: \$RPM_GPG_NAME is empty" && return 1
677    [ -z "$RPM_PACKAGER" ] && \
678        $__echo "E: \$RPM_PACKAGER is empty" && return 1
679
680    ## setup configurations
681    VERSION=@@VTLPKG_VERSION@@
682    RELEASE=@@VTLPKG_RELEASE@@
683
684    ## set a tlpdb file for TeX Live, which is a package database file.
685    TLPDB=@@VTLPKG_TLPDB@@
686    TLPDB_MAXLINE=$(wc -l $TLPDB | awk '{print $1}')
687
688    ## category of collection-*
689    CATEGORYLIST=@@VTLPKG_CATEGORYLIST@@
690
691    ## set some booleans
692    with_option=0
693}
694
695##############################################################################
696
697setup-tlpdb2rpmspec || exit 1
698
699check-parameter $* || exit 1
700
701case $1 in
702    --name|--category|--revision|--depend|--shortdesc|--longdesc|--execute|--catalogue-ctan|--catalogue-date|--catalogue-license|--catalogue-version|--filelist)
703        tlpkg4a $1 $2 || exit 1
704        ;;
705    --minimal-collections|--standard-collections|--full-collections)
706        mkrpmcollection $1 || exit 1
707        ;;
708    *)
709        mkrpmspec $1 || exit 1
710        ;;
711esac
712
713exit
714
715### end of file
Note: See TracBrowser for help on using the repository browser.