|
1
|
+From d3b06e19ae5acb1395cc909005535d08daecb755 Mon Sep 17 00:00:00 2001
|
|
2
|
+From: zhuyaliang <15132211195@163.com>
|
|
3
|
+Date: Mon, 20 Mar 2023 23:06:44 +0800
|
|
4
|
+Subject: [PATCH] command-7z: Add new 7-zip(7zz and 7zzs) project support
|
|
5
|
+
|
|
6
|
+---
|
|
7
|
+ data/packages.match | 6 +++---
|
|
8
|
+ src/fr-command-7z.c | 35 +++++++++++++++++++++++++----------
|
|
9
|
+ src/fr-command-tar.c | 9 +++++----
|
|
10
|
+ 3 files changed, 33 insertions(+), 17 deletions(-)
|
|
11
|
+
|
|
12
|
+--- a/data/packages.match
|
|
13
|
++++ b/data/packages.match
|
|
14
|
+@@ -15,9 +15,9 @@
|
|
15
|
+ lzop=
|
|
16
|
+ ncompress=
|
|
17
|
+ nomarch=
|
|
18
|
+-p7zip=
|
|
19
|
+-p7zip-full=
|
|
20
|
+-p7zip-rar=
|
|
21
|
++7zip=
|
|
22
|
++7zip-full=
|
|
23
|
++7zip-rar=
|
|
24
|
+ rar=
|
|
25
|
+ rpm=
|
|
26
|
+ rzip=
|
|
27
|
+--- a/src/fr-command-7z.c
|
|
28
|
++++ b/src/fr-command-7z.c
|
|
29
|
+@@ -208,7 +208,15 @@
|
|
30
|
+ static void
|
|
31
|
+ fr_command_7z_begin_command (FrCommand *comm)
|
|
32
|
+ {
|
|
33
|
+- if (is_program_in_path ("7z"))
|
|
34
|
++ // Modern 7-Zip by the original author.
|
|
35
|
++ // Statically linked from a binary distribution, almost guaranteed to work.
|
|
36
|
++ if (is_program_in_path ("7zzs"))
|
|
37
|
++ fr_process_begin_command (comm->process, "7zzs");
|
|
38
|
++ // Dynamically linked from either binary or source distribution.
|
|
39
|
++ else if (is_program_in_path ("7zz"))
|
|
40
|
++ fr_process_begin_command (comm->process, "7zz");
|
|
41
|
++ // Legacy p7zip project.
|
|
42
|
++ else if (is_program_in_path ("7z"))
|
|
43
|
+ fr_process_begin_command (comm->process, "7z");
|
|
44
|
+ else if (is_program_in_path ("7za"))
|
|
45
|
+ fr_process_begin_command (comm->process, "7za");
|
|
46
|
+@@ -343,8 +351,10 @@
|
|
47
|
+
|
|
48
|
+ if (spd_support) fr_process_add_arg (comm->process, "-spd");
|
|
49
|
+ fr_process_add_arg (comm->process, "-bd");
|
|
50
|
++ fr_process_add_arg (comm->process, "-bb1");
|
|
51
|
+ fr_process_add_arg (comm->process, "-y");
|
|
52
|
+- fr_process_add_arg (comm->process, "-l");
|
|
53
|
++ if (recursive)
|
|
54
|
++ fr_process_add_arg (comm->process, "-l");
|
|
55
|
+ add_password_arg (comm, comm->password, FALSE);
|
|
56
|
+ if ((comm->password != NULL)
|
|
57
|
+ && (*comm->password != 0)
|
|
58
|
+@@ -478,6 +488,7 @@
|
|
59
|
+
|
|
60
|
+ if (spd_support) fr_process_add_arg (comm->process, "-spd");
|
|
61
|
+ fr_process_add_arg (comm->process, "-bd");
|
|
62
|
++ fr_process_add_arg (comm->process, "-bb1");
|
|
63
|
+ fr_process_add_arg (comm->process, "-y");
|
|
64
|
+ add_password_arg (comm, comm->password, FALSE);
|
|
65
|
+
|
|
66
|
+@@ -618,24 +629,28 @@
|
|
67
|
+ FrCommandCap capabilities;
|
|
68
|
+
|
|
69
|
+ capabilities = FR_COMMAND_CAN_ARCHIVE_MANY_FILES;
|
|
70
|
+- if (! is_program_available ("7za", check_command) && ! is_program_available ("7zr", check_command) && ! is_program_available ("7z", check_command))
|
|
71
|
++ gboolean available_7zip = is_program_available ("7zz", check_command) || is_program_available ("7zzs", check_command);
|
|
72
|
++ if (! available_7zip\
|
|
73
|
++ && ! is_program_available ("7za", check_command) \
|
|
74
|
++ && ! is_program_available ("7zr", check_command) \
|
|
75
|
++ && ! is_program_available ("7z", check_command))
|
|
76
|
+ return capabilities;
|
|
77
|
+
|
|
78
|
+ if (is_mime_type (mime_type, "application/x-7z-compressed")) {
|
|
79
|
+ capabilities |= FR_COMMAND_CAN_READ_WRITE | FR_COMMAND_CAN_CREATE_VOLUMES;
|
|
80
|
+- if (is_program_available ("7z", check_command))
|
|
81
|
++ if (is_program_available ("7z", check_command) || available_7zip)
|
|
82
|
+ capabilities |= FR_COMMAND_CAN_ENCRYPT | FR_COMMAND_CAN_ENCRYPT_HEADER;
|
|
83
|
+ }
|
|
84
|
+ else if (is_mime_type (mime_type, "application/x-7z-compressed-tar")) {
|
|
85
|
+ capabilities |= FR_COMMAND_CAN_READ_WRITE;
|
|
86
|
+- if (is_program_available ("7z", check_command))
|
|
87
|
++ if (is_program_available ("7z", check_command) || available_7zip)
|
|
88
|
+ capabilities |= FR_COMMAND_CAN_ENCRYPT | FR_COMMAND_CAN_ENCRYPT_HEADER;
|
|
89
|
+ }
|
|
90
|
+- else if (is_program_available ("7z", check_command)) {
|
|
91
|
++ else if (is_program_available ("7z", check_command) || available_7zip) {
|
|
92
|
+ if (is_mime_type (mime_type, "application/x-rar")
|
|
93
|
+ || is_mime_type (mime_type, "application/x-cbr"))
|
|
94
|
+ {
|
|
95
|
+- if (! check_command || g_file_test ("/usr/lib/p7zip/Codecs/Rar29.so", G_FILE_TEST_EXISTS) || g_file_test ("/usr/lib/p7zip/Codecs/Rar.so", G_FILE_TEST_EXISTS)
|
|
96
|
++ if (! check_command || available_7zip || g_file_test ("/usr/lib/p7zip/Codecs/Rar29.so", G_FILE_TEST_EXISTS) || g_file_test ("/usr/lib/p7zip/Codecs/Rar.so", G_FILE_TEST_EXISTS)
|
|
97
|
+ || g_file_test ("/usr/libexec/p7zip/Codecs/Rar29.so", G_FILE_TEST_EXISTS) || g_file_test ("/usr/libexec/p7zip/Codecs/Rar.so", G_FILE_TEST_EXISTS))
|
|
98
|
+ capabilities |= FR_COMMAND_CAN_READ;
|
|
99
|
+ }
|
|
100
|
+@@ -674,11 +689,11 @@
|
|
101
|
+ const char *mime_type)
|
|
102
|
+ {
|
|
103
|
+ if (is_mime_type (mime_type, "application/x-rar"))
|
|
104
|
+- return PACKAGES ("p7zip,p7zip-rar");
|
|
105
|
++ return PACKAGES ("7zip,7zip-rar");
|
|
106
|
+ else if (is_mime_type (mime_type, "application/zip") || is_mime_type (mime_type, "application/vnd.ms-cab-compressed"))
|
|
107
|
+- return PACKAGES ("p7zip,p7zip-full");
|
|
108
|
++ return PACKAGES ("7zip,7zip-full");
|
|
109
|
+ else
|
|
110
|
+- return PACKAGES ("p7zip");
|
|
111
|
++ return PACKAGES ("7zip");
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+--- a/src/fr-command-tar.c
|
|
116
|
++++ b/src/fr-command-tar.c
|
|
117
|
+@@ -682,7 +682,8 @@
|
|
118
|
+ fr_process_add_arg (comm->process, "a");
|
|
119
|
+ fr_process_add_arg (comm->process, "-bd");
|
|
120
|
+ fr_process_add_arg (comm->process, "-y");
|
|
121
|
+- fr_process_add_arg (comm->process, "-l");
|
|
122
|
++ if (g_strcmp0 (comm_tar->compress_command, "7zzs") != 0 && g_strcmp0 (comm_tar->compress_command, "7zz") != 0)
|
|
123
|
++ fr_process_add_arg (comm->process, "-l");
|
|
124
|
+
|
|
125
|
+ new_name = g_strconcat (c_tar->uncomp_filename, ".7z", NULL);
|
|
126
|
+ fr_process_add_arg_concat (comm->process, new_name, NULL);
|
|
127
|
+@@ -1087,7 +1088,7 @@
|
|
128
|
+ capabilities |= FR_COMMAND_CAN_READ_WRITE;
|
|
129
|
+ }
|
|
130
|
+ else if (is_mime_type (mime_type, "application/x-7z-compressed-tar")) {
|
|
131
|
+- const char *try_command[3] = { "7za", "7zr", "7z" };
|
|
132
|
++ const char *try_command[5] = { "7zzs", "7zz", "7za", "7zr", "7z" };
|
|
133
|
+ size_t i;
|
|
134
|
+
|
|
135
|
+ for (i = 0; i < G_N_ELEMENTS (try_command); i++) {
|
|
136
|
+@@ -1115,7 +1116,7 @@
|
|
137
|
+ FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
|
|
138
|
+
|
|
139
|
+ if (is_mime_type (mime_type, "application/x-7z-compressed-tar")) {
|
|
140
|
+- const char *try_command[3] = { "7za", "7zr", "7z" };
|
|
141
|
++ const char *try_command[5] = { "7zzs", "7zz", "7za", "7zr", "7z" };
|
|
142
|
+ size_t i;
|
|
143
|
+
|
|
144
|
+ for (i = 0; i < G_N_ELEMENTS (try_command); i++) {
|
|
145
|
+@@ -1153,7 +1154,7 @@
|
|
146
|
+ else if (is_mime_type (mime_type, "application/x-lzop-compressed-tar"))
|
|
147
|
+ return PACKAGES ("tar,lzop");
|
|
148
|
+ else if (is_mime_type (mime_type, "application/x-7z-compressed-tar"))
|
|
149
|
+- return PACKAGES ("tar,p7zip");
|
|
150
|
++ return PACKAGES ("tar,7zip");
|
|
151
|
+ else if (is_mime_type (mime_type, "application/x-zstd-compressed-tar"))
|
|
152
|
+ return PACKAGES ("tar,zstd");
|
|
153
|
+ |