Commit bf2de67e authored by Ragnar Thomsen's avatar Ragnar Thomsen

Add support for AppImage

AppImages are both executables and ISO images and can be handled by
libarchive. Support for opening AppImages was enabled in the
libarchiveplugin. The mimetype for AppImage has been committed to
shared-mime-info, but has not yet been released. We therefore install a
custom mimetype for AppImage.

Test cases for this mimetype were added to MimeTypeTest and ArchiveTest.

FEATURE: 363209
FIXED-IN: 16.08.0
Differential Revision: D2226
parent 21481cb4
...@@ -171,6 +171,12 @@ void ArchiveTest::testProperties_data() ...@@ -171,6 +171,12 @@ void ArchiveTest::testProperties_data()
<< QStringLiteral("test") << QStringLiteral("test")
<< false << true << false << Archive::Unencrypted << false << true << false << Archive::Unencrypted
<< QStringLiteral("test"); << QStringLiteral("test");
QTest::newRow("AppImage")
<< QFINDTESTDATA("data/hello-2.8-x86_64.AppImage")
<< QStringLiteral("hello-2.8-x86_64")
<< true << false << false << Archive::Unencrypted
<< QStringLiteral("hello-2.8-x86_64");
} }
void ArchiveTest::testProperties() void ArchiveTest::testProperties()
...@@ -510,6 +516,13 @@ void ArchiveTest::testExtraction_data() ...@@ -510,6 +516,13 @@ void ArchiveTest::testExtraction_data()
<< QVariantList() << QVariantList()
<< optionsPreservePaths << optionsPreservePaths
<< 6; << 6;
archivePath = QFINDTESTDATA("data/hello-2.8-x86_64.AppImage");
QTest::newRow("extract all entries from an AppImage with path")
<< archivePath
<< QVariantList()
<< optionsPreservePaths
<< 7;
} }
void ArchiveTest::testExtraction() void ArchiveTest::testExtraction()
...@@ -539,7 +552,7 @@ void ArchiveTest::testExtraction() ...@@ -539,7 +552,7 @@ void ArchiveTest::testExtraction()
QFETCH(int, expectedExtractedEntriesCount); QFETCH(int, expectedExtractedEntriesCount);
int extractedEntriesCount = 0; int extractedEntriesCount = 0;
QDirIterator dirIt(destDir.path(), QDir::AllEntries | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); QDirIterator dirIt(destDir.path(), QDir::AllEntries | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
while (dirIt.hasNext()) { while (dirIt.hasNext()) {
extractedEntriesCount++; extractedEntriesCount++;
dirIt.next(); dirIt.next();
......
...@@ -60,6 +60,7 @@ void MimeTypeTest::testMimeTypeDetection_data() ...@@ -60,6 +60,7 @@ void MimeTypeTest::testMimeTypeDetection_data()
const QString isoMimeType = QStringLiteral("application/x-cd-image"); const QString isoMimeType = QStringLiteral("application/x-cd-image");
const QString debMimeType = QMimeDatabase().mimeTypeForFile(QStringLiteral("dummy.deb"), QMimeDatabase::MatchExtension).name(); const QString debMimeType = QMimeDatabase().mimeTypeForFile(QStringLiteral("dummy.deb"), QMimeDatabase::MatchExtension).name();
const QString xarMimeType = QStringLiteral("application/x-xar"); const QString xarMimeType = QStringLiteral("application/x-xar");
const QString appImageMimeType = QStringLiteral("application/x-iso9660-appimage");
QTest::newRow("empty name") << QString() << QStringLiteral("application/octet-stream"); QTest::newRow("empty name") << QString() << QStringLiteral("application/octet-stream");
QTest::newRow("tar.gz") << QFINDTESTDATA("data/simplearchive.tar.gz") << compressedGzipTarMime; QTest::newRow("tar.gz") << QFINDTESTDATA("data/simplearchive.tar.gz") << compressedGzipTarMime;
...@@ -73,6 +74,7 @@ void MimeTypeTest::testMimeTypeDetection_data() ...@@ -73,6 +74,7 @@ void MimeTypeTest::testMimeTypeDetection_data()
QTest::newRow("tar.lz4") << QFINDTESTDATA("data/simplearchive.tar.lz4") << compressedLz4TarMime; QTest::newRow("tar.lz4") << QFINDTESTDATA("data/simplearchive.tar.lz4") << compressedLz4TarMime;
QTest::newRow("deb") << QFINDTESTDATA("data/smallarchive.deb") << debMimeType; QTest::newRow("deb") << QFINDTESTDATA("data/smallarchive.deb") << debMimeType;
QTest::newRow("xar") << QFINDTESTDATA("data/simplearchive.xar") << xarMimeType; QTest::newRow("xar") << QFINDTESTDATA("data/simplearchive.xar") << xarMimeType;
QTest::newRow("AppImage") << QFINDTESTDATA("data/hello-2.8-x86_64.AppImage") << appImageMimeType;
QTest::newRow("zip with wrong extension") << QFINDTESTDATA("data/zip_with_wrong_extension.rar") << QStringLiteral("application/zip"); QTest::newRow("zip with wrong extension") << QFINDTESTDATA("data/zip_with_wrong_extension.rar") << QStringLiteral("application/zip");
QTest::newRow("tar with special char in the extension") << QStringLiteral("foo.tar~1.gz") << compressedGzipTarMime; QTest::newRow("tar with special char in the extension") << QStringLiteral("foo.tar~1.gz") << compressedGzipTarMime;
......
...@@ -18,4 +18,21 @@ ...@@ -18,4 +18,21 @@
<comment xml:lang="en">Tar archive (LZ4-compressed)</comment> <comment xml:lang="en">Tar archive (LZ4-compressed)</comment>
<glob pattern="*.tar.lz4"/> <glob pattern="*.tar.lz4"/>
</mime-type> </mime-type>
<mime-type type="application/x-iso9660-appimage">
<comment>AppImage application bundle</comment>
<sub-class-of type="application/x-executable"/>
<sub-class-of type="application/x-iso9660-image"/>
<generic-icon name="application-x-executable"/>
<magic priority="50">
<match value="ELF" type="string" offset="1" >
<match value="0x41" type="byte" offset="8">
<match value="0x49" type="byte" offset="9">
<match value="0x01" type="byte" offset="10"/>
</match>
</match>
</match>
</magic>
<glob pattern="*.AppImage"/>
</mime-type>
</mime-info> </mime-info>
...@@ -4,7 +4,7 @@ include_directories(${LibArchive_INCLUDE_DIRS}) ...@@ -4,7 +4,7 @@ include_directories(${LibArchive_INCLUDE_DIRS})
set(SUPPORTED_LIBARCHIVE_READWRITE_MIMETYPES "application/x-tar;application/x-compressed-tar;application/x-bzip-compressed-tar;application/x-tarz;application/x-xz-compressed-tar;") set(SUPPORTED_LIBARCHIVE_READWRITE_MIMETYPES "application/x-tar;application/x-compressed-tar;application/x-bzip-compressed-tar;application/x-tarz;application/x-xz-compressed-tar;")
set(SUPPORTED_LIBARCHIVE_READWRITE_MIMETYPES "${SUPPORTED_LIBARCHIVE_READWRITE_MIMETYPES}application/x-lzma-compressed-tar;application/x-lzip-compressed-tar;application/x-tzo;application/x-lrzip-compressed-tar;") set(SUPPORTED_LIBARCHIVE_READWRITE_MIMETYPES "${SUPPORTED_LIBARCHIVE_READWRITE_MIMETYPES}application/x-lzma-compressed-tar;application/x-lzip-compressed-tar;application/x-tzo;application/x-lrzip-compressed-tar;")
set(SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES "application/vnd.debian.binary-package;application/x-deb;application/x-cd-image;application/x-bcpio;application/x-cpio;application/x-cpio-compressed;application/x-sv4cpio;application/x-sv4crc;") set(SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES "application/vnd.debian.binary-package;application/x-deb;application/x-cd-image;application/x-bcpio;application/x-cpio;application/x-cpio-compressed;application/x-sv4cpio;application/x-sv4crc;")
set(SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES "${SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES}application/x-rpm;application/x-source-rpm;application/vnd.ms-cab-compressed;application/x-xar;") set(SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES "${SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES}application/x-rpm;application/x-source-rpm;application/vnd.ms-cab-compressed;application/x-xar;application/x-iso9660-appimage;")
if(LibArchive_VERSION VERSION_EQUAL "3.2.0" OR if(LibArchive_VERSION VERSION_EQUAL "3.2.0" OR
LibArchive_VERSION VERSION_GREATER "3.2.0") LibArchive_VERSION VERSION_GREATER "3.2.0")
...@@ -36,7 +36,8 @@ set(SUPPORTED_READONLY_MIMETYPES ...@@ -36,7 +36,8 @@ set(SUPPORTED_READONLY_MIMETYPES
\"application/x-source-rpm\", \"application/x-source-rpm\",
\"application/vnd.debian.binary-package\", \"application/vnd.debian.binary-package\",
\"application/vnd.ms-cab-compressed\", \"application/vnd.ms-cab-compressed\",
\"application/x-xar") \"application/x-xar\",
\"application/x-iso9660-appimage")
# NOTE: the first double-quotes of the first mime and the last # NOTE: the first double-quotes of the first mime and the last
# double-quotes of the last mime must NOT be escaped. # double-quotes of the last mime must NOT be escaped.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment