#!/bin/bash # tlpdb2rpmspec # # Copyright 2010-2017 Munehiro Yamamoto # This file is licensed under the GNU General Public License version 2 # or any later version. Usage(){ cat</dev/null | grep -v -e alpha-linux -e amd64-freebsd -e amd64-kfreebsd -e amd64-netbsd -e armel-linux -e armhf-linux -e i386-cygwin -e i386-freebsd -e i386-kfreebsd -e i386-linux -e i386-netbsd -e i386-solaris -e mips-irix -e mipsel-linux -e powerpc-linux -e sparc-solaris -e universal-darwin -e win32 -e x86_64-cygwin -e x86_64-darwin -e x86_64-linux -e x86_64-solaris | sed -e "s,.*/,,g" done return 0 } ## tlpkg2manifest [pkgname] tlpkg2manifest(){ [ $# -eq 1 ] || return 1 local pkg=$1 local pkgdeps="$(tlpkg4a --depend $pkg)" local i= tlpkg4a --filelist $pkg || return 1 ## if $pkg is not collection-*, only return the filelist of $pkg $__echo $pkg | egrep -q "^collection-" || return 0 ##!! we need pure filelist of $pkg; remove collection-* pkgdeps=$($__echo $pkgdeps | sed -e "s,collection-[-A-Za-z0-9]*,,g") [ -z "$pkgdeps" ] && return 0 for i in $pkgdeps; do tlpkg4a --filelist $i || return 1 done return 0 } ## tlpkg2maplist [pkgname] tlpkg2maplist(){ [ $# -eq 1 ] || return 1 local pkg=$1 local pkgdeps="$(tlpkg4a --depend $pkg)" local i= tlpkg4a --execute $pkg | grep -e "Map" | sed -e "s,^add,,g" ##!! we need pure filelist of $pkg; remove collection-* pkgdeps=$($__echo $pkgdeps | sed -e "s,collection-[-A-Za-z0-9]*,,g") [ -z "$pkgdeps" ] && return 0 for i in $pkgdeps; do tlpkg4a --execute $i | grep -e "Map" | sed -e "s,^add,,g" done return 0 } ## tlpkg2inilist [pkgname] tlpkg2inilist(){ [ $# -eq 1 ] || return 1 local pkg=$1 local pkgdeps="$(tlpkg4a --depend $pkg)" local i= ## search AddFormat, AddHypen tlpkg4a --execute $pkg | grep -e "Add" ##!! we need pure filelist of $pkg; remove collection-* pkgdeps=$($__echo $pkgdeps | sed -e "s,collection-[-A-Za-z0-9]*,,g") [ -z "$pkgdeps" ] && return 0 for i in $pkgdeps; do tlpkg4a --execute $i | grep -e "Add" done return 0 } ## mkrpmspec [pkgname] mkrpmspec(){ [ $# -eq 1 ] || return 1 local pkg=$1 local i= RPM_SUMMARY="TeX Live: $(tlpkg4a --shortdesc $pkg)" ## Requires tag for texlive RPM_REQUIRES=$(for i in $(tlpkg4a --depend $pkg | egrep "^collection-"); do \ $__echo "Requires: texlive-$i = %{version}"; \ done) ## Requires tag for external dependencies [ ! -z "$ASYMPTOTE_PACKAGE" ] && \ [ ! -z "$(tlpdb2rpmspec --depend $pkg | egrep "^asymptote$")" ] && \ RPM_REQUIRES="${RPM_REQUIRES} Requires: $ASYMPTOTE_PACKAGE" [ ! -z "$DETEX_PACKAGE" ] && \ [ ! -z "$(tlpdb2rpmspec --depend $pkg | egrep "^detex$")" ] && \ RPM_REQUIRES="${RPM_REQUIRES} Requires: $DETEX_PACKAGE" [ ! -z "$DVIPNG_PACKAGE" ] && \ [ ! -z "$(tlpdb2rpmspec --depend $pkg | egrep "^dvipng$")" ] && \ RPM_REQUIRES="${RPM_REQUIRES} Requires: $DVIPNG_PACKAGE" [ ! -z "$LATEXMK_PACKAGE" ] && \ [ ! -z "$(tlpdb2rpmspec --depend $pkg | egrep "^latexmk$")" ] && \ RPM_REQUIRES="${RPM_REQUIRES} Requires: $LATEXMK_PACKAGE" [ ! -z "$LCDF_TYPETOOLS_PACKAGE" ] && \ [ ! -z "$(tlpdb2rpmspec --depend $pkg | egrep "^lcdftypetools$")" ] && \ RPM_REQUIRES="${RPM_REQUIRES} Requires: $LCDF_TYPETOOLS_PACKAGE" [ ! -z "$PSUTILS_PACKAGE" ] && \ [ ! -z "$(tlpdb2rpmspec --depend $pkg | egrep "^psutils$")" ] && \ RPM_REQUIRES="${RPM_REQUIRES} Requires: $PSUTILS_PACKAGE" [ ! -z "$T1UTILS_PACKAGE" ] && \ [ ! -z "$(tlpdb2rpmspec --depend $pkg | egrep "^t1utils$")" ] && \ RPM_REQUIRES="${RPM_REQUIRES} Requires: $T1UTILS_PACKAGE" ## License tag RPM_LICENSE="$(tlpkg2speclicense $pkg)," for i in $(tlpkg4a --depend $pkg | egrep -v "^collection-"); do tmp=$(tlpkg2speclicense $i) $__echo "$RPM_LICENSE" | grep -q "${tmp}," [ $? -eq 1 ] && RPM_LICENSE="${RPM_LICENSE} ${tmp}," done RPM_LICENSE=$($__echo "$RPM_LICENSE" | sed -e "s/,$//" | sed -e "s/^, //") [ -z "$RPM_LICENSE" ] && RPM_LICENSE=distributable PKG_SHORTDESC=$(tlpkg4a --shortdesc $pkg) PKG_LONGDESC=$(tlpkg4a --longdesc $pkg) PKG_CTANPKGSLIST=$(for i in $(tlpkg4a --depend $pkg); do \ if [ -z "$($__echo "$i" | grep "collection-")" ]; then \ $__echo -n "$i: "; \ tmp=$(tlpkg4a --shortdesc $i); \ [ -z "${tmp}" ] && $__echo || $__echo "$tmp"; \ fi done) PKG_ARCHIVELIST=$(tlpkg2archivelist $pkg) [ -z "${PKG_ARCHIVELIST}" ] && \ $__echo "W: empty archive list: $pkg" >&2 ## check whether or not $pkg is collection-lang***** with_colllang=0 $__echo $pkg | egrep -q "^collection-lang" && \ with_colllang=1 ## check to need the subpackage %{name}-doc with_docpkg=0 for i in ${PKG_ARCHIVELIST}; do [ ! -z "$($__echo "$i" | egrep "\.doc\.")" ] && \ with_docpkg=1 && break done with_maplist=0 MAPLIST="$(tlpkg2maplist $pkg)" [ ! -z "$MAPLIST" ] && with_maplist=1 ##$__echo $with_maplist && $__echo "$MAPLIST" && exit with_inilist=0 INILIST="$(tlpkg2inilist $pkg)" [ ! -z "$INILIST" ] && with_inilist=1 ##$__echo $with_inilist && $__echo "$INILIST" && exit cat< filelist.full find %{buildroot}%{_tl_texmfdist} -type d | \\ %__sed -e "s|^%{buildroot}|%dir |" \\ -e "s|\$|/|" >> filelist.full EOF ## subpackage: %{name}-doc if [ $with_docpkg -eq 1 ]; then cat< filelist.doc cat filelist.doc filelist.full | sort | uniq -u > filelist.tmp %__mv -f filelist.tmp filelist.full EOF fi cat</dev/null 2>&1 if [ $? -eq 0 ]; then $__echo "W: already exists: texlive-${i}-${RPM_SPEC_SUFFIX}.spec" >&2 continue fi fi mkrpmspec $i > texlive-${i}-${RPM_SPEC_SUFFIX}.spec if [ $? -eq 1 ]; then $__echo "texlive-${i}-${RPM_SPEC_SUFFIX}.spec: " cat texlive-${i}-${RPM_SPEC_SUFFIX}.spec rm -f texlive-${i}-${RPM_SPEC_SUFFIX}.spec continue fi rpmbuild -ba --define="${macro_sourcedir}" texlive-${i}-${RPM_SPEC_SUFFIX}.spec || return 1 done return 0 } setup-tlpdb2rpmspec(){ __echo=$(which echo 2>/dev/null) [ ! -f $__echo ] && return 1 ## set external dependencies ASYMPTOTE_PACKAGE= DETEX_PACKAGE= DVIPNG_PACKAGE= LATEXMK_PACKAGE= LCDF_TYPETOOLS_PACKAGE= PSUTILS_PACKAGE= T1UTILS_PACKAGE= ## set local tlnet TLNETROOT=@@VTLPKG_TLNETROOT@@ TLPDB=@@VTLPKG_TLPDB@@ ## load your .vtlpkg.conf if [ -f ${HOME}/.vtlpkg.conf ]; then . ${HOME}/.vtlpkg.conf else $__echo "E: ${HOME}/.vtlpkg.conf: No such file" return 1 fi [ -z "$RPM_SPEC_SUFFIX" ] && \ $__echo "E: \$RPM_SPEC_SUFFIX is empty" && return 1 [ -z "$RPM_VENDOR" ] && \ $__echo "E: \$RPM_VENDOR is empty" && return 1 [ -z "$RPM_DISTRIBUTION" ] && \ $__echo "E: \$RPM_DISTRIBUTION is empty" && return 1 [ -z "$RPM_GPG_NAME" ] && \ $__echo "E: \$RPM_GPG_NAME is empty" && return 1 [ -z "$RPM_PACKAGER" ] && \ $__echo "E: \$RPM_PACKAGER is empty" && return 1 ## setup configurations VERSION=@@VTLPKG_VERSION@@ RELEASE=@@VTLPKG_RELEASE@@ ## check texlive.tlpdb [ ! -f $TLPDB ] && \ $__echo "E: \$TLPDB: No such file" && return 1 TLPDB_MAXLINE=$(wc -l $TLPDB | awk '{print $1}') ## category of collection-* CATEGORYLIST=@@VTLPKG_CATEGORYLIST@@ ## set some booleans with_option=0 } ############################################################################## setup-tlpdb2rpmspec || exit 1 check-parameter $* || exit 1 case $1 in --name|--category|--revision|--depend|--shortdesc|--longdesc|--execute|--catalogue-ctan|--catalogue-date|--catalogue-license|--catalogue-version|--filelist) tlpkg4a $1 $2 || exit 1 ;; --minimal-collections|--standard-collections|--full-collections) mkrpmcollection $1 || exit 1 ;; *) mkrpmspec $1 || exit 1 ;; esac exit ### end of file