kdevops.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: kdevops@lists.linux.dev, da.gomez@samsung.com, p.raghav@samsung.com
Cc: Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 1/6] mirror: add a smart git check
Date: Thu, 25 Jan 2024 12:35:02 -0800	[thread overview]
Message-ID: <20240125203507.430113-2-mcgrof@kernel.org> (raw)
In-Reply-To: <20240125203507.430113-1-mcgrof@kernel.org>

If you are on a firewall chances are you will fail miserably with the
default mirroring options and this is a terrible experience as the
git protocol will fail. The git protocol is nice and efficient so
we don't want to change the default to https.

So add a smart git check on make menuconfig which will test if the git
protocol will work, otherwise disable all git options. This incurs
a penalty on checking if the git protocol works once on make menuconfig
with a timeout of 3 seconds. This hack only works on systems which have
netcat installed, otherwise we assume git will work too. Ie, if you want
this smart heuristic install netcat.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 kconfigs/Kconfig.mirror      | 24 +++++++++++++++++++-----
 scripts/test_git_firewall.sh | 17 +++++++++++++++++
 2 files changed, 36 insertions(+), 5 deletions(-)
 create mode 100755 scripts/test_git_firewall.sh

diff --git a/kconfigs/Kconfig.mirror b/kconfigs/Kconfig.mirror
index 1b237c7c32c5..3f0b15859319 100644
--- a/kconfigs/Kconfig.mirror
+++ b/kconfigs/Kconfig.mirror
@@ -47,9 +47,14 @@ config INSTALL_LOCAL_LINUX_MIRROR
 	  first linux-mirror setup and just use USE_LOCAL_LINUX_MIRROR so to
 	  make use of the mirror.
 
+config MIRROR_GIT_WORKS
+	bool
+	default $(shell, ./scripts/test_git_firewall.sh)
+
 choice
 	prompt "Linux mirror protocol"
-	default MIRROR_TORVALDS_GIT
+	default MIRROR_TORVALDS_GIT if MIRROR_GIT_WORKS
+	default MIRROR_TORVALDS_HTTPS if !MIRROR_GIT_WORKS
 	depends on INSTALL_LOCAL_LINUX_MIRROR
 
 config MIRROR_TORVALDS_HTTPS
@@ -70,6 +75,7 @@ config MIRROR_TORVALDS_HTTPS_GOOGLE
 
 config MIRROR_TORVALDS_GIT
 	bool "Git"
+	depends on MIRROR_GIT_WORKS
 	help
 	  If you enable this option then git:// protocol will be used as the
 	  source of the mirror. The URL is:
@@ -105,7 +111,8 @@ config MIRROR_KDEVOPS_LINUS_URL
 
 choice
 	prompt "Linux Next mirror protocol/source"
-	default MIRROR_NEXT_GIT
+	default MIRROR_NEXT_GIT if MIRROR_GIT_WORKS
+	default MIRROR_NEXT_HTTPS if !MIRROR_GIT_WORKS
 	depends on INSTALL_LOCAL_LINUX_MIRROR
 
 config MIRROR_NEXT_HTTPS
@@ -126,6 +133,7 @@ config MIRROR_NEXT_HTTPS_GOOGLE
 
 config MIRROR_NEXT_GIT
 	bool "Git"
+	depends on MIRROR_GIT_WORKS
 	help
 	  If you enable this option then Git protocol will be used as the
 	  source of the mirror. The URL is:
@@ -142,7 +150,8 @@ config MIRROR_NEXT_URL
 
 choice
 	prompt "Linux mcgrof's linux-next fork protocol/source"
-	default MIRROR_MCGROF_GIT
+	default MIRROR_MCGROF_GIT if MIRROR_GIT_WORKS
+	default MIRROR_MCGROF_HTTPS if !MIRROR_GIT_WORKS
 	depends on INSTALL_LOCAL_LINUX_MIRROR
 
 config MIRROR_MCGROF_HTTPS
@@ -163,6 +172,7 @@ config MIRROR_MCGROF_HTTPS_GOOGLE
 
 config MIRROR_MCGROF_GIT
 	bool "Git"
+	depends on MIRROR_GIT_WORKS
 	help
 	  If you enable this option then Git protocol will be used as the
 	  source of the mirror. The URL is:
@@ -179,7 +189,8 @@ config MIRROR_MCGROF_URL
 
 choice
 	prompt "Linux mcgrof's linux fork protocol/source"
-	default MIRROR_MCGROF_LINUS_GIT
+	default MIRROR_MCGROF_LINUS_GIT if MIRROR_GIT_WORKS
+	default MIRROR_MCGROF_LINUS_HTTPS if !MIRROR_GIT_WORKS
 	depends on INSTALL_LOCAL_LINUX_MIRROR
 
 config MIRROR_MCGROF_LINUS_HTTPS
@@ -200,6 +211,7 @@ config MIRROR_MCGROF_LINUS_HTTPS_GOOGLE
 
 config MIRROR_MCGROF_LINUS_GIT
 	bool "Git"
+	depends on MIRROR_GIT_WORKS
 	help
 	  If you enable this option then Git protocol will be used as the
 	  source of the mirror. The URL is:
@@ -216,7 +228,8 @@ config MIRROR_MCGROF_LINUS_URL
 
 choice
 	prompt "Linux stable mirror protocol/source"
-	default MIRROR_STABLE_GIT
+	default MIRROR_STABLE_GIT if MIRROR_GIT_WORKS
+	default MIRROR_STABLE_HTTPS if !MIRROR_GIT_WORKS
 	depends on INSTALL_LOCAL_LINUX_MIRROR
 
 config MIRROR_STABLE_HTTPS
@@ -237,6 +250,7 @@ config MIRROR_STABLE_HTTPS_GOOGLE
 
 config MIRROR_STABLE_GIT
 	bool "Git"
+	depends on MIRROR_GIT_WORKS
 	help
 	  If you enable this option then Git protocol will be used as the
 	  source of the mirror. The URL is:
diff --git a/scripts/test_git_firewall.sh b/scripts/test_git_firewall.sh
new file mode 100755
index 000000000000..019151d5ab9d
--- /dev/null
+++ b/scripts/test_git_firewall.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+CUR_VAL=$1
+which nc &> /dev/null
+if [[ $? -ne 0 ]]; then
+	echo y
+	exit
+fi
+
+# change to port 9419 to verify this will fail if your firewall does not
+# allow git access.
+nc -v -z -w 3 git.kernel.org 9418 &> /dev/null
+if [[ $? -eq 0 ]]; then
+	echo y
+else
+	echo n
+fi
-- 
2.42.0


  reply	other threads:[~2024-01-25 20:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 20:35 [PATCH 0/6] Fix ordering for systemd remote journal support Luis Chamberlain
2024-01-25 20:35 ` Luis Chamberlain [this message]
2024-01-25 20:35 ` [PATCH 2/6] bringup: split provisioning into 2 steps Luis Chamberlain
2024-01-25 20:35 ` [PATCH 3/6] bringup: share bringup method targe and agument by two steps Luis Chamberlain
2024-01-25 20:35 ` [PATCH 4/6] provision: move all provisioning things to its own Makefile Luis Chamberlain
2024-01-25 20:35 ` [PATCH 5/6] bringup: move journal-server setup early Luis Chamberlain
2024-01-25 20:35 ` [PATCH 6/6] journal-server: fix by adjusting ordering Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240125203507.430113-2-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=da.gomez@samsung.com \
    --cc=kdevops@lists.linux.dev \
    --cc=p.raghav@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).