Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs17:/tmp/cvs-serv8295/fink-branch_0_27/perlmod/Fink

Modified Files:
      Tag: branch_0_27
        ChangeLog Engine.pm PkgVersion.pm Validation.pm 
Log Message:
backport conditionals for Shlibs and ConfFiles fields for release as fink-0.27.2


Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.587.4.1
retrieving revision 1.587.4.2
diff -u -d -r1.587.4.1 -r1.587.4.2
--- PkgVersion.pm       17 Mar 2007 20:45:42 -0000      1.587.4.1
+++ PkgVersion.pm       1 Jun 2007 01:19:31 -0000       1.587.4.2
@@ -3168,7 +3168,7 @@
     sudo gcc_select GCC_SELECT_COMMAND
 
 You may need to install a more recent version of the Developer Tools
-(Apple's XCode) to be able to do so.
+(the Apple XCode suite) to be able to do so.
 GCC_MSG
        }
 
@@ -3754,7 +3754,6 @@
        my $self = shift;
        my $do_splitoff = shift || 0;
        my ($ddir, $destdir, $control);
-       my ($conffiles, $listfile);
        my ($daemonicname, $daemonicfile);
        my ($cmd);
 
@@ -3794,6 +3793,14 @@
                }
        }
 
+       # put the info file into the debian directory
+       if (-d "$destdir/DEBIAN") {
+               my $infofile = $self->get_filename();
+               if (defined $infofile) {
+                       cp($infofile, "$destdir/DEBIAN/package.info");
+               }
+       }
+
        # generate dpkg "control" file
 
        my ($pkgname, $parentpkgname, $version, $field, $section, $instsize, 
$prio);
@@ -4222,8 +4229,7 @@
 
        ### shlibs file
 
