From c9a184cf316cfdebe61ca2deacd0e4a0835a081a Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Wed, 4 Sep 2024 22:42:34 +0200 Subject: [PATCH] package/pkg-cargo: don't install crates tracking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, 'cargo install' also installs a kind of "registry" in /usr/.crates2.json and /usr/.crates.toml [0]: To track information of installed executables, some extra files, such as .crates.toml and .crates2.json, are also created under this root. Presumably, this would be used by "cargo uninstall" to properly cleanup the package [1]: By default all binaries are removed for a crate [...]. However, in the context of Buildroot, this is useless, as we do not uninstall packages, and thus those files are superfluous. Tell cargo to not create that tracking information, by using --no-track to "cargo install". Note that this would cause cargo to fail to install a file that already exists [2], like would be the case when running foo-reinstall for example: --no-track By default, Cargo keeps track of the installed packages with a metadata file stored in the installation root directory. This flag tells Cargo not to use or create that file. With this flag, Cargo will refuse to overwrite any existing files unless the --force flag is used. This also disables Cargo’s ability to protect against multiple concurrent invocations of Cargo installing at the same time. However, we do already use --force which allows cargo to overwrite existing files without any further ado, so in our case, --no-track will only disable the tracking information. Also, in Buildroot, we do not have concurrent installation _to the same location_: either PPD is disabled, in which case only one package will be installed to the common target/ at a time, or we're using PPD, so each package will get installed into its own target/. Thus, --no-track has no adverse side effect for us. Fixes: https://gitlab.com/buildroot.org/buildroot/-/issues/17 [0] https://doc.rust-lang.org/cargo/reference/config.html#installroot [1] https://doc.rust-lang.org/cargo/commands/cargo-uninstall.html [2] https://doc.rust-lang.org/cargo/commands/cargo-install.html Reported-by: Thomas Kindler @thomask77 Signed-off-by: Yann E. MORIN Tested-by: Thomas Kindler @thomask77 Signed-off-by: Thomas Petazzoni --- package/pkg-cargo.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk index 41dfcbd096..d94a19024e 100644 --- a/package/pkg-cargo.mk +++ b/package/pkg-cargo.mk @@ -279,6 +279,7 @@ define $(2)_INSTALL_TARGET_CMDS --root $$(TARGET_DIR)/usr/ \ --bins \ --path ./ \ + --no-track \ --force \ --locked \ -Z target-applies-to-host \ @@ -298,6 +299,7 @@ define $(2)_INSTALL_CMDS --root $$(HOST_DIR) \ --bins \ --path ./ \ + --no-track \ --force \ --locked \ $$($(2)_CARGO_INSTALL_OPTS)