Skip to content

Commit

Permalink
Merge branch 'sdk-via-ntlm-proxy'
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed Aug 27, 2015
2 parents 57a73d2 + e37f415 commit 1370d95
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
/portable/root/bin/
/portable/root/cmd/
/portable/root/etc/
/sdk-installer/root/
26 changes: 18 additions & 8 deletions sdk-installer/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,39 @@ esac
GIT_BRANCH="${2:-master}"
GIT_CLONE_URL=https://github.com/git-for-windows/git

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

mkdir -p "$FAKEROOTDIR/usr/bin" "$FAKEROOTDIR/etc" ||
die "Could not create fake root directory"

sed -e "s|@@ARCH@@|$ARCH|g" \
-e "s|@@BITNESS@@|$BITNESS|g" \
-e "s|@@GIT_BRANCH@@|$GIT_BRANCH|g" \
-e "s|@@GIT_CLONE_URL@@|$GIT_CLONE_URL|g" \
< "$SCRIPT_PATH"/setup-git-sdk.bat > /setup-git-sdk.bat ||
<"$SCRIPT_PATH"/setup-git-sdk.bat >"$FAKEROOTDIR"/setup-git-sdk.bat ||
die "Could not generate setup script"

cp /usr/bin/dash.exe "$FAKEROOTDIR/usr/bin/sh.exe" &&
sed -e 's/^#\(XferCommand.*curl\).*/\1 --anyauth -C - -s -L -f %u >%o/' \
</etc/pacman.conf >"$FAKEROOTDIR/etc/pacman.conf.proxy" ||
die "Could not copy extra files into fake root"

fileList="$(cd / && echo \
etc/pacman.* \
usr/bin/gpg.exe \
usr/bin/pacman.exe \
$(ldd /usr/bin/gpg.exe |
sed -n 's/.* \/\(usr\/bin\/.*\.dll\) .*/\1/p') \
usr/bin/msys-crypto-*.dll \
usr/bin/msys-ssl-*.dll \
usr/bin/curl.exe \
usr/bin/gpg.exe \
$(ldd /usr/bin/gpg.exe /usr/bin/curl.exe |
sed -n 's/.* \/\(usr\/bin\/.*\.dll\) .*/\1/p' |
sort |
uniq) \
usr/ssl/certs/ca-bundle.crt \
var/lib/pacman \
setup-git-sdk.bat)"
var/lib/pacman)
$FAKEROOTDIR/setup-git-sdk.bat $FAKEROOTDIR/etc $FAKEROOTDIR/usr"

type 7za ||
pacman -Sy --noconfirm p7zip ||
Expand Down
31 changes: 17 additions & 14 deletions sdk-installer/setup-git-sdk.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
@SET /A counter=0
:INSTALL_RUNTIME
@SET /A counter+=1
@IF %counter% GEQ 5 (
@IF %counter% GEQ 5 @(
@ECHO Could not install msys2-runtime
@PAUSE
@EXIT 1
)

@REM Maybe we need a proxy?
@IF %counter% GEQ 2 (
@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,
Expand All @@ -32,43 +32,46 @@
@SET /p proxy= "HTTP proxy: "
)
@REM Check the proxy variable here because of delayed expansion
@IF NOT "%proxy%" == "" (
@IF NOT "%proxy%" == "" @(
@SET http_proxy=%proxy%
@SET https_proxy=%proxy%
@IF %counter% EQU 2 @(
@COPY "%cwd%"\etc\pacman.conf.proxy "%cwd%"\etc\pacman.conf
)
)

@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
@%cwd%\usr\bin\pacman -Sy --force --noconfirm msys2-runtime
@"%cwd%"\usr\bin\pacman -Sy --force --noconfirm msys2-runtime

@IF ERRORLEVEL 1 GOTO INSTALL_RUNTIME

@SET /A counter=0
:INSTALL_PACMAN
@SET /A counter+=1
@IF %counter% GEQ 5 (
@IF %counter% GEQ 5 @(
@ECHO Could not install pacman
@PAUSE
@EXIT 1
)

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

@IF ERRORLEVEL 1 GOTO INSTALL_PACMAN

@SET /A counter=0
:INSTALL_REST
@SET /A counter+=1
@IF %counter% GEQ 5 (
@IF %counter% GEQ 5 @(
@ECHO Could not install the remaining packages
@PAUSE
@EXIT 1
)

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

@REM Avoid overlapping address ranges
@IF MINGW32 == %MSYSTEM% (
@IF MINGW32 == %MSYSTEM% @(
ECHO Auto-rebasing .dll files
CALL %cwd%\autorebase.bat
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 (
@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
Expand All @@ -99,10 +102,10 @@

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

@IF NOT DEFINED JENKINS_URL (
@IF NOT DEFINED JENKINS_URL @(
@REM Install shortcut on the desktop
@ECHO.
@ECHO Installing the 'Git SDK @@BITNESS@@-bit' shortcut on the Desktop
Expand Down

0 comments on commit 1370d95

Please sign in to comment.