package/pkg-cargo: don't install crates tracking
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 <yann.morin.1998@free.fr>
Tested-by: Thomas Kindler @thomask77
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>