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

  Server: cvs.openpkg.org                  Name:   Michael van Elst
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-re                       Date:   25-Nov-2002 16:28:37
  Branch: HEAD                             Handle: 2002112515283700

  Modified files:
    openpkg-re              openpkg-index

  Log:
    retrieve resource names from existing index files
    fix output formatting

  Summary:
    Revision    Changes     Path
    1.18        +27 -8      openpkg-re/openpkg-index
  ____________________________________________________________________________

  Index: openpkg-re/openpkg-index
  ============================================================
  $ cvs diff -u -r1.17 -r1.18 openpkg-index
  --- openpkg-re/openpkg-index  25 Nov 2002 14:58:47 -0000      1.17
  +++ openpkg-re/openpkg-index  25 Nov 2002 15:28:37 -0000      1.18
  @@ -30,7 +30,7 @@
   use strict;
   
   use Getopt::Std;
  -getopts('r:p:o:i');
  +getopts('r:p:o:ci');
   use vars qw/$opt_r $opt_p $opt_o $opt_c $opt_i/;
   
   use FileHandle;
  @@ -52,13 +52,15 @@
       my($s) = @_;
       my($i);
   
  +    $s =~ s/\n+$//sg;
  +    $s =~ s/\s+$//mg;
  +
       $i = undef;
       while ($s =~ /^(\s+)/mg) {
           $i = $1 if !defined $i || length($1) < length($i);
       }
   
  -    $s =~ s/^$i//mg if defined $i;
  -    $s =~ s/\s+$//mg;
  +    $s =~ s/^\Q$i\E//mg if defined $i;
       $s =~ s/&/&amp;/sg;
       $s =~ s/</&lt;/sg;
       $s =~ s/>/&gt;/sg;
  @@ -359,7 +361,6 @@
       $i = ' ' x $i;
   
       $out = e(n($a,$k));
  -    $out =~ s/\n+$//s;
   
       return if $out eq '';
   
  @@ -738,6 +739,27 @@
       return $path.'/';
   }
   
  +sub getresource ($) {
  +    my($fn) = @_;
  +    my($fh, $buf);
  +
  +    if ($fn =~ /\.bz2$/) {
  +        $fh = new FileHandle "$BZ -dc $fn |"
  +            or die "FATAL: cannot read '$fn' ($!)\n";
  +    } else {
  +        $fh = new FileHandle "< $fn"
  +            or die "FATAL: cannot read '$fn' ($!)\n";
  +    }
  +    $fh->read($buf, 1024);
  +    $fh->close;
  +
  +    if ($buf =~ /<Repository.*?rdf:resource="([^"]+)"/) {
  +        return $1;
  +    }
  +
  +    return undef;
  +}
  +
   #####################################################################
   
   sub write_index ($$$$$) {
  @@ -760,7 +782,7 @@
               $a    = rpm2data($_, $platform);
           } elsif (/([^\/]+\.rdf[^\/]*)$/) {
               $h    = relpath($prefix, $_);
  -            $r    = $resource.dirname($h);
  +            $r    = getresource($_) || $resource.dirname($h);
           }
   
           if ($a) {
  @@ -802,9 +824,6 @@
               or die "FATAL: cannot write to stdout ($!)\n";
       }
   }
  -
  -# sanitize resource path
  -$opt_r =~ s/\/*$/\//s;
   
   xml_head($fh, $opt_r);
   foreach $prefix (@ARGV) {
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to