在优麒麟/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更多更详细的信息。
-
干货分享|教你如何编写桌面快捷方式文件[2021-12-16]
-
一分钟带你了解【麒麟移动运行环境 KMRE】[2021-07-03]
-
“天河二号”雄霸世界超算榜首 豪取“三连冠”[2014-06-24]
-
「开源者行」开源社高校巡回宣讲第二站:上海大学 [2014-11-14]
-
优麒麟使用教程第二期:VirtualBox 虚拟机安装[2019-06-14]
-
数千万次下载、百万行开源代码贡献,优麒麟如何打造中国开源操作系统新名片? - 卓越技术团队访谈录[2022-04-14]
-
优麒麟20.10版本发布--简而美,华而实[2020-10-23]
-
优麒麟 16.10 即将如约而至,UKUI 2.0 惊喜提前看![2019-07-10]
-
【重磅官宣】KMRE 升级版发布,支持自定义安装安卓软件![2021-09-06]
-
优麒麟 19.10 控制面板,更精准更简洁[2019-10-24]
-
Ubuntu Hackathon[2015-06-25]
-
长株潭IT技术沙龙活动(第一期)即将举行[2013-12-02]
-
银河麒麟操作系统社区版4.0.2-SP2正式发布![2017-12-19]
-
优麒麟19.10正式发布—百尺竿头,更进一步[2019-10-18]
-
优麒麟 18.04 LTS 正式版发布,不忘初心,砥砺前行[2018-04-27]
-
优麒麟 22.04 LTS 版本正式发布 - UKUI 3.1开启全新体验![2022-04-22]
-
《优客源创会》正式启动,第一站“重庆西南大学”[2016-05-10]
-
麒麟团队应邀参加 LAS 2019 国际峰会,积极推动 Linux 应用生态建设![2019-11-14]
-
震惊!没想到你是这样的flatpak...[2017-07-14]
-
优客源创会在世界历史文化名城西安成功举行[2016-06-01]