package command: -z now takes an argument to specify the compression method.
The upcoming change to use zstd by default will make the -z no-argument variant obsolete, so instead we need to support passing "zstd" or "zlib" to actually indicate the compression method we want to use.
This commit is contained in:
@@ -40,7 +40,7 @@ command_create(int argc, const char* const* argv)
|
||||
bool quiet = false;
|
||||
bool verbose = false;
|
||||
int32 compressionLevel = BPackageKit::BHPKG::B_HPKG_COMPRESSION_LEVEL_BEST;
|
||||
int32 compression = BPackageKit::BHPKG::B_HPKG_COMPRESSION_ZLIB;
|
||||
int32 compression = parse_compression_argument(NULL);
|
||||
|
||||
while (true) {
|
||||
static struct option sLongOptions[] = {
|
||||
@@ -51,7 +51,7 @@ command_create(int argc, const char* const* argv)
|
||||
};
|
||||
|
||||
opterr = 0; // don't print errors
|
||||
int c = getopt_long(argc, (char**)argv, "+b0123456789C:hi:I:qvz",
|
||||
int c = getopt_long(argc, (char**)argv, "+b0123456789C:hi:I:z:qv",
|
||||
sLongOptions, NULL);
|
||||
if (c == -1)
|
||||
break;
|
||||
@@ -90,6 +90,10 @@ command_create(int argc, const char* const* argv)
|
||||
installPath = optarg;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
compression = parse_compression_argument(optarg);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
quiet = true;
|
||||
break;
|
||||
@@ -98,10 +102,6 @@ command_create(int argc, const char* const* argv)
|
||||
verbose = true;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
compression = BPackageKit::BHPKG::B_HPKG_COMPRESSION_ZSTD;
|
||||
break;
|
||||
|
||||
default:
|
||||
print_usage_and_exit(true);
|
||||
break;
|
||||
|
||||
@@ -45,7 +45,7 @@ command_recompress(int argc, const char* const* argv)
|
||||
bool quiet = false;
|
||||
bool verbose = false;
|
||||
int32 compressionLevel = BPackageKit::BHPKG::B_HPKG_COMPRESSION_LEVEL_BEST;
|
||||
int32 compression = BPackageKit::BHPKG::B_HPKG_COMPRESSION_ZLIB;
|
||||
int32 compression = parse_compression_argument(NULL);
|
||||
|
||||
while (true) {
|
||||
static struct option sLongOptions[] = {
|
||||
@@ -56,7 +56,7 @@ command_recompress(int argc, const char* const* argv)
|
||||
};
|
||||
|
||||
opterr = 0; // don't print errors
|
||||
int c = getopt_long(argc, (char**)argv, "+0123456789:hqvz",
|
||||
int c = getopt_long(argc, (char**)argv, "+0123456789:hz:qv",
|
||||
sLongOptions, NULL);
|
||||
if (c == -1)
|
||||
break;
|
||||
@@ -79,6 +79,10 @@ command_recompress(int argc, const char* const* argv)
|
||||
print_usage_and_exit(false);
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
compression = parse_compression_argument(optarg);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
quiet = true;
|
||||
break;
|
||||
@@ -87,10 +91,6 @@ command_recompress(int argc, const char* const* argv)
|
||||
verbose = true;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
compression = BPackageKit::BHPKG::B_HPKG_COMPRESSION_ZSTD;
|
||||
break;
|
||||
|
||||
default:
|
||||
print_usage_and_exit(true);
|
||||
break;
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <package/hpkg/HPKGDefs.h>
|
||||
|
||||
|
||||
extern const char* __progname;
|
||||
const char* kCommandName = __progname;
|
||||
@@ -61,7 +63,7 @@ static const char* kUsage =
|
||||
" an option only for use in package building. It will cause\n"
|
||||
" the package .self link to point to <path>, which is useful\n"
|
||||
" to redirect a \"make install\". Only allowed with -b.\n"
|
||||
" -z - Use Zstd compression.\n"
|
||||
" -z <type> - Specify compression method to use.\n"
|
||||
" -q - Be quiet (don't show any output except for errors).\n"
|
||||
" -v - Be verbose (show more info about created package).\n"
|
||||
"\n"
|
||||
@@ -107,7 +109,7 @@ static const char* kUsage =
|
||||
"\n"
|
||||
" -0 ... -9 - Use compression level 0 ... 9. 0 means no, 9 best compression.\n"
|
||||
" Defaults to 9.\n"
|
||||
" -z - Use Zstd compression.\n"
|
||||
" -z <type> - Specify compression method to use.\n"
|
||||
" -q - Be quiet (don't show any output except for errors).\n"
|
||||
" -v - Be verbose (show more info about created package).\n"
|
||||
"\n"
|
||||
@@ -124,6 +126,25 @@ print_usage_and_exit(bool error)
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
parse_compression_argument(const char* arg)
|
||||
{
|
||||
if (arg == NULL) {
|
||||
// Default compression method.
|
||||
return BPackageKit::BHPKG::B_HPKG_COMPRESSION_ZLIB;
|
||||
}
|
||||
|
||||
if (strcmp(arg, "zstd") == 0) {
|
||||
return BPackageKit::BHPKG::B_HPKG_COMPRESSION_ZSTD;
|
||||
} else if (strcmp(arg, "zlib") == 0) {
|
||||
return BPackageKit::BHPKG::B_HPKG_COMPRESSION_ZLIB;
|
||||
} else {
|
||||
fprintf(stderr, "error: unknown compression method '%s'\n", arg);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, const char* const* argv)
|
||||
{
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
#ifndef PACKAGE_H
|
||||
#define PACKAGE_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
void print_usage_and_exit(bool error);
|
||||
int32 parse_compression_argument(const char* arg);
|
||||
|
||||
int command_add(int argc, const char* const* argv);
|
||||
int command_checksum(int argc, const char* const* argv);
|
||||
|
||||
Reference in New Issue
Block a user