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

Revision 5080, 24.1 KB checked in by munepi, 13 years ago (diff)

updated tlpdb2rpmspec.sh.in; added README

  • 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 collection-* 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/" -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|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 \
229        $__echo "Requires: texlive-$i = %{version}"; \
230        done)
231
232    ## License tag
233    RPM_LICENSE="$(tlpkg2speclicense $pkg),"
234    for i in $(tlpkg4a --depend $pkg | egrep -v "^collection-"); do
235        tmp=$(tlpkg2speclicense $i)
236        $__echo "$RPM_LICENSE" | grep -q "${tmp},"
237        [ $? -eq 1 ] && RPM_LICENSE="${RPM_LICENSE} ${tmp},"
238    done
239    RPM_LICENSE=$($__echo "$RPM_LICENSE" | sed -e "s/,$//" | sed -e "s/^, //")
240    [ -z "$RPM_LICENSE" ] && RPM_LICENSE=distributable
241
242    PKG_SHORTDESC=$(tlpkg4a --shortdesc $pkg)
243    PKG_LONGDESC=$(tlpkg4a --longdesc $pkg)
244
245    PKG_CTANPKGSLIST=$(for i in $(tlpkg4a --depend $pkg); do \
246        if [ -z "$($__echo "$i" | grep "collection-")" ]; then \
247            $__echo -n "$i: "; \
248            tmp=$(tlpkg4a --shortdesc $i); \
249            [ -z "${tmp}" ] && $__echo || $__echo "$tmp"; \
250        fi
251        done)
252
253    PKG_MANIFEST=$(tlpkg2manifest $pkg)
254    [ -z "${PKG_MANIFEST}" ] && \
255        $__echo "W: empty manifest: $pkg" >&2
256
257    ## check to need the subpackage %{name}-doc
258    with_docpkg=0
259    if [ -z "$($__echo $pkg | grep "collection-documentation")" ]; then
260        for i in ${PKG_MANIFEST}; do
261            [ ! -z "$($__echo "$i" | grep texmf-dist/doc/)" ] && \
262                with_docpkg=1 && break
263        done
264    fi
265
266    with_maplist=0
267    MAPLIST="$(tlpkg2maplist $pkg)"
268    [ ! -z "$MAPLIST" ] && with_maplist=1
269    ##$__echo $with_maplist && $__echo "$MAPLIST" && exit
270
271    with_inilist=0
272    INILIST="$(tlpkg2inilist $pkg)"
273    [ ! -z "$INILIST" ] && with_inilist=1
274    ##$__echo $with_inilist && $__echo "$INILIST" && exit
275
276cat<<EOF
277## -*- coding: utf-8-unix -*-
278## NOTE: This spec file is generated by $(basename $0) ${VERSION}-${RELEASE}:
279## $(basename $0) $pkg
280
281%global _use_internal_dependency_generator 0
282%global __find_provides %{nil}
283%global __find_requires %{nil}
284
285%bcond_with firstbuild
286
287%define tex_destdir     %{_datadir}
288%define texmf           %{tex_destdir}/texmf
289%define texlive_src     %{tex_destdir}/texlive-sources
290%define build_tex_destdir       %{buildroot}%{tex_destdir}
291%define build_texmf     %{buildroot}%{texmf}
292
293%define exec_mktexlsr  [ -x %{_bindir}/texconfig-sys ] && PATH=%{_bindir}:\$PATH %{_bindir}/texconfig-sys rehash
294%define exec_texhash  [ -x %{_bindir}/texhash ] && PATH=%{_bindir}:\$PATH %{_bindir}/texhash
295%define exec_updmap   [ -x %{_bindir}/updmap-sys ] && PATH=%{_bindir}:\$PATH %{_bindir}/updmap-sys --nostop
296%define exec_fmtutil  [ -x %{_bindir}/fmtutil-sys ] && PATH=%{_bindir}:\$PATH %{_bindir}/fmtutil-sys --all >/dev/null 2>&1
297%define exec_upddeffont    [ -x %{_sbindir}/update-defaultfont ] && %{_sbindir}/update-defaultfont 2> /dev/null
298%define vartexfonts %{_var}/lib/texmf
299
300Summary: ${RPM_SUMMARY}
301Summary(ja): ${RPM_SUMMARY}
302Name: texlive-$pkg
303Version: ${VERSION}
304Release: ${RELEASE}%{?_dist_release}
305License: ${RPM_LICENSE}
306Group: Applications/Publishing
307URL:http://www.tug.org/texlive/
308
309Requires: texlive = %{version}
310$RPM_REQUIRES
311
312Requires(post):         texlive = %{version}
313Requires(postun):       texlive = %{version}
314BuildRequires:          texlive-sources = %{version}
315
316BuildArch:      noarch
317Buildroot:      %{_tmppath}/%{name}-%{version}-root
318
319Vendor:         ${RPM_VENDOR}
320Distribution:   ${RPM_DISTRIBUTION}
321Packager:       ${RPM_PACKAGER}
322
323%description
324The TeX Live software distribution offers a complete TeX system for a
325variety of Unix, Macintosh, Windows and other platforms. It
326encompasses programs for editing, typesetting, previewing and printing
327of TeX documents in many different languages, and a large collection
328of TeX macros and font libraries.
329
330The distribution includes extensive general documentation about TeX,
331as well as the documentation for the included software packages.
332
333This package is a collection of ${PKG_SHORTDESC}:
334${PKG_LONGDESC}
335
336This package contains the following CTAN packages:
337${PKG_CTANPKGSLIST}
338
339%description -l ja
340TeX Live ソフトウェアディストリビューションは、
341さまざまな Unix, Macintosh, Windows、および
342他のプラットホームに対して完全な TeX システムを提供します。
343多くの異なった言語を含む TeX ドキュメントの
344編集、組版、閲覧、印刷するためのプログラム、
345そして、TeX マクロやフォントライブラリの大きなコレクションを
346同梱しています。
347
348このディストリビューションは
349同梱しているソフトウェアパッケージのためのドキュメントばかりでなく、
350TeX に関するたくさんの一般的なドキュメントを含んでいます。
351
352このパッケージは以下のようなパッケージ集です。
353${PKG_SHORTDESC}:
354${PKG_LONGDESC}
355
356このパッケージは以下の CTAN パッケージを含んでいます:
357${PKG_CTANPKGSLIST}
358
359EOF
360
361## subpackage: %{name}-doc
362if [ $with_docpkg -eq 1 ]; then
363    cat<<EOF
364%package doc
365Summary: TeX Live: Documentation files of %{name}
366Group: Applications/Publishing
367Requires: %{name} = %{version}-%{release}
368
369%description doc
370This package contains documentation files of %{name}.
371
372EOF
373fi
374
375cat<<EOF
376%prep
377
378%build
379
380%install
381[ -n "%{buildroot}" -a "%{buildroot}" != / ] && %__rm -rf %{buildroot}
382
383PREF=%{buildroot}%{tex_destdir}
384
385manifest=(
386${PKG_MANIFEST}
387)
388
389%__mkdir_p \${PREF}/texmf-dist
390for i in "\${manifest[@]}"; do
391    %__install -m \$(stat -c %a %{texlive_src}/\$i) -p -D %{texlive_src}/\$i \${PREF}/\$i
392done
393EOF
394
395# cat<<EOF
396# ## make symlinks of core script utils
397# mk_symlinks=(
398# texlive-collection-binextra,/usr/bin/dviasm,/usr/share/texmf-dist/scripts/dviasm/dviasm.py
399# texlive-collection-binextra,/usr/bin/findhyph,/usr/share/texmf-dist/scripts/findhyph/findhyph
400# texlive-collection-binextra,/usr/bin/fragmaster,/usr/share/texmf-dist/scripts/fragmaster/fragmaster.pl
401# texlive-collection-binextra,/usr/bin/latex2man,/usr/share/texmf-dist/scripts/latex2man/latex2man
402# texlive-collection-binextra,/usr/bin/latexmk,/usr/share/texmf-dist/scripts/latexmk/latexmk.pl
403# texlive-collection-binextra,/usr/bin/listings-ext.sh,/usr/share/texmf-dist/scripts/listings-ext/listings-ext.sh
404# texlive-collection-binextra,/usr/bin/mkjobtexmf,/usr/share/texmf-dist/scripts/mkjobtexmf/mkjobtexmf.pl
405# texlive-collection-binextra,/usr/bin/pdfcrop,/usr/share/texmf-dist/scripts/pdfcrop/pdfcrop.pl
406# texlive-collection-binextra,/usr/bin/pkfix,/usr/share/texmf-dist/scripts/pkfix/pkfix.pl
407# texlive-collection-binextra,/usr/bin/pkfix-helper,/usr/share/texmf-dist/scripts/pkfix-helper/pkfix-helper
408# texlive-collection-binextra,/usr/bin/purifyeps,/usr/share/texmf-dist/scripts/purifyeps/purifyeps
409# texlive-collection-binextra,/usr/bin/texcount,/usr/share/texmf-dist/scripts/texcount/texcount.pl
410# texlive-collection-binextra,/usr/bin/texdiff,/usr/share/texmf-dist/scripts/texdiff/texdiff
411# texlive-collection-binextra,/usr/bin/texdirflatten,/usr/share/texmf-dist/scripts/texdirflatten/texdirflatten
412# texlive-collection-binextra,/usr/bin/texloganalyser,/usr/share/texmf-dist/scripts/texloganalyser/texloganalyser
413# texlive-collection-context,/usr/bin/context,/usr/share/texmf-dist/scripts/context/stubs/unix/context
414# texlive-collection-context,/usr/bin/ctxtools,/usr/share/texmf-dist/scripts/context/stubs/unix/ctxtools
415# texlive-collection-context,/usr/bin/luatools,/usr/share/texmf-dist/scripts/context/lua/luatools.lua
416# texlive-collection-context,/usr/bin/makempy,/usr/share/texmf-dist/scripts/context/stubs/unix/makempy
417# texlive-collection-context,/usr/bin/mpstools,/usr/share/texmf-dist/scripts/context/stubs/unix/mpstools
418# texlive-collection-context,/usr/bin/mptopdf,/usr/share/texmf-dist/scripts/context/stubs/unix/mptopdf
419# texlive-collection-context,/usr/bin/mtxrun,/usr/share/texmf-dist/scripts/context/lua/mtxrun.lua
420# texlive-collection-context,/usr/bin/mtxtools,/usr/share/texmf-dist/scripts/context/stubs/unix/mtxtools
421# texlive-collection-context,/usr/bin/pdftools,/usr/share/texmf-dist/scripts/context/stubs/unix/pdftools
422# texlive-collection-context,/usr/bin/pstopdf,/usr/share/texmf-dist/scripts/context/stubs/unix/pstopdf
423# texlive-collection-context,/usr/bin/rlxtools,/usr/share/texmf-dist/scripts/context/stubs/unix/rlxtools
424# texlive-collection-context,/usr/bin/runtools,/usr/share/texmf-dist/scripts/context/stubs/unix/runtools
425# texlive-collection-context,/usr/bin/texexec,/usr/share/texmf-dist/scripts/context/stubs/unix/texexec
426# texlive-collection-context,/usr/bin/texfont,/usr/share/texmf-dist/scripts/context/stubs/unix/texfont
427# texlive-collection-context,/usr/bin/texmfstart,/usr/share/texmf-dist/scripts/context/ruby/texmfstart.rb
428# texlive-collection-context,/usr/bin/textools,/usr/share/texmf-dist/scripts/context/stubs/unix/textools
429# texlive-collection-context,/usr/bin/texutil,/usr/share/texmf-dist/scripts/context/stubs/unix/texutil
430# texlive-collection-context,/usr/bin/tmftools,/usr/share/texmf-dist/scripts/context/stubs/unix/tmftools
431# texlive-collection-context,/usr/bin/xmltools,/usr/share/texmf-dist/scripts/context/stubs/unix/xmltools
432# texlive-collection-fontutils,/usr/bin/afm2afm,/usr/share/texmf-dist/scripts/fontools/afm2afm
433# texlive-collection-fontutils,/usr/bin/autoinst,/usr/share/texmf-dist/scripts/fontools/autoinst
434# texlive-collection-fontutils,/usr/bin/cmap2enc,/usr/share/texmf-dist/scripts/fontools/cmap2enc
435# texlive-collection-fontutils,/usr/bin/epstopdf,/usr/share/texmf-dist/scripts/epstopdf/epstopdf.pl
436# texlive-collection-fontutils,/usr/bin/font2afm,/usr/share/texmf-dist/scripts/fontools/font2afm
437# texlive-collection-fontutils,/usr/bin/mkt1font,/usr/share/texmf-dist/scripts/accfonts/mkt1font
438# texlive-collection-fontutils,/usr/bin/ot2kpx,/usr/share/texmf-dist/scripts/fontools/ot2kpx
439# texlive-collection-fontutils,/usr/bin/pfm2kpx,/usr/share/texmf-dist/scripts/fontools/pfm2kpx
440# texlive-collection-fontutils,/usr/bin/showglyphs,/usr/share/texmf-dist/scripts/fontools/showglyphs
441# texlive-collection-fontutils,/usr/bin/vpl2ovp,/usr/share/texmf-dist/scripts/accfonts/vpl2ovp
442# texlive-collection-fontutils,/usr/bin/vpl2vpl,/usr/share/texmf-dist/scripts/accfonts/vpl2vpl
443# texlive-collection-langgreek,/usr/bin/mkgrkindex,/usr/share/texmf-dist/scripts/mkgrkindex/mkgrkindex
444# texlive-collection-langindic,/usr/bin/ebong,/usr/share/texmf-dist/scripts/bengali/ebong.py
445# texlive-collection-latex,/usr/bin/pdfatfi,/usr/share/texmf-dist/scripts/oberdiek/pdfatfi.pl
446# texlive-collection-latexextra,/usr/bin/makeglossaries,/usr/share/texmf-dist/scripts/glossaries/makeglossaries
447# texlive-collection-latexextra,/usr/bin/pdfannotextractor,/usr/share/texmf-dist/scripts/pax/pdfannotextractor.pl
448# texlive-collection-latexextra,/usr/bin/pdfthumb,/usr/share/texmf-dist/scripts/ppower4/pdfthumb.tlu
449# texlive-collection-latexextra,/usr/bin/perltex,/usr/share/texmf-dist/scripts/perltex/perltex
450# texlive-collection-latexextra,/usr/bin/ppower4,/usr/share/texmf-dist/scripts/ppower4/ppower4.tlu
451# texlive-collection-latexextra,/usr/bin/ps4pdf,/usr/share/texmf-dist/scripts/pst-pdf/ps4pdf
452# texlive-collection-latexextra,/usr/bin/splitindex,/usr/share/texmf-dist/scripts/splitindex/perl/splitindex.pl
453# texlive-collection-latexextra,/usr/bin/svn-multi,/usr/share/texmf-dist/scripts/svn-multi/svn-multi.pl
454# texlive-collection-latexextra,/usr/bin/vpe,/usr/share/texmf-dist/scripts/vpe/vpe.pl
455# texlive-collection-latexrecommended,/usr/bin/thumbpdf,/usr/share/texmf-dist/scripts/thumbpdf/thumbpdf.pl
456# texlive-collection-pictures,/usr/bin/cachepic,/usr/share/texmf-dist/scripts/cachepic/cachepic.tlu
457# texlive-collection-pictures,/usr/bin/epspdf,/usr/share/texmf-dist/scripts/epspdf/epspdf
458# texlive-collection-pictures,/usr/bin/epspdftk,/usr/share/texmf-dist/scripts/epspdf/epspdftk
459# texlive-collection-pictures,/usr/bin/fig4latex,/usr/share/texmf-dist/scripts/fig4latex/fig4latex
460# texlive-collection-pstricks,/usr/bin/pst2pdf,/usr/share/texmf-dist/scripts/pst2pdf/pst2pdf.pl
461# texlive-collection-science,/usr/bin/ulqda,/usr/share/texmf-dist/scripts/ulqda/ulqda.pl
462# )
463# %__mkdir_p %{buildroot}%{_bindir}
464# pushd %{buildroot}%{_bindir}
465#     for i in "\${mk_symlinks[@]}"; do
466#         tlc=\$(echo \$i | cut -f 1 -d",")
467#         lnk=\$(echo \$i | cut -f 2 -d"," | %__sed -e "s|/usr/bin/||")
468#         rlnk=\$(echo \$i | cut -f 3 -d"," | %__sed -e "s|/usr/|../|")
469
470#         [ "%{name}" = "\$tlc" ] || continue
471#         [ -f \$rlnk ] || exit 1
472#         %__ln_s \$rlnk \$lnk || exit 1
473#     done
474# popd
475# EOF
476
477cat<<EOF
478## remove asymptote directries, which provides asymptote package
479find %{buildroot} -regex ".*asymptote.*" | xargs %__rm -rf
480
481## Files list
482find %{buildroot} -type f -or -type l | \\
483    %__sed -e "s|%{buildroot}||g" > filelist.full
484
485find %{buildroot}%{texmf}-dist -type d | \\
486    %__sed -e "s|^%{buildroot}|%dir |" \\
487           -e "s|\$|/|"             >> filelist.full
488
489EOF
490
491## subpackage: %{name}-doc
492if [ $with_docpkg -eq 1 ]; then
493    cat<<EOF
494## subpackages
495grep "/texmf-dist/doc/" filelist.full > filelist.doc
496cat filelist.doc filelist.full | sort | uniq -u > filelist.tmp
497%__mv -f filelist.tmp filelist.full
498
499EOF
500fi
501
502cat<<EOF
503%clean
504%__rm -rf %{buildroot}
505
506%post
507%{exec_texhash}
508
509EOF
510
511## Running updmap
512if [ $with_maplist -eq 1 ]; then
513    cat<<EOF
514[ -f %{texmf}/web2c/updmap.cfg ] || exit 0
515
516updmap_lock=%{texmf}/updmap.lock
517$($__echo "$MAPLIST" | while read maptype map; do \
518    cat<<EOT
519%{exec_updmap} --listmaps 2>/dev/null | egrep -q "^#! ${maptype} ${map}" && \\
520    echo -n "    " && \\
521    echo -n "Running updmap: enable ${map} ... " && \\
522    %{exec_updmap} --nomkmap --enable ${maptype} ${map} >/dev/null 2>&1 && \\
523    echo "done." && \\
524    touch \${updmap_lock}
525EOT
526done)
527
528rpm -q --quiet texlive-common || exit 0
529
530[ -f \${updmap_lock} ] && \\
531    echo -n "    " && \\
532    echo -n "Running updmap: recreate map files ... " && \\
533    %{exec_updmap} >/dev/null 2>&1 && \\
534    echo "done." && \\
535    rm -f \${updmap_lock}
536
537EOF
538fi
539
540## Running fmtutil
541if [ $with_inilist -eq 1 ]; then
542    cat<<EOF
543rpm -q --quiet texlive-common || exit 0
544
545echo -n "    "
546echo -n "Running fmtutil ... " && %{exec_fmtutil} && echo "done."
547
548EOF
549fi
550
551cat<<EOF
552exit 0
553
554
555%postun
556if [ "\$1" = 0 ]; then
557    %{exec_texhash}
558
559EOF
560
561## Running updmap
562if [ $with_maplist -eq 1 ]; then
563    cat<<EOF
564    [ -f %{texmf}/web2c/updmap.cfg ] || exit 0
565
566$($__echo "$MAPLIST" | while read maptype map; do \
567    cat<<EOT
568    %{exec_updmap} --listmaps 2>/dev/null | egrep -q "^${maptype} ${map}" && \\
569        echo -n "    " && \\
570        echo -n "Running updmap: disable ${map} ... " && \\
571        %{exec_updmap} --nomkmap --disable ${map} >/dev/null 2>&1 && \\
572        echo "done."
573EOT
574done)
575    echo -n "    " && \\
576        echo -n "Running updmap: recreate map files ... " && \\
577        %{exec_updmap} >/dev/null 2>&1 && \\
578        echo "done."
579
580EOF
581fi
582
583cat<<EOF
584fi
585
586exit 0
587
588%files -f filelist.full
589%defattr(-,root,root,-)
590
591EOF
592## subpackage: %{name}-doc
593if [ $with_docpkg -eq 1 ]; then
594    cat<<EOF
595%files -f filelist.doc doc
596%defattr(-,root,root,-)
597
598EOF
599fi
600
601cat<<EOF
602%changelog
603* Sun Oct 30 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2011-1
604- generated by $(basename $0) 2011-1: $(basename $0) $($__echo $*)
605
606* Mon Mar 23 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2009-4
607- generated by $(basename $0) 2009-4: $(basename $0) $($__echo $*)
608- make symlinks of core script utils (texlive-collection-binextra,
609  texlive-collection-context, texlive-collection-fontutils,
610  texlive-collection-langgreek, texlive-collection-langindic,
611  texlive-collection-latex, texlive-collection-latexextra,
612  texlive-collection-latexrecommended, texlive-collection-pictures,
613  texlive-collection-pstricks, texlive-collection-science)
614
615* Fri Jan 14 2011 Munehiro Yamamoto <munepi@vinelinux.org> 2009-3
616- generated by $(basename $0) 2009-3: $(basename $0) $($__echo $*)
617- improved %%post
618
619* Fri Oct 01 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2009-2
620- generated by $(basename $0) 2009-2: $(basename $0) $($__echo $*)
621- removed arch dependent binaries (texlive-collection-latexextra)
622- fixed perl path
623- improved updmap process in %%post and %%postun
624
625* Sat Aug 07 2010 Munehiro Yamamoto <munepi@vinelinux.org> 2009-1
626- generated by $(basename $0) 2009-1: $(basename $0) $($__echo $*)
627EOF
628
629    return 0
630}
631
632## mkrpmcollection [--minimal-collections|--standard-collections|--full-collections]
633mkrpmcollection(){
634    local category=$($__echo $1 | sed -e "s/--\([a-z]*\)-collections/\1/")
635    local category_pkglist=
636    local i=
637
638    case $category in
639        minimal|standard)
640            category_pkglist=$(grep -e "${category}," $CATEGORYLIST | sed -e "s/${category},//g" | sed -e "s/,$//g")
641            ;;
642        full)
643            category_pkglist=$(Usage | egrep "^collection-")
644            ;;
645        *)
646            $__echo "E: unknown category: $category"
647            return 1
648            ;;
649    esac
650
651    for i in ${category_pkglist}; do
652        mkrpmspec $i > texlive-${i}-vl.spec
653        if [ $? -eq 1 ]; then
654            $__echo "texlive-${i}-vl.spec: "
655            cat texlive-${i}-vl.spec
656            rm -f texlive-${i}-vl.spec
657            continue
658        fi
659        rpmbuild -ba texlive-${i}-vl.spec || return 1
660    done
661
662    return 0
663}
664
665setup-tlpdb2rpmspec(){
666    __echo=$(which echo 2>/dev/null)
667    [ ! -f $__echo ] && return 1
668
669    ## load your .vtlpkg.conf
670    if [ -f ${HOME}/.vtlpkg.conf ]; then
671        . ${HOME}/.vtlpkg.conf
672    else
673        $__echo "E: ${HOME}/.vtlpkg.conf: No such file"
674        return 1
675    fi
676
677    [ -z "$RPM_VENDOR" ] && \
678        $__echo "E: \$RPM_VENDOR is empty" && return 1
679    [ -z "$RPM_DISTRIBUTION" ] && \
680        $__echo "E: \$RPM_DISTRIBUTION is empty" && return 1
681    [ -z "$RPM_GPG_NAME" ] && \
682        $__echo "E: \$RPM_GPG_NAME is empty" && return 1
683    [ -z "$RPM_PACKAGER" ] && \
684        $__echo "E: \$RPM_PACKAGER is empty" && return 1
685
686    ## setup configurations
687    VERSION=@@VTLPKG_VERSION@@
688    RELEASE=@@VTLPKG_RELEASE@@
689
690    ## set a tlpdb file for TeX Live, which is a package database file.
691    TLPDB=@@VTLPKG_TLPDB@@
692    TLPDB_MAXLINE=$(wc -l $TLPDB | awk '{print $1}')
693
694    ## category of collection-*
695    CATEGORYLIST=@@VTLPKG_CATEGORYLIST@@
696
697    ## set some booleans
698    with_option=0
699}
700
701##############################################################################
702
703setup-tlpdb2rpmspec || exit 1
704
705check-parameter $* || exit 1
706
707case $1 in
708    --name|--category|--revision|--depend|--shortdesc|--longdesc|--execute|--catalogue-ctan|--catalogue-date|--catalogue-license|--catalogue-version|--filelist)
709        tlpkg4a $1 $2 || exit 1
710        ;;
711    --minimal-collections|--standard-collections|--full-collections)
712        mkrpmcollection $1 || exit 1
713        ;;
714    *)
715        mkrpmspec $1 || exit 1
716        ;;
717esac
718
719exit
720
721### end of file
Note: See TracBrowser for help on using the repository browser.