#! /usr/bin/perl -w
#------------------------------------------------------------------------------
# check-files.pl - show differences between files.txt and CVS tree
#
# usage: check-files.pl
#
# Please add package directory names to this file!
#
# Creation:    11.09.2003 jw5
# Last Update: $Id$
#------------------------------------------------------------------------------

# --- MODULES ---
use File::Find;

# --- CONFIG ---

# Subdirectories to use
@dirs = (
	"advanced_networking", "ath_pci", "avm-fcclassic", "avm-fcdsl", "avm-fcdsl2", "avm-fcdslsl",
	"avm-fcdslusb", "avm-fcpci", "avm-fcpnp", "avm-fcusb", "avm-fcusb2",
	"avm-fxusb", "base", "bridge", "chrony", "cpmvrmlog", "dnsmasq", "dhcp", "djbdns",
	"doc", "dsl", "dvb", "dyneisfair", "easycron", "faxrcv", "hd", "httpd", "isdn",
	"lcd", "lpdsrv", "modem", "oidentd", "pcmcia", "ppp", "proxy", "qos",
	"register", "rootfs", "samba_lpd", "serial", "shfs", "squid", "sshd",
	"template", "time", "tools", "usb", "usercmd", "vpn", "wlan", "avm-fcdslslusb",
);
# These are pre-compiled pattern, add new ones the same way
@ignore = (
	qr{CVS},
	qr{rootfs.src.busybox[^/]},
	qr{\.cvsignore}
);
# These are the fileslists where all files should be listed...
@filelists = (
	"files.txt"
);

# --- SUBS ---
sub process_file {
	return unless -f;

	foreach $pat (@ignore) {
		return if $File::Find::name =~ /$pat/;
	}
	$real_files{$File::Find::name} = 1;
}

# --- MAIN ---

# read files.txt
foreach $list (@filelists) {
	open (FILES, "<", $list) or die "can't open '$list': $!";

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

	close FILES;
}

# read files in directories
find(\&process_file, @dirs);

# 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";
	}
}

print "\n";

# vi: set ts=4 sw=4:
