Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
packaging
apkg
Commits
60efdbe3
Commit
60efdbe3
authored
Apr 13, 2021
by
Jakub Ružička
Browse files
parse: improve archive parsing
parent
95ccb0c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
apkg/parse.py
View file @
60efdbe3
...
...
@@ -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
n
vr
.
endswith
(
'.tar'
):
n
vr
,
_
,
_
=
n
vr
.
rpartition
(
'.'
)
if
n
ame
.
endswith
(
'.tar'
):
n
ame
,
_
,
_
=
n
ame
.
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
,)
...
...
apkg/pkgstyles/deb.py
View file @
60efdbe3
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment