diff -Nru cargo-0.37.0/debian/changelog cargo-0.37.0/debian/changelog --- cargo-0.37.0/debian/changelog 2019-08-18 21:19:40.000000000 +0200 +++ cargo-0.37.0/debian/changelog 2019-12-03 07:14:56.000000000 +0100 @@ -1,3 +1,11 @@ +cargo (0.37.0-3ubuntu1~19.04.2) disco; urgency=medium + + * Cherry-pick upstream commit to fix build failures when using cargo in + sbuild (LP: #1841191, LP: #1850651) + - add debian/patches/dont-fail-to-acquire-readonly-lock.patch + + -- Olivier Tilloy Tue, 03 Dec 2019 07:14:56 +0100 + cargo (0.37.0-3ubuntu1~19.04.1) disco; urgency=medium * Backport to Disco. diff -Nru cargo-0.37.0/debian/patches/dont-fail-to-acquire-readonly-lock.patch cargo-0.37.0/debian/patches/dont-fail-to-acquire-readonly-lock.patch --- cargo-0.37.0/debian/patches/dont-fail-to-acquire-readonly-lock.patch 1970-01-01 01:00:00.000000000 +0100 +++ cargo-0.37.0/debian/patches/dont-fail-to-acquire-readonly-lock.patch 2019-12-03 07:14:56.000000000 +0100 @@ -0,0 +1,75 @@ +From e46e185e4d007daa1a73f3e99e051d9ad039f5a6 Mon Sep 17 00:00:00 2001 +From: Alex Crichton +Date: Fri, 19 Jul 2019 07:56:33 -0700 +Subject: [PATCH] Don't fail if we can't acquire readonly lock + +This commit updates support from #6940 to not only gracefully handle +situations where the lock can be acquired in readonly but not read/write +mode but also handle situations where even a readonly lock can't be +acquired. If a readonly lock can't be acquired (and the read/write +failed) then we likely can't touch anything in the directory, so there's +no value gained from locking anyway. + +Closes #7147 +--- + src/cargo/util/config.rs | 36 +++++++++++++++++------------------- + 1 file changed, 17 insertions(+), 19 deletions(-) + +diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs +index 54ca624c80..4ae67cb36b 100644 +--- a/src/cargo/util/config.rs ++++ b/src/cargo/util/config.rs +@@ -83,7 +83,7 @@ pub struct Config { + updated_sources: LazyCell>>, + /// Lock, if held, of the global package cache along with the number of + /// acquisitions so far. +- package_cache_lock: RefCell>, ++ package_cache_lock: RefCell, usize)>>, + } + + impl Config { +@@ -887,28 +887,26 @@ impl Config { + // First, attempt to open an exclusive lock which is in general + // the purpose of this lock! + // +- // If that fails because of a readonly filesystem, though, then +- // we don't want to fail because it's a readonly filesystem. In +- // some situations Cargo is prepared to have a readonly +- // filesystem yet still work since it's all been pre-downloaded +- // and/or pre-unpacked. In these situations we want to keep +- // Cargo running if possible, so if it's a readonly filesystem +- // switch to a shared lock which should hopefully succeed so we +- // can continue. ++ // If that fails because of a readonly filesystem or a ++ // permission error, though, then we don't really want to fail ++ // just because of this. All files that this lock protects are ++ // in subfolders, so they're assumed by Cargo to also be ++ // readonly or have invalid permissions for us to write to. If ++ // that's the case, then we don't really need to grab a lock in ++ // the first place here. + // +- // Note that the package cache lock protects files in the same +- // directory, so if it's a readonly filesystem we assume that +- // the entire package cache is readonly, so we're just acquiring +- // something to prove it works, we're not actually doing any +- // synchronization at that point. ++ // Despite this we attempt to grab a readonly lock. This means ++ // that if our read-only folder is shared read-write with ++ // someone else on the system we should synchronize with them, ++ // but if we can't even do that then we did our best and we just ++ // keep on chugging elsewhere. + match self.home_path.open_rw(path, self, desc) { +- Ok(lock) => *slot = Some((lock, 1)), ++ Ok(lock) => *slot = Some((Some(lock), 1)), + Err(e) => { + if maybe_readonly(&e) { +- if let Ok(lock) = self.home_path.open_ro(path, self, desc) { +- *slot = Some((lock, 1)); +- return Ok(PackageCacheLock(self)); +- } ++ let lock = self.home_path.open_ro(path, self, desc).ok(); ++ *slot = Some((lock, 1)); ++ return Ok(PackageCacheLock(self)); + } + + Err(e).chain_err(|| "failed to acquire package cache lock")?; diff -Nru cargo-0.37.0/debian/patches/series cargo-0.37.0/debian/patches/series --- cargo-0.37.0/debian/patches/series 2019-08-18 06:14:25.000000000 +0200 +++ cargo-0.37.0/debian/patches/series 2019-12-03 07:14:56.000000000 +0100 @@ -5,3 +5,4 @@ disable-fetch-tests-on-non-x86.patch disable-tool_paths-custom_runner.patch disable-large_conflict_cache-test-on-non-x86.patch +dont-fail-to-acquire-readonly-lock.patch