Commit 60efdbe3 authored by Jakub Ružička's avatar Jakub Ružička
Browse files

parse: improve archive parsing

parent 95ccb0c2
......@@ -10,19 +10,31 @@ from apkg import ex
RE_NVR = r'^(.+?)([-_])(v?\d+(?:\.\d+)+(?:.+?)?)$'
def split_archive_fn(archive_fn):
def split_archive_ext(archive_fn):
"""
split archive file name into individual parts
split archive file into base name and extension such as '.tar.gz'
return (name, separator, version, extension)
return (name, extension)
"""
nvr, _, ext = archive_fn.rpartition('.')
name, _, ext = archive_fn.rpartition('.')
if not name:
return archive_fn, ''
ext = '.%s' % ext
if nvr.endswith('.tar'):
nvr, _, _ = nvr.rpartition('.')
if name.endswith('.tar'):
name, _, _ = name.rpartition('.')
ext = '.tar%s' % ext
r = re.match(RE_NVR, nvr)
return name, ext
def split_archive_fn(archive_fn):
"""
split archive file name into individual parts
return (name, separator, version, extension)
"""
name, ext = split_archive_ext(archive_fn)
r = re.match(RE_NVR, name)
if r:
return r.groups() + (ext,)
......
......@@ -71,7 +71,7 @@ def build_srcpkg(
template,
env):
archive_path = archive_paths[0]
nv = "%s-%s" % (env['name'], env['version'])
nv, _ = parse.split_archive_ext(archive_path.name)
source_path = build_path / nv
log.info("building deb source package: %s", nv)
log.info("unpacking archive: %s", archive_path)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment