Skip to content

Commit 1370d95

Browse files
committed
Merge branch 'sdk-via-ntlm-proxy'
This topic branch makes the Git SDK work even when there is a proxy requiring NTLM authentication. It will still try to access the Pacman repositories directly, but then ask for the proxy and use curl.exe to access the internet through the proxy, via all methods known to cURL. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 57a73d2 + e37f415 commit 1370d95

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
/portable/root/bin/
1515
/portable/root/cmd/
1616
/portable/root/etc/
17+
/sdk-installer/root/

sdk-installer/release.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,39 @@ esac
2828
GIT_BRANCH="${2:-master}"
2929
GIT_CLONE_URL=https://github.com/git-for-windows/git
3030

31+
FAKEROOTDIR="$(cd "$(dirname "$0")" && pwd)/root"
3132
TARGET="$HOME"/git-sdk-installer-"$1"-$BITNESS.7z.exe
3233
OPTS7="-m0=lzma -mx=9 -md=64M"
3334
TMPPACK=/tmp.7z
3435
SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd)"
3536

37+
mkdir -p "$FAKEROOTDIR/usr/bin" "$FAKEROOTDIR/etc" ||
38+
die "Could not create fake root directory"
39+
3640
sed -e "s|@@ARCH@@|$ARCH|g" \
3741
-e "s|@@BITNESS@@|$BITNESS|g" \
3842
-e "s|@@GIT_BRANCH@@|$GIT_BRANCH|g" \
3943
-e "s|@@GIT_CLONE_URL@@|$GIT_CLONE_URL|g" \
40-
< "$SCRIPT_PATH"/setup-git-sdk.bat > /setup-git-sdk.bat ||
44+
<"$SCRIPT_PATH"/setup-git-sdk.bat >"$FAKEROOTDIR"/setup-git-sdk.bat ||
4145
die "Could not generate setup script"
4246

47+
cp /usr/bin/dash.exe "$FAKEROOTDIR/usr/bin/sh.exe" &&
48+
sed -e 's/^#\(XferCommand.*curl\).*/\1 --anyauth -C - -s -L -f %u >%o/' \
49+
</etc/pacman.conf >"$FAKEROOTDIR/etc/pacman.conf.proxy" ||
50+
die "Could not copy extra files into fake root"
51+
4352
fileList="$(cd / && echo \
4453
etc/pacman.* \
45-
usr/bin/gpg.exe \
4654
usr/bin/pacman.exe \
47-
$(ldd /usr/bin/gpg.exe |
48-
sed -n 's/.* \/\(usr\/bin\/.*\.dll\) .*/\1/p') \
49-
usr/bin/msys-crypto-*.dll \
50-
usr/bin/msys-ssl-*.dll \
55+
usr/bin/curl.exe \
56+
usr/bin/gpg.exe \
57+
$(ldd /usr/bin/gpg.exe /usr/bin/curl.exe |
58+
sed -n 's/.* \/\(usr\/bin\/.*\.dll\) .*/\1/p' |
59+
sort |
60+
uniq) \
5161
usr/ssl/certs/ca-bundle.crt \
52-
var/lib/pacman \
53-
setup-git-sdk.bat)"
62+
var/lib/pacman)
63+
$FAKEROOTDIR/setup-git-sdk.bat $FAKEROOTDIR/etc $FAKEROOTDIR/usr"
5464

5565
type 7za ||
5666
pacman -Sy --noconfirm p7zip ||

