[sysadmin-bin: 1/2] ftpadmin: further updates to the regexes
- From: Bartłomiej Piotrowski <bpiotrowski src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin: 1/2] ftpadmin: further updates to the regexes
- Date: Thu, 14 Jan 2021 08:55:01 +0000 (UTC)
commit 5f503e57a161b0929f54ea245389dabdb6d0a7b7
Author: Abderrahim Kitouni <akitouni gnome org>
Date: Tue Jan 12 16:32:55 2021 +0100
ftpadmin: further updates to the regexes
This considers the old and new version schemes separately
ftpadmin | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/ftpadmin b/ftpadmin
index c69d70a..16002ee 100755
--- a/ftpadmin
+++ b/ftpadmin
@@ -50,8 +50,9 @@ if not os.environ['USER'] in ('ovitters', 'olav'):
DEBUG=False
GROUP='ftpadmin'
-re_file =
re.compile(r'^(?P<module>.*?)[_-](?:(?P<oldversion>([0-9]+[\.])+[a-z0-9]+)-)?(?P<version>(?:(?:[0-9]+\.)*|(?:[0-9]+\-)*)[a-z0-9]+)\.(?P<format>(?:tar\.|diff\.)[a-z][a-z0-9]*)$')
-re_majmin = re.compile(r'^([0-9]+(\.[0-9]+)?).*')
+re_file =
re.compile(r'^(?P<module>.*?)[_-](?:(?P<oldversion>([0-9]+[\.])+[a-z0-9]+)-)?(?P<version>(?:(?:[0-9]+\.)*|(?:[0-9]+\-)*)(?:alpha|beta|rc|(?:[0-9]+)))\.(?P<format>(?:tar\.|diff\.)?[a-z][a-z0-9]*)$')
+re_majmin = re.compile(r'^([0-9]+\.[0-9]+).*')
+re_maj = re.compile(r'^([0-9]+).*')
re_version = re.compile(r'([-.]|\d+|[^-.\d]+)')
re_who = re.compile(r' <[^>]+>$')
re_whitespace = re.compile("\s+")
@@ -72,6 +73,18 @@ SUITES = [
]
DEFAULT_SUITE=SUITES[0]
+def get_majmin(version):
+ """Returns the folder name to be used.
+
+ This is major.minor for the old versioning scheme and major for the new
+ scheme (starting GNOME 40)"""
+ maj = re_maj.sub(r'\1', version)
+ if int(maj) >= 40:
+ return maj
+
+ return re_majmin.sub(r'\1', version)
+
+
def version_cmp(a, b):
"""Compares two versions
@@ -483,7 +496,7 @@ class TarInfo(BasicInfo):
self.module = fileinfo['module']
self.version = fileinfo['version']
self.format = fileinfo['format']
- self.majmin = re_majmin.sub(r'\1', fileinfo['version'])
+ self.majmin = get_majmin(fileinfo['version'])
for tarballname, format, formatname in self.DIFF_FILES:
tarinfo_files.add('%s-%s/%s' % (self.module, self.version, tarballname))
@@ -790,7 +803,7 @@ class DirectoryInfo(BasicInfo):
class SuiteInfo(DirectoryInfo):
def __init__(self, suite, version):
- majmin = re_majmin.sub(r'\1', version)
+ majmin = get_majmin(version)
relpath = os.path.join(suite, majmin, version)
DirectoryInfo.__init__(self, relpath)
@@ -1414,7 +1427,7 @@ class InstallSuites(BasicInfo):
print 'ERROR: Invalid suite: %s' % suite
is_valid = False
- majmin = re_majmin.sub(r'\1', self.version)
+ majmin = get_majmin(self.version)
abspath = os.path.join(self.FTPROOT, suite, majmin, self.version)
if os.path.exists(abspath):
print "ERROR: Suite already exists: %s " % abspath
@@ -1453,7 +1466,7 @@ class InstallSuites(BasicInfo):
for suite in sorted(suites):
sha256 = {}
sys.stdout.write(" - Linking %s tarballs: " % suite)
- majmin = re_majmin.sub(r'\1', self.version)
+ majmin = get_majmin(self.version)
relpath = os.path.join(suite, majmin, self.version, 'sources')
for module in sorted(suites[suite]):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]