diff --git a/apt/private/package_resolution.bzl b/apt/private/package_resolution.bzl index 11643cc..dd99863 100644 --- a/apt/private/package_resolution.bzl +++ b/apt/private/package_resolution.bzl @@ -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(":") + 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} diff --git a/apt/tests/package_resolution_test.bzl b/apt/tests/package_resolution_test.bzl index a078075..b76cff2 100644 --- a/apt/tests/package_resolution_test.bzl +++ b/apt/tests/package_resolution_test.bzl @@ -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) diff --git a/examples/apt/bullseye.lock.json b/examples/apt/bullseye.lock.json old mode 100755 new mode 100644 index 2823cbb..53ca1f0 --- a/examples/apt/bullseye.lock.json +++ b/examples/apt/bullseye.lock.json @@ -106,10 +106,35 @@ "name": "debianutils", "version": "4.11.2" }, + { + "key": "libc6_2.31-13-p-deb11u8_amd64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_amd64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_amd64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_amd64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, { "key": "base-files_11.1-p-deb11u9_amd64", "name": "base-files", "version": "11.1+deb11u9" + }, + { + "key": "libtinfo6_6.2-p-20201114-2-p-deb11u2_amd64", + "name": "libtinfo6", + "version": "6.2+20201114-2+deb11u2" } ], "key": "bash_5.1-2-p-deb11u1_amd64", @@ -149,6 +174,26 @@ "name": "libpcre2-8-0", "version": "10.36-2+deb11u1" }, + { + "key": "libc6_2.31-13-p-deb11u8_amd64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_amd64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_amd64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_amd64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, { "key": "libgmp10_2-6.2.1-p-dfsg-1-p-deb11u1_amd64", "name": "libgmp10", @@ -224,6 +269,41 @@ "name": "tar", "version": "1.34+dfsg-1+deb11u1" }, + { + "key": "libselinux1_3.1-3_amd64", + "name": "libselinux1", + "version": "3.1-3" + }, + { + "key": "libpcre2-8-0_10.36-2-p-deb11u1_amd64", + "name": "libpcre2-8-0", + "version": "10.36-2+deb11u1" + }, + { + "key": "libc6_2.31-13-p-deb11u8_amd64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_amd64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_amd64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_amd64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, + { + "key": "libacl1_2.2.53-10_amd64", + "name": "libacl1", + "version": "2.2.53-10" + }, { "key": "zlib1g_1-1.2.11.dfsg-2-p-deb11u2_amd64", "name": "zlib1g", @@ -295,6 +375,31 @@ "name": "libzstd1", "version": "1.4.8+dfsg-2.1" }, + { + "key": "libc6_2.31-13-p-deb11u8_amd64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_amd64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_amd64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_amd64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, + { + "key": "liblzma5_5.2.5-2.1~deb11u1_amd64", + "name": "liblzma5", + "version": "5.2.5-2.1~deb11u1" + }, { "key": "liblz4-1_1.9.3-2_amd64", "name": "liblz4-1", @@ -360,6 +465,11 @@ "name": "libhogweed6", "version": "3.7.3-1" }, + { + "key": "libgmp10_2-6.2.1-p-dfsg-1-p-deb11u1_amd64", + "name": "libgmp10", + "version": "2:6.2.1+dfsg-1+deb11u1" + }, { "key": "debian-archive-keyring_2021.1.1-p-deb11u1_amd64", "name": "debian-archive-keyring", @@ -370,6 +480,11 @@ "name": "libapt-pkg6.0", "version": "2.2.4" }, + { + "key": "zlib1g_1-1.2.11.dfsg-2-p-deb11u2_amd64", + "name": "zlib1g", + "version": "1:1.2.11.dfsg-2+deb11u2" + }, { "key": "libxxhash0_0.8.0-2_amd64", "name": "libxxhash0", @@ -380,6 +495,11 @@ "name": "libudev1", "version": "247.3-7+deb11u4" }, + { + "key": "libbz2-1.0_1.0.8-4_amd64", + "name": "libbz2-1.0", + "version": "1.0.8-4" + }, { "key": "adduser_3.118-p-deb11u1_amd64", "name": "adduser", @@ -400,6 +520,16 @@ "name": "libpam-modules-bin", "version": "1.4.0-9+deb11u1" }, + { + "key": "libselinux1_3.1-3_amd64", + "name": "libselinux1", + "version": "3.1-3" + }, + { + "key": "libpcre2-8-0_10.36-2-p-deb11u1_amd64", + "name": "libpcre2-8-0", + "version": "10.36-2+deb11u1" + }, { "key": "libpam0g_1.4.0-9-p-deb11u1_amd64", "name": "libpam0g", @@ -884,6 +1014,66 @@ "name": "perl-base", "version": "5.32.1-4+deb11u3" }, + { + "key": "dpkg_1.20.13_amd64", + "name": "dpkg", + "version": "1.20.13" + }, + { + "key": "tar_1.34-p-dfsg-1-p-deb11u1_amd64", + "name": "tar", + "version": "1.34+dfsg-1+deb11u1" + }, + { + "key": "libselinux1_3.1-3_amd64", + "name": "libselinux1", + "version": "3.1-3" + }, + { + "key": "libpcre2-8-0_10.36-2-p-deb11u1_amd64", + "name": "libpcre2-8-0", + "version": "10.36-2+deb11u1" + }, + { + "key": "libc6_2.31-13-p-deb11u8_amd64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_amd64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_amd64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_amd64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, + { + "key": "libacl1_2.2.53-10_amd64", + "name": "libacl1", + "version": "2.2.53-10" + }, + { + "key": "zlib1g_1-1.2.11.dfsg-2-p-deb11u2_amd64", + "name": "zlib1g", + "version": "1:1.2.11.dfsg-2+deb11u2" + }, + { + "key": "liblzma5_5.2.5-2.1~deb11u1_amd64", + "name": "liblzma5", + "version": "5.2.5-2.1~deb11u1" + }, + { + "key": "libbz2-1.0_1.0.8-4_amd64", + "name": "libbz2-1.0", + "version": "1.0.8-4" + }, { "key": "libgdbm6_1.19-2_amd64", "name": "libgdbm6", @@ -893,6 +1083,11 @@ "key": "libgdbm-compat4_1.19-2_amd64", "name": "libgdbm-compat4", "version": "1.19-2" + }, + { + "key": "libdb5.3_5.3.28-p-dfsg1-0.8_amd64", + "name": "libdb5.3", + "version": "5.3.28+dfsg1-0.8" } ], "key": "perl_5.32.1-4-p-deb11u3_amd64", @@ -1052,10 +1247,35 @@ "name": "debianutils", "version": "4.11.2" }, + { + "key": "libc6_2.31-13-p-deb11u8_arm64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_arm64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_arm64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_arm64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, { "key": "base-files_11.1-p-deb11u9_arm64", "name": "base-files", "version": "11.1+deb11u9" + }, + { + "key": "libtinfo6_6.2-p-20201114-2-p-deb11u2_arm64", + "name": "libtinfo6", + "version": "6.2+20201114-2+deb11u2" } ], "key": "bash_5.1-2-p-deb11u1_arm64", @@ -1095,6 +1315,26 @@ "name": "libpcre2-8-0", "version": "10.36-2+deb11u1" }, + { + "key": "libc6_2.31-13-p-deb11u8_arm64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_arm64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_arm64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_arm64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, { "key": "libgmp10_2-6.2.1-p-dfsg-1-p-deb11u1_arm64", "name": "libgmp10", @@ -1170,6 +1410,41 @@ "name": "tar", "version": "1.34+dfsg-1+deb11u1" }, + { + "key": "libselinux1_3.1-3_arm64", + "name": "libselinux1", + "version": "3.1-3" + }, + { + "key": "libpcre2-8-0_10.36-2-p-deb11u1_arm64", + "name": "libpcre2-8-0", + "version": "10.36-2+deb11u1" + }, + { + "key": "libc6_2.31-13-p-deb11u8_arm64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_arm64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_arm64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_arm64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, + { + "key": "libacl1_2.2.53-10_arm64", + "name": "libacl1", + "version": "2.2.53-10" + }, { "key": "zlib1g_1-1.2.11.dfsg-2-p-deb11u2_arm64", "name": "zlib1g", @@ -1241,6 +1516,31 @@ "name": "libzstd1", "version": "1.4.8+dfsg-2.1" }, + { + "key": "libc6_2.31-13-p-deb11u8_arm64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_arm64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_arm64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_arm64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, + { + "key": "liblzma5_5.2.5-2.1~deb11u1_arm64", + "name": "liblzma5", + "version": "5.2.5-2.1~deb11u1" + }, { "key": "liblz4-1_1.9.3-2_arm64", "name": "liblz4-1", @@ -1306,6 +1606,11 @@ "name": "libhogweed6", "version": "3.7.3-1" }, + { + "key": "libgmp10_2-6.2.1-p-dfsg-1-p-deb11u1_arm64", + "name": "libgmp10", + "version": "2:6.2.1+dfsg-1+deb11u1" + }, { "key": "debian-archive-keyring_2021.1.1-p-deb11u1_arm64", "name": "debian-archive-keyring", @@ -1316,6 +1621,11 @@ "name": "libapt-pkg6.0", "version": "2.2.4" }, + { + "key": "zlib1g_1-1.2.11.dfsg-2-p-deb11u2_arm64", + "name": "zlib1g", + "version": "1:1.2.11.dfsg-2+deb11u2" + }, { "key": "libxxhash0_0.8.0-2_arm64", "name": "libxxhash0", @@ -1326,6 +1636,11 @@ "name": "libudev1", "version": "247.3-7+deb11u4" }, + { + "key": "libbz2-1.0_1.0.8-4_arm64", + "name": "libbz2-1.0", + "version": "1.0.8-4" + }, { "key": "adduser_3.118-p-deb11u1_arm64", "name": "adduser", @@ -1346,6 +1661,16 @@ "name": "libpam-modules-bin", "version": "1.4.0-9+deb11u1" }, + { + "key": "libselinux1_3.1-3_arm64", + "name": "libselinux1", + "version": "3.1-3" + }, + { + "key": "libpcre2-8-0_10.36-2-p-deb11u1_arm64", + "name": "libpcre2-8-0", + "version": "10.36-2+deb11u1" + }, { "key": "libpam0g_1.4.0-9-p-deb11u1_arm64", "name": "libpam0g", @@ -1830,6 +2155,66 @@ "name": "perl-base", "version": "5.32.1-4+deb11u3" }, + { + "key": "dpkg_1.20.13_arm64", + "name": "dpkg", + "version": "1.20.13" + }, + { + "key": "tar_1.34-p-dfsg-1-p-deb11u1_arm64", + "name": "tar", + "version": "1.34+dfsg-1+deb11u1" + }, + { + "key": "libselinux1_3.1-3_arm64", + "name": "libselinux1", + "version": "3.1-3" + }, + { + "key": "libpcre2-8-0_10.36-2-p-deb11u1_arm64", + "name": "libpcre2-8-0", + "version": "10.36-2+deb11u1" + }, + { + "key": "libc6_2.31-13-p-deb11u8_arm64", + "name": "libc6", + "version": "2.31-13+deb11u8" + }, + { + "key": "libcrypt1_1-4.4.18-4_arm64", + "name": "libcrypt1", + "version": "1:4.4.18-4" + }, + { + "key": "libgcc-s1_10.2.1-6_arm64", + "name": "libgcc-s1", + "version": "10.2.1-6" + }, + { + "key": "gcc-10-base_10.2.1-6_arm64", + "name": "gcc-10-base", + "version": "10.2.1-6" + }, + { + "key": "libacl1_2.2.53-10_arm64", + "name": "libacl1", + "version": "2.2.53-10" + }, + { + "key": "zlib1g_1-1.2.11.dfsg-2-p-deb11u2_arm64", + "name": "zlib1g", + "version": "1:1.2.11.dfsg-2+deb11u2" + }, + { + "key": "liblzma5_5.2.5-2.1~deb11u1_arm64", + "name": "liblzma5", + "version": "5.2.5-2.1~deb11u1" + }, + { + "key": "libbz2-1.0_1.0.8-4_arm64", + "name": "libbz2-1.0", + "version": "1.0.8-4" + }, { "key": "libgdbm6_1.19-2_arm64", "name": "libgdbm6", @@ -1839,6 +2224,11 @@ "key": "libgdbm-compat4_1.19-2_arm64", "name": "libgdbm-compat4", "version": "1.19-2" + }, + { + "key": "libdb5.3_5.3.28-p-dfsg1-0.8_arm64", + "name": "libdb5.3", + "version": "5.3.28+dfsg1-0.8" } ], "key": "perl_5.32.1-4-p-deb11u3_arm64",