Skip to content

Duplicated package dependencies in *.lock.json #184

@birunts

Description

@birunts

Having a manifest of:

version: 1
sources:
  - channel: jammy main
    url: https://snapshot.ubuntu.com/ubuntu/20250302T030400Z
  - channel: jammy universe
    url: https://snapshot.ubuntu.com/ubuntu/20250302T030400Z
  - channel: jammy-security main
    url: https://snapshot.ubuntu.com/ubuntu/20250302T030400Z
  - channel: jammy-updates main
    url: https://snapshot.ubuntu.com/ubuntu/20250302T030400Z
archs:
  - "arm64"
packages:
  - "gcc"
  - "gcc-aarch64-linux-gnu"

will resolve the packages to

  • gcc
Package: gcc
Architecture: arm64
Version: 4:11.2.0-1ubuntu1
Provides: c-compiler, gcc-aarch64-linux-gnu (= 4:11.2.0-1ubuntu1)
Depends: cpp (= 4:11.2.0-1ubuntu1), gcc-11 (>= 11.2.0-1~)
  • gcc-aarch64-linux-gnu - not available for arm64 arch

However resolver will return gcc package while resolving gcc-aarch64-linux-gnu (due to gcc package with Provides: gcc-aarch64-linux-gnu), causes adding gcc package and its dependency to the lock twice.
Addition of dependencies to the same package does not verifies if the dependency is already there thus it can result with duplicate dependencies e.g.:

{
	"packages": [
		{
			"arch": "arm64",
			"dependencies": [
				...
				{
					"key": "gcc-11_11.4.0-1ubuntu1_22.04_arm64",
					"name": "gcc-11",
					"version": "11.4.0-1ubuntu1~22.04"
				},
				{
					"key": "gcc-11_11.4.0-1ubuntu1_22.04_arm64",
					"name": "gcc-11",
					"version": "11.4.0-1ubuntu1~22.04"
				},
				...
			],
			"key": "gcc_4-11.2.0-1ubuntu1_arm64",
			"name": "gcc",
			"sha256": "426deed543cc32f388ad8336354e312fb76a47450194d2d775d855ad5878f82e",
			"urls": [
				"https://snapshot.ubuntu.com/ubuntu/20250302T030400Z/pool/main/g/gcc-defaults/gcc_11.2.0-1ubuntu1_arm64.deb"
			],
			"version": "4:11.2.0-1ubuntu1"
		}
	]
}

In the end this fails as the defined package contains duplicated deps:

filegroup(
    name = "arm64",
    srcs = [
	...	
    "//gcc-11/arm64:data",
    "//gcc-11/arm64:data",
    ...
] + [":data"],
    visibility = ["//visibility:public"],
)
ERROR: /home/user/.cache/bazel/_bazel_user/a50000001111111abcdef111bca/external/rules_distroless++apt+apt-packages/gcc/arm64/BUILD.bazel:15:10: Label '@@rules_distroless++apt+apt-packages//gcc-11/arm64:data' is duplicated in the 'srcs' attribute of rule 'arm64'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions