summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorĐoàn Trần Công Danh <[email protected]>2020-12-15 23:35:36 +0700
committerVictor Kareh <[email protected]>2023-03-22 07:28:43 -0400
commit4ee39ab04260179144ebb9ac7160df79a5b1e6fc (patch)
tree4c112d1287b9b978de8935ce18b6af2c9bb0220c
parenta36c201627e687e99d1c8b8f3b32e864cede7662 (diff)
downloadengrampa-4ee39ab04260179144ebb9ac7160df79a5b1e6fc.tar.bz2
engrampa-4ee39ab04260179144ebb9ac7160df79a5b1e6fc.tar.xz
zstd: support both old and new mime type
As of it's now, we're supporting zstd {,de}compression with specific mime type that was reported by libmagic as configure time. Thus, the built binaries is not correct after upgrading file-devel after configure. In addition, this configure's time hard-coded value prevent our users from partial upgrade. Let's accept both mime types reported by both old and new file-devel. For the mapping between file extensions and mime types, let's choose the new mime value.
-rw-r--r--caja/caja-engrampa.c3
-rw-r--r--configure.ac45
-rw-r--r--data/engrampa.desktop.in.in2
-rw-r--r--src/fr-command-cfile.c18
-rw-r--r--src/fr-init.c5
5 files changed, 18 insertions, 55 deletions
diff --git a/caja/caja-engrampa.c b/caja/caja-engrampa.c
index 0410c4a..0d303bc 100644
--- a/caja/caja-engrampa.c
+++ b/caja/caja-engrampa.c
@@ -190,7 +190,8 @@ static struct {
{ "application/x-zip", TRUE },
{ "application/x-zip-compressed", TRUE },
{ "application/x-zoo", TRUE },
- { ZSTD_MIME_TYPE, TRUE },
+ { "application/zstd", TRUE },
+ { "application/x-zstd", TRUE },
{ "application/x-zstd-compressed-tar", TRUE },
{ "application/zip", TRUE },
{ "multipart/x-zip", TRUE },
diff --git a/configure.ac b/configure.ac
index ffdcfdf..2c903f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,7 +148,6 @@ AC_ARG_ENABLE([magic],
AS_HELP_STRING([--enable-magic], [use libmagic to detect file type]),,
[enable_magic=no])
-zstd_mime_type="application/zstd"
if test x"$enable_magic" = x"yes" ; then
save_LIBS="$LIBS"
LIBS="$LIBS -lmagic"
@@ -161,47 +160,6 @@ int main () { magic_t m = magic_open(MAGIC_NONE); }
[AC_MSG_RESULT([no])
AC_MSG_ERROR([libmagic is needed for magic])])
- dnl *******************************************
- dnl This check can be removed with file >= 5.38
- dnl *******************************************
- AC_MSG_CHECKING([for zstd mime type])
- AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
-#include <string.h>
-#include <magic.h>]],
- [[
- FILE *fptr;
- char *test_file = "test.zst";
- char *default_mime_type = "application/zstd";
- int status = 0;
- if ((fptr = fopen (test_file,"wb")) == NULL) {
- status = 1;
- } else {
- const unsigned char data[5] = "\x28\xb5\x2f\xfd\0";
- int i;
- for (i = 0; i < strlen (data); i++)
- fwrite (&data[i], 1, 1, fptr);
- fclose (fptr);
- magic_t magic_cookie = magic_open (MAGIC_MIME_TYPE);
- if (magic_cookie == NULL) {
- status = 1;
- } else {
- if (magic_load (magic_cookie, NULL) != 0) {
- status = 1;
- } else {
- const char *mime = magic_file (magic_cookie, test_file);
- status = (strcmp (default_mime_type, mime) == 0);
- }
- magic_close(magic_cookie);
- }
- remove (test_file);
- }
- return status;]])],
- [zstd_mime_type="application/x-zstd"],
- [zstd_mime_type="application/zstd"]
- )
- AC_MSG_RESULT($zstd_mime_type)
- dnl *******************************************
-
LIBS="$save_LIBS"
MAGIC_CFLAGS=
@@ -214,9 +172,6 @@ int main () { magic_t m = magic_open(MAGIC_NONE); }
fi
AM_CONDITIONAL(ENABLE_MAGIC, test x"$enable_magic" != x"no")
-ZSTD_MIME_TYPE="$zstd_mime_type"
-AC_SUBST(ZSTD_MIME_TYPE)
-AC_DEFINE_UNQUOTED(ZSTD_MIME_TYPE, "$zstd_mime_type", [define zstd mime type])
AC_ARG_VAR([CPIO], [Path to the `cpio` command])
AC_PATH_PROGS(CPIO, gcpio cpio, cpio)
diff --git a/data/engrampa.desktop.in.in b/data/engrampa.desktop.in.in
index c23c8ab..6d8c511 100644
--- a/data/engrampa.desktop.in.in
+++ b/data/engrampa.desktop.in.in
@@ -11,7 +11,7 @@ Type=Application
Icon=engrampa
# Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon!
Categories=GTK;Utility;Archiving;Compression;
-MimeType=application/epub+zip;application/x-7z-compressed;application/x-7z-compressed-tar;application/x-ace;application/x-alz;application/x-arc;application/x-arj;application/x-brotli;application/x-brotli-compressed-tar;application/x-bzip;application/x-bzip-compressed-tar;application/x-bzip1;application/x-bzip1-compressed-tar;application/x-cabinet;application/x-cbr;application/x-cbz;application/x-cd-image;application/x-compress;application/x-compressed-tar;application/x-cpio;application/vnd.debian.binary-package;application/x-ear;application/x-ms-dos-executable;application/x-gtar;application/x-gzip;application/x-gzpostscript;application/x-java-archive;application/x-lha;application/x-lzh-compressed;application/x-lrzip;application/x-lrzip-compressed-tar;application/x-lzip;application/x-lzip-compressed-tar;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-lzop-compressed-tar;application/x-ms-wim;application/x-rar;application/x-rar-compressed;application/x-rpm;application/x-source-rpm;application/x-rzip;application/x-tar;application/x-tarz;application/x-stuffit;application/x-war;application/x-xz;application/x-xz-compressed-tar;application/x-zip;application/x-zip-compressed;application/x-zoo;@ZSTD_MIME_TYPE@;application/x-zstd-compressed-tar;application/zip;application/x-archive;application/vnd.ms-cab-compressed;
+MimeType=application/epub+zip;application/x-7z-compressed;application/x-7z-compressed-tar;application/x-ace;application/x-alz;application/x-arc;application/x-arj;application/x-brotli;application/x-brotli-compressed-tar;application/x-bzip;application/x-bzip-compressed-tar;application/x-bzip1;application/x-bzip1-compressed-tar;application/x-cabinet;application/x-cbr;application/x-cbz;application/x-cd-image;application/x-compress;application/x-compressed-tar;application/x-cpio;application/vnd.debian.binary-package;application/x-ear;application/x-ms-dos-executable;application/x-gtar;application/x-gzip;application/x-gzpostscript;application/x-java-archive;application/x-lha;application/x-lzh-compressed;application/x-lrzip;application/x-lrzip-compressed-tar;application/x-lzip;application/x-lzip-compressed-tar;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-lzop-compressed-tar;application/x-ms-wim;application/x-rar;application/x-rar-compressed;application/x-rpm;application/x-source-rpm;application/x-rzip;application/x-tar;application/x-tarz;application/x-stuffit;application/x-war;application/x-xz;application/x-xz-compressed-tar;application/x-zip;application/x-zip-compressed;application/x-zoo;application/zstd;application/x-zstd;application/x-zstd-compressed-tar;application/zip;application/x-archive;application/vnd.ms-cab-compressed;
# Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon!
Keywords=MATE;archive;manager;compression;
X-MATE-DocPath=engrampa/engrampa.xml
diff --git a/src/fr-command-cfile.c b/src/fr-command-cfile.c
index 647dbe3..52b023a 100644
--- a/src/fr-command-cfile.c
+++ b/src/fr-command-cfile.c
@@ -296,7 +296,8 @@ fr_command_cfile_add (FrCommand *comm,
compressed_filename = g_strconcat (filename, ".rz", NULL);
}
- else if (is_mime_type (comm->mime_type, ZSTD_MIME_TYPE)) {
+ else if (is_mime_type (comm->mime_type, "application/zstd")
+ || is_mime_type (comm->mime_type, "application/x-zstd")) {
fr_process_begin_command (comm->process, "zstd");
fr_process_set_working_dir (comm->process, temp_dir);
fr_process_add_arg (comm->process, filename);
@@ -439,7 +440,8 @@ fr_command_cfile_extract (FrCommand *comm,
fr_process_end_command (comm->process);
}
- else if (is_mime_type (comm->mime_type, ZSTD_MIME_TYPE)) {
+ else if (is_mime_type (comm->mime_type, "application/zstd")
+ || is_mime_type (comm->mime_type, "application/x-zstd")) {
fr_process_begin_command (comm->process, "zstd");
fr_process_add_arg (comm->process, "-f");
fr_process_add_arg (comm->process, "-d");
@@ -508,7 +510,8 @@ fr_command_cfile_test (FrCommand *comm)
else if (is_mime_type (comm->mime_type, "application/x-lzop")) {
compress_cmd = "lzop";
}
- else if (is_mime_type (comm->mime_type, ZSTD_MIME_TYPE)) {
+ else if (is_mime_type (comm->mime_type, "application/zstd")
+ || is_mime_type (comm->mime_type, "application/x-zstd")) {
compress_cmd = "zstd";
fr_process_begin_command (comm->process, compress_cmd);
fr_process_add_arg (comm->process, "-v");
@@ -535,7 +538,8 @@ const char *cfile_mime_type[] = { "application/x-gzip",
"application/x-lzop",
"application/x-rzip",
"application/x-xz",
- ZSTD_MIME_TYPE,
+ "application/zstd",
+ "application/x-zstd",
NULL };
static const char **
@@ -590,7 +594,8 @@ fr_command_cfile_get_capabilities (FrCommand *comm,
if (is_program_available ("rzip", check_command))
capabilities |= FR_COMMAND_CAN_READ_WRITE;
}
- else if (is_mime_type (mime_type, ZSTD_MIME_TYPE)) {
+ else if (is_mime_type (mime_type, "application/zstd")
+ || is_mime_type (mime_type, "application/x-zstd")) {
if (is_program_available ("zstd", check_command))
capabilities |= FR_COMMAND_CAN_READ_WRITE;
}
@@ -631,7 +636,8 @@ fr_command_cfile_get_packages (FrCommand *comm,
return PACKAGES ("lzop");
else if (is_mime_type (mime_type, "application/x-rzip"))
return PACKAGES ("rzip");
- else if (is_mime_type (mime_type, ZSTD_MIME_TYPE))
+ else if (is_mime_type (mime_type, "application/zstd")
+ || is_mime_type (mime_type, "application/x-zstd"))
return PACKAGES ("zstd");
return NULL;
diff --git a/src/fr-init.c b/src/fr-init.c
index 256e13e..c018bfa 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -109,7 +109,8 @@ FrMimeTypeDescription mime_type_desc[] = {
{ "application/x-xz", ".xz", N_("Xz compressed file"), 0 },
{ "application/x-xz-compressed-tar", ".tar.xz", N_("Tar compressed with xz"), 0 },
{ "application/x-zoo", ".zoo", N_("Zoo"), 0 },
- { ZSTD_MIME_TYPE, ".zst", N_("Zstandard compressed file"), 0 },
+ { "application/zstd", ".zst", N_("Zstandard compressed file"), 0 },
+ { "application/x-zstd", ".zst", N_("Zstandard compressed file"), 0 },
{ "application/x-zstd-compressed-tar", ".tar.zst", N_("Tar compressed with zstd"), 0 },
{ "application/zip", ".zip", N_("Zip"), 0 },
{ NULL, NULL, NULL, 0 }
@@ -184,7 +185,7 @@ FrExtensionType file_ext_type[] = {
{ ".Z", "application/x-compress" },
{ ".zip", "application/zip" },
{ ".zoo", "application/x-zoo" },
- { ".zst", ZSTD_MIME_TYPE },
+ { ".zst", "application/zstd" },
{ NULL, NULL }
};