From 783f742080eb8a61add0cd17bf04cbfc46f97e81 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 27 Mar 2015 08:25:25 +0100 Subject: [PATCH] net installer: ask for an HTTP proxy upon pacman failure Ideally, we would test for a good indicator that a proxy is required before we ask for an HTTP proxy. Alas, this developer has no access to a setup that requires a proxy to access the web, and was unable to get ahold of that information otherwise. So let's just simply always ask for an HTTP proxy when pacman failed to synchronize and/or update the msys2-runtime package. For good measure, add a script to etc/profile.d/ that will configure the proxy for Git Bash sessions, but only when we set the environment variables ourselves; If the http_proxy variable was set appropriately already outside of the installation script, we do not need to tell the Bash to set them. Signed-off-by: Johannes Schindelin --- net-installer/setup-git-sdk.bat | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/net-installer/setup-git-sdk.bat b/net-installer/setup-git-sdk.bat index c3f17a08be..a3263801c8 100644 --- a/net-installer/setup-git-sdk.bat +++ b/net-installer/setup-git-sdk.bat @@ -22,6 +22,21 @@ @EXIT 1 ) +@REM Maybe we need a proxy? +@IF %counter% GEQ 2 ( + @ECHO. + @ECHO There was a problem accessing the MSys2 repositories + @ECHO If your setup requires an HTTP proxy to access the web, + @ECHO please specify it here, otherwise leave it empty. + @ECHO. + @SET /p proxy= "HTTP proxy: " +) +@REM Check the proxy variable here because of delayed expansion +@IF NOT "%proxy%" == "" ( + @SET http_proxy=%proxy% + @SET https_proxy=%proxy% +) + @REM update the Pacman package indices first, then force-install msys2-runtime @REM (we ship with a stripped-down msys2-runtime, gpg and pacman), so that @REM pacman's post-install scripts run without complaining about heap problems @@ -71,6 +86,16 @@ CALL %cwd%\autorebase.bat ) +@REM If an HTTP proxy is requires, configure it for Git Bash sessions, +@REM but only if the environment variable was not already set globally +@IF DEFINED proxy ( + @ECHO http_proxy=%proxy% > etc\profile.d\proxy.sh + @ECHO https_proxy=%proxy% >> etc\profile.d\proxy.sh + @ECHO export http_proxy https_proxy >> etc\profile.d\proxy.sh + @ECHO. + @ECHO Installed /etc/profile.d/proxy.sh to set proxy in Git Bash +) + @REM Install shortcut on the desktop @bash --login -c 'SHORTCUT="$HOME/Desktop/Git SDK @@BITNESS@@-bit.lnk"; test -f "$SHORTCUT" ^|^| create-shortcut.exe --icon-file /msys2.ico --work-dir / /mingw@@BITNESS@@_shell.bat "$SHORTCUT"'