Skip to content

Commit 084ad98

Browse files
committed
Add a script to generate the Portable Application
Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 87b9ee9 commit 084ad98

File tree

7 files changed

+259
-0
lines changed

7 files changed

+259
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
*.swp
22
/git-extra/pkg/
33
/git-extra/src/
4+
/portable/root/cmd/
5+
/portable/root/git-bash.bat
6+
/portable/root/git-cmd.bat

portable/git-bash.bat.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@REM Do not use "echo off" to not affect any child calls.
2+
@SETLOCAL
3+
4+
@REM Get the absolute path to the current directory, which is assumed to be the
5+
@REM Git installation root.
6+
@FOR /F "delims=" %%I IN ("%~dp0") DO @SET git_install_root=%%~fI
7+
8+
@SET MSYSTEM=MINGW@@BITNESS@@
9+
10+
@IF NOT EXIST %git_install_root%usr\bin\mintty.exe GOTO startsh
11+
@START %git_install_root%usr\bin\mintty -i /usr/share/git/git.ico /usr/bin/bash --login %*
12+
@EXIT
13+
14+
:startsh
15+
@START %git_install_root%usr\bin\bash --login -i %*
16+
@EXIT

portable/git-cmd.bat.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@REM Do not use "echo off" to not affect any child calls.
2+
@SETLOCAL
3+
4+
@REM Get the absolute path to the current directory, which is assumed to be the
5+
@REM Git installation root.
6+
@FOR /F "delims=" %%I IN ("%~dp0") DO @SET git_install_root=%%~fI
7+
@SET PATH=%git_install_root%\usr\bin;%git_install_root%\mingw@@BITNESS@@\bin;%git_install_root%\cmd;%PATH%
8+
9+
@IF NOT EXIST "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
10+
@IF NOT EXIST "%HOME%" @set HOME=%USERPROFILE%
11+
12+
@SET PLINK_PROTOCOL=ssh
13+
@IF NOT DEFINED TERM SET TERM=msys
14+
15+
@SET MSYSTEM=MINGW@@BITNESS@@
16+
17+
@CD /d %HOME%
18+
@CALL %COMSPEC%

portable/release.sh

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/sh
2+
3+
# Build the portable Git for Windows.
4+
5+
test -z "$1" && {
6+
echo "Usage: $0 <version>"
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+
TARGET="$HOME"/PortableGit-"$1".7z.exe
29+
OPTS7="-m0=lzma -mx=9 -md=64M"
30+
TMPPACK=/tmp.7z
31+
SHARE="$(cd "$(dirname "$0")" && pwd)"
32+
33+
case "$SHARE" in
34+
*" "*)
35+
die "This script cannot handle spaces in $SHARE"
36+
;;
37+
esac
38+
39+
40+
# Generate a couple of files dynamically
41+
42+
mkdir -p "$SHARE/root/tmp" ||
43+
die "Could not make tmp/ directory"
44+
45+
mkdir -p "$SHARE/root/cmd" &&
46+
cp /mingw$BITNESS/libexec/git-core/git-log.exe "$SHARE/root/cmd/git.exe" ||
47+
die "Could not copy Git wrapper"
48+
49+
sed "s/@@BITNESS@@/$BITNESS/g" \
50+
< "$SHARE/git-cmd.bat.in" > "$SHARE/root/git-cmd.bat" ||
51+
die "Could not generate git-cmd.bat"
52+
53+
sed "s/@@BITNESS@@/$BITNESS/g" \
54+
< "$SHARE/git-bash.bat.in" > "$SHARE/root/git-bash.bat" ||
55+
die "Could not generate git-bash.bat"
56+
57+
58+
# Make a list of files to include
59+
60+
pacman_list () {
61+
pacman -Ql $(for arg
62+
do
63+
pactree -u "$arg"
64+
done |
65+
sort |
66+
uniq) |
67+
grep -v '/$' |
68+
sed 's/^[^ ]* //'
69+
}
70+
71+
LIST="$(pacman_list mingw-w64-$ARCH-git git-extra ncurses mintty vim \
72+
sed awk less grep gnupg findutils coreutils \
73+
dos2unix which |
74+
grep -v -e '\.[acho]$' -e '/aclocal/' \
75+
-e '/man/' \
76+
-e '^/usr/include/' -e '^/mingw32/include/' \
77+
-e '^/usr/share/doc/' -e '^/mingw32/share/doc/' \
78+
-e '^/usr/share/info/' -e '^/mingw32/share/info/' |
79+
sed 's/^\///')"
80+
81+
LIST="$LIST etc/profile etc/bash.bash_logout etc/bash.bashrc etc/fstab"
82+
LIST="$LIST mingw$BITNESS/etc/gitconfig"
83+
84+
# 7-Zip will strip absolute paths completely... therefore, we can add another
85+
# root directory like this:
86+
87+
LIST="$LIST $SHARE/root/*"
88+
89+
90+
# Make the self-extracting package
91+
92+
type 7za ||
93+
pacman -S p7zip ||
94+
die "Could not install 7-Zip"
95+
96+
echo "Creating archive" &&
97+
(cd / && 7za a $OPTS7 $TMPPACK $LIST) &&
98+
(cat "$SHARE/../net-installer/7zSD.sfx" &&
99+
echo ';!@Install@!UTF-8!' &&
100+
echo 'Progress="yes"' &&
101+
echo 'Title="Portable Git for Windows"' &&
102+
echo 'BeginPrompt="This program installs a complete Git for Windows"' &&
103+
echo 'CancelPrompt="Do you want to cancel Git installation?"' &&
104+
echo 'ExtractDialogText="Please, wait..."' &&
105+
echo 'ExtractPathText="Where do you want to install Git for Windows?"' &&
106+
echo 'ExtractTitle="Extracting..."' &&
107+
echo 'GUIFlags="8+32+64+256+4096"' &&
108+
echo 'GUIMode="1"' &&
109+
echo 'InstallPath="%PROGRAMFILES%\\Git"' &&
110+
echo 'OverwriteMode="0"' &&
111+
echo ';!@InstallEnd@!7z' &&
112+
cat "$TMPPACK") > "$TARGET" &&
113+
echo "Success! You will find the new installer at \"$TARGET\"." &&
114+
echo "It is a self-extracting .7z archive (just append .exe to the filename)" &&
115+
rm $TMPPACK
116+

