mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-17 12:44:38 +03:00
CLI: Add --archives option
when specify '--archive qtbase qttools' then aqt installs these subset of installation. There is no gurantee it works, and it is an advanced option. Implemented #126 Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
@@ -51,13 +51,15 @@ class QtArchives:
|
||||
|
||||
BASE_URL = 'https://download.qt.io/online/qtsdkrepository/'
|
||||
|
||||
def __init__(self, os_name, target, version, arch, modules=None, mirror=None, logging=None, all_extra=False):
|
||||
def __init__(self, os_name, target, version, arch, subarchives=None,
|
||||
modules=None, mirror=None, logging=None, all_extra=False):
|
||||
self.version = version
|
||||
self.target = target
|
||||
self.arch = arch
|
||||
self.mirror = mirror
|
||||
self.os_name = os_name
|
||||
self.all_extra = all_extra
|
||||
all_archives = (subarchives is None)
|
||||
if mirror is not None:
|
||||
self.has_mirror = True
|
||||
self.base = mirror + '/online/qtsdkrepository/'
|
||||
@@ -78,6 +80,8 @@ class QtArchives:
|
||||
self.mod_list.append("qt.qt5.{}.{}.{}".format(qt_ver_num, m, arch))
|
||||
self.mod_list.append("qt.{}.{}.{}".format(qt_ver_num, m, arch))
|
||||
self._get_archives(qt_ver_num)
|
||||
if not all_archives:
|
||||
self.archives = list(filter(lambda a: a.name in subarchives, self.archives))
|
||||
|
||||
def _get_archives(self, qt_ver_num):
|
||||
# Get packages index
|
||||
@@ -124,8 +128,9 @@ class QtArchives:
|
||||
full_version = packageupdate.find("Version").text
|
||||
package_desc = packageupdate.find("Description").text
|
||||
for archive in downloadable_archives:
|
||||
archive_name = archive.split('-', maxsplit=1)[0]
|
||||
package_url = archive_url + name + "/" + full_version + archive
|
||||
self.archives.append(QtPackage(name, package_url, archive, package_desc,
|
||||
self.archives.append(QtPackage(archive_name, package_url, archive, package_desc,
|
||||
has_mirror=self.has_mirror))
|
||||
if len(self.archives) == 0:
|
||||
self.logger.error("Error while parsing package information!")
|
||||
|
||||
@@ -126,6 +126,7 @@ class Cli():
|
||||
modules = args.modules
|
||||
sevenzip = self._set_sevenzip(args)
|
||||
mirror = args.base
|
||||
archives = args.archives
|
||||
self.show_aqt_version()
|
||||
if output_dir is not None:
|
||||
output_dir = os.path.normpath(output_dir)
|
||||
@@ -141,8 +142,8 @@ class Cli():
|
||||
if not all_extra and not self._check_modules_arg(qt_version, modules):
|
||||
self.logger.warning("Some of specified modules are unknown.")
|
||||
try:
|
||||
qt_archives = QtArchives(os_name, target, qt_version, arch, modules=modules, mirror=mirror,
|
||||
logging=self.logger, all_extra=all_extra)
|
||||
qt_archives = QtArchives(os_name, target, qt_version, arch, subarchives=archives, modules=modules,
|
||||
mirror=mirror, logging=self.logger, all_extra=all_extra)
|
||||
except ArchiveDownloadError or ArchiveListError:
|
||||
exit(1)
|
||||
else:
|
||||
@@ -213,6 +214,8 @@ class Cli():
|
||||
"\n Qt 5.13 or below: android_x86_64, android_arm64_v8a"
|
||||
"\n android_x86, android_armv7")
|
||||
install_parser.add_argument('-m', '--modules', nargs='*', help="Specify extra modules to install")
|
||||
install_parser.add_argument('--archives', nargs='*',
|
||||
help="Specify subset modules to install(Default: all standard modules).")
|
||||
install_parser.add_argument('-O', '--outputdir', nargs='?',
|
||||
help='Target output directory(default current directory)')
|
||||
install_parser.add_argument('-b', '--base', nargs='?',
|
||||
|
||||
@@ -61,8 +61,10 @@ class QtInstaller:
|
||||
def retrieve_archive(self, package: QtPackage):
|
||||
archive = package.archive
|
||||
url = package.url
|
||||
name = package.name
|
||||
start_time = time.perf_counter()
|
||||
self.logger.info("Downloading {}...".format(url))
|
||||
self.logger.info("Downloading {}...".format(name))
|
||||
self.logger.debug("Download URL: {}".format(url))
|
||||
session = requests.Session()
|
||||
retry = Retry(connect=5, backoff_factor=0.5)
|
||||
adapter = HTTPAdapter(max_retries=retry)
|
||||
@@ -72,7 +74,7 @@ class QtInstaller:
|
||||
r = session.get(url, allow_redirects=False, stream=True)
|
||||
if r.status_code == 302:
|
||||
newurl = altlink(r.url, r.headers['Location'], logger=self.logger)
|
||||
self.logger.info('Redirected to new URL: {}'.format(newurl))
|
||||
self.logger.info('Redirected URL: {}'.format(newurl))
|
||||
r = session.get(newurl, stream=True)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
self.logger.error("Connection error: %s" % e.args)
|
||||
|
||||
Reference in New Issue
Block a user