*** Validation.pm.fink	Fri May 16 11:10:40 2003
--- Validation.pm	Tue Jun  3 19:20:49 2003
***************
*** 410,427 ****
  # - usage of non-recommended directories (/sw/src, /sw/man, /sw/info, /sw/doc, /sw/libexec, /sw/lib/locale)
  # - usage of other non-standard subdirs 
  # - storage of a .bundle inside /sw/lib/perl5/darwin or /sw/lib/perl5/auto
  # - ideas?
  #
  sub validate_dpkg_file {
! 	my $filename = shift;
  	my @bad_dirs = ("$basepath/src/", "$basepath/man/", "$basepath/info/", "$basepath/doc/", "$basepath/libexec/", "$basepath/lib/locale/");
  	my ($pid, $bad_dir);
  	
! 	print "Validating .deb file $filename...\n";
  	
  	# Quick & Dirty solution!!!
! 	# This is a potential security risk, we should maybe filter $filename...
! 	$pid = open(DPKG_CONTENTS, "dpkg --contents $filename |") or die "Couldn't run dpkg: $!\n";
  	while (<DPKG_CONTENTS>) {
  		# process
  		if (/([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*\.([^\s]*)/) {
--- 410,432 ----
  # - usage of non-recommended directories (/sw/src, /sw/man, /sw/info, /sw/doc, /sw/libexec, /sw/lib/locale)
  # - usage of other non-standard subdirs 
  # - storage of a .bundle inside /sw/lib/perl5/darwin or /sw/lib/perl5/auto
+ # - Emacs packages
+ #     - installation of .elc files
+ #     - installing files directly in /sw/share/emacs/site-lisp
  # - ideas?
  #
  sub validate_dpkg_file {
! 	my $dpkg_filename = shift;
  	my @bad_dirs = ("$basepath/src/", "$basepath/man/", "$basepath/info/", "$basepath/doc/", "$basepath/libexec/", "$basepath/lib/locale/");
  	my ($pid, $bad_dir);
+ 	my $emacs_violation = 0;
+ 	my $filename;
  	
! 	print "Validating .deb file $dpkg_filename...\n";
  	
  	# Quick & Dirty solution!!!
! 	# This is a potential security risk, we should maybe filter $dpkg_filename...
! 	$pid = open(DPKG_CONTENTS, "dpkg --contents $dpkg_filename |") or die "Couldn't run dpkg: $!\n";
  	while (<DPKG_CONTENTS>) {
  		# process
  		if (/([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*([^\s]*)\s*\.([^\s]*)/) {
***************
*** 429,439 ****
  			#print "$filename\n";
  			next if $filename eq "/";
  			if (not $filename =~ /^$basepath/) {
! 				print "Warning: File \"$filename\" installed outside of $basepath\n";
  			} elsif ($filename =~/^($basepath\/lib\/perl5\/auto\/.*\.bundle)/ ) {
! 				print "Warning: Apparent perl XS module installed directly into $basepath/lib/perl5 instead of a versioned subdirectory.\n  Offending file: $1\n"
  			} elsif ( $filename =~/^($basepath\/lib\/perl5\/darwin\/.*\.bundle)/ ) {
! 				print "Warning: Apparent perl XS module installed directly into $basepath/lib/perl5 instead of a versioned subdirectory.\n  Offending file: $1\n"
  			} else {
  				foreach $bad_dir (@bad_dirs) {
  					# Directory from this list are not allowed to exist in the .deb.
--- 434,453 ----
  			#print "$filename\n";
  			next if $filename eq "/";
  			if (not $filename =~ /^$basepath/) {
! 			    print "Warning: File \"$filename\" installed outside of $basepath\n";
  			} elsif ($filename =~/^($basepath\/lib\/perl5\/auto\/.*\.bundle)/ ) {
! 			    print "Warning: Apparent perl XS module installed directly into $basepath/lib/perl5 instead of a versioned subdirectory.\n  Offending file: $1\n";
  			} elsif ( $filename =~/^($basepath\/lib\/perl5\/darwin\/.*\.bundle)/ ) {
! 			    print "Warning: Apparent perl XS module installed directly into $basepath/lib/perl5 instead of a versioned subdirectory.\n  Offending file: $1\n";
! 			} elsif ( ($filename =~/^($basepath\/.*\.elc)$/) &&
! 				  (not (($dpkg_filename =~ /^emacs[0-9][0-9]/) ||
! 					($dpkg_filename =~ /xemacs-base))) {
! 			    $emacs_violation = 1;
! 			    print "Warning: compiled .elc file installed. Package should install .el files, and provide a /sw/lib/emacsen-common/packages/install/<package> script that byte compiles them for each installed Emacs flavour.\n  Offending file: $1\n";
! 			} elsif ( ($filename =~/^($basepath\/share\/emacs\/site-lisp\/[^\/]+)$/) &&
! 				  (not $dpkg_filename =~ /^emacsen-common_/)) {
! 			    $emacs_violation = 1;
! 			    print "Warning: File installed directly in $basepath/share/emacs/site-lisp. Files should be installed in a package subdirectory.\n  Offending file: $1\n"
  			} else {
  				foreach $bad_dir (@bad_dirs) {
  					# Directory from this list are not allowed to exist in the .deb.
***************
*** 446,451 ****
--- 460,470 ----
  				}
  			}
  		}
+ 	}
+ 	if ($emacs_violation)
+ 	{
+ 	    print "Warning: This package does not conform to the emacs package policy outlined in $basepath/share/doc/emacsen-common/debian-emacs-policy
+ \n"
  	}
  	close(DPKG_CONTENTS) or die "Error on close: $!\n";
  }
