To solve a problem I wrote about earlier,
in the text of the program "apt-mirror 0.5.4-1" commented or added new lines.

I marked my changes with comments:
    # *** my comment
    # *** my insert

#-------------------------------------------------------------------------------
sub need_update
{
    my $filename       = shift;
    my $size_on_server = shift;

    my ( undef, undef, undef, undef, undef, undef, undef, $size ) = 
_stat($filename);

    return 1 unless ($size);
    return 0 if $size_on_server == $size;

    unlink( $filename ) || die("apt-mirror: unlink error:  $! for file: 
$filename");  # *** my insert
    return 1;
}

#-------------------------------------------------------------------------------
sub process_index
{
     ...
     if ( exists $lines{"Filename:"} )
     {   # Packages index
         $skipclean{ remove_double_slashes( $path . "/" . $lines{"Filename:"} ) 
} = 1;
         print FILES_ALL remove_double_slashes( $path . "/" . 
$lines{"Filename:"} ) . "\n";
         print FILES_MD5 $lines{"MD5sum:"} . "  " . remove_double_slashes( 
$path . "/" . $lines{"Filename:"} ) . "\n" if defined $lines{"MD5sum:"};
         print FILES_SHA1 $lines{"SHA1:"} . "  " . remove_double_slashes( $path 
. "/" . $lines{"Filename:"} ) . "\n" if defined $lines{"SHA1:"};
         print FILES_SHA256 $lines{"SHA256:"} . "  " . remove_double_slashes( 
$path . "/" . $lines{"Filename:"} ) . "\n" if defined $lines{"SHA256:"};
         if ( need_update( $mirror . "/" . $lines{"Filename:"}, $lines{"Size:"} 
) )
         {
             print FILES_NEW remove_double_slashes( $uri . "/" . 
$lines{"Filename:"} ) . "\n";
             add_url_to_download( $uri . "/" . $lines{"Filename:"}, 
$lines{"Size:"} );
         }
     }
     #else                                      # *** my comment
     elsif ( exists $lines{"Files:"} )  # *** my insert
     {    # Sources index
          foreach ( split( /\n/, $lines{"Files:"} ) )
          {
     ...
}
######################################################################################
## Main download

chdir get_variable("mirror_path") or die("apt-mirror: can't chdir to mirror");

my $need_bytes = 0;
foreach ( values %urls_to_download )
{
    $need_bytes += $_;
}
if ($need_bytes > 0) {   # *** my insert

  my $size_output = format_bytes($need_bytes);

  print "$size_output will be downloaded into archive.\n";

  download_urls( "archive", sort keys %urls_to_download );
}   # *** my insert
######################################################################################

String with "unlink" in "sub need_update" is very important, since "wget" does
not a re-change a package if it is not fully downloaded on previous runs
of "apt-mirror". For example, if in the previous run "apt-mirror" pressed 
"Ctrl+C".

After this change everything works fine and the message:

Processing indexes: [SSSSSUse of uninitialized value $lines{"Files:"} in split 
at /usr/bin/apt-mirror line 829, <STREAM> line 1.
Use of uninitialized value $lines{"Files:"} in split at /usr/bin/apt-mirror 
line 829, <STREAM> line 2.
PPPPP]

no longer appears. And messages for re-download the not completely
downloaded packages also do not occur.

Reply via email to