#!/bin/bash
# 	$Id: show-vine-default.sh,v 1.2 2009/05/20 15:31:29 munepi Exp munepi $	

if [ $# -ne 1 ]; then
    cat<<EOF
Usage:	$(basename $0) <version>
EOF
    exit 1
fi

VERSION=$1

if [ $(egrep -m 1 $VERSION /var/lib/emacsen-common/installed-flavors) ]; then
    FLAVOR=$(egrep -m 1 $VERSION /var/lib/emacsen-common/installed-flavors)
else
    exit 1
fi

[ -d /etc/${FLAVOR} ] || exit 1

ORDER="base faces"
ORDER="${ORDER} $(ls /etc/${FLAVOR}/site-start.d/*-init.el | \
    sed -e "s!.*/[0-9]*\(.*\)-init\.el!\1!g")"

LIST="$(find /usr/share/${FLAVOR}/site-lisp/ \
    -regex '.*/vine-default.*\.el')"

for PKG in $ORDER; do
    if [ $(echo "$LIST" | egrep $PKG) ]; then
	EL=$(echo "$LIST" | egrep $PKG | head -1)
	echo ";;; Begin $EL"
	cat $EL
	echo ";;; End of $EL"
	echo ""
    fi
done

exit

