From b9cd98506bcf3d09d24b58b7274779ffe471ea62 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 26 Aug 2015 15:01:55 +0000 Subject: [PATCH 1/4] sdk-installer: silence the conditional clauses Even if the 'IF' statement already was silenced by prefixing it with an '@', the actual clause was not, so it would be printed to the console in addition to being executed. Signed-off-by: Johannes Schindelin --- sdk-installer/setup-git-sdk.bat | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk-installer/setup-git-sdk.bat b/sdk-installer/setup-git-sdk.bat index 8f13386931..63c16b8e94 100644 --- a/sdk-installer/setup-git-sdk.bat +++ b/sdk-installer/setup-git-sdk.bat @@ -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, @@ -32,7 +32,7 @@ @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% ) @@ -47,7 +47,7 @@ @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 @@ -61,7 +61,7 @@ @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 @@ -82,14 +82,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 ) @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 @@ -102,7 +102,7 @@ @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 From 9d646a6a422faf9626750faae816d0652f744f09 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 26 Aug 2015 15:20:44 +0000 Subject: [PATCH 2/4] sdk-installer: do not clutter root directory We can just as easily use the same trick as portable/release.sh to create a second (fake) root directory and add it to the .7z archive by passing an absolute path (7za.exe will strip the directory from absolute paths). Signed-off-by: Johannes Schindelin --- .gitignore | 1 + sdk-installer/release.sh | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index af902dbfe7..d46fd81940 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ /portable/root/bin/ /portable/root/cmd/ /portable/root/etc/ +/sdk-installer/root/ diff --git a/sdk-installer/release.sh b/sdk-installer/release.sh index fdb0f9cbd6..e23b68c9db 100644 --- a/sdk-installer/release.sh +++ b/sdk-installer/release.sh @@ -28,16 +28,20 @@ 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" || +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" fileList="$(cd / && echo \ @@ -49,8 +53,8 @@ fileList="$(cd / && echo \ usr/bin/msys-crypto-*.dll \ usr/bin/msys-ssl-*.dll \ usr/ssl/certs/ca-bundle.crt \ - var/lib/pacman \ - setup-git-sdk.bat)" + var/lib/pacman) + $FAKEROOTDIR/setup-git-sdk.bat" type 7za || pacman -Sy --noconfirm p7zip || From eb381655bf2fdc6a7434c34ac6083958deca0d6f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 26 Aug 2015 15:23:02 +0000 Subject: [PATCH 3/4] sdk-installer: allow installing into a path with spaces We need to quote the directory properly if it contains spaces. Since this is not a problem, let's just do it. Signed-off-by: Johannes Schindelin --- sdk-installer/setup-git-sdk.bat | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk-installer/setup-git-sdk.bat b/sdk-installer/setup-git-sdk.bat index 63c16b8e94..c332865432 100644 --- a/sdk-installer/setup-git-sdk.bat +++ b/sdk-installer/setup-git-sdk.bat @@ -40,7 +40,7 @@ @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 @@ -54,7 +54,7 @@ ) @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 @@ -68,7 +68,7 @@ ) @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 ^ @@ -84,7 +84,7 @@ @REM Avoid overlapping address ranges @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, @@ -99,8 +99,8 @@ @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 @( @REM Install shortcut on the desktop From e37f415669d053af77df7d2881f809cee8a2f190 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 26 Aug 2015 16:03:50 +0000 Subject: [PATCH 4/4] sdk-installer: support NTLM proxies When Pacman needs to be told to use a proxy, it actually needs to use a helper because Pacman's HTTP support has no clues about authentication: the proxy might require NTLM (or other) authentication. So let's ship with cURL, and fall back to using it with the `--anyauth` option. This fixes https://github.com/git-for-windows/git/issues/309 Signed-off-by: Johannes Schindelin --- sdk-installer/release.sh | 20 +++++++++++++------- sdk-installer/setup-git-sdk.bat | 3 +++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/sdk-installer/release.sh b/sdk-installer/release.sh index e23b68c9db..e6e38bdb8e 100644 --- a/sdk-installer/release.sh +++ b/sdk-installer/release.sh @@ -34,7 +34,7 @@ OPTS7="-m0=lzma -mx=9 -md=64M" TMPPACK=/tmp.7z SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd)" -mkdir -p "$FAKEROOTDIR" || +mkdir -p "$FAKEROOTDIR/usr/bin" "$FAKEROOTDIR/etc" || die "Could not create fake root directory" sed -e "s|@@ARCH@@|$ARCH|g" \ @@ -44,17 +44,23 @@ sed -e "s|@@ARCH@@|$ARCH|g" \ <"$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/' \ + "$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) - $FAKEROOTDIR/setup-git-sdk.bat" + $FAKEROOTDIR/setup-git-sdk.bat $FAKEROOTDIR/etc $FAKEROOTDIR/usr" type 7za || pacman -Sy --noconfirm p7zip || diff --git a/sdk-installer/setup-git-sdk.bat b/sdk-installer/setup-git-sdk.bat index c332865432..67a44a4d43 100644 --- a/sdk-installer/setup-git-sdk.bat +++ b/sdk-installer/setup-git-sdk.bat @@ -35,6 +35,9 @@ @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