1
0
Fork 0

Merging upstream version 1.5.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-24 05:53:15 +01:00
parent 3a44ca3665
commit 060bb99151
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
30 changed files with 328 additions and 279 deletions

View file

@ -1,5 +1,5 @@
/* Zupdate - recompress bzip2, gzip, xz files to lzip files
Copyright (C) 2013-2015 Antonio Diaz Diaz.
/* Zupdate - recompress bzip2, gzip, xz files to lzip format
Copyright (C) 2013-2016 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -72,7 +72,7 @@ void show_help()
"\nOptions:\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"
" -f, --force do not skip a file even if the .lz exists\n"
" -f, --force don't skip a file even if the .lz exists\n"
" -k, --keep keep (don't delete) input files\n"
" -l, --lzip-verbose pass a -v option to the lzip compressor\n"
" -M, --format=<list> process only the formats in <list>\n"
@ -94,10 +94,10 @@ int cant_execute( const std::string & command, const int status )
if( verbosity >= 0 )
{
if( WIFEXITED( status ) )
std::fprintf( stderr, "%s: Error executing '%s'. Exit status = %d.\n",
std::fprintf( stderr, "%s: Error executing '%s'. Exit status = %d\n",
program_name, command.c_str(), WEXITSTATUS( status ) );
else
std::fprintf( stderr, "%s: Can't execute '%s'.\n",
std::fprintf( stderr, "%s: Can't execute '%s'\n",
program_name, command.c_str() );
}
return 1;
@ -162,7 +162,7 @@ int zupdate_file( const std::string & name, const char * const lzip_name,
if( stat( name.c_str(), &in_stats ) != 0 ) // check input file
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't stat input file '%s': %s.\n",
std::fprintf( stderr, "%s: Can't stat input file '%s': %s\n",
program_name, name.c_str(), std::strerror( errno ) );
return 1;
}
@ -198,7 +198,7 @@ int zupdate_file( const std::string & name, const char * const lzip_name,
if( !lz_exists ) // recompress
{
if( verbosity >= 1 )
std::fprintf( stderr, "Recompressing file '%s'.\n", name.c_str() );
std::fprintf( stderr, "Recompressing file '%s'\n", name.c_str() );
int fda[2]; // pipe between decompressor and compressor
if( pipe( fda ) < 0 )
{ show_error( "Can't create pipe", errno ); return 1; }
@ -262,13 +262,14 @@ int zupdate_file( const std::string & name, const char * const lzip_name,
{
if( lz_exists && verbosity >= 1 )
std::fprintf( stderr, "Comparing file '%s'.\n", name.c_str() );
std::fprintf( stderr, "Comparing file '%s'\n", name.c_str() );
std::string zcmp_command( invocation_name );
unsigned i = zcmp_command.size();
while( i > 0 && zcmp_command[i-1] != '/' ) --i;
zcmp_command.resize( i );
zcmp_command += "zcmp "; // ${bindir}zcmp
if( no_rcfile ) zcmp_command += "-N ";
if( verbosity < 0 ) zcmp_command += "-q ";
zcmp_command += name; zcmp_command += ' '; zcmp_command += rname;
int status = std::system( zcmp_command.c_str() );
if( status != 0 )
@ -279,7 +280,7 @@ int zupdate_file( const std::string & name, const char * const lzip_name,
if( !keep_input_files && std::remove( name.c_str() ) != 0 && errno != ENOENT )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't delete input file '%s': %s.\n",
std::fprintf( stderr, "%s: Can't delete input file '%s': %s\n",
program_name, name.c_str(), std::strerror( errno ) );
return 1;
}