lib/crate.py: additionally populate a local registry
The local registry is a more future-proof way to prevent cargo from
accessing the network during the build. Unfortunately, this is only
used during the build of cargo-native for now. The snapshot used while
building cargo-native supports using a local registry ("source
replacement") however the version of cargo supported by rust 1.10 does
not.
Until we can build a new-enough version of cargo that supports
source-replacement, we'll have to patch cargo directly to prevent it
from accessing the network. Once we do have a new-enough cargo, we can
stop populating cargo_home/registry and only create cargo_registry.
This commit is contained in:
@@ -76,6 +76,15 @@ cargo_util_do_configure () {
|
||||
printf "\"%s\"\n" "$p"
|
||||
done | sed -e 's/$/,/' >> ${CARGO_HOME}/config
|
||||
echo "]" >> ${CARGO_HOME}/config
|
||||
|
||||
# Point cargo at our local mirror of the registry
|
||||
cat >> ${CARGO_HOME}/config <<EOF
|
||||
[source.local]
|
||||
local-registry = "${WORKDIR}/cargo_registry"
|
||||
[source.crates-io]
|
||||
replace-with = "local"
|
||||
registry = "https://github.com/rust-lang/crates.io-index"
|
||||
EOF
|
||||
}
|
||||
|
||||
cargo_util_do_compile () {
|
||||
|
||||
17
lib/crate.py
17
lib/crate.py
@@ -47,6 +47,9 @@ class Crate(Wget):
|
||||
def _cargo_cache_path(self, rootdir):
|
||||
return self._cargo_path(rootdir, "cache")
|
||||
|
||||
def _cargo_registry_path(self, rootdir, component=""):
|
||||
return os.path.join(rootdir, "cargo_registry", component)
|
||||
|
||||
def supports(self, ud, d):
|
||||
"""
|
||||
Check to see if a given url is for this fetcher
|
||||
@@ -132,13 +135,18 @@ class Crate(Wget):
|
||||
super(Crate, self).unpack(ud, rootdir, d)
|
||||
|
||||
def _index_unpack(self, ud, rootdir, d):
|
||||
cargo_index = self._cargo_index_path(rootdir)
|
||||
self._index_unpack_to(ud, rootdir, d, cargo_index)
|
||||
|
||||
cargo_registry_index = self._cargo_registry_path(rootdir, "index")
|
||||
self._index_unpack_to(ud, rootdir, d, cargo_registry_index)
|
||||
|
||||
def _index_unpack_to(self, ud, rootdir, d, cargo_index):
|
||||
"""
|
||||
Unpacks the index
|
||||
"""
|
||||
thefile = ud.localpath
|
||||
|
||||
cargo_index = self._cargo_index_path(rootdir)
|
||||
|
||||
cmd = "tar -xz --no-same-owner --strip-components 1 -f %s -C %s" % (thefile, cargo_index)
|
||||
|
||||
# change to the rootdir to unpack but save the old working dir
|
||||
@@ -177,16 +185,21 @@ class Crate(Wget):
|
||||
else:
|
||||
cargo_src = self._cargo_src_path(rootdir)
|
||||
cargo_cache = self._cargo_cache_path(rootdir)
|
||||
cargo_registry = self._cargo_registry_path(rootdir)
|
||||
|
||||
cmd = "tar -xz --no-same-owner -f %s -C %s" % (thefile, cargo_src)
|
||||
|
||||
# ensure we've got these paths made
|
||||
bb.utils.mkdirhier(cargo_cache)
|
||||
bb.utils.mkdirhier(cargo_registry)
|
||||
bb.utils.mkdirhier(cargo_src)
|
||||
|
||||
bb.note("Copying %s to %s/" % (thefile, cargo_cache))
|
||||
shutil.copy(thefile, cargo_cache)
|
||||
|
||||
bb.note("Copying %s to %s/" % (thefile, cargo_registry))
|
||||
shutil.copy(thefile, cargo_registry)
|
||||
|
||||
# path it
|
||||
path = d.getVar('PATH', True)
|
||||
if path:
|
||||
|
||||
Reference in New Issue
Block a user