diff --git a/make-file-list-msys2.sh b/make-file-list-msys2.sh new file mode 100644 index 0000000000..525d1bca1b --- /dev/null +++ b/make-file-list-msys2.sh @@ -0,0 +1,128 @@ +#!/bin/sh + +die () { + echo "$*" >&2 + exit 1 +} + +test -n "$ARCH" && +test -n "$BITNESS" || +die "Need ARCH and BITNESS to be set" + +pacman_list () { + package_list=$(for arg + do + pactree -u "$arg" + done | + grep -v "^\\($(echo $PACKAGE_EXCLUDES | sed \ + -e 's/ /\\|/g' \ + -e 's/mingw-w64-/&\\(i686\\|x86_64\\)-/g')\\)\$" | + sort | + uniq) && + if test -n "$PACKAGE_VERSIONS_FILE" + then + pacman -Q $package_list >"$PACKAGE_VERSIONS_FILE" + fi && + pacman -Ql $package_list | + grep -v '/$' | + sed 's/^[^ ]* //' +} + +install_required () { + # TODO some of these might not be wanted + # Packages that have been added after Git SDK 1.0.0 was released... + required= + for req in mingw-w64-$ARCH-git-credential-manager $SH_FOR_REBASE + do + test -d /var/lib/pacman/local/$req-[0-9]* || + test -d /var/lib/pacman/local/$req-git-[0-9]* || + required="$required $req" + done + test -z "$required" || + pacman -Sy --noconfirm $required >&2 || + die "Could not install required packages: $required" +} + +this_script_dir="$(cd "$(dirname "$0")" && pwd -W)" || +die "Could not determine this script's dir" + +install_required + +SH_FOR_REBASE=dash + +BASE_PACKAGES="$(pacman -Qg base | awk '{print $2}' | tr '\n' ' ')" +GIT_PACKAGES="mingw-w64-$ARCH-git mingw-w64-$ARCH-git-credential-manager git-extra openssh" +UTIL_PACKAGES= +packages="$BASE_PACKAGES $GIT_PACKAGES $UTIL_PACKAGES" + +# TODO need this? should be a parameter? Use BITNESS? +PACKAGE_EXCLUDES="db info heimdal git util-linux curl git-for-windows-keyring + mingw-w64-p11-kit filesystem msys2-launcher-git rebase" +# TODO 05-home-dir.post required by filesystem package but is missing from SDK +# TODO should we exlude all the tz stuff? +EXTRA_FILE_EXCLUDES="/etc/post-install/05-home-dir.post + /mingw$BITNESS/libexec/git-core/git-update-git-for-windows" + +pacman_list $packages "$@" | +grep -v -e '\.[acho]$' -e '\.l[ao]$' -e '/aclocal/' \ + -e '/man/' -e '/pkgconfig/' -e '/emacs/' \ + -e '^/usr/lib/python' -e '^/usr/lib/ruby' \ + -e '^/usr/share/subversion' \ + -e '^/etc/skel/' -e '^/mingw../etc/skel/' \ + -e '^/usr/bin/svn' \ + -e '^/usr/bin/xml.*exe$' \ + -e '^/usr/bin/xslt.*$' \ + -e '^/mingw../share/doc/openssl/' \ + -e '^/mingw../share/doc/gettext/' \ + -e '^/mingw../share/doc/lib' \ + -e '^/mingw../share/doc/pcre2\?/' \ + -e '^/mingw../share/doc/git-doc/.*\.txt$' \ + -e '^/mingw../lib/gettext/' -e '^/mingw../share/gettext/' \ + -e '^/usr/include/' -e '^/mingw../include/' \ + -e '^/usr/share/doc/' \ + -e '^/usr/share/info/' -e '^/mingw../share/info/' \ + -e '^/mingw../share/git-doc/technical/' \ + -e '^/mingw../itcl/' \ + -e '^/mingw../t\(cl\|k\)[^/]*/\(demos\|msgs\|encoding\|tzdata\)/' \ + -e '^/mingw../bin/\(autopoint\|[a-z]*-config\)$' \ + -e '^/mingw../bin/lib\(asprintf\|gettext\|gnutlsxx\|pcre[013-9a-oq-z]\|quadmath\|stdc++\)[^/]*\.dll$' \ + -e '^/mingw../bin/\(asn1\|gnutls\|idn\|mini\|msg\|nettle\|ngettext\|ocsp\|pcre\|rtmp\|xgettext\)[^/]*\.exe$' \ + -e '^/mingw../.*/git-\(remote-testsvn\|shell\)\.exe$' \ + -e '^/mingw../.*/git-cvsserver.*$' \ + -e '^/mingw../.*/gitweb/' \ + -e '^/mingw../lib/tdbc' \ + -e '^/mingw../libexec/git-core/git-archimport$' \ + -e '^/mingw../share/doc/git-doc/git-archimport' \ + -e '^/mingw../libexec/git-core/git-cvsimport$' \ + -e '^/mingw../share/doc/git-doc/git-cvsexport' \ + -e '^/mingw../libexec/git-core/git-cvsexport' \ + -e '^/mingw../share/doc/git-doc/git-cvsimport' \ + -e '^/mingw../share/git\(k\|-gui\)/lib/msgs/' \ + -e '^/mingw../share/nghttp2/' \ + -e '^/usr/bin/msys-\(db\|icu\|gfortran\|stdc++\|quadmath\)[^/]*\.dll$' \ + -e '^/usr/bin/dumper\.exe$' \ + -e '^/usr/share.*/magic$' \ + -e '^/usr/share/perl5/core_perl/Unicode/' \ + -e '^/usr/share/perl5/core_perl/pods/' \ + -e '^/usr/share/perl5/core_perl/Locale/' \ + -e '^/usr/share/perl5/core_perl/Pod/' \ + -e '^/usr/share/perl5/core_perl/ExtUtils/' \ + -e '^/usr/share/perl5/core_perl/CPAN/' \ + -e '^/usr/share/perl5/core_perl/TAP/' \ + -e '^/usr/share/vim/vim74/lang/' \ + -e '^/etc/profile.d/git-sdk.sh$' | +grep -v \ + -e '^/mingw../share/locale/' \ + -e '^/usr/share/locale/' | +grep -v \ + -e "^\\($(echo $EXTRA_FILE_EXCLUDES | + sed 's/ /\\|/g')\\)\$" | +sort | +grep --perl-regexp -v -e '^/usr/(lib|share)/terminfo/(?!.*/(cygwin|dumb|screen.*|xterm.*)$)' | +sed 's/^\///' + +# TODO - need this? +test -z "$PACKAGE_VERSIONS_FILE" || +pacman -Q filesystem $SH_FOR_REBASE rebase \ + util-linux unzip mingw-w64-$ARCH-xpdf-tools \ + >>"$PACKAGE_VERSIONS_FILE" diff --git a/portable-msys2/release.sh b/portable-msys2/release.sh new file mode 100644 index 0000000000..0fdabd4c55 --- /dev/null +++ b/portable-msys2/release.sh @@ -0,0 +1,152 @@ +#!/bin/sh + +# Build the portable MSYS2 + +die () { + echo "$*" >&1 + exit 1 +} + +output_directory="$HOME" +include_pdbs= +while test $# -gt 0 +do + case "$1" in + --output) + shift + output_directory="$1" + ;; + --output=*) + output_directory="${1#*=}" + ;; + --include-pdbs) + include_pdbs=t + ;; + -*) + die "Unknown option: $1" + ;; + *) + break + esac + shift +done + +test $# -gt 0 || +die "Usage: $0 [--output=] [optional components]" + +test -d "$output_directory" || +die "Directory inaccessible: '$output_directory'" + +ARCH="$(uname -m)" +case "$ARCH" in +i686) + BITNESS=32 + MD_ARG=128M + ;; +x86_64) + BITNESS=64 + MD_ARG=256M + ;; +*) + die "Unhandled architecture: $ARCH" + ;; +esac +VERSION=$1 +shift +TARGET="$output_directory"/PortableMSYS2-"$VERSION"-"$BITNESS"-bit.7z.exe +OPTS7="-m0=lzma -mx=9 -md=$MD_ARG -mfb=273 -ms=256M " +TMPPACK=/tmp.7z +SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd)" + +case "$SCRIPT_PATH" in +*" "*) + die "This script cannot handle spaces in $SCRIPT_PATH" + ;; +esac + +# Generate a couple of files dynamically + +cp "$SCRIPT_PATH/../LICENSE.txt" "$SCRIPT_PATH/root/" || +die "Could not copy license file" + +# TODO this is in vc as is root/usr +mkdir -p "$SCRIPT_PATH/root/etc" || +die "Could not make etc/ directory" + +mkdir -p "$SCRIPT_PATH/root/tmp" || +die "Could not make tmp/ directory" + +mkdir -p "$SCRIPT_PATH/root/bin" || +die "Could not make bin/ directory" + +cp /cmd/git.exe "$SCRIPT_PATH/root/bin/git.exe" && +cp /mingw$BITNESS/share/git/compat-bash.exe "$SCRIPT_PATH/root/bin/bash.exe" && +cp /mingw$BITNESS/share/git/compat-bash.exe "$SCRIPT_PATH/root/bin/sh.exe" || +die "Could not install bin/ redirectors" + +cp "$SCRIPT_PATH/../post-install.bat" "$SCRIPT_PATH/root/" || +die "Could not copy post-install script" + +mkdir -p "$SCRIPT_PATH/root/mingw$BITNESS/etc" && +cp /mingw$BITNESS/etc/gitconfig \ + "$SCRIPT_PATH/root/mingw$BITNESS/etc/gitconfig" && +git config -f "$SCRIPT_PATH/root/mingw$BITNESS/etc/gitconfig" \ + credential.helper manager || +die "Could not configure Git-Credential-Manager as default" +test 64 != $BITNESS || +git config -f "$SCRIPT_PATH/root/mingw$BITNESS/etc/gitconfig" --unset pack.packSizeLimit + +# Make a list of files to include +echo Generating file list +LIST="$(ARCH=$ARCH BITNESS=$BITNESS \ + PACKAGE_VERSIONS_FILE="$SCRIPT_PATH"/root/etc/package-versions.txt \ + sh "$SCRIPT_PATH"/../make-file-list-msys2.sh "$@" | + grep -v "^mingw$BITNESS/etc/gitconfig$")" || +die "Could not generate file list" + +rm -rf "$SCRIPT_PATH/root/mingw$BITNESS/libexec/git-core" && +mkdir -p "$SCRIPT_PATH/root/mingw$BITNESS/libexec/git-core" && +ln $(echo "$LIST" | sed -n "s|^mingw$BITNESS/bin/[^/]*\.dll$|/&|p") \ + "$SCRIPT_PATH/root/mingw$BITNESS/libexec/git-core/" || +die "Could not copy .dll files into libexec/git-core/" + +# TODO there are few extra untacked files under /root. Can't figure how they got there +# TODO check for any unwanted pdbs +test -z "$include_pdbs" || { + find "$SCRIPT_PATH/root" -name \*.pdb -exec rm {} \; && + "$SCRIPT_PATH"/../please.sh bundle-pdbs \ + --arch=$ARCH --unpack="$SCRIPT_PATH"/root +} || +die "Could not unpack .pdb files" + +# 7-Zip will strip absolute paths completely... therefore, we can add another +# root directory like this: + +LIST="$LIST $SCRIPT_PATH/root/*" + +# Make the self-extracting package + +type 7za > /dev/null || +pacman -Sy --noconfirm p7zip || +die "Could not install 7-Zip" + +echo "Creating archive" && +(cd / && 7za a $OPTS7 $TMPPACK $LIST) && +(cat "$SCRIPT_PATH/../7-Zip/7zSD.sfx" && + echo ';!@Install@!UTF-8!' && + echo 'Title="Portable MSYS2 for Windows '$BITNESS'-bit"' && + echo 'BeginPrompt="This archive extracts a minimal MSYS2 for Windows '$BITNESS'-bit"' && + echo 'CancelPrompt="Do you want to cancel the portable MSYS2 installation?"' && + echo 'ExtractDialogText="Please, wait..."' && + echo 'ExtractPathText="Where do you want to install portable MSYS2?"' && + echo 'ExtractTitle="Extracting..."' && + echo 'GUIFlags="8+32+64+256+4096"' && + echo 'GUIMode="1"' && + echo 'InstallPath="%%S\\PortableMSYS2"' && + echo 'OverwriteMode="0"' && + echo "RunProgram=\"git-bash.exe --needs-console --hide --no-cd --command=post-install.bat\"" && + echo ';!@InstallEnd@!' && + cat "$TMPPACK") > "$TARGET" && +echo "Success! You will find the new installer at \"$TARGET\"." && +echo "It is a self-extracting .7z archive." && +rm $TMPPACK diff --git a/portable-msys2/root/README.portable b/portable-msys2/root/README.portable new file mode 100644 index 0000000000..7993fd6035 --- /dev/null +++ b/portable-msys2/root/README.portable @@ -0,0 +1,106 @@ +README.portable +======================= + +This version of Git for Windows is portable, i.e. does not need to +be installed. It will run from any directory you place it in, even +from a USB thumbdrive. It will not write permanent entries into the +Windows registry. It does not need administrator privileges to "install". + + +Installation +------------ + +This package is contained in a 7-zip archive with a file name of the form +'PortableGit-.7z.exe'. It is a self-extracting archive: +you can (double-)click it and it will ask for the desired target directory +(which defaults to C:\Program Files\Git). You may change that as needed or +desired. Your user account needs write access to the selected directory. +(You can move that directory with all its contents to a different place or +computer at any time should you later desire so). + +*NOTE*: if you decide to unpack the archive using 7-Zip manually, you must +run the `post-install.bat` script. Git will not run correctly +otherwise. + +Functional differences to the non-portable Git for Windows +---------------------------------------------------------- + +This version does not offer you the convenient right-click context menu +entries "Git GUI Here" and "Git Bash Here", because these would require +to add entries into the Windows registry. + + +Warning +------- + +Since this portable package does not modify any Windows %path% +variables, it is not possible to run the git.exe and gitk.exe files +directly. Start the Git Bash or Git Cmd instead, or add the cmd/ folder +to your %path%. + + +How to start using PortableGit +------------------------------ + +If you are comfortable with a Unix-like shell, just launch 'git-bash.exe'. + +If not, just launch 'git-cmd.exe'. + +Alternatively, you can execute these commands to modify the %path% +variable temporarily: + + set gitdir=c:\portablegit + set path=%gitdir%\cmd;%path% + +Adjust the 'gitdir' according to your setup. As long as you do not +close the command window, you can now simply type "git" or "gitk" to +really call "c:\portablegit\cmd\git.exe" or "c:\portablegit\cmd\gitk.exe". + +By default, git-cmd and git-bash use the directory they were started from as +the working directory when run. You can override this by passing --cd-to-home +to them, which will set the user's home directory as the working directory (as +if Git for Windows was installed). + +In addition, if you set the HOME environment variable (either permanently or +for the current session only) you can make Git store and use the configuration +files in the directory specified in that variable. And if you specify +--cd-to-home, git-bash and git-cmd will use that as the working directory when +launched, too. For example: + + set HOME=%cd%/home + git --cd-to-home +will use the relative directory named home (%cd% specifies the current +directory). + +Quick start +----------- + +Start configuring git with your personal settings: + git config --global user.name "Joe Sixpack" + git config --global user.email joe.sixpack@g_mail.com + +Start using git: + git --help + + +How to change %path% permanently +-------------------------------- + +You may also want to make the modification to the %path% variable a +permanent one. The %path% variable may be changed: + +* either on a System level (for all users in the lower pane), if you are + an Administrator +* or for your own user account only (in the upper pane). + +To change the %path% variable permanently: + +* right-click "My Computer", +* select "Properties", +* open "Advanced", +* click "Environment Variables", +* highlight the "Path" variable, +* click "Edit" (either in upper or in lower pane), +* add your specific path to front of "Variable value" field, separated + by a semicolon from the existing entry. + diff --git a/portable-msys2/root/etc/post-install/13-copy-dlls.post b/portable-msys2/root/etc/post-install/13-copy-dlls.post new file mode 100644 index 0000000000..983d2d86c6 --- /dev/null +++ b/portable-msys2/root/etc/post-install/13-copy-dlls.post @@ -0,0 +1,24 @@ +hardlink_all_dlls () { + exec_path="$(git --exec-path)" || + return + + test ! -e "$exec_path/dlls-copied" || + return + + prefix_path="${exec_path%libexec/git-core}" + ln "$prefix_path/bin/git.exe" "$exec_path/dlls-copied" || { + touch "$exec_path/dlls-copied" + return + } + + if test "a$prefix_path" != "a$exec_path" + then + for dll in "$prefix_path"bin/*.dll + do + ln -f "$dll" "$exec_path" || + echo "ERROR: could not link $dll $exec_path" >&2 + done + fi +} + +hardlink_all_dlls diff --git a/portable-msys2/root/usr/share/git/git-for-windows.ico b/portable-msys2/root/usr/share/git/git-for-windows.ico new file mode 100644 index 0000000000..eadfa52512 Binary files /dev/null and b/portable-msys2/root/usr/share/git/git-for-windows.ico differ diff --git a/portable-msys2/root/usr/share/git/git.ico b/portable-msys2/root/usr/share/git/git.ico new file mode 100644 index 0000000000..b3436d651a Binary files /dev/null and b/portable-msys2/root/usr/share/git/git.ico differ