Bug 440135 - cli7zplugin: add support for original 7-zip
Summary: cli7zplugin: add support for original 7-zip
Status: RESOLVED FIXED
Alias: None
Product: ark
Classification: Applications
Component: plugins (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Ragnar Thomsen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-22 02:17 UTC by 2wxsy58236r3
Modified: 2022-08-29 06:03 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 22.04.2


Attachments
support for 7-zip (466 bytes, text/x-c++src)
2022-01-01 23:07 UTC, Max
Details

Note You need to log in before you can comment on or make changes to this bug.
Description 2wxsy58236r3 2021-07-22 02:17:32 UTC
SUMMARY

Ark currently has plugin for p7zip, but p7zip has been abandoned and the latest version is 16.02, which is released 5 years ago.

(Some distros switched to another fork [1] though, but it seems that the fork's 17.04 version is not based on the latest code base of 7-zip.)

Recently, the developer of 7-zip, Igor Pavlov, released new versions which support Linux.
The latest release is 21.03 beta. The source code can be found at [2]. A precompiled binary for Linux is also available at [2].

7-zip is already in ALT Linux's repo, and there is also AUR package for Arch Linux.

The binary is named "7zz", which is a standalone binary.
It is also possible to build 7z and 7z.so.

I hope there will be a new plugin for the upstream 7-zip.

[1] https://github.com/jinfeihan57/p7zip
[2] https://sourceforge.net/p/sevenzip/discussion/45797/thread/9f5b067368/#0235
Comment 1 Max 2022-01-01 23:07:24 UTC
Created attachment 145032 [details]
support for 7-zip

There's no need for another plugin, existing plugin with this patch applied can
work with Linux version of 7-zip, assuming 7-zip package provides 7z executable.
The patch relaxes regexp to match version string any of p7zip and 7-zip:

p7zip output:

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=ru_RU.UTF-8,Utf16=on,HugeFiles=on,64 bits,8 CPUs x64)


7-zip output:

7-Zip (z) 21.07 (x64) : Copyright (c) 1999-2021 Igor Pavlov : 2021-12-26
 64-bit locale=ru_RU.UTF-8 Threads:8

With this patch Ark can use any of them:

ark.cli7z: Loaded cli_7z plugin
ark.cli7z: Setting up parameters...
ark.cli7z: p7zip version "16.02" detected

ark.cli7z: Loaded cli_7z plugin
ark.cli7z: Setting up parameters...
ark.cli7z: p7zip version "21.07" detected

Perhaps, "p7zip" string should be replace with "7-Zip" to avoid confusion.
Comment 2 Albert Astals Cid 2022-01-01 23:55:31 UTC
Please use invent.kde.org for patches.
Comment 3 Bug Janitor Service 2022-01-02 17:03:46 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/ark/-/merge_requests/90
Comment 4 2wxsy58236r3 2022-01-03 02:00:52 UTC
Thanks!

By the way, do we need to modify and run the autotests with upstream 7-Zip as well?

Although upstream 7-Zip is quite similar to p7zip, I noticed that there are still differences, e.g. when you run `7z x archivetest_encrypted.zip` and enter the password, the password will not be echoed in p7zip, but it will be echoed in 7-Zip.
Comment 5 Albert Astals Cid 2022-01-03 21:05:42 UTC
(In reply to 2wxsy58236r3 from comment #4)
> Thanks!
> 
> By the way, do we need to modify and run the autotests with upstream 7-Zip
> as well?
> 
> Although upstream 7-Zip is quite similar to p7zip, I noticed that there are
> still differences, e.g. when you run `7z x archivetest_encrypted.zip` and
> enter the password, the password will not be echoed in p7zip, but it will be
> echoed in 7-Zip.

Having the autotests work would be indeed a good thing
Comment 6 Max 2022-01-04 11:38:47 UTC
Turned out p7zip and 7-Zip are not one to one compatible, there are minor differences. I've updated patches, so that all autotests are now passed with 7-Zip, but 2 out of 17 fail with p7zip. Unfortunately, I know nothing about autotests to dig into fixing these errors, besides I'm not sure if it's worth it considering p7zip status.
Comment 7 Tony 2022-04-28 23:15:07 UTC
(In reply to Max from comment #6)
> Turned out p7zip and 7-Zip are not one to one compatible, there are minor
> differences. I've updated patches, so that all autotests are now passed with
> 7-Zip, but 2 out of 17 fail with p7zip. Unfortunately, I know nothing about
> autotests to dig into fixing these errors, besides I'm not sure if it's
> worth it considering p7zip status.

Right now in opensuse tumbleweed ark is unable to open or compress to 7z.
P7zip has been removed from the main tumbleweed repos for a while already, replaced by 7zip, not having this puling is a big regresion.
Comment 8 Elvis Angelaccio 2022-05-20 18:12:02 UTC
Git commit 5943a22ac4696158b40cee3a3873e88b81d5539b by Elvis Angelaccio, on behalf of David Gow.
Committed on 20/05/2022 at 18:10.
Pushed by elvisangelaccio into branch 'release/22.04'.

Support '7zip' as well as 'p7zip'

7zip 21.0 finally provided an official native port of 7zip, and has superseded
the p7zip port in some distros (openSUSE, for instance, no longer packages
p7zip).  The CLI interface between them is almost identical, but Ark doesn't
recognise the different version string, so doesn't work with 7zip (making it
impossible to open 7z archives in Ark on openSUSE).

Update the 7zip CLI plugin to detect both p7zip and 7zip's version lines.

M  +9    -0    plugins/cli7zplugin/cliplugin.cpp

https://invent.kde.org/utilities/ark/commit/5943a22ac4696158b40cee3a3873e88b81d5539b
Comment 9 Elvis Angelaccio 2022-05-20 18:12:10 UTC
Git commit 35b397c84fdc7c46a98d02aeca13d1cee1facf6e by Elvis Angelaccio, on behalf of Alex Xu (Hello71).
Committed on 20/05/2022 at 18:11.
Pushed by elvisangelaccio into branch 'release/22.04'.

remove -l flag to 7z a

7z a -l flag was added in ace277330b37 "[GSoC] Implement AddTo, Rename,
Copy, Move, Paste Actions and Jobs" without explanation. -l causes p7zip
to follow symlinks when adding files. this is inconsistent with other
ark plugins, unintuitive, and not supported by upstream 7zip. therefore,
remove it.

M  +0    -5    autotests/plugins/cli7zplugin/cli7ztest.cpp
M  +1    -2    plugins/cli7zplugin/cliplugin.cpp

https://invent.kde.org/utilities/ark/commit/35b397c84fdc7c46a98d02aeca13d1cee1facf6e
Comment 10 Elvis Angelaccio 2022-05-21 15:43:34 UTC
Git commit d020d3904000ecde3471461ce6388f0bdd3c58d5 by Elvis Angelaccio, on behalf of Max Brazhnikov.
Committed on 21/05/2022 at 15:42.
Pushed by elvisangelaccio into branch 'release/22.04'.

Cover one more p7zip vs 7-Zip difference

M  +1    -1    plugins/cli7zplugin/cliplugin.cpp

https://invent.kde.org/utilities/ark/commit/d020d3904000ecde3471461ce6388f0bdd3c58d5
Comment 11 Elvis Angelaccio 2022-05-21 15:43:42 UTC
Git commit b5ee900e2caa47e93d8e490500b6859809f4a6bd by Elvis Angelaccio.
Committed on 21/05/2022 at 13:17.
Pushed by elvisangelaccio into branch 'release/22.04'.

cli7z: conditionally add the -l switch

This commit partly reverts commit 35b397c84fdc7c46a98d02aeca13d1cee1facf6e.

The -l switch is actually needed for p7zip, as shown by the failing
addtest/copytest, since `CliInterface::addFiles` creates a symlink and p7zip
doesn't follow symlinks without the -l switch.

Since we need to add the -l switch conditionally, depending on the
actual 7z binary variant available at runtime, we need to actually check
which 7z variant is available before defining the switches for the add
operation.

This fixes all the unit tests with both p7zip and upstream 7-Zip.

M  +5    -1    autotests/plugins/cli7zplugin/cli7ztest.cpp
M  +25   -1    plugins/cli7zplugin/cliplugin.cpp
M  +6    -0    plugins/cli7zplugin/cliplugin.h

https://invent.kde.org/utilities/ark/commit/b5ee900e2caa47e93d8e490500b6859809f4a6bd
Comment 12 Elvis Angelaccio 2022-05-21 16:06:10 UTC
I'll close this bug for now, as I believe we have fixed all the issues on the 22.04 branch and all unit tests pass with both p7zip and upstream 7-zip. Please comment if that's not the case.

I noticed that regarding 7z header-encryption, p7zip and upstream 7-zip doesn't seem compatible with each other, but that's nothing we can fix from the ark side.
Comment 13 Elvis Angelaccio 2022-05-23 21:38:33 UTC
Git commit 1133bb65bd027e1f8597f17b418a1e09a95ae1c3 by Elvis Angelaccio, on behalf of Max Brazhnikov.
Committed on 23/05/2022 at 21:38.
Pushed by elvisangelaccio into branch 'master'.

cli7zplugin: add support for original 7-Zip

Rename p7zip to 7-Zip and make cli7zplugin to work with both p7zip and 7-Zip binaries.

M  +4    -4    plugins/cli7zplugin/CMakeLists.txt
M  +1    -1    plugins/cli7zplugin/cliplugin.cpp
M  +1    -1    plugins/cli7zplugin/kerfuffle_cli7z.json.cmake

https://invent.kde.org/utilities/ark/commit/1133bb65bd027e1f8597f17b418a1e09a95ae1c3