Browse Source

Add support for zstd compression format where supported

tags/1.12.0
Baptiste Daroussin 1 year ago
parent
commit
d34c8d98a9
7 changed files with 29 additions and 7 deletions
  1. +1
    -1
      docs/pkg-create.8
  2. +16
    -0
      libpkg/packing.c
  3. +1
    -1
      libpkg/pkg.h.in
  4. +2
    -1
      libpkg/pkg_jobs.c
  5. +1
    -1
      libpkg/pkg_repo_meta.c
  6. +1
    -1
      scripts/completion/_pkg.in
  7. +7
    -2
      src/create.c

+ 1
- 1
docs/pkg-create.8 View File

@@ -148,7 +148,7 @@ Set
.Ar format
as the package output format.
It can be one of
.Ar txz , tbz , tgz
.Ar tzst, txz , tbz , tgz
or
.Ar tar
which are currently the only supported formats.


+ 16
- 0
libpkg/packing.c View File

@@ -315,6 +315,17 @@ packing_set_format(struct archive *a, pkg_formats format)
const char *notsupp_fmt = "%s is not supported, trying %s";

switch (format) {
case TZS:
#ifdef HAVE_ARCHIVE_WRITE_ADD_FILTER_ZSTD
if (archive_write_add_filter_zstd(a) == ARCHIVE_OK) {
if (archive_write_set_filter_option(a, NULL, "compression-level", "19") != ARCHIVE_OK) {
pkg_emit_error("bad compression-level");
}
return ("tzst");
}
#endif
pkg_emit_error(notsupp_fmt, "zstd", "xz");
/* FALLTHRU */
case TXZ:
if (archive_write_add_filter_xz(a) == ARCHIVE_OK)
return ("txz");
@@ -342,6 +353,8 @@ packing_format_from_string(const char *str)
{
if (str == NULL)
return TXZ;
if (strcmp(str, "tzst") == 0)
return TZS;
if (strcmp(str, "txz") == 0)
return TXZ;
if (strcmp(str, "tbz") == 0)
@@ -360,6 +373,9 @@ packing_format_to_string(pkg_formats format)
const char *res = NULL;

switch (format) {
case TZS:
res = "tzst";
break;
case TXZ:
res = "txz";
break;


+ 1
- 1
libpkg/pkg.h.in View File

@@ -1124,7 +1124,7 @@ void pkg_solve_problem_free(struct pkg_solve_problem *problem);
/**
* Archive formats options.
*/
typedef enum pkg_formats { TAR, TGZ, TBZ, TXZ } pkg_formats;
typedef enum pkg_formats { TAR, TGZ, TBZ, TXZ, TZS } pkg_formats;

/**
* Create package from an installed & registered package


+ 2
- 1
libpkg/pkg_jobs.c View File

@@ -198,7 +198,8 @@ pkg_jobs_maybe_match_file(struct job_pattern *jp, const char *pattern)
* Compare suffix with .txz or .tbz
*/
dot_pos ++;
if (strcmp(dot_pos, "txz") == 0 ||
if (strcmp(dot_pos, "tzst") == 0 ||
strcmp(dot_pos, "txz") == 0 ||
strcmp(dot_pos, "tbz") == 0 ||
strcmp(dot_pos, "tgz") == 0 ||
strcmp(dot_pos, "tar") == 0) {


+ 1
- 1
libpkg/pkg_repo_meta.c View File

@@ -109,7 +109,7 @@ pkg_repo_meta_open_schema_v1()
"version = {type = integer};\n"
"maintainer = {type = string};\n"
"source = {type = string};\n"
"packing_format = {enum = [txz, tbz, tgz, tar]};\n"
"packing_format = {enum = [tszt, txz, tbz, tgz, tar]};\n"
"digest_format = {enum = [sha256_base32, sha256_hex, blake2_base32, blake2s_base32]};\n"
"digests = {type = string};\n"
"manifests = {type = string};\n"


+ 1
- 1
scripts/completion/_pkg.in View File

@@ -287,7 +287,7 @@ _pkg_args() {
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'(-v --verbose)'{-v,--verbose}'[be verbose]' \
'(-n --no-clobber)'{-n,--no-clobber}"[don't overwrite existing packages]" \
'(-f --format)'{-f+,--format=}'[specify package output format]:format:(tar tgz tbz txz)' \
'(-f --format)'{-f+,--format=}'[specify package output format]:format:(tar tgz tbz txz tzst)' \
'(-o --out-dir)'{-o+,--out-dir=}'[output directory]:outdir:_files -/' \
'(-r --root-dir)'{-r+,--root-dir=}'[specify root directory]:rootdir:_files -/' \
- '(manifest)' \


+ 7
- 2
src/create.c View File

@@ -104,6 +104,9 @@ pkg_create_matches(int argc, char **argv, match_t match, pkg_formats fmt,
}

switch (fmt) {
case TZS:
format = "tzst";
break;
case TXZ:
format = "txz";
break;
@@ -180,7 +183,7 @@ cleanup:
/*
* options:
* -M: manifest file
* -f <format>: format could be txz, tgz, tbz or tar
* -f <format>: format could be tzst, txz, tgz, tbz or tar
* -g: globbing
* -h: pkg name with hash and symlink
* -m: path to dir where to find the metadata
@@ -299,7 +302,9 @@ exec_create(int argc, char **argv)
} else {
if (format[0] == '.')
++format;
if (strcmp(format, "txz") == 0)
if (strcmp(format, "tzst") == 0)
fmt = TZS;
else if (strcmp(format, "txz") == 0)
fmt = TXZ;
else if (strcmp(format, "tbz") == 0)
fmt = TBZ;


Loading…
Cancel
Save