kumquat-buildroot/support/download
Yann E. MORIN fbddd12601 support/download: fix concurrent cargo vendor
Commit 8450b76918 (package/pkg-cargo: move CARGO_HOME into DL_DIR)
allowed for a shared cargo cache of crates. Internally, cargo is
supposed to lock themselves when accessing that cache, and that commit
even had some research in that area, pointing at [0] for complaints
about too-coarse the lock, so it was deemed safe to have a shared cargo
home.

However, in practice, the locking as implemented by cargo, fails to
properly protect the concurrent accesses to the crates cache, with random
failures that manifest themselves like so:

        Blocking waiting for file lock on package cache
        Blocking waiting for file lock on package cache
     Downloading crates ...
    error: failed to sync
    Caused by:
      failed to download packages
    Caused by:
      failed to download `autocfg v1.1.0`
    Caused by:
      unable to get packages from source
    Caused by:
      failed to unpack package `autocfg v1.1.0`
    Caused by:
      failed to unpack entry at `autocfg-1.1.0/src/tests.rs`
    Caused by:
      No such file or directory (os error 2) while canonicalizing [...]

with the last few errors sometime being:

    Caused by:
      failed to parse manifest at `[...]/aho-corasick-0.7.18/Cargo.toml`
    Caused by:
      can't find library `aho_corasick`, rename file to `src/lib.rs` or specify lib.path

So, as we do not systematically use our own cargo build (we can use a
pre-built one with host-rust-bin), we can't patch cargo (even if we knew
what to do!).

Instead, we implement a lock ourselves, by wrapping the call to "cargo
vendor" with a flock(1) on cargo home.

Note: the download wrapper is already flock-ed, but it is a per-package
lock, so it does not prevent different packages from being downloaded in
parallel; if those packages need cargo vendoring, that will not be
protected by the flock on the dl wrapper. So we really do need a flock
on cargo home.

[0] https://github.com/rust-lang/cargo/issues/6930

Fixes: 8450b76918

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Moritz Bitsch <moritz@h6t.eu>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-01-14 21:00:16 +01:00
..
bzr support/download: fix git/svn corrupted cache 2021-03-19 21:22:59 +01:00
cargo-post-process support/download: fix concurrent cargo vendor 2023-01-14 21:00:16 +01:00
check-hash support/download: drop support for the 'none' hash 2022-01-11 21:58:01 +01:00
cvs support/download: fix git/svn corrupted cache 2021-03-19 21:22:59 +01:00
dl-wrapper support/download/dl-wrapper: add concept of download post-processing 2022-01-07 11:19:10 +01:00
file support/download: fix git/svn corrupted cache 2021-03-19 21:22:59 +01:00
git support/download/git: add missing "git lfs install" invocation for LFS support 2022-01-07 19:06:48 +01:00
go-post-process support/download/go-post-process: drop -o pipefail 2022-01-09 11:07:37 +01:00
helpers support/download/helpers: adjust for older coreutils versions 2022-02-11 17:25:24 +01:00
hg support/download/hg: fix broken method 2021-04-28 21:51:10 +02:00
scp support/download: fix git/svn corrupted cache 2021-03-19 21:22:59 +01:00
sftp support/download: Add SFTP support 2022-01-06 09:34:05 +01:00
svn support/download: fix git/svn corrupted cache 2021-03-19 21:22:59 +01:00
wget support/download: fix git/svn corrupted cache 2021-03-19 21:22:59 +01:00