Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command-7z: Add new 7-zip(7zz and 7zzs) project support #472

Merged
merged 1 commit into from
Apr 23, 2023

Conversation

zhuyaliang
Copy link
Member

@zhuyaliang zhuyaliang commented Mar 20, 2023

Add new 7Z (7zz and 7zzs) support
gnome-file-roller
#455
#450
#433

The latest version of 7zz/7zzs supports RAR by default, and there is no need to determine whether it supports RAR

gboolean available_7zip = is_program_available ("7zz", check_command) || is_program_available ("7zzs", check_command);
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)
     || 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))
    capabilities |= FR_COMMAND_CAN_READ;
}

@raveit65
Copy link
Member

Hmm, is 7zz supported by common linux distros. I see only pzip in fedora 38 (just released).

[root@mother ~]# dnf search 7z
Last metadata expiration check: 1:05:30 ago on Fri Apr 14 17:47:41 2023.
========================================= Name & Summary Matched: 7z =========================================
p7zip-gui.x86_64 : 7zG - 7-Zip GUI version
p7zip-plugins.x86_64 : Additional plugins for p7zip
============================================== Name Matched: 7z ==============================================
p7zip.x86_64 : Very high compression ratio file archiver
p7zip-doc.noarch : Manual documentation and contrib directory
============================================ Summary Matched: 7z =============================================
golang-github-kjk-lzmadec.x86_64 : Decompress .7z files in Go using 7z executable
golang-github-kjk-lzmadec-devel.noarch : Decompress .7z files in Go using 7z executable

@zhuyaliang
Copy link
Member Author

zhuyaliang commented Apr 16, 2023

@raveit65 Manual download and installation required 7zz

@raveit65
Copy link
Member

Ok, but can we open rar files with engrampa and p7zip after this change?
Downloading and installing a sub-program by hand seems not comfortable.

@zhuyaliang
Copy link
Member Author

@raveit65

Ok, but can we open rar files with engrampa and p7zip after this change?

Can decompress rar normally

[mate@mouse eom]$ 7zzs l -- /tmp/share.rar

7-Zip (z) 22.01 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-07-15
 64-bit locale=zh_CN.UTF-8 Threads:2, ASM

Scanning the drive for archives:
1 file, 10983 bytes (11 KiB)

Listing archive: /tmp/share.rar

--
Path = /tmp/share.rar
Type = Rar5
Physical Size = 10983
Solid = -
Blocks = 4
Encrypted = -
Multivolume = -
Volumes = 1

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2021-03-13 18:06:56 ....A         8274         2619  user-window.c
2021-03-13 18:06:56 ....A         2307          927  user-window.h
2022-11-29 19:57:13 ....A         1148          522  update_auto_login_layout.patch
2021-03-17 00:11:51 ....A        34447         6590  user-group-window.c
------------------- ----- ------------ ------------  ------------------------
2022-11-29 19:57:13              46176        10658  4 files

Downloading and installing a sub-program by hand seems not comfortable.

There are currently no available installation packages available, but some users have chosen to manually install them, so we should add support

@lukefromdc
Copy link
Member

lukefromdc commented Apr 21, 2023 via email

Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this PR installed and Debian's 7-zip package installed, I can create a .7z but not a .tar.7z archive, the latter regardless of attempting to compress one file or a batch. Compressing to a .7z archive works fine with a batch of files. If this is the intended behavior tar.7z should be removed from the list of options shown in caja-engrampa's "compress" menu

@raveit65
Copy link
Member

raveit65 commented Apr 21, 2023

I can open .7z archive but i can't create a archive. No idea what's wrong here.

@raveit65
Copy link
Member

raveit65 commented Apr 21, 2023

@zhuyaliang
My friend adding some comments to code like in file-roler would really help to understand the PR.
https://gitlab.gnome.org/GNOME/file-roller/-/commit/b798bbd96d3777c20026f1dc2d3e15ecb5bc853d#0687cc92286b7cb5f44c7697bdbe5d00dcad598c_180_180

fr_command_7z_begin_command (FrCommand *comm)
{
	if (_g_program_is_in_path ("7z"))
	// Modern 7-Zip by the original author.
	// Statically linked from a binary distribution, almost guaranteed to work.
	if (_g_program_is_in_path ("7zzs"))
		fr_process_begin_command (comm->process, "7zzs");
	// Dynamically linked from either binary or source distribution.
	else if (_g_program_is_in_path ("7zz"))
		fr_process_begin_command (comm->process, "7zz");
	// Legacy p7zip project.
	else if (_g_program_is_in_path ("7z"))
		fr_process_begin_command (comm->process, "7z");
	else if (_g_program_is_in_path ("7za"))
		fr_process_begin_command (comm->process, "7za");

after reading file-roller commit it was clear that
a) the commit support both programs (p7zip and 7zz)
b) p7zip is unmaintained and 7zz is the replacement
c) distros like fedora/redhat family can use p7zip

I would be helpful to add more comments to PR like in file-roller.
Well, i tested your Commit with p7zip and everything works well (extracting rar, creating .7z and tar.7z archives).
So from my (fedora maintainer) point of view the commit works and i will approve it.

Copy link
Member

@raveit65 raveit65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhuyaliang
Copy link
Member Author

@lukefromdc Code update, please test again

Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the latest changes compressing to .7z produces an archive containing the files chosen, compressing to tar.7z produced a .tar file compressed with 7zip, which I am assuming to be the intended behavior and is certainly functional. Looks good to go

@lukefromdc lukefromdc merged commit 6f49d2c into master Apr 23, 2023
@lukefromdc lukefromdc deleted the 7zz-support branch April 23, 2023 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants