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 openpkg-web          Date:   15-Jan-2003 13:15:47
  Branch: HEAD                             Handle: 2003011512154402

  Modified files:
    openpkg-src/openpkg-tool
                            openpkg-build.pl openpkg-tool.spec openpkg.pod
    openpkg-web             news.txt

  Log:
    optimize get_revdep, add -L and -W option for generating a dependency
    list

  Summary:
    Revision    Changes     Path
    1.34        +86 -34     openpkg-src/openpkg-tool/openpkg-build.pl
    1.25        +2  -2      openpkg-src/openpkg-tool/openpkg-tool.spec
    1.10        +15 -0      openpkg-src/openpkg-tool/openpkg.pod
    1.2812      +1  -0      openpkg-web/news.txt
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg-tool/openpkg-build.pl
  ============================================================================
  $ cvs diff -u -r1.33 -r1.34 openpkg-build.pl
  --- openpkg-src/openpkg-tool/openpkg-build.pl 14 Jan 2003 12:00:55 -0000      1.33
  +++ openpkg-src/openpkg-tool/openpkg-build.pl 15 Jan 2003 12:15:46 -0000      1.34
  @@ -29,8 +29,12 @@
   $|=1; # autoflush
   
   use strict;
  -use vars qw/$opt_R $opt_r $opt_f $opt_u $opt_U $opt_a $opt_A $opt_z $opt_Z $opt_P 
