I offer version 2 of the correction:

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

#-------------------------------------------------------------------------------
# I agree with Justin Pasher (932...@bugs.debian.org) and with Stephan Seitz 
(932...@bugs.debian.org),
# if you look a little lower in the text of the program "apt-mirror",
# you can see a similar code, but for all 3 archive formats:
#
# sub find_dep11_files_in_release
#    ...
#   if ( $filename =~ 
m{^$component/dep11/(Components-${arch}\.ml|icons-[^./]+\.tar)\.(gz|bz2|xz)$} )
#
#So maybe better:

sub find_translation_files_in_release
{
    ...
      # if ( $filename =~ m{^$component/i18n/Translation-[^./]*\.bz2$} ) # my 
comment
      if ( $filename =~ m{^$component/i18n/Translation-[^./]*\.(gz|bz2|xz)$} )  
# my insert

# In order not to think about it anymore, especially since all the rest of the 
text supports all 3 formats.
#-------------------------------------------------------------------------------
sub need_update
{
    my $filename       = shift;
    my $size_on_server = shift;

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

    // $size may have a value "undef", if the file on client side is apsent.
    # return 1  unless ($size);        # *** my comment 2
    return 1  unless (defined $size);  # *** my insert  2
    return 1  if ($size <= 0);         # *** my insert  2

    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