| |
pkg_create_set_format(struct archive *pkg_archive, pkg_formats format)
|
| |
{
|
| |
switch (format) {
|
| - |
case TAR:
|
| - |
archive_write_set_compression_none(pkg_archive);
|
| - |
return ("tar");
|
| - |
case TGZ:
|
| - |
if (archive_write_set_compression_gzip(pkg_archive) != ARCHIVE_OK) {
|
| - |
warnx("gzip compression is not supported, trying plain tar");
|
| - |
return (pkg_create_set_format(pkg_archive, TAR));
|
| + |
case TXZ:
|
| + |
if (archive_write_set_compression_xz(pkg_archive) == ARCHIVE_OK) {
|
| + |
return ("txz");
|
| |
} else {
|
| - |
return ("tgz");
|
| + |
warnx("xz compression is not supported, trying bzip2");
|
| |
}
|
| |
case TBZ:
|
| - |
if (archive_write_set_compression_bzip2(pkg_archive) != ARCHIVE_OK) {
|
| - |
warnx("bzip2 compression is not supported, trying gzip");
|
| - |
return (pkg_create_set_format(pkg_archive, TGZ));
|
| - |
} else {
|
| + |
if (archive_write_set_compression_bzip2(pkg_archive) == ARCHIVE_OK) {
|
| |
return ("tbz");
|
| + |
} else {
|
| + |
warnx("bzip2 compression is not supported, trying gzip");
|
| |
}
|
| - |
case TXZ:
|
| - |
if (archive_write_set_compression_xz(pkg_archive) != ARCHIVE_OK) {
|
| - |
warnx("xz compression is not supported, trying bzip2");
|
| - |
return (pkg_create_set_format(pkg_archive, TBZ));
|
| + |
case TGZ:
|
| + |
if (archive_write_set_compression_gzip(pkg_archive) == ARCHIVE_OK) {
|
| + |
return ("tgz");
|
| |
} else {
|
| - |
return ("txz");
|
| + |
warnx("gzip compression is not supported, trying plain tar");
|
| |
}
|
| + |
case TAR:
|
| + |
archive_write_set_compression_none(pkg_archive);
|
| + |
return ("tar");
|
| |
}
|
| |
return (NULL);
|
| |
}
|