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

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


1)方案一


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

snapcraft.yaml


name: electronic-wechat
version: '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 channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
  electronic-wechat:
    command: desktop-launch $SNAP/wechat.wrapper
    plugs:
      - unity7
      - opengl
      - network
      - pulseaudio
      - home
      - browser-support
      - gsettings
      - x11

parts:
  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)方案二


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


snapcraft.yaml


name: electronic-wechat
version: '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 channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
  electronic-wechat:
    command: desktop-launch $SNAP/wechat.wrapper
    plugs:
      - unity7
      - opengl
      - network
      - pulseaudio
      - home
      - browser-support
      - gsettings
      - x11

parts:
  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 list
Name                 Version  Rev  Developer  Notes
core                 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已经被成功安装到我的电脑中.运行我们的应用:








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值