Skip to content

Commit 394c95e

Browse files
committed
Merge branch 'net-installer'
With this branch merged, you can create a new net installer using net-installer/release.sh <version> to produce the git-sdk-64-installer-<version.exe file in your home directory (when running in a 32-bit MSys2, it generates the 32-bit version, of course). This is best done directly after upgrading the current setup via pacman -Syu (When msys2-runtime needs to be updated, that should be done in an individual call first, because you have to quit everything MSys2 immediately after upgrading -- including mintty, pacman and bash -- to avoid nasty heap corruption problems caused by an msys-2.0.dll that was changed in-flight.) Signed-off-by: Johannes Schindelin <[email protected]>
2 parents b41dfcf + 405a5de commit 394c95e

File tree

8 files changed

+323
-57
lines changed

8 files changed

+323
-57
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.swp
22
/git-extra/pkg/
3+
/git-extra/src/

git-extra/PKGBUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,27 @@ SigLevel = Optional\n\
4040
"post_upgrade () {" \
4141
" post_install" \
4242
"}" > $startdir/$pkgname.install
43+
44+
gcc -o create-shortcut.exe $startdir/create-shortcut.c -luuid -lole32
4345
}
4446

4547
package() {
48+
case "$CARCH" in
49+
i686)
50+
mingwdir="mingw32"
51+
;;
52+
x86_64)
53+
mingwdir="mingw64"
54+
;;
55+
esac
56+
4657
install -d -m755 $pkgdir/etc/profile.d
4758
install -d -m755 $pkgdir/usr/bin
4859
install -d -m755 $pkgdir/usr/share/git
60+
install -d -m755 $pkgdir/$mingwdir/bin
4961
install -m644 $startdir/vimrc $pkgdir/etc
5062
install -m755 $startdir/vi $pkgdir/usr/bin
63+
install -m755 create-shortcut.exe $pkgdir/$mingwdir/bin
5164
install -m755 $startdir/git-prompt.sh $pkgdir/etc/profile.d
5265
install -m755 $startdir/aliases.sh $pkgdir/etc/profile.d
5366
install -m644 $startdir/msys2-32.ico $pkgdir/usr/share/git

git-extra/create-shortcut.c

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#include <stdio.h>
2+
#include <shlobj.h>
3+
4+
void die(const char *message)
5+
{
6+
CoUninitialize();
7+
fprintf(stderr, "%s\n", message);
8+
fprintf(stderr, "last error: %d\n", GetLastError());
9+
exit(1);
10+
}
11+
12+
int main(int argc, char **argv)
13+
{
14+
const char *progname = argv[0];
15+
const char *work_dir = NULL, *arguments = NULL, *icon_file = NULL;
16+
const char *description = NULL;
17+
int show_cmd = 1;
18+
19+
static WCHAR wsz[1024];
20+
HRESULT hres;
21+
IShellLink* psl;
22+
IPersistFile* ppf;
23+
24+
25+
while (argc > 2) {
26+
if (argv[1][0] != '-')
27+
break;
28+
if (!strcmp(argv[1], "--work-dir"))
29+
work_dir = argv[2];
30+
else if (!strcmp(argv[1], "--arguments"))
31+
arguments = argv[2];
32+
else if (!strcmp(argv[1], "--show-cmd"))
33+
show_cmd = atoi(argv[2]);
34+
else if (!strcmp(argv[1], "--icon-file"))
35+
icon_file = argv[2];
36+
else if (!strcmp(argv[1], "--description"))
37+
description = argv[2];
38+
else {
39+
fprintf(stderr, "Unknown option: %s\n", argv[1]);
40+
return 1;
41+
}
42+
43+
argc -= 2;
44+
argv += 2;
45+
}
46+
47+
if (argc > 1 && !strcmp(argv[1], "--")) {
48+
argc--;
49+
argv++;
50+
}
51+
52+
if (argc < 3) {
53+
fprintf(stderr, "Usage: %s [options] <source> <destination>\n",
54+
progname);
55+
return 1;
56+
}
57+
58+
hres = CoInitialize(NULL);
59+
if (FAILED(hres))
60+
die ("Could not initialize OLE");
61+
62+
hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
63+
&IID_IShellLink, (void **)&psl);
64+
65+
if (FAILED(hres))
66+
die ("Could not get ShellLink interface");
67+
68+
hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile,
69+
(void **) &ppf);
70+
71+
if (FAILED(hres))
72+
die ("Could not get PersistFile interface");
73+
74+
hres = psl->lpVtbl->SetPath(psl, argv[1]);
75+
if (FAILED(hres))
76+
die ("Could not set path");
77+
78+
if (work_dir)
79+
psl->lpVtbl->SetWorkingDirectory(psl, work_dir);
80+
81+
if (show_cmd)
82+
psl->lpVtbl->SetShowCmd(psl, show_cmd);
83+
84+
if (icon_file)
85+
psl->lpVtbl->SetIconLocation(psl, icon_file, 0);
86+
if (arguments)
87+
psl->lpVtbl->SetArguments(psl, arguments);
88+
if (description)
89+
psl->lpVtbl->SetDescription(psl, description);
90+
91+
wsz[0] = 0;
92+
MultiByteToWideChar(CP_ACP,
93+
0, argv[2], -1, wsz, 1024);
94+
hres = ppf->lpVtbl->Save(ppf,
95+
(const WCHAR*)wsz, TRUE);
96+
97+
ppf->lpVtbl->Release(ppf);
98+
psl->lpVtbl->Release(psl);
99+
100+
if (FAILED(hres))
101+
die ("Could not save link");
102+
103+
CoUninitialize();
104+
return 0;
105+
}

