Package management in git for windows?

前端 未结 6 461
你的背包
你的背包 2020-12-12 15:35

I\'m reading the github wiki for git-for-windows and it says that msys2 bundles pacman: https://github.com/git-for-windows/git/wiki/Package-management

But when I invo

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 16:03

    "Git for Windows SDK" is 5.33GB compared to "Git for Windows" 691MB compared to "Portable Git" 275MB. I use the lean and mean Portable Git. At first, it seems hopeless trying to restore and use pacman in the latter two flavors of Git (msys2), because Google excluded ALL metadata files in /var/lib/pacman/local. Please read this official explanation:

    https://wiki.archlinux.org/index.php/Pacman#.22Failed_to_commit_transaction_.28conflicting_files.29.22_error

    Without those metadata files, you don't know the exact collection and version of the msys2 packages Google selected to build a release of those 2 flavors of Git. If you force to install or copy the current version of msys2 packages, you run the risk of version mismatch with git binaries Google built and tested.

    Well, that's until I discover this file: /etc/package-versions.txt, the laundry list of matching msys2 packages and versions. Now there is a definitive source in github. Here is how I restore pacman in Portable Git:

    Step 1: Go to msys2 to download 3 packages: pacman, pacman-mirrors and msys2-keyring. Click the "File:" link of each package.

    Step 2: Unpack them at the root then restore pacman with these commands:

    cd /
    tar x --xz -vf ~/Downloads/msys2-keyring-1~20201002-1-any.pkg.tar.xz usr
    tar x --xz -vf ~/Downloads/pacman-mirrors-20201028-1-any.pkg.tar.xz etc
    tar x --xz -vf ~/Downloads/pacman-5.2.2-4-x86_64.pkg.tar.xz usr
    pacman-key --init
    pacman-key --populate msys2
    pacman -Syu
    

    Step 3: The next two commands restore all matching metadata. The second command is multi-line but still safe to cut and paste (be patient):

    URL=https://github.com/git-for-windows/git-sdk-64/raw/main
    cat /etc/package-versions.txt | while read p v; do d=/var/lib/pacman/local/$p-$v;
     mkdir -p $d; for f in desc files install mtree; do curl -sSL "$URL$d/$f" -o $d/$f;
     done; done
    

    Step 4: Now, is it too much to ask for 'make' and 'zip'?

    pacman -S make zip
    

    Voilà, still just a 337MB mean little environment that can expand and upgrade!

提交回复
热议问题