在优麒麟/Ubuntu上构建麒麟影音snap包
Snaps是易于创建和安装的容器化软件包,它们可以自动更新并且安全运行。同时由于它们捆绑了本身所需的依赖,snaps 应用可以不加修改的运行在大部分Linux系统上。
麒麟影音是优麒麟默认的视频播放器,它使用MPV和MPlayer作为后端引擎,支持大多数音频和视频格式,并且同时支持x86和ARM平台。
接下来,我们将展示如何在优麒麟/Ubuntu 16.04(官方推荐的版本是16.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”表示程序可以访问网络等等。更详细的说明,可以参考:https://docs.snapcraft.io/core/interfaces.
”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应用!你可以在snapcraft.io获取关于snap更多更详细的信息。
-
优麒麟团队谭郁松博士将在 《2015 OpenStack技术大会》做主题报告[2015-03-30]
-
[简讯] CCN 联合实验室 Ubuntu Kylin 技术研讨会在长沙召开![2016-09-01]
-
优麒麟 - 你真的了解【开始菜单】吗?[2021-07-16]
-
武城张家口河北建筑工程学院首次优麒麟( Ubuntu Kylin )发布派对[2015-06-01]
-
优客源创会在世界历史文化名城西安成功举行[2016-06-01]
-
【干货分享】优麒麟上的硬盘读写性能测试(附感恩节获奖名单)[2021-12-16]
-
优麒麟(Ubuntu Kylin )社区协Linux伊甸园举办“开源者行上海松江站”[2015-04-21]
-
KMRE 再升级!你们想要的功能它来了~[2022-05-05]
-
Ubuntu Kylin 14.10“秀出自己” 壁纸征集大赛获奖作品出炉[2014-09-24]
-
【用户投稿】优麒麟社区懒人版本(含软件全家桶)一键安装[2022-01-10]
-
Ubuntu Kylin 14.10 "My Life·My Style·My Self ——秀出自己"壁纸征集大赛启动![2014-07-15]
-
不忘初心,砥砺前行——优麒麟社区2018年元旦致辞[2018-01-01]
-
Ubuntu/优麒麟 19.10内测夏令营[2019-08-28]
-
优麒麟 20.04.1 发布,多达 418 处更新![2020-08-07]
-
银河麒麟操作系统社区版4.0.2-SP2正式发布![2017-12-19]
-
Ubuntu Kylin 下常用应用使用 snap 包推荐[2016-08-22]
-
优麒麟 18.04.4 LTS 版本发布![2020-02-13]
-
涨知识:如何在优麒麟和银河麒麟社区版上构建Linux跨平台的snap/flatpak包?[2017-05-10]
-
震惊!没想到你是这样的flatpak...[2017-07-14]