如何打包electronic-wechat(微信)为snap包

来源:互联网 发布:www.4399js.com 编辑:程序博客网 时间:2024/05/19 15:25

基于开发者程路的项目:https://github.com/dawndiy/electronic-wechat-snap,我对该项目做了一些小的修改.但最终把electronic-wechat打包为snap应用.


1)方案一


在整个方案中,我们直接把一个稳定编译好的发布直接下载打包.这个项目的源码:

https://github.com/liu-xiao-guo/wechat

snapcraft.yaml


name: electronic-wechatversion: '1.4.0'summary: A better WeChat on macOS and Linux. Built with Electron.description: |  Electronic WeChat is a unoffical WeChat client. A better WeChat on  macOS and Linux. Built with Electron.grade: stable # must be 'stable' to release into candidate/stable channelsconfinement: strict # use 'strict' once you have the right plugs and slotsapps:  electronic-wechat:    command: desktop-launch $SNAP/wechat.wrapper    plugs:      - unity7      - opengl      - network      - pulseaudio      - home      - browser-support      - gsettings      - x11parts:  electronic-wechat:    plugin: dump    source: https://github.com/geeeeeeeeek/electronic-wechat/releases/download/v1.4.0/linux-x64.tar.gz    stage-packages:      - libnss3      - fontconfig-config      - gnome-themes-standard      - fonts-wqy-microhei      - libasound2-data      - fcitx-frontend-gtk2      - overlay-scrollbar-gtk2      - libatk-adaptor      - libcanberra-gtk-module    filesets:      no-easy-install-files:        - -usr/sbin/update-icon-caches        - -README.md    stage:      - $no-easy-install-files    prime:      - $no-easy-install-files  wechat-copy:    plugin: dump    source: .    filesets:      wechat.wrapper: wechat.wrapper    after:       - electronic-wechat      - desktop-gtk2

在这里,我们直接在地址https://github.com/geeeeeeeeek/electronic-wechat/releases/download/v1.4.0/linux-x64.tar.gz下载已经编译好的稳定的版本,并进行打包.这里我们可以利用dump plugin来帮我们进行安装.

2)方案二


我们可以利用最新的代码来编译,并打包.这个项目的源码在:

https://github.com/liu-xiao-guo/wechat1

snapcraft.yaml


name: electronic-wechatversion: '1.4.0'summary: A better WeChat on macOS and Linux. Built with Electron.description: |  Electronic WeChat is a unoffical WeChat client. A better WeChat on  macOS and Linux. Built with Electron.grade: stable # must be 'stable' to release into candidate/stable channelsconfinement: strict # use 'strict' once you have the right plugs and slotsapps:  electronic-wechat:    command: desktop-launch $SNAP/wechat.wrapper    plugs:      - unity7      - opengl      - network      - pulseaudio      - home      - browser-support      - gsettings      - x11parts:  electronic-wechat:    plugin: nodejs    source-type: git    source: https://github.com/geeeeeeeeek/electronic-wechat/    source-branch: production    npm-run:      - build:linux    install: cp -r dist $SNAPCRAFT_PART_INSTALL    stage-packages:      - libnss3      - fontconfig-config      - gnome-themes-standard      - fonts-wqy-microhei      - libasound2-data      - fcitx-frontend-gtk2      - overlay-scrollbar-gtk2      - libatk-adaptor      - libcanberra-gtk-module    filesets:      no-easy-install-files:        - -usr/sbin/update-icon-caches        - -README.md    stage:      - $no-easy-install-files    prime:      - $no-easy-install-files  wechat-copy:    plugin: dump    source: .    filesets:      wechat.wrapper: wechat.wrapper    after:       - electronic-wechat      - desktop-gtk2

最新的代码在地址https://github.com/geeeeeeeeek/electronic-wechat/可以找到.我们利用nodejs plugin来帮我们进行打包.在这里,我们使用了snapcraft的Scriplets来覆盖我们的nodejs plugin中的install:

   install: cp -r dist $SNAPCRAFT_PART_INSTALL

对于上面的npm-run那一句,我们甚至也可以删除,并用snapcraft中的Scriplets来实现:

build: npm run build:linux

我们在项目的根目录下打入如下的命令:

$ snapcraft

它将最终帮我们生成我们所需要的.snap文件.我们可以安装到我们的系统中:

$ sudo snap install electronic-wechat_1.4.0_amd64.snap --dangerous

liuxg@liuxg:~$ snap listName                 Version  Rev  Developer  Notescore                 16.04.1  888  canonical  -electronic-wechat    1.4.0    x1              -hello-world          6.3      27   canonical  -hello-xiaoguo        1.0      x1              -snappy-debug         0.28     26   canonical  -ubuntu-app-platform  1        22   canonical  -

我们可以看到electronic-wechat已经被成功安装到我的电脑中.运行我们的应用:








0 0
原创粉丝点击