#!/bin/bash

#########################################

CHRDIR=/chroot

#########################################

aptls() {
    echo -ne " "
    #grep "^deb " $1/etc/apt/sources.list |sed -e "s/^deb [a-z\:\.\/]* //" |grep "main" |grep -v "updates" |grep -v "backports"
    vers=`grep "^deb " $1/etc/apt/sources.list |sed -e "s/^deb [a-z\:\.\/\-]* //" | sed -e "s/^\([a-z]*\).*/\1/" |uniq`
    echo $vers
}

# gather from all the chroots
if [ -d $CHRDIR ]; then
    CHROOTS=`find $CHRDIR -maxdepth 1 -type d`
fi

echo -n "root: "
ver=`cat /etc/debian_version`
echo -n $ver
aptls /

for CHR in $CHROOTS; do
    if [ -f $CHR/etc/debian_version ]; then 
	ver=`cat $CHR/etc/debian_version`
	echo -n "$CHR: "
	echo -n $ver
	aptls $CHR
    fi
done
