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

feat: support apt colon arch syntax #38

Merged
9 changes: 9 additions & 0 deletions apt/private/package_resolution.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def _parse_dep(raw):

version = (version_and_const[:vconst_i], version_and_const[vconst_i + 1:])

# Depends: python3:any
# is equivalent to
# Depends: python3 [any]
colon_i = raw.find(":")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if colon_i != -1:
arch_after_colon = raw[colon_i + 1:]
raw = raw[:colon_i]
archs = [arch_after_colon.strip()]

name = raw.strip()
return {"name": name, "version": version, "arch": archs}

Expand Down
40 changes: 40 additions & 0 deletions apt/tests/package_resolution_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,46 @@ def _parse_depends_test(ctx):
package_resolution.parse_depends("libcap-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386], autoconf, debhelper (>> 5.0.0), file, libc6 (>= 2.7-1), libpaper1, psutils"),
)

asserts.equals(
env,
[
{"name": "python3", "version": None, "arch": ["any"]},
],
package_resolution.parse_depends("python3:any"),
)

asserts.equals(
env,
[
[
{"name": "gcc-i686-linux-gnu", "version": (">=", "4:10.2"), "arch": None},
{"name": "gcc", "version": None, "arch": ["i386"]},
],
[
{"name": "g++-i686-linux-gnu", "version": (">=", "4:10.2"), "arch": None},
{"name": "g++", "version": None, "arch": ["i386"]},
],
{"name": "dpkg-cross", "version": None, "arch": None},
],
package_resolution.parse_depends("gcc-i686-linux-gnu (>= 4:10.2) | gcc:i386, g++-i686-linux-gnu (>= 4:10.2) | g++:i386, dpkg-cross"),
)

asserts.equals(
env,
[
[
{"name": "gcc-x86-64-linux-gnu", "version": (">=", "4:10.2"), "arch": None},
{"name": "gcc", "version": None, "arch": ["amd64"]},
],
[
{"name": "g++-x86-64-linux-gnu", "version": (">=", "4:10.2"), "arch": None},
{"name": "g++", "version": None, "arch": ["amd64"]},
],
{"name": "dpkg-cross", "version": None, "arch": None},
],
package_resolution.parse_depends("gcc-x86-64-linux-gnu (>= 4:10.2) | gcc:amd64, g++-x86-64-linux-gnu (>= 4:10.2) | g++:amd64, dpkg-cross"),
)

return unittest.end(env)

version_depends_test = unittest.make(_parse_depends_test)
Loading
Loading