1
0

Gestite multiple versioni. Ora anche prerelease e daily sono supportati.

This commit is contained in:
Emiliano Vavassori 2022-04-30 23:31:06 +02:00
parent 15369c0895
commit d0f73d0f16
3 changed files with 81 additions and 79 deletions

View File

@ -110,9 +110,9 @@ class Base(object):
# version. # version.
# If the version has only 2 points in it (or splits into three parts by '.'), that's not a full version and we will call the getlatestver() function # If the version has only 2 points in it (or splits into three parts by '.'), that's not a full version and we will call the getlatestver() function
fullversion = version fullversion = str(version)
if len(version.split('.')) <= 3: if len(fullversion.split('.')) <= 3:
fullversion = Base.fullversion(version) fullversion = str(Base.fullversion(version))
# So the final URL is the Archive one, plus the full versions, plus a # So the final URL is the Archive one, plus the full versions, plus a
# final '/deb/' - and an arch subfolder # final '/deb/' - and an arch subfolder
@ -120,7 +120,7 @@ class Base(object):
retval = {} retval = {}
# x86 binaries are not anymore offered after 6.3.0. # x86 binaries are not anymore offered after 6.3.0.
if parse_version(version) < parse_version('6.3.0'): if parse_version(fullversion) < parse_version('6.3.0'):
retval['x86'] = baseurl + 'x86/' retval['x86'] = baseurl + 'x86/'
else: else:
retval['x86'] = '-' retval['x86'] = '-'
@ -131,15 +131,20 @@ class Base(object):
@staticmethod @staticmethod
def collectedbuilds(query): def collectedbuilds(query):
"""Creates a list of Builds based on each namedver found.""" """Creates a list of Builds based on each queried version found."""
retval = [] retval = []
if '.' in query:
# Called with a numeric query. Pass it to RemoteBuild
retval.append(RemoteBuild(query))
else:
# Named query
a = Base.namedver(query) a = Base.namedver(query)
if isinstance(a, list) and len(a) > 1: if isinstance(a, list) and len(a) > 1:
retval = [ Build(query, version) for version in Base.namedver(query) ] retval.extend([ RemoteBuild(query, version) for version in a ])
else: else:
retval.append(RemoteBuild(query)) retval.append(RemoteBuild(query))
return retval return sorted(retval, key=lambda x: x.version)
class RemoteBuild(object): class RemoteBuild(object):
@ -150,32 +155,33 @@ class RemoteBuild(object):
self.version = '' self.version = ''
self.basedirurl = { 'x86': '-', 'x86_64': '-' } self.basedirurl = { 'x86': '-', 'x86_64': '-' }
if version and isinstance(version, str):
self.version = version
if not '.' in self.query: if not '.' in self.query:
# Named version. # Named version.
# Let's check if a specific version was requested. # Let's check if a specific version was requested.
if version: if self.version == '':
self.version = version
else:
# In case it was not requested, we will carry on the generic # In case it was not requested, we will carry on the generic
# namedver() query. # namedver() query.
# If the results are more than one, we'll take the latest (since we are requested to provide a single build). # If the results are more than one, we'll take the latest (since we are requested to provide a single build).
a = Base.namedver(self.query) a = Base.namedver(self.query)
if isinstance(a, list) and len(a) == 0: if isinstance(a, list):
# No results from the query - let's return default values
return
if len(a) == 1: if len(a) == 1:
# version is a single one. # version is a single one.
self.version = a[0] self.version = a[0]
else: else:
# In this case, we will select the latest release. # In this case, we will select the latest release.
self.version = sorted(a)[-1] self.version = sorted(a)[-1]
# If the version has already a version, as requested by user,
# continue using that version
else: else:
# In case of numbered queries, put it as initial version # In case of numbered queries, put it as initial version
self.version = self.query self.version = self.query
if len(self.version.split('.')) < 4: if len(str(self.version).split('.')) < 4:
# If not 4 dotted, let's search for the 4 dotted version # If not 4 dotted, let's search for the 4 dotted version
self.version = Base.fullversion(self.version) self.version = Base.fullversion(self.version)