-       if ($self->has_param("Shlibs")) {
-               my $shlibsbody = $self->param_expanded("Shlibs");
+       if (length(my $shlibsbody = $self->get_shlibs_field)) {
                chomp $shlibsbody;
                my $shlibsfile = "$destdir/DEBIAN/shlibs";
 
@@ -4252,21 +4258,27 @@
 
        ### config file list
 
-       if ($self->has_param("conffiles")) {
-               $listfile = "$destdir/DEBIAN/conffiles";
-               $conffiles = join("\n", grep {$_} split(/\s+/, 
$self->param("conffiles")));
-               $conffiles = &expand_percent($conffiles, $self->{_expand}, 
$self->get_info_filename." \"conffiles\"")."\n";
+       if ($self->has_param('ConfFiles')) {
+               my $files = $self->param_expanded('ConfFiles');
+               $files =~ s/\s+/ /g; # Make it one line
+               $files = $self->conditional_space_list($files,
+                       "ConfFiles of ".$self->get_fullname()." in 
".$self->get_info_filename
+               );
 
-               print "Writing conffiles list...\n";
+               if ($files =~ /\S/) {
+                       # we actually have something
+                       print "Writing conffiles list...\n";
 
-               if ( open(SCRIPT,">$listfile") ) {
-                       print SCRIPT $conffiles;
-                       close(SCRIPT) or die "can't write conffiles list file 
for ".$self->get_fullname().": $!\n";
-                       chmod 0644, $listfile;
-               } else {
-                       my $error = "can't write conffiles list file for 
".$self->get_fullname().": $!";
-                       $notifier->notify(event => 'finkPackageBuildFailed', 
description => $error);
-                       die $error . "\n";
+                       my $listfile = "$destdir/DEBIAN/conffiles";
+                       if ( open my $scriptFH, '>', $listfile ) {
+                               print $scriptFH map "$_\n", split /\s+/, $files;
+                               close $scriptFH or die "can't write conffiles 
list file for ".$self->get_fullname().": $!\n";
+                               chmod 0644, $listfile;
+                       } else {
+                               my $error = "can't write conffiles list file 
for ".$self->get_fullname().": $!";
+                               $notifier->notify(event => 
'finkPackageBuildFailed', description => $error);
+                               die $error . "\n";
+                       }
                }
        }
 
@@ -5293,6 +5305,35 @@
        return ($_[0]->get_full_trees)[-1];
 }
 
+=item get_shlibs_field
+
+       my $shlibs_field = $pv->get_shlibs_field;
+
+Returns a multiline string of the Shlibs entries. Conditionals are
+supported as prefix to a whole entry (not to specific dependencies
+like a pkglist field). The string will always be defined, but will be
+null if no entries, and every entry (even last) will have trailing
+newline.
+
+=cut
+
+sub get_shlibs_field {
+       my $self = shift;
+
+       my @shlibs_raw = split /\n/, $self->param_default_expanded('Shlibs', 
'');  # lines from .info
+       my $shlibs_cooked = '';  # processed results
+       foreach my $info_line (@shlibs_raw) {
+               next if $info_line =~ /^#/;  # skip comments
+               if ($info_line =~ s/^\s*\((.*?)\)//) {
+                       # have a conditional
+                       next if not &eval_conditional($1, "Shlibs of 
".$self->get_info_filename);
+               }
+               $info_line =~ /^\s*(.*?)\s*$/;  # strip off leading/trailing 
whitespace
+               $shlibs_cooked .= "$1\n" if length $1;
+       }
+       $shlibs_cooked;
+}
+
 =item scanpackages
 
   scanpackages;

Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.398.4.1
retrieving revision 1.398.4.2
diff -u -d -r1.398.4.1 -r1.398.4.2
--- Engine.pm   19 Mar 2007 16:58:02 -0000      1.398.4.1
+++ Engine.pm   1 Jun 2007 01:19:31 -0000       1.398.4.2
@@ -2349,7 +2349,7 @@
                        } elsif ($_ =~ 
/^source(\d*rename|directory|\d+extractdir)$/ or
                                         $_ =~ /^tar\d*filesrename$/ or
                                         $_ =~ 
/^update(configguess|libtool)indirs$/ or
-                                        $_ =~ /^set/ or $_ =~ 
/^(jar|doc|conf)files$/ or
+                                        $_ =~ /^set/ or $_ =~ 
/^(jar|doc)files$/ or
                                         $_ =~ /^patch(|file|file-md5)$/ or $_ 
eq 'appbundles' or
                                         $_ eq 'infodocs' or $_ =~ 
/^daemonicname$/
                                        ) {
@@ -2372,7 +2372,25 @@
                                        );
                                        printf "%s: %s\n", $_, $value if length 
$value;
                                }
-                       } elsif ($_ =~ 
/^(((pre|post)(inst|rm))script)|(shlibs|runtimevars|custommirror)|daemonicfile$/)
 {
+                       } elsif ($_ eq 'conffiles') {
+                               # singleline fields start on the same line, have
+                               # embedded newlines removed, and are not wrapped
+                               # need conditionals processing
+                               if ($pkg->has_param($_)) {
+                                       my $value = 
$pkg->conditional_space_list(
+                                               
$pkg->param_expanded("ConfFiles"),
+                                               "ConfFiles of 
".$pkg->get_fullname()." in ".$pkg->get_info_filename
+                                       );
+                                       printf "%s: %s\n", $_, $value if length 
$value;
+                               }
+                       } elsif ($_ eq 'shlibs') {
+                               # multiline field with specific accessor
+                               my $value = $pkg->get_shlibs_field();
+                               if (length $value) {
+                                       $value =~ s/^/ /gm;
+                                       printf "%s:\n%s", $_, $value;
+                               }
+                       } elsif ($_ =~ 
/^(((pre|post)(inst|rm))script)|(runtimevars|custommirror)|daemonicfile$/) {
                                # multiline fields start on a new line and are
                                # indented one extra space
                                if ($pkg->has_param($_)) {

Index: Validation.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Validation.pm,v
retrieving revision 1.250
retrieving revision 1.250.4.1
diff -u -d -r1.250 -r1.250.4.1
--- Validation.pm       4 Mar 2007 22:03:14 -0000       1.250
+++ Validation.pm       1 Jun 2007 01:19:32 -0000       1.250.4.1
@@ -616,9 +616,18 @@
                
        }
 
-       if (&validate_info_component($properties, "", $filename, $info_level) 
== 0) {
+       if (&validate_info_component(
+                        properties => $properties,
+                        filename => $filename,
+                        info_level => $info_level,
+               ) == 0) {
                $looks_good = 0;
-       } elsif ($properties->{infotest} and 
&validate_info_component($test_properties, "", $filename, $info_level, 1) == 0) 
{
+       } elsif ($properties->{infotest} and &validate_info_component(
+                                properties => $test_properties,
+                                filename => $filename,
+                                info_level => $info_level,
+                                is_infotest => 1,
+                        ) == 0) {
                $looks_good = 0;
        }
 
@@ -700,7 +709,13 @@
                                }
                        }
 
-                       if (&validate_info_component($splitoff_properties, 
$splitoff_field, $filename, $info_level) == 0) {
+                       if (&validate_info_component(
+                                        properties => $splitoff_properties,
+                                        splitoff_field => $splitoff_field,
+                                        filename => $filename,
+                                        info_level => $info_level,
+                                        builddepends => 
$properties->{builddepends},
+                               ) == 0) {
                                $looks_good = 0;
                        }
 
@@ -863,19 +878,7 @@
        if (exists $properties->{patchfile}) {
 
                # must declare BuildDepends on a fink that supports it
-               my $has_fink_bdep = 0;
-               $value = &pkglist2lol($properties->{builddepends});
-               foreach (@$value) {
-                       foreach my $atom (@$_) {
-                               $atom =~ s/^\(.*?\)\s*//;
-                               next unless $atom =~ 
/^fink\s*\(\s*(>>|>=)\s*(.*?)\)\s*$/;
-                               $has_fink_bdep = 1 if version_cmp($2, '>=', 
'0.24.12');
-                       }
-               }
-               if (!$has_fink_bdep) {
-                       print "Error: Use of PatchFile requires declaring a 
BuildDepends on \"fink (>= 0.24.12)\" or higher. ($filename)\n";
-                       $looks_good = 0;
-               }
+               $looks_good = 0 unless 
_min_fink_version($properties->{builddepends}, '0.24.12', 'use of PatchFile', 
$filename);
 
                # can't mix old and new patching styles
                if (exists $properties->{patch}) {
@@ -983,14 +986,63 @@
        return 1;
 }
 
+# Given a $builddepends from the $filename .info field, check whether
+# any "fink" less than the given $required_version will suffice. If so
+# (i.e., insufficient dependency for something that requires at least
+# the given version-string), print warning indicating the minimum
+# requirement for $feature
+
+sub _min_fink_version {
+       my $builddepends = shift;
+       my $required_version = shift;
+       my $feature = shift;
+       my $filename = shift;
+
+       $builddepends = &pkglist2lol($builddepends);
+
+       my $has_fink_bdep = 0;
+       foreach (@$builddepends) {
+               foreach my $atom (@$_) {
+                       $atom =~ s/^\(.*?\)\s*//;
+                       next unless $atom =~ 
/^fink\s*\(\s*(>>|>=)\s*(.*?)\)\s*$/;
+                       $has_fink_bdep = 1 if version_cmp($2, '>=', 
$required_version);
+               }
+       }
+
+       if (!$has_fink_bdep) {
+               print "Error: $feature requires declaring a BuildDepends on 
fink (>= $required_version) or higher. ($filename)\n";
+               return 0;
+       }
+       return 1;
+}
+
 # checks that are common to a parent and a splitoff package of a .info file
 # returns boolean of whether everything is okay
+# The following parameters are known:
+#   properties        hashref (will not be altered)
+#   splitoff_field    "splitoffN", or null or undef in parent
+#   filename          filename of .info file being validated
+#   info_level        InfoN level
+#   is_infotest       boolean indicating if this is an InfoTest field
+#   builddepends      BuildDepends of parent if this is not a parent field
+
 sub validate_info_component {
-       my $properties = shift;      # hashref (will not be altered)
-       my $splitoff_field = shift;  # "splitoffN", or null or undef in parent
-       my $filename = shift;
-       my $info_level = shift;
-       my $is_infotest = shift || 0;
+       my %options;
+       if (ref $_[0]) {
+               # old-style positional-parameters
+               @options{qw/ properties splitoff_field filename info_level 
is_infotest /} = @_;
+       } else {
+               # new-style named parameters
+               %options = @_;
+       }
+       my $properties = $options{properties};
+       my $splitoff_field = $options{splitoff_field};
+       my $filename = $options{filename};
+       my $info_level = $options{info_level};
+       my $is_infotest = $options{is_infotest};
+
+       # make sure this $option is available even in parent
+       $options{builddepends} = $properties->{builddepends} unless 
$splitoff_field;
 
        my (@pkg_required_fields, %pkg_valid_fields);
 
@@ -1157,6 +1209,11 @@
                my %shlibs;
                foreach (@shlibs) {
                        next unless /\S/;
+
+                       if (s/^\s*\(.*?\)\s*//) {
+                               $looks_good = 0 unless 
_min_fink_version($options{builddepends}, '0.27.2', 'use of conditionals in 
Shlibs', $filename);
+                       }
+
                        my @shlibs_parts;
                        if (scalar(@shlibs_parts = split ' ', $_, 3) != 3) {
                                print "Warning: Malformed line in field 
\"shlibs\"$splitoff_field. ($filename)\n  $_\n";
@@ -1176,18 +1233,18 @@
                                $looks_good = 0;
                        }
                        my @shlib_deps = split /\s*\|\s*/, $shlibs_parts[2], -1;
-               # default value of $libarch, if absent, is "32"
+                       # default value of $libarch, if absent, is "32"
                        my $libarch = "32";
-               # strip off the end of the last @shlib_deps entry (the stuff
-               # beyond the final close-paren), which should consist of digits
-               # and "-" only, and use as $libarch
+                       # strip off the end of the last @shlib_deps entry (the 
stuff
+                       # beyond the final close-paren), which should consist 
of digits
+                       # and "-" only, and use as $libarch
                        if ($shlib_deps[$#shlib_deps] =~ 
/^(.*\))\s*([^\s\)]+)$/ ) {
                                $shlib_deps[$#shlib_deps] = $1;
                                $libarch = $2;
                        }
-               # This hack only allows one particular percent expansion in the
-               # $libarch field, because this subroutine doesn't do percent 
-               # expansions.  OK for now, but should be fixed eventually.
+                       # This hack only allows one particular percent 
expansion in the
+                       # $libarch field, because this subroutine doesn't do 
percent 
+                       # expansions.  OK for now, but should be fixed 
eventually.
                        my $num_expand = {"type_num[-64bit]" => "64"};
                        $libarch = &expand_percent($libarch, $num_expand, 
$filename.' Package');
                        if (not ($libarch eq "32" or $libarch eq "64" or 
$libarch eq "32-64")) {
@@ -1211,6 +1268,10 @@
                }
        }
 
+       $value = $properties->{conffiles};
+       if (defined $value and $value =~ /\(.*?\)/) {
+               $looks_good = 0 unless 
_min_fink_version($options{builddepends}, '0.27.2', 'use of conditionals in 
ConfFiles', $filename);
+       }
 
        # Special checks when package building script uses an explicit interp
 

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1441.2.4
retrieving revision 1.1441.2.5
diff -u -d -r1.1441.2.4 -r1.1441.2.5
--- ChangeLog   27 Apr 2007 21:32:05 -0000      1.1441.2.4
+++ ChangeLog   1 Jun 2007 01:19:30 -0000       1.1441.2.5
@@ -1,3 +1,8 @@
+2007-05-31  Daniel Macks  <[EMAIL PROTECTED]>
+
+       * Engine.pm, PkgVersion.pm, Validation.pm: Backport conditional
+       ConfFiles and Shlibs to branch_0.27 (target release 0.27.2)
+
 2007-04-27  Dave Morrison  <[EMAIL PROTECTED]>
 
        * VirtPackage.pm: (backport from HEAD) Parse a greater variety of 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Fink-commits mailing list
Fink-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to