libarchive/libarchive-test — Issue #14: 15 - Recent win32 portability changes break cygwin 
Author: amejia1
Created: 2012-01-20 19:23:11+00:00
State: open

What steps will reproduce the problem?
1. checkout svn rev 772
2. bootstrap and (try to) build
3. see glorious errors...

On cygwin, it is possible for _WIN32 to be defined -- which disables a lot
of unix-oriented code and enables w32-specific workarounds. But, on cygwin,
that's the job of the cygwin runtime; in almost all cases, the proper
choice is to use the "unix" code and let cygwin do its thing.

Most of this patch is mechanical:

#ifdef _WIN32 --> #if defined(_WIN32) && !defined(__CYGWIN__)
#ifndef _WIN32 --> #if !defined(_WIN32) || defined(__CYGWIN__)

but not *always*. I also created new files

cpio/cpio_cygwin.c
cpio/cpio_cygwin.h
tar/bsdtar_cygwin.c
tar/bsdtar_cygwin.h

by copying the relevant portions of the _windows files (cygwin doesn't
provide a mechanism to determine whether a user is privileged or not, so
you have to use the w32api to do so...)

Finally, I revised the Makefile.am to add the new files to the _SOURCES as
appropriate, and updated configure.ac to supply the necessary
AM_CONDITIONALS and AC_DEFINES. I tried to also update CMakeLists
similarly, but I'm not a CMake guru so I'm not sure if I did that part
right; it's untested.

The rest, though, is tested: I maintain the cygwin libarchive package
http://cygwin.com/ml/cygwin-announce/2009-03/msg00057.html
http://cygwin.com/ml/cygwin-announce/2009-03/msg00054.html

and with these changes it once again passes all of the tests in the
testsuite (and actually builds, too...)

I'm fairly sure that these changes do not impact other platforms at all,
since they are all guarded by #ifdefs or AM_CONDITIONALs, but I'm not set
up to easily verify that. If you like, I can break this relatively large
patch into smaller chunks, complete with ChangeLog entries, but I'm not
sure how you prefer to operate on this project.

The attached patch is against rev 722.

CMakeLists.txt | 58 ++++---
Makefile.am | 68 ++++++++
configure.ac | 22 ++
cpio/cpio.c | 26 ++-
cpio/cpio_cygwin.c | 139 +++++++++++++++++
cpio/cpio_cygwin.h | 41 +++++
cpio/cpio_platform.h | 4
cpio/cpio_windows.c | 3
cpio/test/main.c | 10 -
cpio/test/test.h | 18 +-
cpio/test/test_0.c | 2
cpio/test/test_basic.c | 14 -
cpio/test/test_format_newc.c | 14 +
cpio/test/test_gcpio_compat.c | 10 -
cpio/test/test_option_L.c | 10 -
cpio/test/test_option_a.c | 2
cpio/test/test_option_c.c | 12 -
cpio/test/test_option_f.c | 4
cpio/test/test_option_u.c | 2
cpio/test/test_option_version.c | 2
cpio/test/test_owner_parse.c | 56 +++++--
cpio/test/test_passthrough_dotdot.c | 2
cpio/test/test_passthrough_reverse.c | 4
libarchive/archive.h | 4
libarchive/archive_check_magic.c | 4
libarchive/archive_entry.c | 2
libarchive/archive_entry.h | 4
libarchive/archive_read_disk_set_standard_lookup.c | 6
libarchive/archive_read_support_compression_program.c | 2
libarchive/archive_string.c | 16 +-
libarchive/archive_windows.c | 5
libarchive/archive_write_disk.c | 21 +-
libarchive/archive_write_disk_set_standard_lookup.c | 4
libarchive/archive_write_set_compression_program.c | 2
libarchive/archive_write_set_format_mtree.c | 6
libarchive/config_windows.h | 2
libarchive/filter_fork_windows.c | 4
libarchive/test/main.c | 12 -
libarchive/test/test.h | 11 -
libarchive/test/test_read_disk.c | 6
libarchive/test/test_read_extract.c | 6
libarchive/test/test_write_disk.c | 18 +-
libarchive/test/test_write_disk_failures.c | 2
libarchive/test/test_write_disk_hardlink.c | 2
libarchive/test/test_write_disk_perms.c | 4
libarchive/test/test_write_disk_secure.c | 4
tar/bsdtar.c | 13 +
tar/bsdtar.h | 1
tar/bsdtar_cygwin.c | 141
++++++++++++++++++
tar/bsdtar_cygwin.h | 44 +++++
tar/bsdtar_platform.h | 4
tar/bsdtar_windows.c | 3
tar/cmdline.c | 1
tar/read.c | 2
tar/test/main.c | 10 -
tar/test/test.h | 9 -
tar/test/test_0.c | 2
tar/test/test_basic.c | 14 -
tar/test/test_copy.c | 4
tar/test/test_patterns.c | 2
tar/test/test_strip_components.c | 2
tar/test/test_symlink_dir.c | 12 -
tar/test/test_windows.c | 8 -
tar/tree.c | 14 -
tar/write.c | 2
65 files changed, 764 insertions(+), 194 deletions(-)

Original link: http://code.google.com/p/libarchive/issues/detail?id=15