Skip to content

Instantly share code, notes, and snippets.

@gdlmx
Last active May 15, 2018 17:35
Show Gist options
  • Save gdlmx/ac3030dc930c1fbdfc7b86b272b56ca9 to your computer and use it in GitHub Desktop.
Save gdlmx/ac3030dc930c1fbdfc7b86b272b56ca9 to your computer and use it in GitHub Desktop.
#!/bin/bash
tar -C / -pxf pacman-5.0.1.6403.520736d-1-x86_64.pkg.tar etc usr var
tar -C / -pxf pacman-mirrors-20160112-1-any.pkg.tar etc
tar -C / -pxf msys2-keyring-r9.397a52e-1-any.pkg.tar usr
pacman-key --init
pacman-key --populate msys2
# add installed packages to pacman db
# full list: https://github.com/git-for-windows/git-sdk-64/tree/master/var/lib/pacman/local
pacman -Sy --dbonly msys2-runtime bash perl gnupg libutil-linux
#!/bin/sh
# Determine which packages exist in the current MSYS2 environment
# Intended to be used in Git-for-Windows
export OUTDIR=$PWD
wget http://repo.msys2.org/msys/x86_64/msys.files.tar.gz
mkdir -p pacman-local msys-files
tar -xf msys.files.tar.gz -C msys-files
function file2pkg () {
# Find the corresponding package folder and move it to $PWD/pacman-local/
# the first match wins
F=$(grep -Fls "$1" msys-files/*/files | head -n 1)
[ "$F" != "" ] && ( mv $(dirname "$F") "$OUTDIR/pacman-local/" && echo $F is moved )
}
export -f file2pkg
find /usr/bin/ -type f -exec bash -c 'file2pkg usr/bin/$(basename "{}")' \;
find /mingw64/bin/ -type f -exec bash -c 'file2pkg usr/bin/$(basename "{}")' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment