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:
Hiroshi Miura
2020-05-19 10:23:43 +09:00
parent ea6407f232
commit fcb5b45631
3 changed files with 16 additions and 6 deletions

View File

@@ -51,13 +51,15 @@ class QtArchives:
BASE_URL = 'https://download.qt.io/online/qtsdkrepository/' 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.version = version
self.target = target self.target = target
self.arch = arch self.arch = arch
self.mirror = mirror self.mirror = mirror
self.os_name = os_name self.os_name = os_name
self.all_extra = all_extra self.all_extra = all_extra
all_archives = (subarchives is None)
if mirror is not None: if mirror is not None:
self.has_mirror = True self.has_mirror = True
self.base = mirror + '/online/qtsdkrepository/' 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.qt5.{}.{}.{}".format(qt_ver_num, m, arch))
self.mod_list.append("qt.{}.{}.{}".format(qt_ver_num, m, arch)) self.mod_list.append("qt.{}.{}.{}".format(qt_ver_num, m, arch))
self._get_archives(qt_ver_num) 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): def _get_archives(self, qt_ver_num):
# Get packages index # Get packages index
@@ -124,8 +128,9 @@ class QtArchives:
full_version = packageupdate.find("Version").text full_version = packageupdate.find("Version").text
package_desc = packageupdate.find("Description").text package_desc = packageupdate.find("Description").text
for archive in downloadable_archives: for archive in downloadable_archives:
archive_name = archive.split('-', maxsplit=1)[0]
package_url = archive_url + name + "/" + full_version + archive 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)) has_mirror=self.has_mirror))
if len(self.archives) == 0: if len(self.archives) == 0:
self.logger.error("Error while parsing package information!") self.logger.error("Error while parsing package information!")

View File

@@ -126,6 +126,7 @@ class Cli():
modules = args.modules modules = args.modules
sevenzip = self._set_sevenzip(args) sevenzip = self._set_sevenzip(args)
mirror = args.base mirror = args.base
archives = args.archives
self.show_aqt_version() self.show_aqt_version()
if output_dir is not None: if output_dir is not None:
output_dir = os.path.normpath(output_dir) 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): if not all_extra and not self._check_modules_arg(qt_version, modules):
self.logger.warning("Some of specified modules are unknown.") self.logger.warning("Some of specified modules are unknown.")
try: try:
qt_archives = QtArchives(os_name, target, qt_version, arch, modules=modules, mirror=mirror, qt_archives = QtArchives(os_name, target, qt_version, arch, subarchives=archives, modules=modules,
logging=self.logger, all_extra=all_extra) mirror=mirror, logging=self.logger, all_extra=all_extra)
except ArchiveDownloadError or ArchiveListError: except ArchiveDownloadError or ArchiveListError:
exit(1) exit(1)
else: else:
@@ -213,6 +214,8 @@ class Cli():
"\n Qt 5.13 or below: android_x86_64, android_arm64_v8a" "\n Qt 5.13 or below: android_x86_64, android_arm64_v8a"
"\n android_x86, android_armv7") "\n android_x86, android_armv7")
install_parser.add_argument('-m', '--modules', nargs='*', help="Specify extra modules to install") 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='?', install_parser.add_argument('-O', '--outputdir', nargs='?',
help='Target output directory(default current directory)') help='Target output directory(default current directory)')
install_parser.add_argument('-b', '--base', nargs='?', install_parser.add_argument('-b', '--base', nargs='?',

View File

@@ -61,8 +61,10 @@ class QtInstaller:
def retrieve_archive(self, package: QtPackage): def retrieve_archive(self, package: QtPackage):
archive = package.archive archive = package.archive
url = package.url url = package.url
name = package.name
start_time = time.perf_counter() 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() session = requests.Session()
retry = Retry(connect=5, backoff_factor=0.5) retry = Retry(connect=5, backoff_factor=0.5)
adapter = HTTPAdapter(max_retries=retry) adapter = HTTPAdapter(max_retries=retry)
@@ -72,7 +74,7 @@ class QtInstaller:
r = session.get(url, allow_redirects=False, stream=True) r = session.get(url, allow_redirects=False, stream=True)
if r.status_code == 302: if r.status_code == 302:
newurl = altlink(r.url, r.headers['Location'], logger=self.logger) 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) r = session.get(newurl, stream=True)
except requests.exceptions.ConnectionError as e: except requests.exceptions.ConnectionError as e:
self.logger.error("Connection error: %s" % e.args) self.logger.error("Connection error: %s" % e.args)