Skip to content

Commit 2a3c089

Browse files
committed
Merge pull request #4 from dscho/git-bash
git: build /git-bash.exe & /git-cmd.exe, too
2 parents bdc650f + 1dc84d0 commit 2a3c089

File tree

4 files changed

+131
-4
lines changed

4 files changed

+131
-4
lines changed

mingw-w64-git/PKGBUILD

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
_realname=git
55

66
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
7-
tag=2.3.3
8-
pkgver=2.3.3.1.3ee6eff
9-
pkgrel=1
7+
tag=2.3.4
8+
pkgver=2.3.4.2.521863b
9+
pkgrel=2
1010
pkgdesc="The fast distributed version control system (mingw-w64)"
1111
arch=('i686' 'x86_64')
1212
url="http://git-for-windows.github.io/"
@@ -37,11 +37,35 @@ pkgver() {
3737
printf "%s.%s.%s" "${tag}" "${pkgrel}" "$(git rev-parse --short HEAD)"
3838
}
3939

40+
case "$CARCH" in
41+
i686)
42+
SHAREDIR=/mingw32/share/git
43+
;;
44+
x86_64)
45+
SHAREDIR=/mingw64/share/git
46+
;;
47+
esac
48+
4049
build() {
4150
export PYTHON_PATH=/usr/bin/python2
4251
cd "$srcdir/git"
4352

44-
make -j1 all
53+
make -j1 all &&
54+
55+
gcc -DMAGIC_RESOURCE -mwindows -s -O2 -Wall -o edit-res.exe \
56+
compat/win32/git-wrapper.c git.res -lshlwapi &&
57+
cp edit-res.exe git-bash.exe &&
58+
./edit-res.exe icon git-bash.exe $startdir/git-for-windows.ico &&
59+
./edit-res.exe command git-bash.exe \
60+
"usr\\bin\\mintty.exe -i $SHAREDIR/git-for-windows.ico /usr/bin/bash --login -i" \
61+
'@@COMSPEC@@ /C "@@EXEPATH@@\usr\bin\bash.exe" --login -i' &&
62+
gcc -DMAGIC_RESOURCE -mconsole -s -O2 -Wall -o git-cmd.exe \
63+
compat/win32/git-wrapper.c git.res -lshlwapi &&
64+
./edit-res.exe icon git-cmd.exe $startdir/git-for-windows.ico &&
65+
./edit-res.exe command git-cmd.exe '@@COMSPEC@@ /K' &&
66+
mkdir -p cmd &&
67+
cp git-wrapper.exe cmd/git.exe &&
68+
./edit-res.exe icon cmd/git.exe $startdir/git-for-windows.ico
4569
}
4670

