mirror: add a smart git check
PATCH 1/1 mirror: add a smart git check
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 <[email protected]>
---
Thoughts? I think its worth the impact to increase user experience.
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
kconfigs/Kconfig.mirror +19 -5
@@ -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:
scripts/test_git_firewall.sh new file +17 -0
@@ -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
Signature · 1 line
2.42.0