Skip to content

Commit 9fac47a

Browse files
authored
Merge pull request #470 from jmt-lab/twoliter-cargo-vendor
fix: move vendoring of cargo dependencies to cargo vendor
2 parents 560d67f + 077bef7 commit 9fac47a

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

twoliter/embedded/Makefile.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,20 @@ dependencies = ["setup"]
354354
script_runner = "bash"
355355
script = [
356356
'''
357+
declare -a CARGO_MANIFESTS
358+
# We make sure there is an empty folder at least here
359+
# to make the docker mount happy later on
360+
mkdir -p .cargo/vendor
357361
for ws in sources variants .; do
358-
[ -s "${BUILDSYS_ROOT_DIR}/${ws}/Cargo.toml" ] || continue
359-
cargo fetch --locked --manifest-path "${BUILDSYS_ROOT_DIR}/${ws}/Cargo.toml"
362+
[ -s "${BUILDSYS_ROOT_DIR}/${ws}/Cargo.lock" ] || continue
363+
CARGO_MANIFESTS+=(--sync "${BUILDSYS_ROOT_DIR}/${ws}/Cargo.toml")
360364
done
365+
cargo vendor --locked --no-delete --versioned-dirs --respect-source-config ${CARGO_MANIFESTS[@]} .cargo/vendor > .cargo/config.toml 2> .cargo/vendor.log || {
366+
echo "vendoring of cargo dependencies failed"
367+
cat .cargo/vendor.log
368+
exit 1
369+
}
370+
rm .cargo/vendor.log
361371
362372
chmod -R o+r ${CARGO_HOME}
363373
'''

twoliter/embedded/build.Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ RUN --mount=target=/host \
109109
rm /bypass
110110

111111
USER builder
112-
RUN --mount=source=.cargo,target=/home/builder/.cargo \
112+
# We only mount the config.toml and the vendor directory instead of the whole .cargo directory
113+
# because the .git and .registry directories are specific to the version of cargo and can cause
114+
# incapatibility between the host cargo and the cargo in the sdk
115+
RUN --mount=source=.cargo/config.toml,target=/home/builder/rpmbuild/.cargo/config.toml \
116+
--mount=source=.cargo/vendor,target=/home/builder/rpmbuild/.cargo/vendor \
113117
--mount=type=cache,target=/home/builder/.cache,from=cache,source=/cache \
114118
--mount=source=sources,target=/home/builder/rpmbuild/BUILD/sources \
115119
--mount=target=/host \

0 commit comments

Comments
 (0)