给 MSYS2 添加国内源


https://wiki.qt.io/MSYS2
pacman -S base-devel git mercurial svn wget p7zip
软件包 开发包

 https://packages.msys2.org/updates

http://mirrors.ustc.edu.cn/msys2/

https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/

最近一段时间不知怎么的,使用默认的 MSYS2 源升级软件或是安装新软件的特别的慢。所以就翻了翻国内的几个开源软件的镜像库,发现中科大的库里就有 MSYS2。所以就研究了一下,给 MSYS2 添加了中科大的源。

简单的说 msys64\etc\pacman.d 目录下有三个文件。
mirrorlist.msys
mirrorlist.mingw64
mirrorlist.mingw32

##
## 32-bit Mingw-w64 repository mirrorlist
##

## Primary
## msys2.org
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686
Server = http://mirrors.ustc.edu.cn/msys2/mingw/i686
Server = http://repo.msys2.org/mingw/i686

##
## 64-bit Mingw-w64 repository mirrorlist
##

## Primary
## msys2.org
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64
Server = http://mirrors.ustc.edu.cn/msys2/mingw/x86_64
Server = http://repo.msys2.org/mingw/x86_64


##
## MSYS2 repository mirrorlist
##

## Primary
## msys2.org
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch
Server = http://mirrors.ustc.edu.cn/msys2/msys/$arch
Server = http://repo.msys2.org/msys/$arch

 https://packages.msys2.org/group/

Group    Packages
base    32
base-devel    58
compression    9
Database    2
development    79
editors    3
kde-applications    3
kdebase    3
kf5    102
libraries    77
mingw-w64-cross    9
mingw-w64-cross-toolchain    9
mingw-w64-i686    2
mingw-w64-i686-gimp-plugins    1
mingw-w64-i686-qt    2
mingw-w64-i686-qt-static    1
mingw-w64-i686-qt5    2
mingw-w64-i686-qt5-static    1
mingw-w64-i686-toolchain    17
mingw-w64-i686-vulkan-devel    4
mingw-w64-x86_64    2
mingw-w64-x86_64-gimp-plugins    1
mingw-w64-x86_64-qt    2
mingw-w64-x86_64-qt-static    1
mingw-w64-x86_64-qt5    2
mingw-w64-x86_64-qt5-static    1
mingw-w64-x86_64-toolchain    17
mingw-w64-x86_64-vulkan-devel    4
msys2-devel    7
net-utils    10
perl-modules    121
python-modules    2
sys-utils    6
tesseract-data    200
utilities    1
VCS    4
vim-plugins
  • base-devel for any building
  • msys2-devel for building msys2 packages
  • mingw-w64-i686-toolchain for building mingw32 packages
  • mingw-w64-x86_64-toolchain for building mingw64 packages

https://github.com/msys2/msys2/wiki/Creating-Packages#re-building-a-package

重新打包。。

mingw64 
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\msys2]
@="MSYS2"
"Icon"="C:\\msys64\\mingw64.ico"

[HKEY_CLASSES_ROOT\Directory\shell\msys2\command]
@="C:\\msys64\\msys2_shell.cmd -mingw64 -here"

[HKEY_CLASSES_ROOT\Directory\Background\shell\msys2]
@="MSYS2"
"Icon"="C:\\msys64\\mingw64.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\msys2\command]
@="C:\\msys64\\msys2_shell.cmd -mingw64 -here"

[HKEY_CLASSES_ROOT\Drive\shell\msys2]
@="MSYS2"
"Icon"="C:\\msys64\\mingw64.ico"

[HKEY_CLASSES_ROOT\Drive\shell\msys2\command]
@="C:\\msys64\\msys2_shell.cmd -mingw64 -here"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\msys2]
@="MSYS2"
"Icon"="C:\\msys64\\mingw64.ico"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\msys2\command]
@="C:\\msys64\\msys2_shell.cmd -mingw64 -here"
配置右键菜单

