Windows下編譯打包Spice PC客戶端

 

1 環境搭建

1.1 準備工做

安裝啓動:git

  1. 安裝替換圖標工具: Resource Hacker
  2. 安裝exe製做工具: NSIS(提取碼:3dfp),在Plugins目錄下添加 processwork.dll 插件
  3. 安裝編譯工具: msys2,在開始菜單中啓動 MSYS2 MinGW 64-bit,進入 MINGW64 環境

注意事項:windows

  1. 生成32位應用程序須要在另外一個msys2下的MINGW32 環境下進行
  2. 對於MinGW 32-bit,將下文中出現的 x86_64 替換成 i686 便可
  3. msys2 的安裝目錄(例如D:\msys64)就是根目錄
  4. 全部源碼須要下載至根目錄,再進行編譯安裝

1.2 更新軟件包

pacman -Syu

軟件包 (6) bash-4.4.023-1  filesystem-2018.12-1  mintty-1~2.9.5-1
           msys2-runtime-2.11.2-1  pacman-5.1.2-2  pacman-mirrors-20180604-2

根據提示,關閉 msys2,從開始菜單欄從新啓動,而後再執行一次。bash

1.3 安裝開發工具

pacman -S base-devel --noconfirm

:: 在組 base-devel 中有 56 成員:
:: 軟件倉庫 msys
1) asciidoc  2) autoconf  3) autoconf2.13  4) autogen  5) automake-wrapper  6) automake1.10  7) automake1.11  8) automake1.12  9) automake1.13  10) automake1.14  11) automake1.15  12) automake1.16  13) automake1.6  14) automake1.7  15) automake1.8  16) automake1.9  17) bison  18) diffstat  19) diffutils  20) dos2unix  21) file  22) flex  23) gawk  24) gdb  25) gettext  26) gettext-devel  27) gperf  28) grep  29) groff  30) help2man  31) intltool  32) lemon  33) libtool  34) libunrar  35) libunrar-devel  36) m4  37) make  38) man-db  39) pacman  40) pactoys-git  41) patch  42) patchutils  43) perl  44) pkg-config  45) pkgfile  46) quilt  47) rcs  48) scons  49) sed  50) swig  51) texinfo  52) texinfo-tex  53) ttyrec  54) unrar  55) wget  56) xmlto

1.4 安裝工具鏈

pacman -S mingw-w64-x86_64-toolchain --noconfirm

:: 在組 mingw-w64-x86_64-toolchain 中有 17 成員:
:: 軟件倉庫 mingw64
1) mingw-w64-x86_64-binutils  2) mingw-w64-x86_64-crt-git  3) mingw-w64-x86_64-gcc  4) mingw-w64-x86_64-gcc-ada  5) mingw-w64-x86_64-gcc-fortran  6) mingw-w64-x86_64-gcc-libgfortran  7) mingw-w64-x86_64-gcc-libs  8) mingw-w64-x86_64-gcc-objc  9) mingw-w64-x86_64-gdb  10) mingw-w64-x86_64-headers-git  11) mingw-w64-x86_64-libmangle-git  12) mingw-w64-x86_64-libwinpthread-git  13) mingw-w64-x86_64-make  14) mingw-w64-x86_64-pkg-config  15) mingw-w64-x86_64-tools-git  16) mingw-w64-x86_64-winpthreads-git  17) mingw-w64-x86_64-winstorecompat-git

1.5 安裝依賴包

pacman -S \
mingw-w64-x86_64-gst-libav \
mingw-w64-x86_64-gst-plugins-bad \
mingw-w64-x86_64-gst-plugins-base \
mingw-w64-x86_64-gst-plugins-good \
mingw-w64-x86_64-gst-plugins-ugly \
mingw-w64-x86_64-gstreamer --noconfirm
pacman -S \
mingw-w64-x86_64-icoutils \
mingw-w64-x86_64-python2-six \
mingw-w64-x86_64-python2-pyparsing --noconfirm

1.6 安裝spice-gtk的依賴包

(1)安裝spice-gtk 0.35-3及其依賴包app

pacman -S mingw-w64-x86_64-spice-gtk --noconfirm

(2)保留依賴包,卸載spice-gtk等ide

pacman -R mingw-w64-x86_64-spice-gtk \
mingw-w64-x86_64-usbredir \
mingw-w64-x86_64-libusb \
mingw-w64-x86_64-spice-protocol --noconfirm

2 編譯客戶端

版本說明:工具

組件名稱 瘦終端版本 pacman默認 PC客戶端
spice-protocol 0.12.13 0.12.14-1 0.12.13(make install)
libusb 1.0.21 1.0.22-1 1.0.22(make install)
usbredir 0.7.1 0.8.0-1 0.8.0(make install)
spice-gtk 0.34 0.35-3 0.34(make install)

編譯步驟:開發工具

  1. spice-protocol 0.12.23
  2. libusb 1.0.22
  3. usbredir 0.8.0
  4. spice-gtk 0.34
  5. clouddesktop-client

