OpenPKG CVS Repository
  http://www.openpkg.org/cvsweb/cvsweb.cgi
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Thomas Lotterer
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-re                       Date:   22-Aug-2002 15:01:03
  Branch: HEAD                             Handle: 2002082214010200

  Modified files:
    openpkg-re              src2make.pl src2make.sh

  Log:
    add support for --classes filter

  Summary:
    Revision    Changes     Path
    1.41        +48 -8      openpkg-re/src2make.pl
    1.5         +3  -0      openpkg-re/src2make.sh
  ____________________________________________________________________________

  Index: openpkg-re/src2make.pl
  ============================================================
  $ cvs diff -u -r1.40 -r1.41 src2make.pl
  --- openpkg-re/src2make.pl    14 Aug 2002 10:05:06 -0000      1.40
  +++ openpkg-re/src2make.pl    22 Aug 2002 13:01:02 -0000      1.41
  @@ -122,7 +122,8 @@
       't|tmpdir=s'    => \$tmpdir,
       's|srcdir=s'    => \$srcdir,
       'o|outdir=s'    => \$outdir,
  -    'n|nouninstall' => \$nouninstall
  +    'n|nouninstall' => \$nouninstall,
  +    'c|classes=s'   => \@classes
   );
   if ($help) {
       print "Usage: $progname [options]\n" .
  @@ -136,7 +137,8 @@
             " -g,--group=groupid group id to use\n" .
             " -t,--tmpdir=PATH   filesystem path to temporary directory\n" .
             " -s,--srcdir=PATH   filesystem path to source directory (for source 
RPMs)\n" .
  -          " -o,--outdir=PATH   filesystem path to output directory (for 
Makefiles)\n";
  +          " -o,--outdir=PATH   filesystem path to output directory (for 
Makefiles)\n" .
  +          " -c,--classes=+A-B  include/exclude class (CORE, BASE, PLUS, PRIV, EVAL, 
JUNK)";
       exit(0);
   }
   $outdir = $srcdir if ($outdir eq '');
  @@ -161,6 +163,24 @@
       &cleanup_remember("rm -rf $tmpdir");
   }
   
  +foreach $item (@classes) {
  +    $remainder = $item;
  +    while ($remainder) {
  +        $remainder =~ m|^(.)(\w+)(.*)$|;
  +        ($classinit, $classhave, $remainder) = ($1,$2,$3);
  +        if ($classinit eq "+") {
  +            $classinit = 1;
  +        }
  +        elsif ($classinit eq "-") {
  +            $classinit = 0;
  +        }
  +        else {
  +            die "class \"$classhave\" in \"$item\" must be prefixed with + or - but 
found $classinit";
  +        }
  +        push @classcheck, [ $classhave, $classinit ];
  +    }
  +}
  +
   #
   #   scan source directory for Source RPMs and build dependency graphs
   #   Examples: foo-1.2-1.0.4.src.rpm
  @@ -175,7 +195,7 @@
   my @SRC = sort(glob("$srcdir/*.src.rpm"));
   &verbose(sprintf("found %d source RPMs under %s", $#SRC+1, $srcdir));
   @SRC = () if ($debug and -f "$progname.db");
  -foreach my $srcrpm (@SRC) {
  +SRCRPM: foreach my $srcrpm (@SRC) {
       $srcrpm =~ s|^$srcdir/||s;
   
       &verbose("scanning $srcdir/$srcrpm");
  @@ -189,17 +209,37 @@
   
       #   query source RPM package
       my $q = '';
  -    foreach my $t (qw(Name Version Release)) {
  +    foreach my $t (qw(Name Version Release Distribution)) {
           $q .= "S-$t:<%{$t}>\n";
       }
       $q .= "[M-BuildPreReq:<%{REQUIRENAME} %|REQUIREFLAGS?{%{REQUIREFLAGS:depflags} 
%{REQUIREVERSION}}:{}|>\n]";
       my $o = `$prefix/bin/rpm -qp --qf "$q" $srcdir/$srcrpm`;
       $o =~ s|M-BuildPreReq:<rpmlib\(.*?\).*?>\n||gs;
       my $r = &parseresponse($o);
  -    my $pkg_name     = $r->{Name};
  -    my $pkg_version  = $r->{Version};
  -    my $pkg_release  = $r->{Release};
  -    my $pkg_breq     = $r->{BuildPreReq};
  +    my $pkg_name         = $r->{Name};
  +    my $pkg_version      = $r->{Version};
  +    my $pkg_release      = $r->{Release};
  +    my $pkg_distribution = $r->{Distribution};
  +    my $pkg_breq         = $r->{BuildPreReq};
  +
  +    #   apply include/exclude class filter
  +    if (not $pkg_distribution =~ m|\[(\w+)\]|) {
  +        print STDERR "$progname:WARNING: skipping unclassified $pkg_distribution\n";
  +        next SRCRPM;
  +    }
  +    if (defined @classcheck) {
  +        $classhave  = $1;
  +        $classpass  = 1 - $classcheck[0]->[1];
  +        foreach $i (@classcheck) {
  +            if ($classhave eq $i->[0]) {
  +                $classpass = $i->[1];
  +            }
  +        }
  +        if (not $classpass) {
  +            print STDERR "$progname: skipping class $classhave due to class 
filter\n";
  +            next SRCRPM;
  +        }
  +    }
   
       #   query .spec inside source RPM package
       #   (because RPM has only single REQUIRE queries and applied to
  Index: openpkg-re/src2make.sh
  ============================================================
  $ cvs diff -u -r1.4 -r1.5 src2make.sh
  --- openpkg-re/src2make.sh    31 Jul 2002 12:55:23 -0000      1.4
  +++ openpkg-re/src2make.sh    22 Aug 2002 13:01:02 -0000      1.5
  @@ -6,5 +6,8 @@
       --srcdir=$HOME/work/openpkg/pkg/src \
       --tmpdir=/tmp/$USER/openpkg \
       --outdir=. \
  +    --classes=+CORE+BASE+PLUS \
  +    --classes=+PRIV \
  +    --classes=+EVAL-JUNK \
       --verbose
   
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to