#! /usr/bin/perl -w

@dirs = ("base", "bridge", "dhcp", "djbdns", "dsl", "hd", "httpd", "isdn", 
	 "lcd", "lpdsrv", "modem", "pcmcia", "ppp", "proxy", "register", 
	 "rootfs", "rootfs_mod", "samba_lpd", "serial", "squid", "sshd", 
	 "time", "tools", "template", "qos", "wlan", "usb", "easycron", 
	 "doc", "faxrcv", "dyneisfair", "avm-fcdsl2", "avm-fcdsl", "avm-fcpci", "avm-fcpnp", 
	 "avm-fcclassic", "avm-fcdslsl", "vpn", "ath_pci" , "avm-fcusb2");

# read files.txt
open (FILES, "files.txt") or die "can't open files.txt";

while (<FILES>) {
  /^. (.*)$/;
  $files{$1} = 1;
}

close FILES;

@ignore = (".*CVS.*", ".*2\.4\.20.*", ".*rootfs.src.busybox[^/].*", ".cvsignore");
# read files in directories
foreach $dir (@dirs) {
  open (FIND, "find $dir -type f -print |") or die "find failed";
 LINE: while (<FIND>) {
    chomp;
    foreach $i (@ignore) {
      next LINE if /$i/;
    }
    $real_files{$_} = 1;
  }
  close FIND;
}

# compare both hashes
print "Missing files:\n\n"; 
foreach $key (sort keys %files) {
  if (! defined ($real_files{$key})) {
    print " $key\n";
  }
}

print "\n\nNot in files.txt:\n\n"; 
foreach $key (sort keys %real_files) {
  if (! defined ($files{$key})) {
    print " $key\n";
  }
}