2.1 編譯spice-protocol

(1)下載spice-protocol 0.12.13源碼測試

git clone http://10.142.233.181:8888/ctg-cache/spice-protocol.git

(2)而後make installflex

cd /spice-protocol && ./configure && make && make install

2.2 編譯libusb

(1)下載libusb-1.0.22源碼

git clone http://10.142.233.181:8888/zengzhihua/libusb-1.0.22.git

(2)而後make install

cd /libusb-1.0.22 && ./configure && make && make install

2.3 編譯usbredir

(1)下載usbredir-0.8.0源碼

git clone http://10.142.233.181:8888/zengzhihua/usbredir-0.8.0.git

(2)而後make install(首次編譯時必須執行 sh autogen.sh

cd /usbredir-0.8.0 && sh autogen.sh && ./configure && make && make install

2.4 編譯spice-gtk

(1)下載spice-gtk 0.34源碼

git clone http://10.142.233.181:8888/zengzhihua/spice-gtk-0.34.git

(2)而後configure

cd /spice-gtk-0.34 && ./configure --disable-werror --enable-vala

成功後出現:

configure:

        Spice-Gtk 0.34
        ==============

        prefix:                   /mingw64
        c compiler:               gcc
        Target:                   Windows

        Gtk:                      3.0
        Coroutine:                winfiber
        PulseAudio:               no
        GStreamer Audio:          yes
        GStreamer Video:          yes
        SASL support:             yes
        Smartcard support:        no
        USB redirection support:  yes
        DBus:                     yes
        WebDAV support:           yes
        LZ4 support:              yes

        Now type 'make' to build spice-gtk

(3)而後make install

make -j4 && make install

(4)編譯完成後執行spicy測試一下

spicy

2.5 編譯客戶端

(1)下載clouddesktop-client中windows-master分支的源碼

git clone -b windows-master http://10.142.233.181:8888/ctg-cache/clouddesktop-client.git clouddesktop-client-windows

(2)而後make install(注:首次編譯時必須執行sh autogen.shx.x.x 替換成相應的版本號)

cd /clouddesktop-client-windows && sh autogen.sh && \
./configure --prefix=/CtyunDesktop-x64-x.x.x && \
make -j4 && make install

2.6 快速編譯

(1)下載源碼(可在 Git Bash 執行)

git clone http://10.142.233.181:8888/ctg-cache/spice-protocol.git && \
git clone http://10.142.233.181:8888/zengzhihua/libusb-1.0.22.git && \
git clone http://10.142.233.181:8888/zengzhihua/usbredir-0.8.0.git && \
git clone http://10.142.233.181:8888/zengzhihua/spice-gtk-0.34.git && \
git clone -b windows-master http://10.142.233.181:8888/ctg-cache/clouddesktop-client.git clouddesktop-client-windows

(2)編譯腳本(x.x.x 替換成相應的版本號)

cd /spice-protocol && ./configure && make && make install && \
cd /libusb-1.0.22 && ./configure && make && make install && \
cd /usbredir-0.8.0 && sh autogen.sh && ./configure && make && make install && \
cd /spice-gtk-0.34 && ./configure --disable-werror --enable-vala && make -j4 && make install && \
cd /clouddesktop-client-windows && sh autogen.sh && ./configure --prefix=/CtyunDesktop-x64-x.x.x && make -j4 && ./src/remote-viewer.exe --debug

3 打包客戶端

3.1 替換應用程序圖標

打開Resource Hacker
(1)Open → 選擇 /CtyunDesktop-x64-x.x.x/bin/remote-viewer.exe
(2)Add Binary or Image Resource → 選擇 clouddesktop-client-windows/nsis/NSIS-Icon.ico
(3)Save(Ctrl+S)

3.2 修改配置

進入clouddesktop-client-windows/nsis
(1)修改 MakePackage-x64.bat 中的 dirname(CtyunDesktop-x64-x.x.x)
(2)修改 NSIS-Licence-x64.txt 中的 Software Licence (安裝程序的許可說明)

3.3 運行腳本

(1)進入clouddesktop-client-windows/nsis,雙擊運行 MakePackage-x64.bat腳本,成功後進入CtyunDesktop-x64-x.x.x,文件結構以下:

|-- bin/
|-- lib/
|-- log/
|-- plugin/
|-- share/
|-- cloud-desktop-config.ini

(2)修改 cloud-desktop-config.ini 中的 cloud_urls ,對應不一樣環境的https接口地址

3.4 打包生成exe

進入clouddesktop-client-windows/nsis
(1)使用 HM VNISEdit 2.0.3 打開 NSIS-Setup-x64.nsi
(2)修改版本號: !define PRODUCT_VERSION "x.x.x"
(3)運行腳本:工具欄→NSIS→編譯腳本,獲得 CtyunDesktop-x64-x.x.x.exe

相關文章
相關標籤/搜索