#!/bin/sh
# filter
ROLE=proxy
CACHE=/mnt/i/net/Http
grep --text ^http:// | \
  sed -e 's@ftp://[^ ]*@@g' | \
  while read line ; do
    for url in $line ; do 
        base=`basename "$url"`
	[ -e /usr/portage/distfiles/$base ] && break
        pre=`sed -e "s@http://@${CACHE}@" <<< $url`
        [ -e $pre ] && break
        echo $line
        break
      done
  done
exit 0
