X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=pkgs.py;h=d9155f4dfa94f6845238e99203f1f296a5872400;hb=HEAD;hp=3087493efe2647dc7700d5094de31b9dd7adc771;hpb=91c933336b0b9882eeb87686fe8632cfb370b5f1;p=build.git diff --git a/pkgs.py b/pkgs.py index 3087493e..c588e5c0 100755 --- a/pkgs.py +++ b/pkgs.py @@ -36,13 +36,16 @@ import re default_arch = 'x86_64' known_archs = ['i386', 'i686', 'x86_64'] -default_fcdistro = 'f31' +default_fcdistro = 'f41' known_fcdistros = [ 'centos5', 'centos6', # oldies but we have references to that in the pkgs files - 'f8', 'f10', 'f12', 'f14', 'f16', 'f18', 'f20', 'f21', 'f22', 'f23', 'f24', - # these ones are still relevant - 'f25', 'f27', 'f29', 'f31', + 'f8', 'f10', 'f12', 'f14', 'f16', 'f18', + 'f20', 'f21', 'f22', 'f23', 'f24', 'f25', 'f27', + # these ones are still relevant; + # f32 is mentioned to be able to use create-vms with that distro + # as we're running into issues to build a minimal f33 from a f29 host + 'f29', 'f31', 'f32', 'f33', 'f35', 'f37', 'f39', 'f41', # scientific linux 'sl6', # debians @@ -51,12 +54,15 @@ known_fcdistros = [ 'trusty', # 14.04 LTS 'xenial', # 16.04 LTS 'bionic', # 18.04 LTS + 'focal', # 20.04 LTS + 'jammy', # 22.04 LTS + 'noble', # 24.04 LTS ] default_pldistro = 'onelab' known_keywords = [ 'group', 'groupname', 'groupdesc', - 'package', 'pip', 'gem', + 'package', 'pip', 'gem', 'nodeyumexclude', 'plcyumexclude', 'yumexclude', 'precious', 'junk', 'mirror', ] @@ -102,25 +108,25 @@ class PkgsParser: return self.version <= version else: raise Exception( - 'Internal error - unexpected qualifier {}'.format(qualifier)) + f'Internal error - unexpected qualifier {qualifier}') m_comment = re.compile(r'\A\s*#') m_blank = re.compile(r'\A\s*\Z') m_ident = re.compile(r'\A'+re_ident+r'\Z') re_qualified = r'\s*' - re_qualified += r'(?P[+-]?)' - re_qualified += r'\s*' - re_qualified += r'(?P{re_ident})'.format(re_ident=re_ident) - re_qualified += r'\s*' - re_qualified += r'(?P>=|<=|=)' - re_qualified += r'\s*' - re_qualified += r'(?P{re_ident}[0-9]+)'.format(re_ident=re_ident) - re_qualified += r'\s*' - m_qualified = re.compile(r'\A{re_qualified}\Z'.format(re_qualified=re_qualified)) + re_qualified += rf'(?P[+-]?)' + re_qualified += rf'\s*' + re_qualified += rf'(?P{re_ident})' + re_qualified += rf'\s*' + re_qualified += rf'(?P=|<=|>=)' + re_qualified += rf'\s*' + re_qualified += rf'(?P{re_ident}[0-9]+)' + re_qualified += rf'\s*' + m_qualified = re.compile(rf'\A{re_qualified}\Z') re_old = '[a-z]+[+-][a-z]+[0-9]+' - m_old = re.compile(r'\A{}\Z'.format(re_old)) + m_old = re.compile(rf'\A{re_old}\Z') # returns a tuple (included, excluded) def parse(self, filename): @@ -139,7 +145,7 @@ class PkgsParser: ########## single ident if self.m_ident.match(left): if left not in known_keywords: - raise Exception("Unknown keyword {left}".format(**locals())) + raise Exception(f"Unknown keyword {left}") elif left == self.keyword: included += rights.split() else: @@ -147,9 +153,9 @@ class PkgsParser: if m: (plus_minus, kw, qual, fcdistro) = m.groups() if kw not in known_keywords: - raise Exception("Unknown keyword in {left}".format(**locals())) + raise Exception(f"Unknown keyword in {left}") if fcdistro not in known_fcdistros: - raise Exception('Unknown fcdistro {fcdistro}'.format(**locals())) + raise Exception(f'Unknown fcdistro {fcdistro}') # skip if another keyword if kw != self.keyword: continue # does this fcdistro match ? @@ -160,32 +166,31 @@ class PkgsParser: # skip if the qualifier does not fit if not self.match (qual, version): if self.options.verbose: - print('{filename}:{lineno}:qualifer {left} does not apply' - .format(**locals()), file=stderr) + print(f'{filename}:{lineno}:qualifer {left} does not apply', + file=stderr) continue # we're in, let's add (default) or remove (if plus_minus is minus) if plus_minus == '-': if self.options.verbose: - print('{filename}:{lineno}: from {left}, excluding {rights}' - .format(**locals()), file=stderr) + print(f'{filename}:{lineno}: from {left}, excluding {rights}', + file=stderr) excluded += rights.split() else: if self.options.verbose: - print('{filename}:{lineno}: from {left}, including {rights}'\ - .format(**locals()), file=stderr) + print(f'{filename}:{lineno}: from {left}, including {rights}', + file=stderr) included += rights.split() elif self.m_old.match(left): - raise Exception('Old-fashioned syntax not supported anymore {left}'.\ - format(**locals())) + raise Exception(f'Old-fashioned syntax not supported anymore {left}') else: - raise Exception('error in left expression {left}'.format(**locals())) + raise Exception(f'error in left expression {left}') except Exception as e: ok = False - print("{filename}:{lineno}:syntax error: {e}".format(**locals()), file=stderr) + print(f"{filename}:{lineno}:syntax error: {e}", file=stderr) except Exception as exc: ok = False - print('Could not parse file', filename, exc, file=stderr) + print(f'Could not parse file {filename} {exc=}', file=stderr) return (ok, included, excluded) def run (self): @@ -219,7 +224,7 @@ def main (): parser = OptionParser(usage=usage) parser.add_option( '-a', '--arch', dest='arch', action='store', default=default_arch, - help='target arch, e.g. i386 or x86_64, default={}'.format(default_arch)) + help=f'target arch, e.g. i386 or x86_64, default={default_arch}') parser.add_option( '-f', '--fcdistro', dest='fcdistro', action='store', default=default_fcdistro, help='fcdistro, e.g. f12 or centos5')