NEWS

新闻

了解优麒麟最新资讯,关注社区和产品动态。

NEWS

Learn about the latest news.

Enjoy Snap pacakge for kylin-video on Ubuntu and Ubuntu Kylin!

2018-06-27 14:05:30

Snaps are containerised software packages that are simple to create and install. They could auto-update and are safe to run. Forthermore, because they bundle their dependencies, they could work on all major Linux systems without modification. 

Kylin Video is the default video player on Ubuntu Kylin, which utilizes MPV and MPlayer as background play engine. Kylin Video supports most of the audio and video formats, with a professional user interface. It supports both x86 and ARM platform. 

We are going to show you how to snap kylin-video on Ubuntu/Ubuntu Kylin 16.04 which is the recommend platforms. 

First, get the source code of kylin-video from github:

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

Then, install the command line tool snapcraft and build tools:

$ sudo apt update

$ sudo apt install snapcraft build-essential

Then, Use snapcraft to generate the template snapcraft.yaml file which describe the entire build process for a 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

Modify the name, version, summary entries to fit our case:

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.

For the convenience of testing, we set grade to devel, and confinement to devmode, and after everything works fine, we change it to stable and strict

grade: devel

confinement: devmode

The “apps” YAML subsection exposes apps and daemon from your package to the host system, declares their permissions and run conditions.

apps:

  kylin-video:

    command: desktop-launch kylin-video

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

In this case, we have a app “kylin-video” and we launch our app by “desktop-launch” program. All GUI applications need to use desktop-launch so that the application is granted the necessary access to the desktop.

The “plugs” represent the list of interfaces the app should have access to. For example, “home” means your app can access non-hidden files in user's $HOME and gvfs mounted directories owned by the user to read/write/lock. “network” means your app can access the network as a client. For more details please refer tohttps://docs.snapcraft.io/core/interfaces

The parts YAML subsection declares individual pieces of code to be imported and possibly built or modified in your snap at packaging time.

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” tell snapcraft how to build kylin-video and “source” point to the location of source code.

“build-packages” list the packages to install on the build host before building the part.

“stage-packages” list the packages to be downloaded and unpacked to join the part before it’s build.

“after” make sure it build “desktop-qt5” which is the necessary part of Qt-based applications before build kylin-video. 

Now, you can build your snap from the project directory by running snapcraft:

$ snapcraft

and install it:

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

you can use the “snap info” command to get more details about it:

$ 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 -

Finally, you can launch it:

$ kylin-video

Congratulations, you’ve just made a snap, and you can obtain more knowledge from snapcraft.io.