MSYS2配置總結

MSYS2下載:http://www.msys2.org/html

MSYS2是什麼

  • MSYS2 (Minimal SYStem 2) 是一個MSYS的獨立改寫版本,主要用於 shell 命令行開發環境。同時它也是一個在Cygwin (POSIX 兼容性層) 和 MinGW-w64(從"MinGW-生成")基礎上產生的,追求更好的互操做性的 Windows 軟件。
  • MSYS2 [1] 是MSYS的一個升級版,準確的說是集成了pacman和Mingw-w64的Cygwin升級版, 提供了bash shell等linux環境、版本控制軟件(git/hg)和MinGW-w64 工具鏈。與MSYS最大的區別是移植了 Arch Linux的軟件包管理系統 Pacman(實際上是與Cygwin的區別)。

特色

  • 安裝方便
  • 自帶 pacman 管理,可使用 pkgtool 來 makepkg
  • 較快的源速度(能夠修改源地址)
  • 自帶軟件和庫較全並且比較新
  • 使用mingw-w64工具鏈,能夠編譯32位或64位代碼(須要自行安裝)
  • 中文支持好,能夠直接輸入和瀏覽中文目錄

1、MSYS2的MirrorList配置

一、修改msys2安裝目錄下的/etc/pacman.d文件夾裏面的3個mirrorlist.*文件

[mirrorlist.mingw32]
#中國科學技術大學開源軟件鏡像
Server = http://mirrors.ustc.edu.cn/msys2/mingw/i686/
#北京理工大學開源軟件鏡像
Server = http://mirror.bit.edu.cn/msys2/REPOS/MINGW/i686
#清華大學開源軟件鏡像
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686
#日本北陸先端科學技術大學院大學 sourceforge 鏡像
Server = http://jaist.dl.sourceforge.net/project/msys2/REPOS/MINGW/i686
Server = ftp://ftp.jaist.ac.jp/pub/sourceforge/m/ms/msys2/REPOS/MINGW/i686
Include = /etc/pacman.d/mirrorlist.mingw32

[mirrorlist.mingw64]
#中國科學技術大學開源軟件鏡像
Server = http://mirrors.ustc.edu.cn/msys2/mingw/x86_64/
#北京理工大學開源軟件鏡像
Server = http://mirror.bit.edu.cn/msys2/REPOS/MINGW/x86_64
#清華大學開源軟件鏡像
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64
#日本北陸先端科學技術大學院大學 sourceforge 鏡像
Server = http://jaist.dl.sourceforge.net/project/msys2/REPOS/MINGW/x86_64
Server = ftp://ftp.jaist.ac.jp/pub/sourceforge/m/ms/msys2/REPOS/MINGW/x86_64
Include = /etc/pacman.d/mirrorlist.mingw64

[mirrorlist.msys]
#中國科學技術大學開源軟件鏡像
Server = http://mirrors.ustc.edu.cn/msys2/msys/$arch
#北京理工大學開源軟件鏡像
Server = http://mirror.bit.edu.cn/msys2/REPOS/MSYS2/$arch
#清華大學開源軟件鏡像
Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch
#日本北陸先端科學技術大學院大學 sourceforge 鏡像
Server = http://jaist.dl.sourceforge.net/project/msys2/REPOS/MSYS2/$arch
Server = ftp://ftp.jaist.ac.jp/pub/sourceforge/m/ms/msys2/REPOS/MSYS2/$arch
Include = /etc/pacman.d/mirrorlist.msys

二、修改/etc/pacman.conf,把下面註釋行放開

XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u

三、更新軟件包

pacman -Syu

2、經常使用工具安裝

一、查看工具套件

pacman -Sg

獲得結果以下:node

kf5
mingw-w64-i686-toolchain
mingw-w64-i686
mingw-w64-i686-gimp-plugins
mingw-w64-i686-qt4
mingw-w64-i686-qt
mingw-w64-i686-qt5
mingw-w64-i686-vulkan-devel
tesseract-data
mingw-w64-x86_64-toolchain
mingw-w64-x86_64
mingw-w64-x86_64-gimp-plugins
mingw-w64-x86_64-qt4
mingw-w64-x86_64-qt
mingw-w64-x86_64-qt5
mingw-w64-x86_64-vulkan-devel
libraries
development
base-devel
base
msys2-devel
compression
VCS
sys-utils
Database
net-utils
editors
python-modules
mingw-w64-cross-toolchain
mingw-w64-cross
MSYS2-devel
perl-modules

