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:   03-Feb-2003 17:52:24
  Branch: HEAD                             Handle: 2003020316522300

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

  Log:
    use options from installed base to direct parser to correct
    dependencies

  Summary:
    Revision    Changes     Path
    1.48        +88 -34     openpkg-src/openpkg-tool/openpkg-build.pl
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg-tool/openpkg-build.pl
  ============================================================================
  $ cvs diff -u -r1.47 -r1.48 openpkg-build.pl
  --- openpkg-src/openpkg-tool/openpkg-build.pl 3 Feb 2003 12:58:55 -0000       1.47
  +++ openpkg-src/openpkg-tool/openpkg-build.pl 3 Feb 2003 16:52:23 -0000       1.48
  @@ -554,23 +554,39 @@
   }
   
   #
  +# merge any number of options together
  +#
  +sub combine_options {
  +    my($old) = shift;
  +    my($new) = { %$old };
  +    foreach (grep { defined $_ } @_) {
  +        override_options($new,$_,''),
  +    }
  +    return $new;
  +}
  +
  +#
   # pull in OPTIONS for a package or an RPM file
   #
  -sub get_with ($$;$) {
  -    my($env,$t,$fn) = @_;
  +sub get_with ($;$) {
  +    my($t,$fn) = @_;
       my(@l,%with);
       my($opt);
   
  -    if (($env && $env->{zero}) || $t->{OPTIONS}) {
  +    if ($t->{OPTIONS}) {
           $opt = $t->{OPTIONS};
       } else {
           if (defined $fn) {
               @l = run("$RPM -qi -p $fn");
  +            $opt = parse_options(\@l);
  +            # don't write back result, this is just
  +            # for testing compatibility of a binary
  +            # package
           } else {
               @l = run("$RPM -qi $t->{name}");
  +            $opt = parse_options(\@l);
  +            $t->{OPTIONS} = $opt;
           }
  -        $opt = parse_options(\@l);
  -        $t->{OPTIONS} = $opt if $env;
       }
       return $opt;
   }
  @@ -675,8 +691,8 @@
       return $l =~ /(?:^|\s)\Q$p\E(?:\s|$)/;
   }
   
  -sub simple_text_parser ($$$$$) {
  -    my($fh,$url,$with,$map,$pfmatch) = @_;
  +sub simple_text_parser ($$$$$$) {
  +    my($fh,$url,$with,$map,$pfmatch,$installed) = @_;
       my(@include);
   
       my($section);
  @@ -826,8 +842,12 @@
                       : parse_options($desc);
   
                   if ($options) {
  -                    $mywith = { %$options };
  -                    override_options($mywith, $with, '');
  +                    my(@t) = get_targets($installed->{$name},sub { 1; });
  +                    $mywith = combine_options(
  +                        $options,
  +                        @t ? $t[0]->{OPTIONS} : undef,
  +                        $with
  +                    );
                   } else {
                       $mywith = $with;
                   }
  @@ -860,8 +880,8 @@
       return \@include;
   }
   
  -sub xml_parser ($$$$$) {
  -    my($fh, $url, $with, $map, $pfmatch) = @_;
  +sub xml_parser ($$$$$$) {
  +    my($fh, $url, $with, $map, $pfmatch, $installed) = @_;
       my(@include);
   
       my($xml,$rep,$sub);
  @@ -917,8 +937,12 @@
               : parse_options($desc);
   
           if ($options) {
  -            $mywith = { %$options };
  -            override_options($mywith, $with, '');
  +            my(@t) = get_targets($installed->{$name},sub { 1; });
  +            $mywith = combine_options(
  +                $options,
  +                @t ? $t[0]->{OPTIONS} : undef,
  +                $with
  +            );
           } else {
               $mywith = $with;
           } 
  @@ -993,8 +1017,8 @@
   # fetch index from file or URL
   # recursively fetch sub-indexes
   #
  -sub get_index ($$$$$) {
  -    my($url,$fn,$with,$noxml,$pfmatch) = @_;
  +sub get_index ($$$$$$) {
  +    my($url,$fn,$with,$noxml,$pfmatch,$installed) = @_;
       my(%map,$include);
   
       open_index($url,$fn);
  @@ -1007,9 +1031,11 @@
       }
   
       if ($noxml) {
  -        $include = simple_text_parser(\*RFH, $url, $with, \%map, $pfmatch);
  +        $include = simple_text_parser(\*RFH, $url, $with,
  +                                      \%map, $pfmatch, $installed);
       } else {
  -        $include = xml_parser(\*RFH, $url, $with, \%map, $pfmatch);
  +        $include = xml_parser(\*RFH, $url, $with,
  +                              \%map, $pfmatch, $installed);
       }
   
       close(RFH)
  @@ -1022,7 +1048,7 @@
       foreach (@$include) {
           my($submap);
           my($suburl,$subfn) = relurl($url,$fn,$_);
  -        $submap = get_index($suburl,$subfn,$with,$noxml,$pfmatch);
  +        $submap = get_index($suburl,$subfn,$with,$noxml,$pfmatch,$installed);
           while (my($name,$vmap) = each %$submap) {
               while (my($vs,$recs) = each %$vmap) {
                   push @{$map{$name}->{$vs}}, @$recs;
  @@ -1046,11 +1072,22 @@
   }
   
   #
  +# fetch targets of a name that
  +# satisfies a condition
  +#
  +sub get_targets ($$) {
  +    my($relmap, $cond) = @_;
  +    return map {
  +            @{$relmap->{$_}}
  +        } get_versions($relmap, $cond);
  +}
  +
  +#
   # there can be multiple sources for a target release
   #
   sub chose_source ($$$$@) {
       my($env, $name, $select, $vmap, @vers) = @_;
  -    my(@recs,@nrecs,$rec);
  +    my(@recs,@nrecs,$rec,%nam);
   
       return unless @vers;
   
  @@ -1096,16 +1133,19 @@
       }
   
       if (scalar(@recs) > 1) {
  -
  -        print "# ambigous sources for $name\n";
  -        my($i) = 0;
  -        foreach (@recs) {
  -            print "# $i: ".vsn($_)." = $_->{href}\n";
  -            $i++;
  +        %nam = map { $_->{name} => 1 } @recs;
  +        if (scalar(keys %nam) > 1) {
  +            print "# ambigous sources for $name\n";
  +            my($i) = 0;
  +            foreach (@recs) {
  +                print "# $i: ".vsn($_)." = $_->{href}\n";
  +                $i++;
  +            }
  +            return;
           }
  -        return;
  -
  -    } elsif (@recs) {
  +    }
  +    
  +    if (@recs) {
           if ($env->{upgrade}) {
               $rec = $recs[-1];
           } else {
  @@ -1314,7 +1354,7 @@
       if ($i && (@vers = get_versions($i, $cond))) {
           foreach (@vers) {
               $t = $i->{$_}->[0];
  -            get_with($env,$t);
  +            get_with($t);
               if (target_suitable($t, $env->{with})) {
                   $tdef = $t;
                   unless ($env->{upgrade}) {
  @@ -1395,7 +1435,7 @@
               return;
           }
           # use options from installed base
  -        override_options(get_with($env,$target), get_with($env,$t),
  +        override_options(get_with($target), get_with($t),
                            $env->{config}->{optreg});
           # remember this is a rebuild for a proxy package
           $target->{PROXY} = $t->{PROXY};
  @@ -1701,7 +1741,7 @@
       my(%target) = %$t;
   
       # pull in options from binary RPM file
  -    get_with(undef,\%target, $fn);
  +    get_with(\%target, $fn);
   
       return \%target;
   }
  @@ -1744,8 +1784,21 @@
       #
       if ($old) {
           $old = { %$old };
  -        if (!override_options($old, $new, $c->{optreg}) && !$rebuild) {
  -            return '';
  +        if (!override_options($old, $new, $c->{optreg})) {
  +            #
  +            # nothing was changed against previous options
  +            #
  +            # if $rebuild is true this is an already installed
  +            # target and 'previous options' may be different
  +            # from the package defaults
  +            #
  +            # but if $rebuild is false this is a package from
  +            # repository, it must be package defaults and we
  +            # can drop the --defines from the script
  +            #
  +            if (!$rebuild) {
  +                return '';
  +            }
           }
       } else {
           $old = $new;
  @@ -1998,7 +2051,8 @@
                       $opt_f,
                       ($opt_W ? undef : \%with),
                       $opt_X,
  -                    $config->{platform});
  +                    $config->{platform},
  +                    $installed);
   
   $env = {
       config     => $config,
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to