OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Michael van Elst
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-src                      Date:   22-Jan-2003 13:49:25
  Branch: HEAD                             Handle: 2003012212492400

  Modified files:
    openpkg-src/openpkg-tool
                            openpkg-build.pl

  Log:
    handle conditional dependencies that are enabled by default parameters

  Summary:
    Revision    Changes     Path
    1.42        +94 -61     openpkg-src/openpkg-tool/openpkg-build.pl
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg-tool/openpkg-build.pl
  ============================================================================
  $ cvs diff -u -r1.41 -r1.42 openpkg-build.pl
  --- openpkg-src/openpkg-tool/openpkg-build.pl 22 Jan 2003 10:46:56 -0000      1.41
  +++ openpkg-src/openpkg-tool/openpkg-build.pl 22 Jan 2003 12:49:24 -0000      1.42
  @@ -634,7 +634,7 @@
   # grep XML Bag against condition
   # return as flat list
   #
  -sub with_list ($$) {
  +sub xwith ($$) {
       my($bags,$with) = @_;
       my($bag,$li,$el);
       my(@out);
  @@ -650,6 +650,25 @@
       return \@out;
   }
   
  +#
  +# grep simple parser bag against condition
  +# return as flat list
  +#
  +sub swith ($$$) {
  +    my($bags,$name,$with) = @_;
  +    my($cond);
  +    my(@out);
  +
  +    foreach $cond (keys %$bags) {
  +        next unless conditional($cond, $with);
  +        if (exists $bags->{$cond}->{$name}) {
  +            push @out, @{$bags->{$cond}->{$name}};
  +        }
  +    }
  +
  +    return \@out;
  +}
  +
   sub goodpf ($$) {
       my($l,$p) = @_;
       return 1 if $l eq '';
  @@ -662,14 +681,13 @@
   
       my($section);
       my($name,$version);
  -    my($href,$release,$desc);
  -    my(@prereq,@bprereq);
  -    my(@provides,@conflicts,@source,@nosource);
  -    my(%options);
  +    my($href,$release,$desc,$bags);
  +    my(%options,@provides);
       my($platform,$prefix);
       my($rec);
       my($tag,$cond,$attrname,$attrval,$body);
  -    my($useit);
  +    my($usecond);
  +    my($options, $mywith);
   
       print "# using simple text parser\n";
   
  @@ -686,12 +704,7 @@
               $desc      = '';
               $platform  = undef;
               $prefix    = undef;
  -            @prereq    = ();
  -            @bprereq   = ();
  -            @provides  = ();
  -            @conflicts = ();
  -            @source    = ();
  -            @nosource  = ();
  +            $bags      = {};
           }
   
           if (!(defined $href) &&
  @@ -717,37 +730,49 @@
               $
               /mx;
   
  -        $useit = conditional($cond,$with);
  -
           if ($tag eq 'Description') {
  +            $usecond = $cond;
               $section = 'description';
           } elsif ($tag eq '/Description') {
  +            $usecond = $cond;
               $section = undef;
           } elsif ($section eq 'description') {
               $desc .= $_;
           } elsif ($tag eq 'PreReq') {
  -            $section = 'prereq' if $useit;
  +            $usecond = $cond;
  +            $section = 'prereq';
           } elsif ($tag eq '/PreReq') {
  +            $usecond = undef;
               $section = undef;
           } elsif ($tag eq 'BuildPreReq') {
  -            $section = 'bprereq' if $useit;
  +            $usecond = $cond;
  +            $section = 'bprereq';
           } elsif ($tag eq '/BuildPreReq') {
  +            $usecond = undef;
               $section = undef;
           } elsif ($tag eq 'Provides') {
  -            $section = 'provides' if $useit;
  +            $usecond = $cond;
  +            $section = 'provides';
           } elsif ($tag eq '/Provides') {
  +            $usecond = undef;
               $section = undef;
           } elsif ($tag eq 'Conflicts') {
  -            $section = 'conflicts' if $useit;
  +            $usecond = $cond;
  +            $section = 'conflicts';
           } elsif ($tag eq '/Conflicts') {
  +            $usecond = undef;
               $section = undef;
           } elsif ($tag eq 'NoSource') {
  -            $section = 'nosource' if $useit;
  +            $usecond = $cond;
  +            $section = 'nosource';
           } elsif ($tag eq '/NoSource') {
  +            $usecond = undef;
               $section = undef;
           } elsif ($tag eq 'Source') {
  -            $section = 'source' if $useit;
  +            $usecond = $cond;
  +            $section = 'source';
           } elsif ($tag eq '/Source') {
  +            $usecond = undef;
               $section = undef;
           } elsif ($tag eq 'Name') {
               $name = $body;
  @@ -766,18 +791,10 @@
                       content   => $body
                   };
               }
  -            if ($section eq 'prereq') {
  -                push(@prereq, $body);
  -            } elsif ($section eq 'bprereq') {
  -                push(@bprereq, $body);
  -            } elsif ($section eq 'provides') {
  -                push(@provides, $body);
  -            } elsif ($section eq 'conflicts') {
  -                push(@conflicts, $body);
  -            } elsif ($section eq 'source') {
  -                push(@source, $body);
  -            } elsif ($section eq 'nosource') {
  -                push(@nosource, $body);
  +            if ($section eq 'provides') {
  +                push @provides, $body;
  +            } elsif ($section ne '') {
  +                push @{$bags->{"$usecond"}->{$section}}, $body;
               }
           } elsif ($tag eq '/rdf:Description') {
   
  @@ -804,26 +821,33 @@
                       });
                   }
   
  +                $options = %options
  +                    ? { %options }
  +                    : parse_options($desc);
  +
  +                if ($options) {
  +                    $mywith = { %$options };
  +                    override_options($mywith, $with, '');
  +                } else {
  +                    $mywith = $with;
  +                }
  +
                   $rec = {
                       href      => (relurl($url, undef, $href))[0],
                       name      => $name,
                       version   => $version,
                       release   => $release,
  -                    depends   => depend_list([ @bprereq ]),
  -                    keeps     => depend_list([ @prereq ]),
  -                    conflicts => [ @conflicts ],
  -                    source    => [ @source ],
  -                    nosource  => [ @nosource ],
  +                    depends   => depend_list(swith($bags,'bprereq',$mywith)),
  +                    keeps     => depend_list(swith($bags,'prereq',$mywith)),
  +                    conflicts => swith($bags,'conflicts',$mywith),
  +                    source    => swith($bags,'source',$mywith),
  +                    nosource  => swith($bags,'nosource',$mywith),
                       desc      => $desc,
                       platform  => $platform,
  -                    prefix    => $prefix
  +                    prefix    => $prefix,
  +                    OPTIONS   => $options
                   };
   
  -                $rec->{OPTIONS} =
  -                    %options
  -                    ? { %options }
  -                    : parse_options($rec->{desc});
  -
                   foreach (@provides) {
                       push(@{$map->{$_->{name}}->{vs($_)}}, $rec);
                   }
  @@ -837,20 +861,21 @@
   }
   
   sub xml_parser ($$$$$) {
  -    my($fh, $url, $with, $map,$pfmatch) = @_;
  +    my($fh, $url, $with, $map, $pfmatch) = @_;
       my(@include);
   
  -    my($xml,$desc,$sub);
  +    my($xml,$rep,$sub);
       my($provides,@provides,%options,$rec);
  -    my($href,$name,$version,$release);
  +    my($href,$name,$version,$release,$desc);
  +    my($options, $mywith);
   
       print "# using XML parser\n";
   
  -    $xml  = XML::Simple::XMLin($fh, forcearray => 1);
  -    $desc = $xml->{'Repository'}->[0]->{'rdf:Description'};
  -    $sub  = $xml->{'Repository'}->[0]->{'Repository'};
  +    $xml = XML::Simple::XMLin($fh, forcearray => 1);
  +    $rep = $xml->{'Repository'}->[0]->{'rdf:Description'};
  +    $sub = $xml->{'Repository'}->[0]->{'Repository'};
   
  -    foreach (@$desc) {
  +    foreach (@$rep) {
   
           $href    = $_->{'href'};
           $name    = xel($_->{'Name'});
  @@ -886,6 +911,18 @@
               });
           }
   
  +        $desc = xel($_->{'Description'});
  +        $options = %options
  +            ? { %options }
  +            : parse_options($desc);
  +
  +        if ($options) {
  +            $mywith = { %$options };
  +            override_options($mywith, $with, '');
  +        } else {
  +            $mywith = $with;
  +        } 
  +
           $rec = {
               href      => (relurl($url, undef, $href))[0],
               name      => $name,
  @@ -893,18 +930,14 @@
               release   => $release,
               platform  => xel($_->{'Platform'}),
               prefix    => xel($_->{'Prefixes'}),
  -            depends   => depend_list(with_list($_->{'BuildPreReq'}, $with)),
  -            keeps     => depend_list(with_list($_->{'PreReq'}, $with)),
  -            conflicts => with_list($_->{'Conflicts'}, $with),
  -            source    => with_list($_->{'Source'}, $with),
  -            nosource  => with_list($_->{'NoSource'}, $with),
  -            desc      => xel($_->{'Description'})
  +            depends   => depend_list(xwith($_->{'BuildPreReq'}, $mywith)),
  +            keeps     => depend_list(xwith($_->{'PreReq'}, $mywith)),
  +            conflicts => xwith($_->{'Conflicts'}, $mywith),
  +            source    => xwith($_->{'Source'}, $mywith),
  +            nosource  => xwith($_->{'NoSource'}, $mywith),
  +            desc      => $desc,
  +            OPTIONS   => $options
           };
  -
  -        $rec->{OPTIONS} =
  -            %options
  -            ? { %options }
  -            : parse_options($rec->{desc});
   
           foreach (@provides) {
               push(@{$map->{$_->{name}}->{vs($_)}}, $rec);
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to