Skip to content

Commit

Permalink
Merge pull request #841 from tsteven4/operations
Browse files Browse the repository at this point in the history
Handle Updates.xml Operation extract elements. Fix the issue #840
  • Loading branch information
miurahr authored Dec 1, 2024
2 parents 0392095 + 1b2a9b2 commit 4625000
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test-install-qt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
py: "3.12"
qtver: 6.8.0
artifact: standard
- os: ubuntu-latest
py: "3.12"
# 6.8.1 introduces Operations elements in Updates.xml
qtver: 6.8.1
artifact: standard
steps:
- uses: actions/checkout@v4
with:
Expand Down
28 changes: 25 additions & 3 deletions aqt/archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import posixpath
from dataclasses import dataclass, field
from itertools import islice, zip_longest
from logging import getLogger
from typing import Dict, Iterable, List, Optional, Set, Tuple
from xml.etree.ElementTree import Element # noqa
Expand All @@ -46,6 +47,7 @@ class QtPackage:
base_url: str
archive_path: str
archive: str
archive_install_path: str
package_desc: str
pkg_update_name: str
version: Optional[Version] = field(default=None)
Expand Down Expand Up @@ -128,12 +130,13 @@ class PackageUpdate:
dependencies: Iterable[str]
auto_dependon: Iterable[str]
downloadable_archives: Iterable[str]
archive_install_paths: Iterable[str]
default: bool
virtual: bool
base: str

def __post_init__(self):
for iter_of_str in self.dependencies, self.auto_dependon, self.downloadable_archives:
for iter_of_str in self.dependencies, self.auto_dependon, self.downloadable_archives, self.archive_install_paths:
assert isinstance(iter_of_str, Iterable) and not isinstance(iter_of_str, str)
for _str in self.name, self.display_name, self.description, self.release_date, self.full_version, self.base:
assert isinstance(_str, str)
Expand Down Expand Up @@ -177,6 +180,7 @@ def fromstring(base, update_xml_text: str):
except ElementTree.ParseError as perror:
raise ArchiveListError(f"Downloaded metadata is corrupted. {perror}") from perror
updates = Updates()
extract_xpath = "Operations/Operation[@name='Extract']/Argument"
for packageupdate in update_xml.iter("PackageUpdate"):
pkg_name = updates._get_text(packageupdate.find("Name"))
display_name = updates._get_text(packageupdate.find("DisplayName"))
Expand All @@ -186,8 +190,20 @@ def fromstring(base, update_xml_text: str):
dependencies = updates._get_list(packageupdate.find("Dependencies"))
auto_dependon = updates._get_list(packageupdate.find("AutoDependOn"))
archives = updates._get_list(packageupdate.find("DownloadableArchives"))
archive_install_paths = updates._get_list(None)
default = updates._get_boolean(packageupdate.find("Default"))
virtual = updates._get_boolean(packageupdate.find("Virtual"))
if packageupdate.find(extract_xpath) is not None:
arc_args = map(
lambda x: x.text,
islice(packageupdate.iterfind(extract_xpath), 1, None, 2),
)
archives = ssplit(", ".join(arc_args))
path_args = map(
lambda x: x.text.replace("@TargetDir@/", "", 1),
islice(packageupdate.iterfind(extract_xpath), 0, None, 2),
)
archive_install_paths = ssplit(", ".join(path_args))
updates.package_updates.append(
PackageUpdate(
pkg_name,
Expand All @@ -198,6 +214,7 @@ def fromstring(base, update_xml_text: str):
dependencies,
auto_dependon,
archives,
archive_install_paths,
default,
virtual,
base,
Expand Down Expand Up @@ -429,7 +446,9 @@ def _parse_update_xml(self, os_target_folder, update_xml_text, target_packages:
target_packages.remove_module_for_package(packageupdate.name)
should_filter_archives: bool = bool(self.subarchives) and self.should_filter_archives(packageupdate.name)

for archive in packageupdate.downloadable_archives:
for archive, archive_install_path in zip_longest(
packageupdate.downloadable_archives, packageupdate.archive_install_paths, fillvalue=""
):
archive_name = archive.split("-", maxsplit=1)[0]
if should_filter_archives and self.subarchives is not None and archive_name not in self.subarchives:
continue
Expand All @@ -447,6 +466,7 @@ def _parse_update_xml(self, os_target_folder, update_xml_text, target_packages:
base_url=base_url,
archive_path=archive_path,
archive=archive,
archive_install_path=archive_install_path,
package_desc=packageupdate.description,
pkg_update_name=packageupdate.name, # For testing purposes
)
Expand All @@ -468,10 +488,11 @@ def _append_tool_update(self, os_target_folder, update_xml, target, tool_version
raise NoPackageFound(message, suggested_action=self.help_msg())
package_desc = packageupdate.description
downloadable_archives = packageupdate.downloadable_archives
archive_install_paths = packageupdate.archive_install_paths
if not downloadable_archives:
message = f"The package '{self.arch}' contains no downloadable archives!"
raise NoPackageFound(message)
for archive in downloadable_archives:
for archive, archive_install_path in zip_longest(downloadable_archives, archive_install_paths, fillvalue=""):
archive_path = posixpath.join(
# online/qtsdkrepository/linux_x64/desktop/tools_ifw/
os_target_folder,
Expand All @@ -486,6 +507,7 @@ def _append_tool_update(self, os_target_folder, update_xml, target, tool_version
base_url=self.base,
archive_path=archive_path,
archive=archive,
archive_install_path=archive_install_path,
package_desc=package_desc,
pkg_update_name=name, # Redundant
)
Expand Down
1 change: 1 addition & 0 deletions aqt/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ def installer(
name = qt_package.name
base_url = qt_package.base_url
archive: Path = archive_dest / qt_package.archive
base_dir = posixpath.join(base_dir, qt_package.archive_install_path)
start_time = time.perf_counter()
Settings.load_settings(file=settings_ini)
# setup queue logger
Expand Down
1 change: 1 addition & 0 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,7 @@ def mock_extractor_that_fails(*args, **kwargs):
"base_url",
"archive_path",
"archive",
"archive_install_path",
"package_desc",
"pkg_update_name",
),
Expand Down

0 comments on commit 4625000

Please sign in to comment.