[1/4] cargo: don't update git submodules in --offline mode

Message ID 20220606132653.60232-2-brgl@bgdev.pl
State New
Headers show
Series cargo: improve the build process and add a new recipe | expand

Commit Message

Bartosz Golaszewski June 6, 2022, 1:26 p.m. UTC
This adds a patch to the cargo recipe that prohibits cargo from trying
to update git submodules when running in --offline mode.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 meta/recipes-devtools/cargo/cargo.inc         |  2 +-
 ...-t-update-submodules-in-offline-mode.patch | 32 +++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/cargo/cargo/0001-git-don-t-update-submodules-in-offline-mode.patch

Comments

Alexander Kanavin June 6, 2022, 3:20 p.m. UTC | #1
I think you need to get this merged upstream first, seems like neither
party has a complete understanding of what is going on and whether the
patch is correct.

Alex

On Mon, 6 Jun 2022 at 15:27, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> This adds a patch to the cargo recipe that prohibits cargo from trying
> to update git submodules when running in --offline mode.
>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
> ---
>  meta/recipes-devtools/cargo/cargo.inc         |  2 +-
>  ...-t-update-submodules-in-offline-mode.patch | 32 +++++++++++++++++++
>  2 files changed, 33 insertions(+), 1 deletion(-)
>  create mode 100644 meta/recipes-devtools/cargo/cargo/0001-git-don-t-update-submodules-in-offline-mode.patch
>
> diff --git a/meta/recipes-devtools/cargo/cargo.inc b/meta/recipes-devtools/cargo/cargo.inc
> index 607c51fc3d..6ab4e0a5f7 100644
> --- a/meta/recipes-devtools/cargo/cargo.inc
> +++ b/meta/recipes-devtools/cargo/cargo.inc
> @@ -11,7 +11,7 @@ LIC_FILES_CHKSUM = " \
>      file://LICENSE-THIRD-PARTY;md5=f257ad009884cb88a3a87d6920e7180a \
>  "
>
> -
> +SRC_URI += "file://0001-git-don-t-update-submodules-in-offline-mode.patch"
>  S = "${RUSTSRC}/src/tools/cargo"
>  CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor"
>  EXCLUDE_FROM_WORLD = "1"
> diff --git a/meta/recipes-devtools/cargo/cargo/0001-git-don-t-update-submodules-in-offline-mode.patch b/meta/recipes-devtools/cargo/cargo/0001-git-don-t-update-submodules-in-offline-mode.patch
> new file mode 100644
> index 0000000000..d138c4b911
> --- /dev/null
> +++ b/meta/recipes-devtools/cargo/cargo/0001-git-don-t-update-submodules-in-offline-mode.patch
> @@ -0,0 +1,32 @@
> +From 4768c657905356da417f50d3cbb203c76baf1ab2 Mon Sep 17 00:00:00 2001
> +From: Bartosz Golaszewski <brgl@bgdev.pl>
> +Date: Mon, 6 Jun 2022 12:13:02 +0200
> +Subject: [PATCH] git: don't update submodules in offline mode
> +
> +When we're running in --offline mode, don't try to update git
> +submodules or else we're bail out with a network error if it's actually
> +inaccessible.
> +---
> +Upstream-Status: Submitted [https://github.com/rust-lang/cargo/pull/10730]
> +
> + src/tools/cargo/src/cargo/sources/git/utils.rs | 4 +++-
> + 1 file changed, 3 insertions(+), 1 deletion(-)
> +
> +diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs
> +index 4eafae1c9..9ed991e36 100644
> +--- a/src/cargo/sources/git/utils.rs
> ++++ b/src/cargo/sources/git/utils.rs
> +@@ -177,7 +177,9 @@ impl GitDatabase {
> +             Some(c) => c,
> +             None => GitCheckout::clone_into(dest, self, rev, cargo_config)?,
> +         };
> +-        checkout.update_submodules(cargo_config)?;
> ++        if !cargo_config.offline() {
> ++            checkout.update_submodules(cargo_config)?;
> ++        }
> +         Ok(checkout)
> +     }
> +
> +--
> +2.34.1
> +
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#166628): https://lists.openembedded.org/g/openembedded-core/message/166628
> Mute This Topic: https://lists.openembedded.org/mt/91576742/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>

Patch

diff --git a/meta/recipes-devtools/cargo/cargo.inc b/meta/recipes-devtools/cargo/cargo.inc
index 607c51fc3d..6ab4e0a5f7 100644
--- a/meta/recipes-devtools/cargo/cargo.inc
+++ b/meta/recipes-devtools/cargo/cargo.inc
@@ -11,7 +11,7 @@  LIC_FILES_CHKSUM = " \
     file://LICENSE-THIRD-PARTY;md5=f257ad009884cb88a3a87d6920e7180a \
 "
 
-
+SRC_URI += "file://0001-git-don-t-update-submodules-in-offline-mode.patch"
 S = "${RUSTSRC}/src/tools/cargo"
 CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor"
 EXCLUDE_FROM_WORLD = "1"
diff --git a/meta/recipes-devtools/cargo/cargo/0001-git-don-t-update-submodules-in-offline-mode.patch b/meta/recipes-devtools/cargo/cargo/0001-git-don-t-update-submodules-in-offline-mode.patch
new file mode 100644
index 0000000000..d138c4b911
--- /dev/null
+++ b/meta/recipes-devtools/cargo/cargo/0001-git-don-t-update-submodules-in-offline-mode.patch
@@ -0,0 +1,32 @@ 
+From 4768c657905356da417f50d3cbb203c76baf1ab2 Mon Sep 17 00:00:00 2001
+From: Bartosz Golaszewski <brgl@bgdev.pl>
+Date: Mon, 6 Jun 2022 12:13:02 +0200
+Subject: [PATCH] git: don't update submodules in offline mode
+
+When we're running in --offline mode, don't try to update git
+submodules or else we're bail out with a network error if it's actually
+inaccessible.
+---
+Upstream-Status: Submitted [https://github.com/rust-lang/cargo/pull/10730]
+
+ src/tools/cargo/src/cargo/sources/git/utils.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs
+index 4eafae1c9..9ed991e36 100644
+--- a/src/cargo/sources/git/utils.rs
++++ b/src/cargo/sources/git/utils.rs
+@@ -177,7 +177,9 @@ impl GitDatabase {
+             Some(c) => c,
+             None => GitCheckout::clone_into(dest, self, rev, cargo_config)?,
+         };
+-        checkout.update_submodules(cargo_config)?;
++        if !cargo_config.offline() {
++            checkout.update_submodules(cargo_config)?;
++        }
+         Ok(checkout)
+     }
+ 
+-- 
+2.34.1
+