云网牛站
所在位置:首页 > Linux教程 > 在优麒麟/Ubuntu系统上构建麒麟影音snap包

在优麒麟/Ubuntu系统上构建麒麟影音snap包

2018-06-26 20:35:11作者:linux人稿源:优麒麟

本文将为你介绍在优麒麟/Ubuntu系统上构建麒麟影音snap包的方法。

Snaps是易于创建与安装的容器化软件包,它可以自动更新并且安全运行。同时由于它们捆绑了本身所需的依赖,snaps 应用可以不加修改的运行在大部分Linux系统上。

 

麒麟影音是优麒麟默认的视频播放器,它使用MPV和MPlayer作为后端引擎,支持大多数音频和视频格式,并且同时支持x86和ARM平台。

接下来,我们将展示如何在优麒麟/Ubuntu 16.04(官方推荐的版本是16.04,其他版本可能存在问题,比如Ubuntu 18.04上可能不行。)上构建麒麟影音的snap包。

 

首先,我们从github上获取麒麟影音的源码:

$ git clone https://github.com/ukui/kylin-video.git

 

然后安装命令行工具 snapcraft 和编译工具链:

$ sudo apt update

$ sudo apt install snapcraft build-essential

 

使用snapcraft生成模板文件snapcraft.yaml,这个文件描述了此snap的整个构建过程:

运行:$ cd kylin-video

运行:$ snapcraft init

name: my-snap-name # you probably want to 'snapcraft register '

version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'

summary: Single-line elevator pitch for your amazing snap # 79 char long summary

description: |

This is my-snap's description. You have a paragraph or two to tell the

most important story about your snap. Keep it under 100 words though,

we live in tweetspace and your description wants to look good in the snap store.

grade: devel # must be 'stable' to release into candidate/stable channels

confinement: devmode # use 'strict' once you have the right plugs and slots

parts:

my-part:

# See 'snapcraft plugins'

plugin: nil

 

根据实际情况填入软件名、版本号、摘要和描述:

name: kylin-video

version: "1.1.6"

summary: Kylin Video

description: |

Qt5 Mplayer and MPV front-end, with basic features like playing

videos and audios to more advanced features. It supports both x86

and ARM platform, and supports most of the audio and video formats.

 

我们先把grade和confinement设置为开发模式,以便测试,待软件测试没问题后,再分别修改为”stable”和”strict”后,上传发布。

grade: devel

confinement: devmode

 

“apps”将应用程序暴露给主机系统,同时声明程序需要的权限和运行限制。

apps:

kylin-video:

command: desktop-launch kylin-video

plugs: [home, unity7, network, network-binding, desktop, pulseaudio, x11]

 

在这里,我们有一个名为kylin-video的app,并且通过”desktop-launch”来启动它。所有的GUI程序都需要使用”desktop-launch”,以保证获取到访问桌面的必要权限。

 

“plugs”代表程序需要访问的系统接口,比如:“home”表示程序可以访问用户家目录下的非隐藏文件和用户拥有的通过gvfs挂载的目录。“network”表示程序可以访问网络等等。

 

”parts”部分描述了在打包阶段将要引入的软件:

parts:

kylin-video:

plugin: qmake

source: .

qt-version: qt5

build-packages:

- g++

- qtbase5-dev

- qt5-qmake

- qtscript5-dev

- qttools5-dev-tools

- zlib1g-dev

stage-packages:

- libc6

- libgcc1

- libqt5core5a

- libqt5gui5

- libqt5network5

- libqt5widgets5

- libstdc++6

- zlib1g

- mplayer

- mpv

- mesa-vdpau-drivers

- libxcb1

- libglu1-mesa

- freeglut3

- libgpm2

- qttranslations5-l10n

 

after: [desktop-qt5]

plugin:告诉snapcraft如何编译麒麟音影。

source:指向源码目录,可以是本地的,也可以是网络上的(bzr, git, tar)。

build-packages:指示在编译前需要安装的包列表,即编译依赖。

stage-packages:定义需要打入到snap包中的包列表。

after: 表明“kylin-video”需要在“desktop-qt5”编译完成之后才进行编译。”desktop-qt5”是所有基于Qt的程序所必须的部分。

 

现在,你可以在项目主目录下运行如下命令来构建snap包了:

$ snapcraft

 

然后通过以下命令安装在当前目录生成的snap包:

$ sudo snap install kylin-video_1.1.6_amd64.snap --devmode

 

还可以通过以下命令获取关于此包更详细的信息:

$ snap info kylin-video

name:      kylin-video

summary:   Kylin Video

publisher: 

license:   unknown

description: |

Qt5 Mplayer and MPV front-end, with basic features like playing

videos and audios to more advanced features. It supports both x86

and ARM platform, and supports most of the audio and video formats.

commands:

- kylin-video

refresh-date: yesterday at 20:03 CST

installed:    1.1.6 (x2) 149MB -

 

接着,你就可以启动它了:

$ kylin-video

 

恭喜,你已经成功构建了一个snap应用!

 

相关主题

Ubuntu 16.04 LTS使用Snap软件包

精选文章
热门文章