View File

@ -5,25 +5,26 @@ import loaih
from lxml import etree from lxml import etree
import tempfile, os, sys, glob, subprocess, shutil, re, shlex import tempfile, os, sys, glob, subprocess, shutil, re, shlex
class Build(object): class Collection(list):
def __init__(self, query, arch = ['x86', 'x86_64']):
"""Build a list of version to check/build for this round."""
super().__init__()
self.extend([ Build(query, arch, version) for version in loaih.Base.collectedbuilds(query) ])
class Build(loaih.RemoteBuild):
LANGSTD = [ 'ar', 'de', 'en-GB', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'pt-BR', 'ru', 'zh-CN', 'zh-TW' ] LANGSTD = [ 'ar', 'de', 'en-GB', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'pt-BR', 'ru', 'zh-CN', 'zh-TW' ]
LANGBASIC = [ 'en-GB' ] LANGBASIC = [ 'en-GB' ]
ARCHSTD = [ u'x86', u'x86_64' ] ARCHSTD = [ u'x86', u'x86_64' ]
def __init__(self, query, arch): def __init__(self, query, arch, version = None):
"""Build all versions that can be found in the indicated repo.""" super().__init__(query, version)
self.query = query
self.arch = arch self.arch = arch
# Getting versions and so on
v = versions.BuildVersion(self.query)
self.version = v.version
print(f"Debug {self.version}")
self.short_version = str.join('.', self.version.split('.')[0:2]) self.short_version = str.join('.', self.version.split('.')[0:2])
self.branch_version = None self.branch_version = None
if not '.' in self.query: if not '.' in self.query:
self.branch_version = self.query self.branch_version = self.query
self.url = v.basedirurl self.url = self.basedirurl
# Other default values # Other default values
self.language = 'basic' self.language = 'basic'
@ -52,7 +53,6 @@ class Build(object):
self.full_path = '' self.full_path = ''
self.baseurl = '' self.baseurl = ''
def calculate(self): def calculate(self):
"""Calculate exclusions and other variables.""" """Calculate exclusions and other variables."""
# AppName # AppName
@ -89,7 +89,7 @@ class Build(object):
if len(self.relative_path) == 0: if len(self.relative_path) == 0:
if self.query == 'daily': if self.query == 'daily':
self.relative_path.append('daily') self.relative_path.append('daily')
elif self.query == 'primageerelease': elif self.query == 'prerelease':
self.relative_path.append('prerelease') self.relative_path.append('prerelease')
# Not the same check, an additional one # Not the same check, an additional one

View File

@ -3,7 +3,7 @@
import click import click
import yaml import yaml
import loaih import loaih, loaih.build
import re, sys, json import re, sys, json
@click.group() @click.group()
@ -22,11 +22,6 @@ def getversion(query, jsonout):
queries.append(query) queries.append(query)
for q in queries: for q in queries:
if '.' in q:
# Numbered version. It is safe to send it to Build.
b.append(loaih.RemoteBuild(q))
else:
# Named version. For safety, we call a helper method for a collection
b.extend(loaih.Base.collectedbuilds(q)) b.extend(loaih.Base.collectedbuilds(q))
if len(b) > 0: if len(b) > 0:
@ -66,8 +61,9 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
# generic default. # generic default.
for build in config['builds']: for build in config['builds']:
# Loop a run for each build. # Loop a run for each build.
obj = loaih.Build(build['query'], arches) collection = loaih.build.Collection(build['query'], arches)
for obj in collection:
# Configuration phase # Configuration phase
obj.language = build['language'] obj.language = build['language']
obj.offline_help = build['offline_help'] obj.offline_help = build['offline_help']
@ -92,8 +88,8 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
del obj del obj
else: else:
obj = loaih.Build(query, arches) collection = loaih.build.Collection(query, arches)
for obj in collection:
# Configuration phase # Configuration phase
obj.language = language obj.language = language
obj.offline_help = offline obj.offline_help = offline