sdk-installer/setup-git-sdk.bat

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
@SET /A counter=0
1717
:INSTALL_RUNTIME
1818
@SET /A counter+=1
19-
@IF %counter% GEQ 5 (
19+
@IF %counter% GEQ 5 @(
2020
@ECHO Could not install msys2-runtime
2121
@PAUSE
2222
@EXIT 1
2323
)
2424

2525
@REM Maybe we need a proxy?
26-
@IF %counter% GEQ 2 (
26+
@IF %counter% GEQ 2 @(
2727
@ECHO.
2828
@ECHO There was a problem accessing the MSys2 repositories
2929
@ECHO If your setup requires an HTTP proxy to access the web,
@@ -32,43 +32,46 @@
3232
@SET /p proxy= "HTTP proxy: "
3333
)
3434
@REM Check the proxy variable here because of delayed expansion
35-
@IF NOT "%proxy%" == "" (
35+
@IF NOT "%proxy%" == "" @(
3636
@SET http_proxy=%proxy%
3737
@SET https_proxy=%proxy%
38+
@IF %counter% EQU 2 @(
39+
@COPY "%cwd%"\etc\pacman.conf.proxy "%cwd%"\etc\pacman.conf
40+
)
3841
)
3942

4043
@REM update the Pacman package indices first, then force-install msys2-runtime
4144
@REM (we ship with a stripped-down msys2-runtime, gpg and pacman), so that
4245
@REM pacman's post-install scripts run without complaining about heap problems
43-
@%cwd%\usr\bin\pacman -Sy --force --noconfirm msys2-runtime
46+
@"%cwd%"\usr\bin\pacman -Sy --force --noconfirm msys2-runtime
4447

4548
@IF ERRORLEVEL 1 GOTO INSTALL_RUNTIME
4649

4750
@SET /A counter=0
4851
:INSTALL_PACMAN
4952
@SET /A counter+=1
50-
@IF %counter% GEQ 5 (
53+
@IF %counter% GEQ 5 @(
5154
@ECHO Could not install pacman
5255
@PAUSE
5356
@EXIT 1
5457
)
5558

5659
@REM next, force update pacman, but first we need bash and info for that.
57-
@%cwd%\usr\bin\pacman -S --force --noconfirm bash info pacman
60+
@"%cwd%"\usr\bin\pacman -S --force --noconfirm bash info pacman
5861

5962
@IF ERRORLEVEL 1 GOTO INSTALL_PACMAN
6063

6164
@SET /A counter=0
6265
:INSTALL_REST
6366
@SET /A counter+=1
64-
@IF %counter% GEQ 5 (
67+
@IF %counter% GEQ 5 @(
6568
@ECHO Could not install the remaining packages
6669
@PAUSE
6770
@EXIT 1
6871
)
6972

7073
@REM now update the rest
71-
@%cwd%\usr\bin\pacman -S --force --noconfirm ^
74+
@"%cwd%"\usr\bin\pacman -S --force --noconfirm ^
7275
base python less openssh patch make tar diffutils ca-certificates ^
7376
git perl-Error perl perl-Authen-SASL perl-libwww perl-MIME-tools ^
7477
perl-Net-SMTP-SSL perl-TermReadKey dos2unix asciidoc xmlto ^
@@ -82,14 +85,14 @@
8285
@IF ERRORLEVEL 1 GOTO INSTALL_REST
8386

8487
@REM Avoid overlapping address ranges
85-
@IF MINGW32 == %MSYSTEM% (
88+
@IF MINGW32 == %MSYSTEM% @(
8689
ECHO Auto-rebasing .dll files
87-
CALL %cwd%\autorebase.bat
90+
CALL "%cwd%"\autorebase.bat
8891
)
8992

9093
@REM If an HTTP proxy is requires, configure it for Git Bash sessions,
9194
@REM but only if the environment variable was not already set globally
92-
@IF DEFINED proxy (
95+
@IF DEFINED proxy @(
9396
@ECHO http_proxy=%proxy% > etc\profile.d\proxy.sh
9497
@ECHO https_proxy=%proxy% >> etc\profile.d\proxy.sh
9598
@ECHO export http_proxy https_proxy >> etc\profile.d\proxy.sh
@@ -99,10 +102,10 @@
99102

100103
@REM Before running a shell, let's prevent complaints about "permission denied"
101104
@REM from MSys2's /etc/post-install/01-devices.post
102-
@MKDIR %cwd%\dev\shm 2> NUL
103-
@MKDIR %cwd%\dev\mqueue 2> NUL
105+
@MKDIR "%cwd%"\dev\shm 2> NUL
106+
@MKDIR "%cwd%"\dev\mqueue 2> NUL
104107

105-
@IF NOT DEFINED JENKINS_URL (
108+
@IF NOT DEFINED JENKINS_URL @(
106109
@REM Install shortcut on the desktop
107110
@ECHO.
108111
@ECHO Installing the 'Git SDK @@BITNESS@@-bit' shortcut on the Desktop

0 commit comments

Comments
 (0)