4771
package() {
@@ -57,4 +81,14 @@ package() {
5781

5882
# subtree, for backwards-compatibility with MSys2's Git package
5983
make -C contrib/subtree prefix="$pkgdir/$PREFIX" install
84+
85+
# Git Bash, Git CMD
86+
install -d -m755 $pkgdir$SHAREDIR
87+
install -m755 $startdir/git-for-windows.ico $pkgdir$SHAREDIR
88+
install -m755 git-bash.exe git-cmd.exe $pkgdir
89+
90+
# Install Git wrapper into /cmd/
91+
install -d -m755 $pkgdir/cmd
92+
install -m755 cmd/git.exe $startdir/gitk.cmd $startdir/start-ssh-agent.cmd \
93+
$pkgdir/cmd
6094
}

mingw-w64-git/git-for-windows.ico

93.1 KB
Binary file not shown.

mingw-w64-git/gitk.cmd

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@REM Do not use "echo off" to not affect any child calls.
2+
3+
@REM Get the absolute path to the parent directory, which is assumed to be the
4+
@REM Git installation root.
5+
@FOR /F "delims=" %%I IN ("%~dp0..") DO @SET toplevel=%%~fI
6+
@SET MSYSTEM=mingw64
7+
@IF NOT EXIST "%toplevel%\%MSYSTEM%\bin\git.exe" @SET MSYSTEM=mingw32
8+
@SET PATH=%toplevel%\%MSYSTEM%\bin;%toplevel%\usr\bin;%PATH%
9+
10+
@IF NOT EXIST "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
11+
@IF NOT EXIST "%HOME%" @set HOME=%USERPROFILE%
12+
13+
@START "gitk" wish.exe "%toplevel%\%MSYSTEM%\bin\gitk" -- %*

mingw-w64-git/start-ssh-agent.cmd

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
@REM Do not use "echo off" to not affect any child calls.
2+
3+
@REM Enable extensions, the `verify` call is a trick from the setlocal help
4+
@VERIFY other 2>nul
5+
@SETLOCAL EnableDelayedExpansion
6+
@IF ERRORLEVEL 1 (
7+
@ECHO Unable to enable extensions
8+
@GOTO failure
9+
)
10+
11+
@REM Start the ssh-agent if needed by git
12+
@FOR %%i IN ("git.exe") DO @SET GIT=%%~$PATH:i
13+
@IF EXIST "%GIT%" (
14+
@REM Get the ssh-agent executable
15+
@FOR %%i IN ("ssh-agent.exe") DO @SET SSH_AGENT=%%~$PATH:i
16+
@IF NOT EXIST "%SSH_AGENT%" (
17+
@FOR %%s IN ("%GIT%") DO @SET GIT_DIR=%%~dps
18+
@FOR %%s IN ("!GIT_DIR!") DO @SET GIT_DIR=!GIT_DIR:~0,-1!
19+
@FOR %%s IN ("!GIT_DIR!") DO @SET GIT_ROOT=%%~dps
20+
@FOR %%s IN ("!GIT_ROOT!") DO @SET GIT_ROOT=!GIT_ROOT:~0,-1!
21+
@FOR /D %%s in ("!GIT_ROOT!\usr\bin\ssh-agent.exe") DO @SET SSH_AGENT=%%~s
22+
@IF NOT EXIST "!SSH_AGENT!" @GOTO ssh-agent-done
23+
)
24+
@REM Get the ssh-add executable
25+
@FOR %%s IN ("!SSH_AGENT!") DO @SET BIN_DIR=%%~dps
26+
@FOR %%s in ("!BIN_DIR!") DO @SET BIN_DIR=!BIN_DIR:~0,-1!
27+
@FOR /D %%s in ("!BIN_DIR!\ssh-add.exe") DO @SET SSH_ADD=%%~s
28+
@IF NOT EXIST "!SSH_ADD!" @GOTO ssh-agent-done
29+
@REM Check if the agent is running
30+
@FOR /f "tokens=1-2" %%a IN ('tasklist /fi "imagename eq ssh-agent.exe"') DO (
31+
@ECHO %%b | @FINDSTR /r /c:"[0-9][0-9]*" > NUL
32+
@IF "!ERRORLEVEL!" == "0" @SET SSH_AGENT_PID=%%b
33+
)
34+
@REM Connect up the current ssh-agent
35+
@IF [!SSH_AGENT_PID!] == [] (
36+
@ECHO Removing old ssh-agent sockets
37+
@FOR /d %%d IN (%TEMP%\ssh-??????*) DO @RMDIR /s /q %%d
38+
) ELSE (
39+
@ECHO Found ssh-agent at !SSH_AGENT_PID!
40+
@FOR /d %%d IN (%TEMP%\ssh-??????*) DO (
41+
@FOR %%f IN (%%d\agent.*) DO (
42+
@SET SSH_AUTH_SOCK=%%f
43+
@SET SSH_AUTH_SOCK=!SSH_AUTH_SOCK:%TEMP%=/tmp!
44+
@SET SSH_AUTH_SOCK=!SSH_AUTH_SOCK:\=/!
45+
)
46+
)
47+
@IF NOT [!SSH_AUTH_SOCK!] == [] (
48+
@ECHO Found ssh-agent socket at !SSH_AUTH_SOCK!
49+
) ELSE (
50+
@ECHO Failed to find ssh-agent socket
51+
SET SSH_AGENT_PID=
52+
)
53+
)
54+
@REM See if we have the key
55+
@SET "HOME=%USERPROFILE%"
56+
@"!SSH_ADD!" -l 1>NUL 2>NUL
57+
@SET result=!ERRORLEVEL!
58+
@IF NOT !result! == 0 (
59+
@IF !result! == 2 (
60+
@ECHO | @SET /p=Starting ssh-agent:
61+
@FOR /f "tokens=1-2 delims==;" %%a IN ('"!SSH_AGENT!"') DO (
62+
@IF NOT [%%b] == [] @SET %%a=%%b
63+
)
64+
@ECHO. done
65+
)
66+
@"!SSH_ADD!"
67+
@ECHO.
68+
)
69+
)
70+
71+
:ssh-agent-done
72+
:failure
73+
74+
@ENDLOCAL & @SET "SSH_AUTH_SOCK=%SSH_AUTH_SOCK%" ^
75+
& @SET "SSH_AGENT_PID=%SSH_AGENT_PID%"
76+
77+
@ECHO %cmdcmdline% | @FINDSTR /l "\"\"" >NUL
78+
@IF NOT ERRORLEVEL 1 (
79+
@CALL cmd %*
80+
)

0 commit comments

Comments
 (0)