net-installer/7zSD.sfx

95.5 KB
Binary file not shown.

net-installer/release.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/sh
2+
3+
# Recreate git-sdk-$VERSION.exe
4+
5+
test -z "$1" && {
6+
echo "Usage: $0 <version> [<gitbranch>]"
7+
exit 1
8+
}
9+
10+
die () {
11+
echo "$*" >&1
12+
exit 1
13+
}
14+
15+
ARCH="$(uname -m)"
16+
case "$ARCH" in
17+
i686)
18+
BITNESS=32
19+
;;
20+
x86_64)
21+
BITNESS=64
22+
;;
23+
*)
24+
die "Unhandled architecture: $ARCH"
25+
;;
26+
esac
27+
28+
GIT_BRANCH="${2:-master}"
29+
GIT_CLONE_URL=https://github.com/git-for-windows/git
30+
31+
TARGET="$HOME"/git-sdk-$BITNESS-installer-"$1".7z.exe
32+
OPTS7="-m0=lzma -mx=9 -md=64M"
33+
TMPPACK=/tmp.7z
34+
SHARE="$(cd "$(dirname "$0")" && pwd)"
35+
36+
sed -e "s|@@ARCH@@|$ARCH|g" \
37+
-e "s|@@BITNESS@@|$BITNESS|g" \
38+
-e "s|@@GIT_BRANCH@@|$GIT_BRANCH|g" \
39+
-e "s|@@GIT_CLONE_URL@@|$GIT_CLONE_URL|g" \
40+
< "$SHARE"/setup-git-sdk.bat > /setup-git-sdk.bat ||
41+
die "Could not generate setup script"
42+
43+
fileList="$(cd / && echo \
44+
etc/pacman.* \
45+
usr/bin/gpg.exe \
46+
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 \
51+
usr/ssl/certs/ca-bundle.crt \
52+
var/lib/pacman \
53+
setup-git-sdk.bat)"
54+
55+
type 7za ||
56+
pacman -S p7zip ||
57+
die "Could not install 7-Zip"
58+
59+
echo "Creating archive" &&
60+
(cd / && 7za -x'!var/lib/pacman/*' a $OPTS7 "$TMPPACK" $fileList) &&
61+
(cat "$SHARE/7zSD.sfx" &&
62+
echo ';!@Install@!UTF-8!' &&
63+
echo 'Title="Git for Windows '$BITNESS'-bit SDK"' &&
64+
echo 'BeginPrompt="This archive bootstraps an SDK to build, test and package Git for Windows '$BITNESS'-bit"' &&
65+
echo 'CancelPrompt="Do you want to cancel the Git '$BITNESS'-bit SDK installation?"' &&
66+
echo 'ExtractDialogText="Please, wait..."' &&
67+
echo 'ExtractPathText="Where do you want to install the Git '$BITNESS'-bit SDK?"' &&
68+
echo 'ExtractTitle="Extracting..."' &&
69+
echo 'GUIFlags="8+32+64+256+4096"' &&
70+
echo 'GUIMode="1"' &&
71+
echo 'InstallPath="C:\\git-sdk-'$BITNESS'"' &&
72+
echo 'OverwriteMode="2"' &&
73+
echo 'RunProgram="cmd /c \"%%T\setup-git-sdk.bat\""' &&
74+
echo 'Delete="%%T\setup-git-sdk.bat"' &&
75+
echo ';!@InstallEnd@!' &&
76+
cat "$TMPPACK") > "$TARGET" &&
77+
echo "Success! You will find the new installer at \"$TARGET\"." &&
78+
echo "It is a self-extracting .7z archive (just append .exe to the filename)" &&
79+
rm $TMPPACK

