#!/bin/sh
# -*-mode: sh; tab-width: 8; coding: utf-8-unix -*-
# filter

CACHE=/mnt/i/net/Http
grep ^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
