diff mbox series

cargo.bbclass: use offline mode for building

Message ID 20230315074851.26633-1-frederic.martinsons@gmail.com
State Accepted, archived
Commit 8e9ec03c73e8c09e223d6f6cce297df363991350
Headers show
Series cargo.bbclass: use offline mode for building | expand

Commit Message

Frédéric Martinsons March 15, 2023, 7:48 a.m. UTC
From: Frederic Martinsons <frederic.martinsons@gmail.com>

There should not be any network access during the build step so
specify this explicitely to cargo.
This will allow better error message, e.g:

| Caused by:
|  can't checkout from 'ssh://git@.../fmartinsons/zbus-git-dep-test.git': you are in  the offline mode (--offline)

Instead of

|   Updating git repository `ssh://git@.../fmartinsons/zbus-git-dep-test.git`
| warning: spurious network error (2 tries remaining): failed to resolve address for gitlab.com: Temporary failure in name resolution;class=Net (12)

Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
---
 meta/classes-recipe/cargo.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Kiernan March 15, 2023, 3:07 p.m. UTC | #1
On Wed, Mar 15, 2023 at 7:49 AM Frederic Martinsons
<frederic.martinsons@gmail.com> wrote:
>
> From: Frederic Martinsons <frederic.martinsons@gmail.com>
>
> There should not be any network access during the build step so
> specify this explicitely to cargo.
> This will allow better error message, e.g:
>
> | Caused by:
> |  can't checkout from 'ssh://git@.../fmartinsons/zbus-git-dep-test.git': you are in  the offline mode (--offline)
>
> Instead of
>
> |   Updating git repository `ssh://git@.../fmartinsons/zbus-git-dep-test.git`
> | warning: spurious network error (2 tries remaining): failed to resolve address for gitlab.com: Temporary failure in name resolution;class=Net (12)
>
> Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>

Tested-by: Alex Kiernan <alex.kiernan@gmail.com>

> ---
>  meta/classes-recipe/cargo.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes-recipe/cargo.bbclass b/meta/classes-recipe/cargo.bbclass
> index 93e185f2c9..7a8cc1e751 100644
> --- a/meta/classes-recipe/cargo.bbclass
> +++ b/meta/classes-recipe/cargo.bbclass
> @@ -39,7 +39,7 @@ MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml"
>
>  RUSTFLAGS ??= ""
>  BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}"
> -CARGO_BUILD_FLAGS = "-v --target ${RUST_HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}"
> +CARGO_BUILD_FLAGS = "-v --offline --target ${RUST_HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}"
>
>  # This is based on the content of CARGO_BUILD_FLAGS and generally will need to
>  # change if CARGO_BUILD_FLAGS changes.
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#178525): https://lists.openembedded.org/g/openembedded-core/message/178525
> Mute This Topic: https://lists.openembedded.org/mt/97622913/3618097
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kiernan@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/cargo.bbclass b/meta/classes-recipe/cargo.bbclass
index 93e185f2c9..7a8cc1e751 100644
--- a/meta/classes-recipe/cargo.bbclass
+++ b/meta/classes-recipe/cargo.bbclass
@@ -39,7 +39,7 @@  MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml"
 
 RUSTFLAGS ??= ""
 BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}"
-CARGO_BUILD_FLAGS = "-v --target ${RUST_HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}"
+CARGO_BUILD_FLAGS = "-v --offline --target ${RUST_HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}"
 
 # This is based on the content of CARGO_BUILD_FLAGS and generally will need to
 # change if CARGO_BUILD_FLAGS changes.