自行根據須要安裝,通常較經常使用安裝python

pacman -S --noconfirm mingw-w64-x86_64-toolchain libraries development base-devel msys2-devel compression VCS sys-utils net-utils editors python-modules
pacman -S --noconfirm mingw-w64-cross mingw-w64-cross-toolchain

二、經常使用工具

  • 查看可安裝軟件列表
pacman -Sl
  • 安裝python
pacman -S --noconfirm mingw-w64-x86_64-python2 mingw-w64-x86_64-python2-setuptools mingw-w64-x86_64-python2-pip mingw-w64-x86_64-python2-ipython
pacman -S --noconfirm mingw-w64-x86_64-python3 mingw-w64-x86_64-python3-setuptools mingw-w64-x86_64-python3-pip mingw-w64-x86_64-python3-ipython
  • 安裝python科學計算庫
pacman -S --noconfirm mingw-w64-x86_64-python2-numpy mingw-w64-x86_64-python2-scipy mingw-w64-x86_64-python2-matplotlib mingw-w64-x86_64-python2-pandas
pacman -S --noconfirm mingw-w64-x86_64-python3-numpy mingw-w64-x86_64-python3-scipy mingw-w64-x86_64-python3-matplotlib mingw-w64-x86_64-python3-pandas
  • 安裝全部python工具
pacman -Sl | grep mingw-w64-x86_64-python2 | awk '{print "pacman -S --noconfirm "$2}' > python2-all.sh
sh python2-all.sh
pacman -Sl | grep mingw-w64-x86_64-python3 | awk '{print "pacman -S --noconfirm "$2}' > python3-all.sh
sh python3-all.sh
  • 安裝nodejs
pacman -S --noconfirm mingw-w64-x86_64-nodejs
  • 安裝幫助手冊
pacman -S --noconfirm help2man man-db man-pages-posix
  • 安裝zsh和git
pacman -S --noconfirm zsh git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  • 啓動打開zsh
vim .bashrc

在文件最後一行添加,固然也能夠直接在命令行中執行linux

exec zsh
  • 安裝vim
pacman -S --noconfirm vim
wget -qO- https://raw.github.com/ma6174/vim/master/setup.sh | sh -x

3、Pacman 命令詳解

Pacman 是一個命令行工具,這意味着當你執行下面的命令時,必須在終端或控制檯中進行。git

一、更新系統

  • 在 Arch Linux 中,使用一條命令便可對整個系統進行更新:
pacman -Syu
  • 若是你已經使用 pacman -Sy 將本地的包數據庫與遠程的倉庫進行了同步,也能夠只執行:
pacman -Su

二、安裝包

pacman -S 包名 例如,執行 pacman -S firefox 將安裝 Firefox。你也能夠同時安裝多個包,只需以空格分隔包名便可。
pacman -Sy 包名 與上面命令不一樣的是,該命令將在同步包數據庫後再執行安裝。
pacman -Sv 包名 在顯示一些操做信息後執行安裝。
pacman -U 安裝本地包,其擴展名爲 pkg.tar.gz。

三、刪除包

pacman -R 包名 該命令將只刪除包,不包含該包的依賴。
pacman -Rs 包名 在刪除包的同時,也將刪除其依賴。
pacman -Rd 包名 在刪除包時不檢查依賴。

四、搜索包

pacman -Ss 關鍵字 這將搜索含關鍵字的包。
pacman -Qi 包名 查看有關包的信息。
pacman -Ql 包名 列出該包的文件。

五、其餘用法

pacman -Sw 包名 只下載包,不安裝。
pacman -Sc Pacman 下載的包文件位於 /var/cache/pacman/pkg/ 目錄。該命令將清理未安裝的包文件。
pacman -Scc 清理全部的緩存文件。

關於 Pacman 更加詳細的用法,能夠閱讀Pacman 的手冊頁github

相關文章
相關標籤/搜索