#!/usr/bin/sh
NOVERSION=false
INSTALLED=no
while [ $# -gt 0 ]; do
    if [ x$1 = x--no-version ]; then
	NOVERSION=true
    elif [ x$1 = xinstalled ]; then
        INSTALLED=yes
    fi
    shift
done
if [ $INSTALLED = no ]; then
    exit 0
fi
LIST=$(cd /usr/lib64/sagemath/local/var/lib/sage/installed; echo *)
if [ $NOVERSION = false ]; then
    for pkg in $LIST; do
	echo $pkg | sed -e 's/-/ /'
    done
else
    for pkg in $LIST; do
	echo $pkg | sed -e 's/-.*//'
    done
fi
