When reading archive entries from disk strip any "fflags" entry headers
that may have been loaded from the filesystem when libarchive is built
with HAVE_STRUCT_STAT_ST_FLAGS (struct stat has 'st_flags'). The local
filesystem flags are not useful for distribution. Furthermore, GNU tar
does not understand the "SCHILY.fflags" extended header used to store
the flags in the archive. Use the approach from commit e8558efa
(cmArchiveWrite: Clear xattr and acl from entries, 2011-04-07) to remove
the flags and avoid producing the non-portable extended header.
This wasn't necessary for TAR-like (TGZ, TBZ2, etc...) archive
because for those the size was 0. Either there is an error in
upstream libarchive concerning the size or we should not rely
on size of the entry for adding content.
Do not recurse through directory symlinks when adding files.
Recursing through directory symlinks will generate broken archives,
i.e., they will look something like this:
foo -> bar/bar
foo/Info <- Shouldn't be in archive.
bar/bar
bar/bar/Info
When reading archive entries from disk strip any xattr and acl entry
headers that may have been loaded from the filesystem (e.g. selinux).
These fields are only useful for backup tools and not for packaging and
distribution of software. Furthermore, the GNU tar 1.15.1 on at least
one Linux distribution treats unknown entry headers as an error rather
than a warning. Therefore avoiding such fields is necessary for archive
portability.
Suggested-by: Tim Kientzle <tim@kientzle.com>
This is not needed but it does not cost much to do it for all
potentially supported format in libarchive. XZ and LZMA are not
builtin libarchive and require external lib but if
CMAKE_USE_SYSTEM_LIBARCHIVE is ON then we may get it for free.
This will be needed to use cmArchiveWrire in cmCPackArchiveGenerator
with the same feature set as before. Note that adding zip
support to libarchive-wrapper would also makes it easy to add
a new -E zip command to cmake commands.
Some stream libraries return size_t from gcount() and some return
ssize_t. Add an explicit cast to ios::streamsize for its return value.
Also refactor use of nnext to reduce the use of casts.
The libarchive interface accepts size_t but returns ssize_t. The std
streams interface wants streamsize, which is typically ssize_t. Since
no one type for our variable matches without conversions, make the
conversions explicit to avoid -Wsign-conversion and -Wsign-compare
warnings.