Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13054

Modified Files:
        ChangeLog Validation.pm 
Log Message:
Overhaul parsing of .deb control data to allow more uniform access.


Index: Validation.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Validation.pm,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -d -r1.137 -r1.138
--- Validation.pm       28 Jul 2004 10:53:48 -0000      1.137
+++ Validation.pm       29 Jul 2004 07:13:39 -0000      1.138
@@ -821,12 +821,31 @@
        my $installed_headers = 0;
        my $installed_dylibs = 0;
        my $scrollkeeper_misuse_warned = 0;
-       my @omf_sources;
+       my $deb_control;
 
        print "Validating .deb file $dpkg_filename...\n";
-       
+
        # Quick & Dirty solution!!!
        # This is a potential security risk, we should maybe filter $dpkg_filename...
+
+       # read some fields from the control file
+       foreach (qw/ builddependsonly package depends /) {
+               $deb_control->{$_} = `dpkg --field $dpkg_filename $_`;
+               chomp $deb_control->{$_};
+       }
+
+       # read some control script files
+       foreach (qw/ preinst postinst prerm postrm /) {
+               $deb_control->{$_} = [ `dpkg -I $dpkg_filename $_ 2>/dev/null` ];
+#              print "control file $_:\n", @{$deb_control->{$_}};
+#              print "control file $_:\n", map { /^\s*scrollkeeper-update/ ? "+$_" : 
"-$_" } @{$deb_control->{$_}};
+       }
+
+       # create hash where keys are names of packages listed in Depends
+       $deb_control->{depends_pkgs} = {
+               map { /\s*([^ \(]*)/, undef } split /[|,]/, $deb_control->{depends}
+       };
+
        $pid = open(DPKG_CONTENTS, "dpkg --contents $dpkg_filename |") or die 
"Couldn't run dpkg: $!\n";
        my @dpkg_contents = <DPKG_CONTENTS>;
        close(DPKG_CONTENTS) or die "Error on close: ", $?>>8, " $!\n";
@@ -874,20 +893,20 @@
                        } elsif ( $filename =~/\.dylib$/ ) {
                                $installed_dylibs = 1;
                        } elsif ( $filename =~/^$basepath\/share\/omf\/.*\.omf/ ) {
-                               push @omf_sources, $filename;
+                               foreach (qw/ postinst postrm /) {
+                                       next if $_ eq "postrm" && 
$deb_control->{package} eq "scrollkeeper"; # circular dep
+                                       if (not grep { /^\s*scrollkeeper-update/ } 
@{$deb_control->{$_}}) {
+                                               print "Warning: scrollkeeper source 
file found, but scrollkeeper-update not called\nin $_. See scrollkeeper package docs 
for information. Offending file:\n  $filename\n";
+                                               $looks_good = 0;
+                                       }
+                               }
                        } elsif ( $filename =~/^$basepath\/lib\/pkgconfig\/\S+$/ ) {
-                               my $depends = `dpkg --field $dpkg_filename Depends`;
-                               $depends =~ s/\(.*?\)//g;
-                               $depends =~ s/(\A|\s*[,|]\s*|\Z)/ /g;
-                               if (not $depends =~ / pkgconfig /) {
+                               if (not exists 
$deb_control->{depends_pkgs}->{pkgconfig}) {
                                        print "Warning: Package appears to contain 
pkg-config file but does not depend on the package \"pkgconfig\"\n  Offending file: 
$filename\n";
                                        $looks_good = 0;
                                }
                        } elsif ( $filename =~ /^$basepath\/etc\/daemons\/\S+$/ ) {
-                               my $depends = `dpkg --field $dpkg_filename Depends`;
-                               $depends =~ s/\(.*?\)//g;
-                               $depends =~ s/(\A|\s*[,|]\s*|\Z)/ /g;
-                               if (not $depends =~ / daemonic /) {
+                               if (not exists 
$deb_control->{depends_pkgs}->{daemonic}) {
                                        print "Warning: Package appears to contain a 
daemonicfile but does not depend on the package \"daemonic\"\n  Offending file: 
$filename\n";
                                        $looks_good = 0;
                                }
@@ -922,42 +941,40 @@
                                close(DAEMONIC_FILE) or die "Error on close: ", $?>>8, 
" $!\n";
                        } elsif ( $filename =~ /^$basepath\/var\/scrollkeeper/ ) {
                                if (not $scrollkeeper_misuse_warned++) {
-                                       print "Warning: Found 
$basepath/var/scrollkeeper, which usually results from calling\nscrollkeeper-update 
during CompileScript or InstallScript. See the\nscrollkeeper package docs for 
information on the correct use of that utilty.\n";
+                                       print "Warning: Found 
$basepath/var/scrollkeeper, which usually results from calling\nscrollkeeper-update 
during CompileScript or InstallScript. See the\nscrollkeeper package docs for 
information on the correct use of that utility.\n";
                                        $looks_good = 0;
                                }
                        }
                }
        }
