Fix daca2 using latest version of package (#2393)
* Add semver import for sorting ls-lR list * Fix using latest release version of package * Import semver with pip in travis file
This commit is contained in:
parent
2c28440f15
commit
e6d692d960
|
@ -27,6 +27,7 @@ before_install:
|
|||
- travis_retry python2 -m pip install --user unittest2
|
||||
- travis_retry python2 -m pip install --user pexpect # imported by tools/ci.py
|
||||
- travis_retry python2 -m pip install --user pygments
|
||||
- travis_retry python2 -m pip install --user semver
|
||||
# Python 3 modules
|
||||
- travis_retry python3 -m pip install --user setuptools --upgrade
|
||||
- travis_retry python3 -m pip install --user pytest
|
||||
|
@ -36,6 +37,7 @@ before_install:
|
|||
- travis_retry python3 -m pip install --user requests # imported by tools/pr.py
|
||||
- travis_retry python3 -m pip install --user pygments
|
||||
- travis_retry sudo python3 -m pip install demjson # installs jsonlint => sudo required
|
||||
- travis_retry python3 -m pip install --user semver
|
||||
|
||||
matrix:
|
||||
# do notify immediately about it when a job of a build fails.
|
||||
|
|
|
@ -12,6 +12,7 @@ import shutil
|
|||
import glob
|
||||
import os
|
||||
import time
|
||||
import semver
|
||||
|
||||
DEBIAN = ('ftp://ftp.se.debian.org/debian/',
|
||||
'ftp://ftp.debian.org/debian/')
|
||||
|
@ -31,6 +32,14 @@ def wget(filepath):
|
|||
return False
|
||||
|
||||
|
||||
def latestvername(names):
|
||||
if len(names) == 1:
|
||||
return names[0]
|
||||
names.sort(cmp=semver.cmp, key=lambda x: x[x.index(
|
||||
'_')+1:x.index('.orig.tar')-x.index('_')+1])
|
||||
return names[-1]
|
||||
|
||||
|
||||
def getpackages():
|
||||
if not wget('ls-lR.gz'):
|
||||
return []
|
||||
|
@ -43,17 +52,20 @@ def getpackages():
|
|||
path = None
|
||||
archives = []
|
||||
filename = None
|
||||
filenames = []
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if len(line) < 4:
|
||||
if filename:
|
||||
archives.append(path + '/' + filename)
|
||||
archives.append(path + '/' + latestvername(filenames))
|
||||
path = None
|
||||
filename = None
|
||||
filenames = []
|
||||
elif line[:12] == './pool/main/':
|
||||
path = line[2:-1]
|
||||
elif path and '.orig.tar.' in line:
|
||||
filename = line[1 + line.rfind(' '):]
|
||||
filenames.append(filename)
|
||||
|
||||
for a in archives:
|
||||
print(a)
|
||||
|
|
|
@ -19,6 +19,7 @@ import os
|
|||
import re
|
||||
import datetime
|
||||
import time
|
||||
import semver
|
||||
|
||||
DEBIAN = ('ftp://ftp.de.debian.org/debian/',
|
||||
'ftp://ftp.debian.org/debian/')
|
||||
|
@ -37,6 +38,14 @@ def wget(filepath):
|
|||
return False
|
||||
|
||||
|
||||
def latestvername(names):
|
||||
if len(names) == 1:
|
||||
return names[0]
|
||||
names.sort(cmp=semver.cmp, key=lambda x: x[x.index(
|
||||
'_')+1:x.index('.orig.tar')-x.index('_')+1])
|
||||
return names[-1]
|
||||
|
||||
|
||||
def getpackages():
|
||||
if not wget('ls-lR.gz'):
|
||||
sys.exit(1)
|
||||
|
@ -86,6 +95,7 @@ def getpackages():
|
|||
previous_path = ''
|
||||
archives = []
|
||||
filename = None
|
||||
filenames = []
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if len(line) < 4:
|
||||
|
@ -97,17 +107,19 @@ def getpackages():
|
|||
if res2 is None:
|
||||
res2 = re.match(r'(.*)[-.][0-9.]+$', previous_path)
|
||||
if res1 is None or res2 is None or res1.group(1) != res2.group(1):
|
||||
archives.append(path + '/' + filename)
|
||||
archives.append(path + '/' + latestvername(filenames))
|
||||
else:
|
||||
archives[-1] = path + '/' + filename
|
||||
archives[-1] = path + '/' + latestvername(filenames)
|
||||
if path:
|
||||
previous_path = path
|
||||
path = None
|
||||
filename = None
|
||||
filenames = []
|
||||
elif line.startswith('./pool/main/'):
|
||||
path = line[2:-1]
|
||||
elif path and line.endswith(('.orig.tar.gz', '.orig.tar.bz2')):
|
||||
filename = line[1 + line.rfind(' '):]
|
||||
filenames.append(filename)
|
||||
|
||||
return archives
|
||||
|
||||
|
|
Loading…
Reference in New Issue