File do.mklists of Package texlive-bin

#!/bin/bash -e
#
# Generate lists from full texlive tree
#
# Author: Werner Fink <werner@suse.de>

  LC_CTYPE=POSIX
LC_COLLATE=POSIX
export LC_CTYPE LC_COLLATE

: ${ROOT:=${RPM_BUILD_ROOT}}
: ${ARCH:=${BINARY}}
: ${TMPDIR:=/var/tmp}

if test ! -d ${TMPDIR} ; then
    mkdir -m 1755 ${TMPDIR}
fi

return=0
basedb=""
createit=""
finalize=""
binary=""
while getopts ":b:cfa" y ; do
    case $y in
    b)  basedb=$OPTARG	;;
    c)	createit=yes	;;
    f)  finalize=yes	;;
    a)  binary=yes	;;
    *)  echo ${0##*/}: Unknown parameter 1>&2
	exit 1
    esac
done

if test -z "$basedb" ; then
    echo ${0##*/}: No main data base provided 1>&2
    exit 1
fi
basedb="${TMPDIR}/${basedb}"
  rest="${basedb}-rest"

if test -n "$createit" -a "$createit" = "yes" ; then
    set -o noclobber
    set +o noglob
    exe="\./usr/\(\(\|\(lib\|share\)/texmf/\)bin/\(\|${ARCH}/\)[^/]*\|\(lib/\|lib64/\).*\.\(so\(\.[\.0-9]\+\)?\|l?a\)\)\$"

    rm -f $basedb $rest
    if test -n "$ROOT" -a -d "$ROOT" ; then
	pushd "$ROOT"
	find \( \( -not -type d \) -a -regex "$exe" -exec bash do.exec '{}' \; \) -o \
	     \( \( \( -not -type d \) -a \( -not -type l \) \) -printf '%p\n' \) -o \
	     \( -type d -printf '%p/\n' \) -o \( -type l -printf '%p\n'  \) \
	| sed 's@^\.@@' | sort -k 2 -t / > $basedb
	return=$?
	popd
    else
	find /etc/texmf /usr/lib/texmf /usr/share/texmf /var/cache/texmf /var/lib/texmf \
	     \( \( -not -type d \) -a -regex "$exe" -exec bash do.exec '{}' \; \) -o \
	     \( \( \( -not -type d \) -a \( -not -type l \) \) -printf '%p\n' \) -o \
	     \( -type d -printf '%p/\n' \) -o \( -type l -printf '%p\n'  \) \
	| sort -k 2 -t / > $basedb
	return=$?
    fi
    unset exe

    if test -s $basedb ; then
	grep -vE "^(/(|sbin/|sbin/conf.d/)|\
/etc/(|cron.daily/|permissions.d/|profile.d/|skel/)|\
/usr/X11R6/(|bin/|include/|lib/(|X11/(|app-defaults/)))|\
/usr/(|bin/|include/|sbin/|share/(|X11/(|app-defaults/)|doc/(|packages/)|info/|man/(|man[0-9]/))|lib/|lib64/)|\
/var/(|adm/(|fillup-templates/)|cache/(|fonts/)|lib/))\$" < $basedb > $rest
    else
	false
    fi
    exit 0
fi

if test ! -s "$basedb" ; then
    echo ${0##*/}: data base $basedb does not exist 1>&2
    exit 1
fi

if test -n "$finalize" -a "$finalize" = "yes" ; then
    set -o noclobber
    set +o noglob

    for pkg in ${basedb}-* ; do
	test "$pkg" -ef "$rest" && continue || true
	tmp=${pkg}.tmp

	case "$pkg" in
	*-bin-base)
	    BINDIR="s@^(/usr/lib/texmf(|/bin(|/$ARCH)))/\$@%isbin %dir \1@g"
	    BINDIR="${BINDIR};s@^(/var/lib/texmf)/\$@%isbin %dir %attr(1755, root, root) \1@g"
	    BINDIR="${BINDIR};s@^(/var/lib/texmf/link(|/$ARCH))/\$@%isbin %dir \1@g"
	    ;;
	*-base)
	    BINDIR="s@^(/usr/lib/texmf/bin/$ARCH)/\$@%isbin %dir \1@g"
	    BINDIR="${BINDIR};s@^(/var/lib/texmf/link(|/$ARCH))/\$@%isbin %dir \1@g"
	    ;;
	esac

	(echo '%defattr(-, root, root)'
	 sed -r -e "s@^(/usr/(lib|share)(|/texmf(/doc)?)(/info|/man(|/man[0-9])))/\$@%docdir \1\n%nobin %dir \1@g" \
		-e "s@^(/usr/share/doc/packages\/.*)/\$@%docdir \1\n%nobin %dir \1@g" \
		-e "s@^(/usr/(lib|share)(|/texmf(/doc)?)(/info|/man(|/man[0-9]))/[^/]+)\$@%doc \1@g" \
		-e "s@^([^%]etc/.*/ls-R)\$@%verify(not md5 mtime size) \1@" \
		-e "s@^([^%]var/.*/ls-R)\$@%attr(0666, root, root) %verify(not md5 mtime size) \1@" \
		-e "s@^([^%]usr/.*/ls-R)\$@%verify(user group link) \1@" \
		-e "s@^([^%]etc/.*[^/]+)\$@%config %verify(not md5 mtime size) \1@g" \
		-e "$BINDIR" \
		-e "s@^(/var/lib/texmf/fonts/map/.*\.map)\$@%verify(not link md5 mtime size) \1@g" \
		-e "s@^(/var/lib/texmf/web2c/.*\.(fmt|mem|base))\$@%verify(not md5 mtime size) \1@g" \
		-e "s@^(/var/lib/texmf(|/dist|/main))/\$@%dir %attr(1755, root, root) \1@g" \
		-e "s@^(/var/cache/texmf)/\$@%dir %attr(1755, root, root) \1@g" \
		-e "s@^(/var/cache/texmf/fonts(|/pk|/source|/tfm))/\$@%dir %attr(1777, root, root) \1@g" \
		-e "s@^(/usr/bin/[^/]*[^\*])\*\$@%isbin \1@g" \
		-e "s@^([^%].*)/\$@%dir \1@g" \
		-e "\@^%(no|is)bin@! s@^(.*[^\*])\$@%nobin \1@g"  \
		-e "\@^%(no|is)bin@! s@^(.*)\*\$@%isbin \1@g"
	) < ${pkg} > $tmp
	mv $tmp $pkg
    done
    exit $return
fi

if test -n "$binary" -a "$binary" = "yes" ; then
    set -o noclobber
    set +o noglob

    for pkg in ${basedb}-* ; do
	test "$pkg" -ef "$rest" && continue || true
	dir=${pkg%/*}
	bin=${pkg##*/}
	bin=${dir}/${bin/texlive/texlive-bin}
	(echo '%defattr(-, root, root)'
	 sed -rn '/^%isbin/{ s@%isbin[[:blank:]]+@@p; }') < $pkg > $bin
    done
    exit $return
fi

set -o noclobber
set -o noglob
while read -r pkg pat typ ; do
    case "$pkg" in
    \#*|"") continue ;;
    esac

    pkg=${basedb}-${pkg}
    test -n "$typ" && pkg=${pkg}-${typ}
    tmp=${pkg}.tmp

    if test -e $pkg ; then
	sort -k 2 -t / -m $pkg <(exec grep -E "$pat" $rest) > $tmp
	mv $tmp $pkg
    else
	sort -k 2 -t / < <(exec grep -E "$pat" $rest) > $pkg
    fi
    if grep -vFf $pkg $rest > $tmp ; then
	mv $tmp $rest
    else
	mv $tmp $rest
    fi
done
openSUSE Build Service is sponsored by