Bug#485552: reprepro: Patches for portability to AIX

2008-06-10 Thread Bernhard R. Link
* Carey Evans [EMAIL PROTECTED] [080610 06:34]:
 This bug is not about the Debian packaging of reprepro, but about
 compiling the upstream source on a non-Linux system.

Thanks for testing reprepro there. But please note reprepro is targeted
for systems using glibc or other compatible ones having all the gnu
extensions I like to use, as I deem reprepro seldom useful outside Debian
systems.
I'm willing to incorporate changes increasing portability outside of
that range, unless they make the code uglier or more fragile (or they
can be easily worked around).

 - A number of the files use malloc() and free() without including
 stdlib.h. The AIX C library is careful only to define these where
 the various standards say they should be found. I haven't provided a
 patch for this one.

Thanks for finding this. Should be fixed in CVS now.

 - The last parameter for execl() should be (char*)NULL, not just NULL,
 in case char* is a different size to whatever NULL resolves to. GCC
 4.3 warns about this on AIX.

What is NULL there? I'm assuming NULL is (void)0 (and not simply 0).
Does compiling with -DNULL=(void*)0 help?

 - AIX 5.3 doesn't provide O_NOFOLLOW. I most cases, this is combined
 with O_EXCL which seems to be redundant, and I've removed it; in
 donefile.c I've taken the potential security exposure and not used it.
 You might wish to define it to 0 instead.

I think that can also easily worked around by just adding -DO_NOFOLLOW=0
to CPPFLAGS.

 - AIX 5.3 doesn't have endian.h, but does get the BSD-ish
 BYTE_ORDER, BIG_ENDIAN and LITTLE_ENDIAN macros if you include
 sys/param.h and/or sys/types.h. I haven't included a patch for
 configure.ac, etc., to get them to detect HAVE_ENDIAN_H on Linux, but
 it should be trivial. Alternatively, there's AC_C_BIGENDIAN.

