Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Alpine package alias names in rosdep_repo_check #31565

Merged
merged 3 commits into from
Jun 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions test/rosdep_repo_check/apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def parse_apkindex(f):
# t:1602354892
# c:183e99f73bb1223768aa7231a836a3e98e94c03e
# i:docs rtpproxy=2.1.1-r0
# p:alias-of-rtpproxy=2.1.1-r0

while True:
entry = {}
Expand All @@ -61,6 +62,45 @@ def parse_apkindex(f):
break


class Dependency:
"""
Dependency class represents apk (Alpine Package) dependency information.
"""

type = None
"""
:ivar: the type of the Dependency.
e.g.
- None: package
- 'cmd': command
- 'so': shared object
"""

name = None
"""
:ivar: the name of the Dependency.
"""

version = None
"""
:ivar: the version of the Dependency.
"""

def __init__(self, item):
try:
self.type, self.name = item.split(':', 1)
except (ValueError):
self.name = item
try:
self.name, self.version = self.name.split('=', 1)
except (ValueError):
pass


def parse_deps(text):
return [Dependency(item) for item in text.split(' ')]


def enumerate_apk_packages(base_url, os_name, os_code_name, os_arch):
"""
Enumerate packages in an apk (Alpine Package) repository.
Expand Down Expand Up @@ -93,6 +133,11 @@ def enumerate_apk_packages(base_url, os_name, os_code_name, os_arch):
pkg_url = os.path.join(base_url, pkg_filename)
yield PackageEntry(pkg_name, pkg_version, pkg_url, source_name=source_name)

if 'p' in index_entry:
for d in parse_deps(index_entry['p']):
if d.type is None:
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
yield PackageEntry(d.name, pkg_version, pkg_url, source_name=source_name, binary_name=pkg_name)


def apk_base_url(base_url):
"""
Expand Down