cargo: never contact the registry
It's forbidden to access the network during the build phase in bitbake. Since this version of cargo does not yet support source-replacement, we must patch out the behavior instead.
This commit is contained in:
committed by
Steven Walter
parent
cb753fc536
commit
1059968d25
@@ -4,6 +4,7 @@ require cargo.inc
|
|||||||
SRC_URI += " \
|
SRC_URI += " \
|
||||||
git://github.com/rust-lang/cargo.git;protocol=https;name=cargo \
|
git://github.com/rust-lang/cargo.git;protocol=https;name=cargo \
|
||||||
file://0001-disable-cargo-snapshot-fetch.patch \
|
file://0001-disable-cargo-snapshot-fetch.patch \
|
||||||
|
file://0001-Never-update-the-registry-index.patch \
|
||||||
git://github.com/rust-lang/rust-installer.git;protocol=https;name=rust-installer;destsuffix=${S}/src/rust-installer \
|
git://github.com/rust-lang/rust-installer.git;protocol=https;name=rust-installer;destsuffix=${S}/src/rust-installer \
|
||||||
"
|
"
|
||||||
# Compatible with Rust 1.10.0
|
# Compatible with Rust 1.10.0
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
From 27df8ab04275dfd715d1756fc517bb0323f1b210 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Steven Walter <stevenrwalter@gmail.com>
|
||||||
|
Date: Fri, 2 Sep 2016 14:02:03 -0400
|
||||||
|
Subject: [PATCH] Never update the registry index
|
||||||
|
|
||||||
|
Bitbake will fetch the index for us so that we needn't do network IO
|
||||||
|
during a build
|
||||||
|
---
|
||||||
|
src/cargo/ops/cargo_run.rs | 2 +-
|
||||||
|
src/cargo/sources/registry.rs | 34 +---------------------------------
|
||||||
|
2 files changed, 2 insertions(+), 34 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs
|
||||||
|
index 6764118..379b98b 100644
|
||||||
|
--- a/src/cargo/ops/cargo_run.rs
|
||||||
|
+++ b/src/cargo/ops/cargo_run.rs
|
||||||
|
@@ -1,7 +1,7 @@
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use ops::{self, CompileFilter};
|
||||||
|
-use util::{self, CargoResult, process, ProcessError};
|
||||||
|
+use util::{self, CargoResult, ProcessError};
|
||||||
|
use core::Package;
|
||||||
|
|
||||||
|
pub fn run(manifest_path: &Path,
|
||||||
|
diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs
|
||||||
|
index 614d654..a0c7fe6 100644
|
||||||
|
--- a/src/cargo/sources/registry.rs
|
||||||
|
+++ b/src/cargo/sources/registry.rs
|
||||||
|
@@ -166,7 +166,6 @@ use std::path::{PathBuf, Path};
|
||||||
|
|
||||||
|
use curl::http;
|
||||||
|
use flate2::read::GzDecoder;
|
||||||
|
-use git2;
|
||||||
|
use rustc_serialize::hex::ToHex;
|
||||||
|
use rustc_serialize::json;
|
||||||
|
use tar::Archive;
|
||||||
|
@@ -174,7 +173,7 @@ use url::Url;
|
||||||
|
|
||||||
|
use core::{Source, SourceId, PackageId, Package, Summary, Registry};
|
||||||
|
use core::dependency::{Dependency, DependencyInner, Kind};
|
||||||
|
-use sources::{PathSource, git};
|
||||||
|
+use sources::PathSource;
|
||||||
|
use util::{CargoResult, Config, internal, ChainError, ToUrl, human};
|
||||||
|
use util::{hex, Sha256, paths, Filesystem, FileLock};
|
||||||
|
use ops;
|
||||||
|
@@ -464,38 +463,7 @@ impl<'cfg> RegistrySource<'cfg> {
|
||||||
|
|
||||||
|
/// Actually perform network operations to update the registry
|
||||||
|
fn do_update(&mut self) -> CargoResult<()> {
|
||||||
|
- if self.updated {
|
||||||
|
- return Ok(())
|
||||||
|
- }
|
||||||
|
- try!(self.checkout_path.create_dir());
|
||||||
|
- let lock = try!(self.checkout_path.open_rw(Path::new(INDEX_LOCK),
|
||||||
|
- self.config,
|
||||||
|
- "the registry index"));
|
||||||
|
- let path = lock.path().parent().unwrap();
|
||||||
|
-
|
||||||
|
- try!(self.config.shell().status("Updating",
|
||||||
|
- format!("registry `{}`", self.source_id.url())));
|
||||||
|
- let repo = try!(git2::Repository::open(path).or_else(|_| {
|
||||||
|
- let _ = lock.remove_siblings();
|
||||||
|
- git2::Repository::init(path)
|
||||||
|
- }));
|
||||||
|
-
|
||||||
|
- // git fetch origin
|
||||||
|
- let url = self.source_id.url().to_string();
|
||||||
|
- let refspec = "refs/heads/*:refs/remotes/origin/*";
|
||||||
|
-
|
||||||
|
- try!(git::fetch(&repo, &url, refspec, &self.config).chain_error(|| {
|
||||||
|
- internal(format!("failed to fetch `{}`", url))
|
||||||
|
- }));
|
||||||
|
-
|
||||||
|
- // git reset --hard origin/master
|
||||||
|
- let reference = "refs/remotes/origin/master";
|
||||||
|
- let oid = try!(repo.refname_to_id(reference));
|
||||||
|
- trace!("[{}] updating to rev {}", self.source_id, oid);
|
||||||
|
- let object = try!(repo.find_object(oid, None));
|
||||||
|
- try!(repo.reset(&object, git2::ResetType::Hard, None));
|
||||||
|
self.updated = true;
|
||||||
|
- self.cache.clear();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
||||||
Reference in New Issue
Block a user