#!/bin/sh

# dependees maintained by the same maintainer are listed without
# name/email. only "external" dependees (ones maintained by someone else)
# have the name/email displayed.

EES=ees
if [ "$( basename $0 )" = "getmaintreqs" ]; then
  REV=-r
  EES=encies
fi

source ~/sbostuff/sbostuff.sh

##if [ "$1" = "-b" ]; then
##  shift
##  builds="$1"
##  cdsb $builds && maint="$( source ./*.info && echo $MAINTAINER )"
##  shift
##  if [ "$*" ]; then
##    echo "$( basename $0 ): -b only allows one build" 1>&2
##	 exit 1
##  fi
##else
##  maint="$*"
##  builds="$( getmaintbuilds "$@" )"
##fi

maint="$*"
builds="$( getmaintbuilds "$@" )"

for i in $builds; do
  set $( hoorex -m $REV $i )
  if [ "$2" ]; then
    echo -n "$1"
    shift
    echo -n ": "
    can_orphan=yes
    for j in "$@"; do
      echo -n "$j "
      cdsb $j
      source ./$j.info
      if [ "$MAINTAINER" != "$maint" -a "$EMAIL" != "NOEMAIL" ]; then
        can_orphan=no
        echo -n "('$MAINTAINER' $EMAIL)  "
      fi
    done
    echo
    [ "$can_orphan" = "yes" ] && orphanable+="$i "
  else
    orphanable+="$1 "
  fi
done

if [ "$orphanable" != "" ]; then
  echo "These have no depend$EES by other maintainers:"
  echo "$orphanable"
fi