-       
+
 # Note that if the .deb was compiled with an old version of fink which
 # does not record the BuildDependsOnly field, or with an old version
 # which did not use the "Undefined" value for the BuildDependsOnly field,
 # the warning is not issued
 
        if ($installed_headers and $installed_dylibs) {
-               my $BDO = `dpkg --field $dpkg_filename BuildDependsOnly`;
-               if ($BDO =~ /Undefined/) {
+               if ($deb_control->{builddependsonly} =~ /Undefined/) {
                        print "Warning: Headers installed in $basepath/include, as 
well as a dylib, but package does not declare BuildDependsOnly to be true (or 
false)\n";
                        $looks_good = 0;
                }
        }
 
-       # scrollkeeper-update should be called from PostInstScript and PostRmScript
-       if (grep { /^\s*scrollkeeper-update/ } `dpkg -I $dpkg_filename PreInst PreRm 
2>/dev/null`) {
-               print "Warning: scrollkeeper-update in PreInstScript or PreRmScript is 
a no-op\nSee scrollkeeper package docs for more information\n";
-               $looks_good = 0;
+       # verify Depends:scrollkeeper
+       foreach (qw/ preinst postinst prerm postrm /) {
+               next if $deb_control->{package} eq "scrollkeeper"; # circular dep
+               if ( grep { /^\s*scrollkeeper-update/ } @{$deb_control->{$_}} and not 
exists $deb_control->{depends_pkgs}->{scrollkeeper}) {
+                       print "Warning: Calling scrollkeeper-update in $_ requires 
\"Depends:scrollkeeper\"\n";
+                       $looks_good = 0;
+               }
        }
-       if (grep { /^\s*scrollkeeper-update/ } `dpkg -I $dpkg_filename PostInst PostRm 
2>/dev/null`) {
-               my $depends = `dpkg --field $dpkg_filename Depends`;
-               $depends =~ s/\(.*?\)//g;
-               $depends =~ s/(\A|\s*[,|]\s*|\Z)/ /g;
-               if (not $depends =~ / scrollkeeper /) {
-                       print "Warning: Calling scrollkeeper-update requires 
\"Depends:scrollkeeper\"\n";
+
+       # scrollkeeper-update should be called from PostInstScript and PostRmScript
+       foreach (qw/ preinst prerm /) {
+               if (grep { /^\s*scrollkeeper-update/ } @{$deb_control->{$_}}) {
+                       print "Warning: scrollkeeper-update in $_ is a no-op\nSee 
scrollkeeper package docs for information.\n";
                        $looks_good = 0;
                }
-       } elsif (@omf_sources) {
-               print "Warning: scrollkeeper source file(s) found, but 
scrollkeeper-update not called\nby control scripts. See scrollkeeper package docs for 
more information.\n",map "  $_\n", @omf_sources;
-               $looks_good = 0;
        }
 
        if ($looks_good and Fink::Config::verbosity_level() == 3) {

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.677
retrieving revision 1.678
diff -u -d -r1.677 -r1.678
--- ChangeLog   28 Jul 2004 18:03:32 -0000      1.677
+++ ChangeLog   29 Jul 2004 07:13:39 -0000      1.678
@@ -1,3 +1,10 @@
+2004-07-28  Daniel Macks  <[EMAIL PROTECTED]>
+
+       * Validation.pm: Parse .deb control early; make data available in
+       $deb_control. For scrollkeeper-update check: make sure it's called
+       by *both* control scripts; remove circular dependency requirement
+       for scrollkeeper.deb.
+
 2004-07-28  Benjamin Reed  <[EMAIL PROTECTED]>
 
        * VirtPackage.pm: handle newer cctools that don't contain the



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
Fink-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to