--- Begin Message ---
Package: gddrescue
Version: 1.2-1.1
Tags: patch
Gddrescue has a number of problems, I fixed those in the appended patch:
- It FTBFS at least on g++-4.3/mips because llabs, snprintf, and
strtoll are not in the std:: namespace, they are gnu extensions
in std::__gnu_gxx::, or global names in ::. (This appears to be a
bug fix in latest GCC). I chose to simply use the global version.
- The build system does not use GNU configure but a much less capable
script which doesn't handle e.g. compiler flags. This means none
of the flags in debian/rules was used (and the noopt was ineffective).
- debian/rules defines CFLAGS, but no CXXFLAGS. Since only c++ is
used, I changed the flag variable name so it gets used by the build.
I also pass CXXFLAGS explicitely to the make invocation, that way it
overrides the hardcoded options in the upstream Makefile{,.in}.
Thiemo
diff -uprN gddrescue-1.2.original/ddrescue.cc gddrescue-1.2/ddrescue.cc
--- gddrescue-1.2.original/ddrescue.cc 2006-03-16 18:14:05.000000000 +0000
+++ gddrescue-1.2/ddrescue.cc 2008-04-05 13:14:57.000000000 +0100
@@ -176,9 +176,9 @@ const char * format_num( long long num,
const char *p = "";
max = std::max( 999LL, std::min( 999999LL, max ) );
- for( int i = 0; i < 8 && std::llabs( num ) > std::llabs( max ); ++i )
+ for( int i = 0; i < 8 && ::llabs( num ) > ::llabs( max ); ++i )
{ num /= factor; p = prefix[i]; }
- std::snprintf( buf, sizeof( buf ), "%lld %s", num, p );
+ ::snprintf( buf, sizeof( buf ), "%lld %s", num, p );
return buf;
}
diff -uprN gddrescue-1.2.original/debian/rules gddrescue-1.2/debian/rules
--- gddrescue-1.2.original/debian/rules 2005-10-29 11:27:35.000000000 +0100
+++ gddrescue-1.2/debian/rules 2008-04-05 14:08:44.000000000 +0100
@@ -16,18 +16,18 @@ DEB_HOST_GNU_TYPE ?= $(shell dpkg-arch
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-CFLAGS = -Wall -g
+CXXFLAGS = -Wall -g -Wl,-z,defs
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
+ CXXFLAGS += -O0
else
- CFLAGS += -O2
+ CXXFLAGS += -O2
endif
config.status: configure
dh_testdir
# Add here commands to configure the package.
- CFLAGS="$(CFLAGS) -Wl,-z,defs" ./configure \
+ ./configure \
--prefix=/usr \
--mandir=\$${prefix}/share/man \
--infodir=\$${prefix}/share/info
@@ -39,7 +39,7 @@ build-stamp: config.status
dh_testdir
# Add here commands to compile the package.
- $(MAKE)
+ $(MAKE) CXXFLAGS="$(CXXFLAGS)"
#docbook-to-man debian/gddrescue.sgml > gddrescue.1
touch build-stamp
diff -uprN gddrescue-1.2.original/logbook.cc gddrescue-1.2/logbook.cc
--- gddrescue-1.2.original/logbook.cc 2008-04-05 14:22:22.000000000 +0100
+++ gddrescue-1.2/logbook.cc 2008-04-05 13:17:07.000000000 +0100
@@ -168,8 +168,8 @@ void split_domain_border_sblocks( std::v
void logfile_error( const char * filename, const int linenum ) throw()
{
char buf[80];
- std::snprintf( buf, sizeof( buf ), "error in logfile %s, line %d\n",
- filename, linenum );
+ ::snprintf( buf, sizeof( buf ), "error in logfile %s, line %d\n",
+ filename, linenum );
show_error( buf );
}
@@ -194,7 +194,7 @@ bool update_logfile( const std::vector<
if( !f )
{
char buf[80];
- std::snprintf( buf, sizeof( buf ), "error opening logfile %s for writing",
filename );
+ ::snprintf( buf, sizeof( buf ), "error opening logfile %s for writing",
filename );
show_error( buf, errno );
return false;
}
@@ -212,7 +212,7 @@ bool update_logfile( const std::vector<
if( std::fclose( f ) )
{
char buf[80];
- std::snprintf( buf, sizeof( buf ), "error writing logfile %s", filename );
+ ::snprintf( buf, sizeof( buf ), "error writing logfile %s", filename );
show_error( buf, errno );
return false;
}
@@ -233,10 +233,10 @@ void Logbook::set_rescue_domain( const l
if( _domain.pos() >= isize )
{
char buf[80];
- std::snprintf( buf, sizeof( buf ), "can't start reading at pos %lld",
- _domain.pos() ); show_error( buf );
- std::snprintf( buf, sizeof( buf ), "input file is only %lld bytes long",
- isize ); show_error( buf );
+ ::snprintf( buf, sizeof( buf ), "can't start reading at pos %lld",
+ _domain.pos() ); show_error( buf );
+ ::snprintf( buf, sizeof( buf ), "input file is only %lld bytes long",
+ isize ); show_error( buf );
std::exit(1);
}
if( _domain.size() < 0 || _domain.pos() + _domain.size() > isize )
@@ -392,7 +392,7 @@ int Logbook::copy_errors() throw()
const int msglen = std::strlen( msgbuf );
for( int retry = 1; _max_retries < 0 || retry <= _max_retries; ++retry )
{
- std::snprintf( msgbuf + msglen, sizeof( msgbuf ) - msglen, "%d", retry );
+ ::snprintf( msgbuf + msglen, sizeof( msgbuf ) - msglen, "%d", retry );
unsigned int index = 0;
bool first_post = true, bad_block_found = false;
split_domain_border_sblocks( sblock_vector, _domain );
diff -uprN gddrescue-1.2.original/main.cc gddrescue-1.2/main.cc
--- gddrescue-1.2.original/main.cc 2008-04-05 14:22:22.000000000 +0100
+++ gddrescue-1.2/main.cc 2008-04-05 14:19:57.000000000 +0100
@@ -95,7 +95,7 @@ long long getnum( const char * ptr, cons
{
errno = 0;
char *tail;
- long long result = std::strtoll( ptr, &tail, 0 );
+ long long result = ::strtoll( ptr, &tail, 0 );
if( tail == ptr )
{ show_error( "bad or missing numerical argument", 0, true );
std::exit(1); }
@@ -128,7 +128,7 @@ long long getnum( const char * ptr, cons
std::exit(1); }
for( int i = 0; i < exponent; ++i )
{
- if( LONG_LONG_MAX / factor >= std::llabs( result ) ) result *= factor;
+ if( LONG_LONG_MAX / factor >= ::llabs( result ) ) result *= factor;
else { errno = ERANGE; break; }
}
}
@@ -153,7 +153,7 @@ bool check_identical( const char * name1
void internal_error( const char * msg ) throw()
{
char buf[80];
- std::snprintf( buf, sizeof( buf ), "internal error: %s.\n", msg );
+ ::snprintf( buf, sizeof( buf ), "internal error: %s.\n", msg );
show_error( buf );
exit( 3 );
}
--- End Message ---