使用WScript是为了解决启动时窗体闪烁的问题。

创建文件msys2_here.vbs,我放在了 "D:\software"

set ws=WScript.CreateObject("WScript.shell")
ws.Run "C:\msys64\msys2_shell.cmd -mingw64 -here", 0

创建msys2 here.reg ,用于在注册表中创建菜单。将"D:\software"改为自己的路径,双击注册表文件导入即可

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\msys2_shell]
@="MSYS2 Here"
"Icon"="C:\\msys64\\msys2.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\msys2_shell\command]
@="WScript \"D:\\software\\msys2_here.vbs\""

参考:
https://zhuanlan.zhihu.com/p/33789023
配置桌面快捷方式

和上一节类似,主要为了解决窗口闪烁问题
新建文件D:\software\msys2.vbs

set ws=WScript.CreateObject("WScript.shell")
ws.Run "C:\msys64\msys2_shell.cmd -mingw64", 0

通过右键菜单-新建快捷方式,输入

C:\Windows\System32\wscript.exe "D:\\software\\msys2.vbs"

修改快捷方式图标为

%SystemDrive%\msys64\msys2.ico
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\msys2]
@="MSYS2"
"Icon"="E:\\msys64\\msys2.ico"

[HKEY_CLASSES_ROOT\Directory\shell\msys2\command]
@="E:\\msys64\\msys2_shell.cmd -here"

[HKEY_CLASSES_ROOT\Directory\Background\shell\msys2]
@="MSYS2"
"Icon"="E:\\msys64\\msys2.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\msys2\command]
@="E:\\msys64\\msys2_shell.cmd -here"

[HKEY_CLASSES_ROOT\Drive\shell\msys2]
@="MSYS2"
"Icon"="E:\\msys64\\msys2.ico"

[HKEY_CLASSES_ROOT\Drive\shell\msys2\command]
@="E:\\msys64\\msys2_shell.cmd -here"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\msys2]
@="MSYS2"
"Icon"="E:\\msys64\\msys2.ico"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\msys2\command]
@="E:\\msys64\\msys2_shell.cmd -here"
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\Classes\Directory\Background\shell\MINGW64 here]
"Icon"="C:\\msys64\\mingw64.exe"

[HKEY_LOCAL_MACHINE\Software\Classes\Directory\Background\shell\MINGW64 here\command]
@="C:\\msys64\\mingw64.exe bash"

[HKEY_LOCAL_MACHINE\Software\Classes\Directory\shell\MINGW64 here]
"Icon"="C:\\msys64\\mingw64.exe"

[HKEY_LOCAL_MACHINE\Software\Classes\Directory\shell\MINGW64 here\command]
@="C:\\msys64\\mingw64.exe bash"

[HKEY_LOCAL_MACHINE\Software\Classes\LibraryFolder\Background\shell\MINGW64 here]
"Icon"="C:\\msys64\\mingw64.exe"

[HKEY_LOCAL_MACHINE\Software\Classes\LibraryFolder\Background\shell\MINGW64 here\command]
@="C:\\msys64\\mingw64.exe bash"





有时候我们需要在Windows某个文件夹下,启动MSYS2的命令终端,运行sh.exe。为了方便操作,我们将启动的操作添加到右键菜单下。步骤如下:

    首先设置环境变量:set MSYS2_PATH_TYPE=inherit & set CHERE_INVOKING=1。其中第一个变量是让MSYS2继承Windows的环境变量路径,第二个是以 Windows 工作目录作为 msys2 工作目录。
    打开注册表:regedit.exe 然后在HKEY_CLASSES_ROOT\Directory\Background\shell目录下添加一个项命名为open MSYS2 here,然后在这个文件上在新建一个项命名为command,然后将其值改为在cmd下运行启动MSYS2的命令,我的供参考:D:\msys64\usr\bin\sh.exe --login -i
    添加完成,可以试试了。