Hm, I'll have to take a look into these. Otherwise adding a file
endian.h to the source which #defines them to their BSD counterparts
should be easy. (perhaps I'll go the AC_C_BIGENDIAN route)

 - AIX 5.3 doesn't have vasnprintf (or dprintf). I've removed
 vmprintf(), changed formaterror to use snprintf with a static buffer
 that is much larger than anything it will have to hold, and changed
 mprintf() and dprintf() to call vsnprintf twice, as shown in the GNU
 libc manual. I figure that there's no point making dprintf() use
 vasprintf(), because they're both GNU libc extensions.

 - AIX doesn't have getopt_long, but I've compiled against libiberty from GCC.

Aren't vasnprintf and dprintf in libiberty, too? At least vasnprintf I
would have expected there.

 - _D_EXACT_NAMELEN is a GNU extension. I just use strlen(r-d_name) if
 it isn't defined.

Well, this could be fixed with a -D, too. But I think that is garanteed
to be an #define and it's only three lines in an header, so I added
that.

 - I don't check zlibCompileFlags() when using zlib 1.1, which is what
 I have available.

Sorry, support for older zlib was removed 2007-11-18.
Does it really produce correct .gz files when you just prevent the
safety guard against too old versions (At least I an hardly imagine
they have an gz header)?

Hochachtungsvoll,
Bernhard R. Link
-- 
Never contain programs so few bugs, as when no debugging tools are available!
Niklaus Wirth



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#485552: reprepro: Patches for portability to AIX

2008-06-10 Thread Carey Evans
On Wed, Jun 11, 2008 at 4:00 AM, Bernhard R. Link [EMAIL PROTECTED] wrote:
 Thanks for testing reprepro there. But please note reprepro is targeted
 for systems using glibc or other compatible ones having all the gnu
 extensions I like to use, as I deem reprepro seldom useful outside Debian
 systems.

No problem.

 - The last parameter for execl() should be (char*)NULL, not just NULL,
 in case char* is a different size to whatever NULL resolves to. GCC
 4.3 warns about this on AIX.

 What is NULL there? I'm assuming NULL is (void)0 (and not simply 0).
 Does compiling with -DNULL=(void*)0 help?

NULL is 0, as per C99 sections 7.17.3 and 6.3.2.3.3; defining NULL to
(void*)0 helps. The Open Group examples at
http://www.opengroup.org/onlinepubs/95399/functions/exec.html do
all use (char *)0.

 I think that can also easily worked around by just adding -DO_NOFOLLOW=0
 to CPPFLAGS.

True. This could also go into configure with AC_CHECK_DECL, but that
might be a bit dangerous.

 Aren't vasnprintf and dprintf in libiberty, too? At least vasnprintf I
 would have expected there.

It is, though I don't see dprintf. Of course, I only started looking
for getopt_long once I'd reimplemented mprintf(); I could have saved
myself quite a bit of time.

 - _D_EXACT_NAMELEN is a GNU extension. I just use strlen(r-d_name) if
 it isn't defined.

 Well, this could be fixed with a -D, too. But I think that is garanteed
 to be an #define and it's only three lines in an header, so I added
 that.

And for what it's worth, _D_EXACT_NAMELEN would expand to exactly that
in this case.

 Does it really produce correct .gz files when you just prevent the
 safety guard against too old versions (At least I an hardly imagine
 they have an gz header)?

Thanks for setting me straight, I should have looked further first.
Now I get to see whether I can recompile zlib without breaking the
custom version of OpenSSH here.

I'll see how I go with libiberty and zlib 1.2. Thanks.

-- 
Laissez lire, et laissez danser; ces deux amusements ne feront jamais
de mal au monde.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#485552: reprepro: Patches for portability to AIX

2008-06-10 Thread Carey Evans
After installing zlib 1.2.3, and configuring with CC='gcc -pthread'
CPPFLAGS=-DO_NOFOLLOW=0 LIBS=-liberty, the remaining changes I need to
get reprepro to compile are detecting big- or little-endian systems,
defining _D_EXACT_NAMELEN, and including stdlib.h. On a 32-bit
platform, having NULL defined as 0 doesn't matter.

This is a much smaller set of changes. Sorry for including so many
unnecessary modifications in the first patch.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#485552: reprepro: Patches for portability to AIX

2008-06-09 Thread Carey Evans
Package: reprepro
Version: 3.5.0
Tags: patch

This bug is not about the Debian packaging of reprepro, but about
compiling the upstream source on a non-Linux system.

For various reasons, I'm compiling reprepro for AIX 5.3 with GCC, to
use on IBM i5/OS V5R4 for a few hundred Debian PCs. I encountered a
handful of problems that needed changes, as listed below, and I'm
including a patch for most of them. Overall I'm very impressed with
the portability of the code.

- A number of the files use malloc() and free() without including
stdlib.h. The AIX C library is careful only to define these where
the various standards say they should be found. I haven't provided a
patch for this one.

- The last parameter for execl() should be (char*)NULL, not just NULL,
in case char* is a different size to whatever NULL resolves to. GCC
4.3 warns about this on AIX.

- AIX 5.3 doesn't provide O_NOFOLLOW. I most cases, this is combined
with O_EXCL which seems to be redundant, and I've removed it; in
donefile.c I've taken the potential security exposure and not used it.
You might wish to define it to 0 instead.

- AIX 5.3 doesn't have endian.h, but does get the BSD-ish
BYTE_ORDER, BIG_ENDIAN and LITTLE_ENDIAN macros if you include
sys/param.h and/or sys/types.h. I haven't included a patch for
configure.ac, etc., to get them to detect HAVE_ENDIAN_H on Linux, but
it should be trivial. Alternatively, there's AC_C_BIGENDIAN.

- AIX 5.3 doesn't have vasnprintf (or dprintf). I've removed
vmprintf(), changed formaterror to use snprintf with a static buffer
that is much larger than anything it will have to hold, and changed
mprintf() and dprintf() to call vsnprintf twice, as shown in the GNU
libc manual. I figure that there's no point making dprintf() use
vasprintf(), because they're both GNU libc extensions.

- _D_EXACT_NAMELEN is a GNU extension. I just use strlen(r-d_name) if
it isn't defined.

- I don't check zlibCompileFlags() when using zlib 1.1, which is what
I have available.

- AIX doesn't have getopt_long, but I've compiled against libiberty from GCC.

- AIX GCC needs an option -pthread to compile and link threadsafe
code (like Berkeley DB), not -D_REENTRANT. I added this option to the
CFLAGS when running configure. I don't know how autoconf is supposed
to discover this.

Please let me know if you'd like any more information.

-- 
Laissez lire, et laissez danser; ces deux amusements ne feront jamais
de mal au monde.
*** aptmethod.c.origFri Jun  6 21:07:53 2008
--- aptmethod.c Tue Jun 10 11:40:10 2008
***
*** 335,341 
if( methodname == NULL )
exit(255);
  
!   (void)execl(methodname,methodname,NULL);
  
e = errno;
fprintf(stderr, Error %d while executing '%s': %s\n,
--- 335,341 
if( methodname == NULL )
exit(255);
  
!   (void)execl(methodname,methodname,(char*)NULL);
  
e = errno;
fprintf(stderr, Error %d while executing '%s': %s\n,
*** checks.c.orig   Wed Apr  9 01:01:42 2008
--- checks.cTue Jun 10 10:34:11 2008
***
*** 171,185 
  
  static const char *formaterror(const char *format, ...) {
va_list ap;
!   static char *data = NULL;
  
-   if( data != NULL )
-   free(data);
va_start(ap, format);
!   data = vmprintf(format, ap);
va_end(ap);
-   if( data == NULL )
-   return Out of memory;
return data;
  }
  
--- 171,181 
  
  static const char *formaterror(const char *format, ...) {
va_list ap;
!   static char data[1024];
  
va_start(ap, format);
!   snprintf(data, sizeof(data), format, ap);
va_end(ap);
return data;
  }
  
*** database.c.orig Wed Apr  9 01:01:43 2008
--- database.c  Tue Jun 10 11:28:38 2008
***
*** 84,90 
lockfile = calc_dirconcat(db-directory, lockfile);
if( lockfile == NULL )
return RET_ERROR_OOM;
!   fd = 
open(lockfile,O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY,S_IRUSR|S_IWUSR);
while( fd  0 ) {
int e = errno;
if( e == EEXIST ) {
--- 84,90 
lockfile = calc_dirconcat(db-directory, lockfile);
if( lockfile == NULL )
return RET_ERROR_OOM;
!   fd = open(lockfile,O_WRONLY|O_CREAT|O_EXCL|O_NOCTTY,S_IRUSR|S_IWUSR);
while( fd  0 ) {
int e = errno;
if( e == EEXIST ) {
***
*** 95,101 
while( timetosleep  0 )
timetosleep = sleep(timetosleep);
tries++;
!   fd = 
open(lockfile,O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY,S_IRUSR|S_IWUSR);
continue;
  
}
--- 95,101 
while( timetosleep  0