$opt_N $opt_E $opt_i $opt_D $opt_p $opt_q $opt_s $opt_S $opt_X $opt_M/;
  -my $getopts = 'R:r:f:uUaAzZP:N:E:iD:p:qsSXM';
  +use vars qw/
  +    $opt_R $opt_r $opt_f $opt_u $opt_U $opt_a $opt_A
  +    $opt_z $opt_Z $opt_P $opt_N $opt_E $opt_i $opt_D
  +    $opt_p $opt_q $opt_s $opt_S $opt_X $opt_M $opt_L
  +    $opt_W/;
  +my $getopts = 'R:r:f:uUaAzZP:N:E:iD:p:qsSXMLW';
   getopts($getopts);
   
   ##########################################################################
  @@ -116,7 +120,7 @@
       my($cond,$with) = @_;
       my(@s,$res);
   
  -    return 1 if $cond eq '';
  +    return 1 if $cond eq '' || !defined $with;
   
       foreach (split(/\s+/,$cond)) {
           if ($_ eq '+') {
  @@ -449,9 +453,8 @@
   # compute reverse dependency map
   #
   #
  -sub get_revdep ($) {
  -    my($env) = @_;
  -    my($i) = $env->{'installed'};
  +sub get_revdep ($$) {
  +    my($env, $i) = @_;
       my($r) = $env->{'repository'};
       my($pkg, %dep, %dlist, %rev);
       my(@vers,$t);
  @@ -481,8 +484,10 @@
                   next unless $i->{$t->{name}};
                   next unless $t->{depends};
                   foreach (depends2pkglist($t->{depends})) {
  -                    $dep{$_}{$t->{name}} = 1;
  -                    push @{$dlist{$_}}, $t;
  +                    unless ($dep{$_}{$t->{name}}) {
  +                        $dep{$_}{$t->{name}} = 1;
  +                        push @{$dlist{$_}}, $t;
  +                    }
                   }
               }
           }
  @@ -1389,7 +1394,7 @@
           $target->{REBUILD}) {
   
           unless ($env->{revdep}) {
  -            $env->{revdep} = get_revdep($env);
  +            $env->{revdep} = get_revdep($env, $env->{intalled});
           }
   
           foreach $t (@{$env->{revdep}->{$target->{name}}}) {
  @@ -1407,15 +1412,11 @@
   }
   
   #
  -# generate build lists for targets matched by pattern
  +# grep environment for packages that match a pattern
   #
  -# all input and output is passed in 'env' hash
  -#
  -sub build_list ($$) {
  +sub search_pattern ($$) {
       my($pattern, $env) = @_;
  -    my(@goals,@targets,@keeps,@conflicts,@bonly,$t);
  -    my($name,$r,$i,@vers);
  -    my(@todo,%keep);
  +    my(@todo);
   
       #
       # handle various patterns
  @@ -1446,10 +1447,26 @@
                   } keys %{$env->{repository}};
       }
   
  +    return \@todo;
  +}
  +
  +#
  +# generate build lists for targets matched by pattern
  +#
  +# all input and output is passed in 'env' hash
  +#
  +sub build_list ($$) {
  +    my($pattern, $env) = @_;
  +    my(@goals,@targets,@keeps,@conflicts,@bonly,$t);
  +    my($name,$r,$i,@vers);
  +    my($todo,%keep);
  +
  +    $todo = search_pattern($pattern, $env);
  +
       #
       # chose sources for goals from repository
       #
  -    foreach $name (@todo) {
  +    foreach $name (@$todo) {
           $t = undef;
   
           #
  @@ -1502,6 +1519,21 @@
       return (\@targets, \@bonly, \@conflicts);
   }
   
  +sub build_deps ($$) {
  +    my($pattern, $env) = @_;
  +    my($todo);
  +
  +    $todo = search_pattern($pattern, $env);
  +
  +    $env->{revdep} = get_revdep($env, $env->{repository});
  +
  +    return [ map {
  +        $env->{revdep}->{$_}
  +        ? ( @{$env->{revdep}->{$_}} )
  +        : ( )
  +    } @$todo ];
  +}
  +
   #######################################################################
   
   #
  @@ -1765,6 +1797,17 @@
       }
   }
   
  +#
  +# print dependency list
  +#
  +sub print_deps ($) {
  +    my($list) = @_;
  +
  +    foreach (@$list) {
  +        print vsn($_),"\n";
  +    }
  +}
  +
   #######################################################################
   
   my($config,$url,$repository,$installed,$env,$list,$bonly,$clist);
  @@ -1809,7 +1852,11 @@
   }
   
   $installed      = $opt_Z ? {} : get_installed();
  -$repository     = get_index($url.'00INDEX.rdf',$opt_f,\%with,$opt_X);
  +$repository     = get_index(
  +                    $url.'00INDEX.rdf',
  +                    $opt_f,
  +                    ($opt_W ? undef : \%with),
  +                    $opt_X);
   
   $env = {
       config     => $config,
  @@ -1831,23 +1878,28 @@
                      scalar(%with) > 0 )
   };
   
  -($list,$bonly,$clist) = build_list($pattern, $env);
  -die "FATAL: cannot find package\n" unless defined $list;
  -
  -if ($opt_M) {
  -    print_map($installed,$repository,$list,$bonly,$clist);
  -} elsif ($opt_S) {
  -    print_status($installed,$repository,$list,$bonly,$clist);
  -} elsif ($opt_s) {
  -    print_status($installed,{},$list,$bonly,$clist);
  +if ($opt_L) {
  +    ($list) = build_deps($pattern, $env);
  +    print_deps($list);
   } else {
  -    if (@{$env->{fatal}}) {
  -        die "FATAL errors occured while building:\n",
  -            join (',', @{$env->{fatal}}),
  -            "\n";
  -    }
  +    ($list,$bonly,$clist) = build_list($pattern, $env);
  +    die "FATAL: cannot find package\n" unless defined $list;
   
  -    print_list1($list,$config,$opt_a || $opt_u || $opt_U,\%with,$opt_i);
  -    print_list2($bonly,$config);
  +    if ($opt_M) {
  +        print_map($installed,$repository,$list,$bonly,$clist);
  +    } elsif ($opt_S) {
  +        print_status($installed,$repository,$list,$bonly,$clist);
  +    } elsif ($opt_s) {
  +        print_status($installed,{},$list,$bonly,$clist);
  +    } else {
  +        if (@{$env->{fatal}}) {
  +            die "FATAL errors occured while building:\n",
  +                join (',', @{$env->{fatal}}),
  +                "\n";
  +        }
  +
  +        print_list1($list,$config,$opt_a || $opt_u || $opt_U,\%with,$opt_i);
  +        print_list2($bonly,$config);
  +    }
   }
   
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg-tool/openpkg-tool.spec
  ============================================================================
  $ cvs diff -u -r1.24 -r1.25 openpkg-tool.spec
  --- openpkg-src/openpkg-tool/openpkg-tool.spec        14 Jan 2003 15:48:17 -0000     
 1.24
  +++ openpkg-src/openpkg-tool/openpkg-tool.spec        15 Jan 2003 12:15:46 -0000     
 1.25
  @@ -32,8 +32,8 @@
   Distribution: OpenPKG [PLUS]
   Group:        Bootstrapping
   License:      GPL
  -Version:      20030114
  -Release:      20030114
  +Version:      20030115
  +Release:      20030115
   
   #   list of sources
   Source0:      openpkg.sh
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg-tool/openpkg.pod
  ============================================================================
  $ cvs diff -u -r1.9 -r1.10 openpkg.pod
  --- openpkg-src/openpkg-tool/openpkg.pod      13 Jan 2003 16:35:08 -0000      1.9
  +++ openpkg-src/openpkg-tool/openpkg.pod      15 Jan 2003 12:15:46 -0000      1.10
  @@ -60,6 +60,8 @@
   [B<-s>]
   [B<-S>]
   [B<-M>]
  +[B<-L>]
  +[B<-W>]
   [B<-X>]
   [B<-P> I<priv-cmd>]
   [B<-N> I<non-priv-cmd>]
  @@ -254,6 +256,19 @@
   =item B<-M>
   
   Similar to B<-s> but print a short dependency map.
  +
  +=item B<-L>
  +
  +Print a list of packages in the repository that depend on the target.
  +
  +=item B<-W>
  +
  +Include all conditional dependencies as if all possible configuration
  +options had been switched on. This has little use except for generating
  +an all-inclusive list with the B<-L> option.
  +I<ATTENTION: Even mutually exclusive options are evaluated to be 'on',
  +building packages with B<-W> therefore might fail or cause unusuable
  +results!>
   
   =item B<-X>
   
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-web/news.txt
  ============================================================================
  $ cvs diff -u -r1.2811 -r1.2812 news.txt
  --- openpkg-web/news.txt      15 Jan 2003 11:09:40 -0000      1.2811
  +++ openpkg-web/news.txt      15 Jan 2003 12:15:44 -0000      1.2812
  @@ -1,3 +1,4 @@
  +15-Jan-2003: Upgraded package: P<openpkg-tool-20030115-20030115>
   15-Jan-2003: Upgraded package: P<automake-1.7.2-20030115>
   15-Jan-2003: Upgraded package: P<shiela-1.0.4-20030115>
   15-Jan-2003: Upgraded package: P<grepmail-4.91-20030115>
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to