Skip to content

Commit

Permalink
archivers/ark: switch from p7zip to 7-zip
Browse files Browse the repository at this point in the history
Add support for original 7-Zip and use it instead of p7zip.
Full patch has been submitted upstream:

https://invent.kde.org/utilities/ark/-/merge_requests/90

PR:		260866 261368
  • Loading branch information
MaxBrazhnikov committed Feb 9, 2022
1 parent bfe6fa9 commit 160358b
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
11 changes: 10 additions & 1 deletion archivers/ark/Makefile
@@ -1,5 +1,6 @@
PORTNAME= ark
DISTVERSION= ${KDE_APPLICATIONS_VERSION}
PORTREVISION= 1
CATEGORIES= archivers kde kde-applications

MAINTAINER= kde@FreeBSD.org
Expand All @@ -19,6 +20,8 @@ USE_QT= concurrent core dbus gui network widgets xml \

USE_LDCONFIG= yes

PATCH_STRIP= -p1

OPTIONS_DEFINE= 7ZIP RAR ZIP DOCS
OPTIONS_DEFAULT= 7ZIP ZIP DOCS
OPTIONS_DEFAULT_i386= RAR
Expand All @@ -28,7 +31,7 @@ OPTIONS_SUB= YES
# The 7ZIP and RAR options only need runtime dependencies;
# the port builds identically with or without them.
7ZIP_DESC= Support for 7-Zip archives (runtime)
7ZIP_RUN_DEPENDS= 7z:archivers/p7zip
7ZIP_RUN_DEPENDS= 7zz:archivers/7-zip

RAR_DESC= Support for RAR archives (runtime)
RAR_RUN_DEPENDS= unrar:archivers/unrar \
Expand All @@ -41,4 +44,10 @@ ZIP_CMAKE_BOOL_OFF= CMAKE_DISABLE_FIND_PACKAGE_LibZip
# Override shared library version
KDE_APPLICATIONS_SHLIB_VER= ${KDE_APPLICATIONS_VERSION}

post-patch:
${REINPLACE_CMD} '/Program/s,"7z","7zz",' \
${WRKSRC}/plugins/cli7zplugin/cliplugin.cpp
${REINPLACE_CMD} 's,"7z","7zz",' \
${WRKSRC}/plugins/cli7zplugin/kerfuffle_cli7z.json.cmake

.include <bsd.port.mk>
76 changes: 76 additions & 0 deletions archivers/ark/files/patch-7zip
@@ -0,0 +1,76 @@
diff --git a/plugins/cli7zplugin/CMakeLists.txt b/plugins/cli7zplugin/CMakeLists.txt
index 735c833a..3450a504 100644
--- a/plugins/cli7zplugin/CMakeLists.txt
+++ b/plugins/cli7zplugin/CMakeLists.txt
@@ -7,7 +7,7 @@ set(kerfuffle_cli7z_SRCS cliplugin.cpp)
ecm_qt_declare_logging_category(kerfuffle_cli7z_SRCS
HEADER ark_debug.h
IDENTIFIER ARK
- CATEGORY_NAME ark.cli7z DESCRIPTION "Ark p7zip" EXPORT ARK)
+ CATEGORY_NAME ark.cli7z DESCRIPTION "Ark 7-Zip" EXPORT ARK)

# NOTE: the first double-quotes of the first mime and the last
# double-quotes of the last mime must NOT be escaped.
@@ -24,9 +24,9 @@ kerfuffle_add_plugin(kerfuffle_cli7z ${kerfuffle_cli7z_SRCS})
set(SUPPORTED_ARK_MIMETYPES "${SUPPORTED_ARK_MIMETYPES}${SUPPORTED_CLI7Z_MIMETYPES}" PARENT_SCOPE)
set(INSTALLED_KERFUFFLE_PLUGINS "${INSTALLED_KERFUFFLE_PLUGINS}kerfuffle_cli7z;" PARENT_SCOPE)

-find_program(P7ZIP 7z)
-if(P7ZIP)
- message(STATUS "Found p7zip executable: ${P7ZIP}")
+find_program(7ZIP 7z)
+if(7ZIP)
+ message(STATUS "Found 7-Zip executable: ${7ZIP}")
else()
message(WARNING "Could not find the 7z executable. Ark won't be able to handle the 7z archive format.")
endif()
diff --git a/plugins/cli7zplugin/cliplugin.cpp b/plugins/cli7zplugin/cliplugin.cpp
index 1781117a..3450ad22 100644
--- a/plugins/cli7zplugin/cliplugin.cpp
+++ b/plugins/cli7zplugin/cliplugin.cpp
@@ -50,8 +50,7 @@ void CliPlugin::setupCliProperties()
m_cliProps->setProperty("captureProgress", false);

m_cliProps->setProperty("addProgram", QStringLiteral("7z"));
- m_cliProps->setProperty("addSwitch", QStringList{QStringLiteral("a"),
- QStringLiteral("-l")});
+ m_cliProps->setProperty("addSwitch", QStringLiteral("a"));

m_cliProps->setProperty("deleteProgram", QStringLiteral("7z"));
m_cliProps->setProperty("deleteSwitch", QStringLiteral("d"));
@@ -111,7 +110,7 @@ bool CliPlugin::readListLine(const QString& line)
return false;
}

- const QRegularExpression rxVersionLine(QStringLiteral("^p7zip Version ([\\d\\.]+) .*$"));
+ const QRegularExpression rxVersionLine(QStringLiteral("^7-Zip .* ([\\d\\.]+) .*$"));
QRegularExpressionMatch matchVersion;

switch (m_parseState) {
@@ -120,7 +119,7 @@ bool CliPlugin::readListLine(const QString& line)
if (matchVersion.hasMatch()) {
m_parseState = ParseStateHeader;
const QString p7zipVersion = matchVersion.captured(1);
- qCDebug(ARK) << "p7zip version" << p7zipVersion << "detected";
+ qCDebug(ARK) << "7-Zip version" << p7zipVersion << "detected";
}
break;

@@ -294,7 +293,7 @@ bool CliPlugin::readDeleteLine(const QString &line)
{
if (line.startsWith(QLatin1String("Error: ")) &&
line.endsWith(QLatin1String(" is not supported archive"))) {
- Q_EMIT error(i18n("Delete operation failed. Try upgrading p7zip or disabling the p7zip plugin in the configuration dialog."));
+ Q_EMIT error(i18n("Delete operation failed. Try upgrading 7-Zip or disabling the 7-Zip plugin in the configuration dialog."));
return false;
}

@@ -333,7 +332,7 @@ void CliPlugin::handleMethods(const QStringList &methods)

bool CliPlugin::isPasswordPrompt(const QString &line)
{
- return line.startsWith(QLatin1String("Enter password (will not be echoed):"));
+ return line.startsWith(QLatin1String("Enter password"));
}

bool CliPlugin::isWrongPasswordMsg(const QString &line)
2 changes: 1 addition & 1 deletion archivers/ark/pkg-message
Expand Up @@ -3,7 +3,7 @@
message: <<EOM
Support for 7zip and rar archives requires the appropriate executables.
If ark has been packaged without options 7ZIP or RAR, you can install
archivers/p7zip (for 7ZIP) or archivers/unrar and archivers/rar (for RAR)
archivers/7-zip (for 7ZIP) or archivers/unrar and archivers/rar (for RAR)
to allow ark to handle those archives.
EOM
}
Expand Down

0 comments on commit 160358b

Please sign in to comment.