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:   09-Jul-2002 21:35:33
  Branch: HEAD                             Handle: 2002070920353300

  Modified files:
    openpkg-re              buildrdf.pl

  Log:
    - improved $tmpdir handling including command line option --tmpdir
    - hardend against rpm and rpm2cpio failures (i.e. due to defective RPMs)
    - disabled creation of '= *' default version comparison

  Summary:
    Revision    Changes     Path
    1.15        +25 -9      openpkg-re/buildrdf.pl
  ____________________________________________________________________________

  Index: openpkg-re/buildrdf.pl
  ============================================================
  $ cvs diff -u -r1.14 -r1.15 buildrdf.pl
  --- openpkg-re/buildrdf.pl    8 Jul 2002 14:57:50 -0000       1.14
  +++ openpkg-re/buildrdf.pl    9 Jul 2002 19:35:33 -0000       1.15
  @@ -18,8 +18,8 @@
   # - program skips inaccessible folders and prints a warning
   # - modifying filesystem during operation causes unpredictable results
   # 
  -# $Id: buildrdf.pl,v 1.14 2002/07/08 14:57:50 thl Exp $
  -# $Revision: 1.14 $
  +# $Id: buildrdf.pl,v 1.15 2002/07/09 19:35:33 thl Exp $
  +# $Revision: 1.15 $
   # 
   # (C)20011022 Cable & Wireless Deutschland GmbH
   # Application Services, Development Team
  @@ -40,6 +40,7 @@
   my $help = 0;
   my $compress = 0;
   my $rpm = "rpm";
  +my $tmpdir = "/tmp/$0-$$";
   
   #main
   Getopt::Long::Configure("bundling");
  @@ -50,6 +51,7 @@
       'c|compress'  => \$compress,
       'r|rdffile=s' => \$rdffile,
       'R|rpm=s'     => \$rpm,
  +    't|tmpdir=s'  => \$tmpdir,
   );
   if ($help) {
       print "Usage: buildrdf [options]\n" .
  @@ -59,10 +61,14 @@
             " -v,--verbose       enable verbose run-time mode\n" .
             " -r,--rdffile=NAME  name of RDF index file\n" .
             " -R,--rpm=PROG      path to RPM program\n";
  +          " -t,--tmpdir=dir    path to a temporary directory\n";
       exit(0);
   }
   @folders = @ARGV;
   
  +print STDERR "creating temporary directory $tmpdir\n" if ($verbose);
  +mkdir $tmpdir;
  +
   foreach $folder (@folders) {
   
       my $foldername = $folder;
  @@ -102,6 +108,10 @@
       print FILE $rdf;
       close(FILE);
   }
  +
  +print STDERR "removing temporary directory $tmpdir\n" if ($verbose);
  +rmdir $tmpdir;
  +
   exit 0;
   
   sub scanfolder {
  @@ -210,6 +220,9 @@
   
       #make the query
       $v = `$rpm -qp --qf "$q" $prefix$folder$file`;
  +    if ( $? != 0 ) {
  +        print STDERR "$0: ERROR: $rpm cannot query $prefix$folder$file, error 
$?\n"; #report but ignore errors
  +    }
   
       #   pull out entrails from a source package
       $v .= entrails("$prefix$folder$file") if $s;
  @@ -259,13 +272,16 @@
       m|.*/(.*)-[^-]+-[^-]+|;
       my $name = $1;
   
  -    #FIXME do we really need a FILE instead of stdio? If so, make it better!
  -    my $rc = `cd /tmp && ${rpm}2cpio <$rpmsource 2>/dev/null | cpio -i '$name.spec' 
2>/dev/null`;
  -    open(SPEC, "</tmp/$name.spec") || die; 
  +    my $rc = `cd $tmpdir && ${rpm}2cpio <$rpmsource 2>/dev/null | cpio -i 
'$name.spec' 2>/dev/null`;
  +    if ( $? != 0 ) {
  +        print STDERR "$0: ERROR: $rpm cannot read $name.spec from  $rpmsource, 
error $?\n"; #report but ignore errors
  +        return;
  +    }
  +    open(SPEC, "<$tmpdir/$name.spec") || die; 
       my $spec = '';
       $spec .= $_ while (<SPEC>);
       close(SPEC);
  -    unlink "/tmp/$name.spec";
  +    unlink "$tmpdir/$name.spec";
   
       my $define = {};
       $spec =~ s|^%define\s+(\S+)\s+(\S+)|$define->{$1} = $2, ''|mge;
  @@ -289,9 +305,9 @@
   
           sub parserequire {
               my ($reqlist, $reqspec) = @_;
  -            if ($reqspec =~ m/^\S+$/) {
  -                $reqspec = "$reqspec = *";
  -            }
  +            #if ($reqspec =~ m/^\S+$/) {
  +            #    $reqspec = "$reqspec = *";
  +            #}
               push(@{$reqlist}, $reqspec);
           }
           return $reqlist;
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to