net-installer/setup-git-sdk.bat

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
@REM Set up the Git SDK
2+
3+
@REM determine root directory
4+
5+
@REM https://technet.microsoft.com/en-us/library/bb490909.aspx says:
6+
@REM <percent>~dpI Expands <percent>I to a drive letter and path only.
7+
@REM <percent>~fI Expands <percent>I to a fully qualified path name.
8+
@FOR /F "delims=" %%D in ("%~dp0") do @set cwd=%%~fD
9+
10+
@REM set PATH
11+
@set PATH=%cwd%\usr\bin;%PATH%
12+
13+
@REM set MSYSTEM so that MSys2 starts up in the correct mode
14+
@set MSYSTEM=MINGW@@BITNESS@@
15+
16+
@SET /A counter=0
17+
:INSTALL_RUNTIME
18+
@SET /A counter+=1
19+
@IF %counter% GEQ 5 (
20+
@ECHO "Could not install msys2-runtime"
21+
@PAUSE
22+
@EXIT 1
23+
)
24+
25+
@REM update the Pacman package indices first, then force-install msys2-runtime
26+
@REM (we ship with a stripped-down msys2-runtime, gpg and pacman), so that
27+
@REM pacman's post-install scripts run without complaining about heap problems
28+
@%cwd%\usr\bin\pacman -Sy --force --noconfirm msys2-runtime
29+
30+
@IF ERRORLEVEL 1 GOTO INSTALL_RUNTIME
31+
32+
@SET /A counter=0
33+
:INSTALL_PACMAN
34+
@SET /A counter+=1
35+
@IF %counter% GEQ 5 (
36+
@ECHO "Could not install pacman"
37+
@PAUSE
38+
@EXIT 1
39+
)
40+
41+
@REM next, force update pacman, but first we need bash and info for that.
42+
@%cwd%\usr\bin\pacman -S --force --noconfirm bash info pacman
43+
44+
@IF ERRORLEVEL 1 GOTO INSTALL_PACMAN
45+
46+
@SET /A counter=0
47+
:INSTALL_REST
48+
@SET /A counter+=1
49+
@IF %counter% GEQ 5 (
50+
@ECHO "Could not install the remaining packages"
51+
@PAUSE
52+
@EXIT 1
53+
)
54+
55+
@REM now update the rest
56+
@%cwd%\usr\bin\pacman -S --force --noconfirm ^
57+
base python less openssh patch make tar diffutils ca-certificates ^
58+
perl-Error perl perl-Authen-SASL perl-libwww perl-MIME-tools ^
59+
perl-Net-SMTP-SSL perl-TermReadKey ^
60+
mintty vim git-extra ^
61+
mingw-w64-@@ARCH@@-git mingw-w64-@@ARCH@@-toolchain ^
62+
mingw-w64-@@ARCH@@-curl mingw-w64-@@ARCH@@-expat ^
63+
mingw-w64-@@ARCH@@-openssl mingw-w64-@@ARCH@@-tcl ^
64+
mingw-w64-@@ARCH@@-pcre
65+
66+
@IF ERRORLEVEL 1 GOTO INSTALL_REST
67+
68+
@REM Avoid overlapping address ranges
69+
@IF MINGW32 == %MSYSTEM% (
70+
ECHO "Auto-rebasing .dll files"
71+
CALL %cwd%\autorebase.bat
72+
)
73+
74+
@REM Install shortcut on the desktop
75+
@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"'
76+
77+
@REM now clone the Git sources, build it, and start an interactive shell
78+
@mintty -i /msys2.ico bash --login -c "mkdir -p /usr/src && cd /usr/src && git clone -b @@GIT_BRANCH@@ -c core.autocrlf=false https://github.com/git-for-windows/git && cd git && make install; bash --login -i"
79+
80+
@IF ERRORLEVEL 1 PAUSE

setup-git-sdk.bat

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)