summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/libarchivearchive.cpp
Commit message (Collapse)AuthorAgeFilesLines
* ExtractOp: fix leftover empty directories when 'targetDir' arg is usedArttu Tarkiainen2022-10-311-2/+2
| | | | | | | | | | | | | | | | | | | | The problem was that the directory passed for the DirectoryGuard object handling the creation of leading directories was missing the target directory itself, instead the path ended to its parent directory. When installer does the undo-step for Extract operation, only empty directories are deleted, so in case any directory from a path is missing from the created directory list, the leading directories won't be also deleted. QFileInfo::absolutePath() returns the path of the parent directory for the given path even if it is a directory, fix by using instead the QFileInfo::absoluteFilePath(), which includes the name after the last directory separator. Task-number: QTIFW-2764 Change-Id: I5b03142b46db566615f4983fa3e2ff2690f25262 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Translations: fix duplicate source stringArttu Tarkiainen2022-06-031-1/+1
| | | | | Change-Id: I73e07ac8d4099df0c0a3bade4bc40cb1467fbbe2 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Fix "Can't unlink already-existing object" errors on extractArttu Tarkiainen2022-05-041-4/+10
| | | | | | | | | | | | | | | | | | | | | | On Windows, extracting archives containing same files and directories would sometimes cause "Can't unlink already-existing object: Permission denied" error when replacing existing files. This was caused by releasing the FileGuard lock object for the archive entry without ensuring the entry was closed. Normally libarchive clients do not need to care about this, as the entry is closed automatically by archive_write_header() and archive_write_close() as required, but in our case there is a need access synchronization because archives can extract entries with the same entry paths in parallel. Fix by calling archive_write_finish_entry() before releasing the lock, so that no file handles are left open and no file attribute changes are left pending for the implicit closing on writing the next entry header. Task-number: QTIFW-2620 Change-Id: I7e7322927964296c3b32ef4a052a91f1ba29aac3 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* libarchive: add more descriptive error messagesArttu Tarkiainen2022-04-281-36/+70
| | | | | | | | Some of the error paths, especially when packaging archives, gave too vague information about what went wrong. Change-Id: I04388a6d333533fb370a472fa82d9562b17df37e Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Add support for parallel extraction of component archivesArttu Tarkiainen2022-04-211-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce ConcurrentOperationRunner class used for running installer operations concurrently in the global thread pool. Add execution groups for operations; Unpack operations are run concurrently for all components requesting installation, operations belonging to Install group are run sequentially for sorted components one at a time as before. From the default registered operations the Extract op is moved to Unpack group. Move the previously on-the-fly backup steps of Extract operation to the ExtractArchiveOperation::backup(), so that backups are done before any archives are extracted, and that we know if any of the archives requires administrator privileges to unpack. Reparent QInstaller::Error to QException to support throwing and catching exceptions across thread boundaries. Use RAII for the server-side objects of the classes supporting the remote client-server protocol of installer framework. The concurrent extraction revealed that it was still possible that the local socket was disconnected and thus the RemoteServer- Connection thread finished before receiving and processing the final "Destroy" command packet, leaking the dynamically allocated objects. Task-number: QTIFW-2566 Change-Id: Ib8c2928b9405b7b3465c731018df73acb51e949f Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Add locale include, needed for VS2019 buildKatja Marttila2022-03-081-0/+4
| | | | | Change-Id: I29827c4197249b289641693b691a8a5d72277458 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
* Fix extracting entries with file paths that contain unicode charactersArttu Tarkiainen2022-02-171-32/+236
| | | | | | | | | | | | Libarchive stores most paths internally in a multistring that can contain a combination of a wide character string, multibyte string in current locale or unicode string encoded as UTF-8. Try to retrieve and set a variant of the string with the correct encoding when converting libarchive strings to/from Qt string classes. Task-number: QTIFW-2506 Change-Id: I7e7c1e3c5709b669df68b2f3918789ad4ebe4f13 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Libarchive: include errno code description in error stringsArttu Tarkiainen2022-02-021-20/+36
| | | | | | | | | Sometimes the textual error message returned by archive_error_string() does not reveal enough useful information, add also the error code from archive_errno(). Change-Id: Icc62168bc862484bfa1efc70dd8ca2e341b3394f Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Gain admin rights when user is missing privilege to create symlinksArttu Tarkiainen2022-01-311-1/+6
| | | | | | | | | | | | | | | On Windows, the non-admin users cannot create symbolic links by default. Extracting archives containing symlinks would fail if the installer was no started as administrator. Catch the case and auto-elevate installer to extract such archives. Do not elevate installer if the current user has the privilege for symlink creation, or if the Developer mode is enabled, allowing unprivileged creation of symlinks. Task-number: QTIFW-2428 Change-Id: I0b6b1079daabb9727055dce8a9475c203d7e92b0 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* ArchiveFactory: register handlers for .qbsp file extensionArttu Tarkiainen2022-01-111-1/+7
| | | | | | | | | | | QBSP archives were missing a handler which caused UnzipArchiveTask to fail when fetching metadata. Also fix the resulted segfault in UnzipArchiveTask::doTask() when ArchiveFactory::create() returns nullptr for unknown file extension - it now handles the exception properly. Task-number: QTIFW-2475 Change-Id: I72624763a06d6e7495daebd69970a5f22a4fd6d3 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Libarchive: enable support for uncompressed tar archivesArttu Tarkiainen2021-12-091-8/+5
| | | | | | | Task-number: QTIFW-2404 Change-Id: I4c62d283d54a1f180f9c3525da0728a1c75ef50e Reviewed-by: Iikka Eklund <iikka.eklund@qt.io> Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Enable handling 7z archives with libarchiveArttu Tarkiainen2021-12-091-0/+3
| | | | | | | | | | | | | | Make libarchive the default handler for 7z archives if the IFW tools were built with the 'libarchive' configuration feature. The LZMA SDK library is still built and can be used instead if the config feature is omitted. Also modify tests. Task-number: QTIFW-2375 Change-Id: I1091d5fa140cbd783cddecc595f35c6562639b07 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Libarchive: fix handling of glob pattern arguments when creating archiveArttu Tarkiainen2021-12-031-1/+21
| | | | | | | | | Arguments with wildcards were not working if archivegen was called from somewhere else than shell, like from within a Python script. Task-number: QTIFW-2423 Change-Id: Icf6d6c3c45ad9050a03c1a3dd7c4d9f10d1f3be6 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Libarchive: Fix extracting hard links pointing to files in archiveArttu Tarkiainen2021-11-031-0/+12
| | | | | | | | | | | Since we already adjust the output path for archive entries, libarchive would fail with the error string "Hard-link target '...' does not exist" for hard links referring to extracted files. Fix by also adjusting the hard link target paths. Task-number: QTIFW-2403 Change-Id: I8f78117c5b0707a70c76433ca1c1483ea49b432b Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Fix creating archives containing Windows shortcutsArttu Tarkiainen2021-10-291-1/+1
| | | | | | | | | | | | | On Windows, QFileInfo::isSymLink() returns true for *.lnk files, which unlike symlinks contain data - when creating an archive the writing was incorrectly skipped. Also add test case for creating and extracting archives containing either symlinks or shortcuts. Change-Id: I3ebbd28e889ffa17ece7378c3812244a55df20d5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Fix symlink handling when packaging Zip archivesArttu Tarkiainen2021-10-271-1/+1
| | | | | | | | | | | | archive_write_header() will write the complete symlink to the archive, the client application should not try to write any data for symlinks or if archive_entry_size() is zero. The tar.* archives were not affected by this. Task-number: QTIFW-2382 Change-Id: I6a5e62ef4c7e650ad806f183556e39ac8ae8cdc3 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Add support for seeking files handled with libarchiveArttu Tarkiainen2021-10-261-5/+111
| | | | | | | | | | | | | | | | | | | This fixes losing executable bits of files in Zip archives when extracted. Zip archives store file metadata in two ways, partial metadata per-entry and full metadata at the end of archive. IFW's read implementation previously did only streaming without support for seeking archives, which is required to obtain full metadata - meaning the partial metadata was used instead by libarchive's Zip reader. The extracted entries between the two metadata types are not consistent. This change also enables usage of archive formats that cannot be accurately handled with a streaming model, like 7zip which needs to read key data from the end of the file before reading file data from the beginning. Task-number: QTIFW-2372 Change-Id: Ie4ed33040fc52de073546e46d9da726816f47a81 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
* Add support for handling archive files with libarchiveArttu Tarkiainen2021-09-141-0/+819
libarchive is a multi-format archive and compression library written in C and licensed under the new BSD license. Usage of libarchive brings in support for additional archive formats (in addition to 7z) with the installer framework, like zip and tar, with several available compression methods like gzip, bzip2 and xz. libarchive will coexist as a supported archive format handler with the LZMA SDK currently used in the framework, which will continue to be used for handling the 7-Zip file format. This change introduces classes for handling archive operations using both libraries, removes most calls to the old Lib7z facade and migrates the code base to use the new handling methods. Task-number: QTIFW-2255 Change-Id: I8d77110ded503060495a3d6fdfdbc26281df9453 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Katja Marttila <katja.marttila@qt.io>