portable/root/Git Bash.vbs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Set fso = CreateObject("Scripting.FileSystemObject")
2+
Set shell = CreateObject("WScript.Shell")
3+
4+
Const TemporaryFolder = 2
5+
linkfile = fso.BuildPath(fso.GetSpecialFolder(TemporaryFolder), "Git Bash.lnk")
6+
gitdir = fso.GetParentFolderName(WScript.ScriptFullName)
7+
8+
' Dynamically create a shortcut with the current directory as the working directory.
9+
Set link = shell.CreateShortcut(linkfile)
10+
link.TargetPath = fso.BuildPath(gitdir, "usr\bin\sh.exe")
11+
link.Arguments = "--login -i"
12+
link.IconLocation = fso.BuildPath(gitdir, "usr\share\git\git.ico")
13+
If WScript.Arguments.Length > 0 Then link.WorkingDirectory = WScript.Arguments(0)
14+
link.Save
15+
16+
Set app = CreateObject("Shell.Application")
17+
app.ShellExecute linkfile
18+

portable/root/README.portable

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
README.portable
2+
=======================
3+
4+
This version of Git for Windows is portable, i.e. does not need to
5+
be installed. It will run from any directory you place it in, even
6+
from a USB thumbdrive. It will not write permanent entries into the
7+
Windows registry. It does not need administrator privileges to "install".
8+
9+
10+
Installation
11+
------------
12+
13+
This package is contained in a 7-zip archive with a file name of the form
14+
'PortableGit-<versionstring>.7z.exe'. It is a self-extracting archive:
15+
you can (double-)click it and it will ask for the desired target directory
16+
(which defaults to C:\Program Files\Git). You may change that as needed or
17+
desired. Your user account needs write access to the selected directory.
18+
(You can move that directory with all its contents to a different place or
19+
computer at any time should you later desire so).
20+
21+
22+
Functional differences to the non-portable Git for Windows
23+
----------------------------------------------------------
24+
25+
This version does not offer you the convenient right-click context menu
26+
entries "Git GUI Here" and "Git Bash Here", because these would require
27+
to add entries into the Windows registry.
28+
29+
30+
Warning
31+
-------
32+
33+
Since this portable package does not modify any Windows %path%
34+
variables, it is not possible to run the git.exe and gitk.exe files
35+
directly. Start the Git Bash or Git Cmd instead, or add the cmd/ folder
36+
to your %path%.
37+
38+
39+
How to start using PortableGit
40+
------------------------------
41+
42+
If you are comfortable with a Unix-like shell, just launch 'git-bash.bat'.
43+
44+
If not, just launch 'git-cmd.bat'.
45+
46+
Alternatively, you can execute these commands to modify the %path%
47+
variable temporarily:
48+
49+
set gitdir=c:\portablegit
50+
set path=%gitdir%\cmd;%path%
51+
52+
Adjust the 'gitdir' according to your setup. As long as you do not
53+
close the command window, you can now simply type "git" or "gitk" to
54+
really call "c:\portablegit\cmd\git.cmd" or "c:\portablegit\cmd\gitk.cmd".
55+
56+
57+
Quick start
58+
-----------
59+
60+
Start configuring git with your personal settings:
61+
git config --global user.name "Joe Sixpack"
62+
git config --global user.email joe.sixpack@g_mail.com
63+
64+
Start using git:
65+
git --help
66+
67+
68+
How to change %path% permanently
69+
--------------------------------
70+
71+
You may also want to make the modification to the %path% variable a
72+
permanent one. The %path% variable may be changed:
73+
74+
* either on a System level (for all users in the lower pane), if you are
75+
an Administrator
76+
* or for your own user account only (in the upper pane).
77+
78+
To change the %path% variable permanently:
79+
80+
* right-click "My Computer",
81+
* select "Properties",
82+
* open "Advanced",
83+
* click "Environment Variables",
84+
* highlight the "Path" variable,
85+
* click "Edit" (either in upper or in lower pane),
86+
* add your specific path to front of "Variable value" field, separated
87+
by a semicolon from the existing entry.
88+
54 KB
Binary file not shown.

0 commit comments

Comments
 (0)