Detailed Linux methods for packaging applications as snap package formats

Source: Internet
Author: User

Distributing applications on Linux is not always easy. There are a variety of package formats, basic systems, and available libraries, all of which are a headache as distributions are released over and over again. Now, however, we have something simpler: Snap.

Snap is a new way for developers to package their applications, and it brings many advantages over traditional package formats such as. deb,.rpm. Snap is secure, isolated from each other, and host systems use similar apparmor technologies that are cross-platform and self-contained, allowing developers to accurately package the dependencies required by the application. Sandbox isolation also enhances security and allows applications and the entire snap-based system to be rolled back when problems arise. Snap is really the future of Linux application packaging.

Creating a snap package is not difficult. First, you need a snap base runtime environment that allows your desktop environment to recognize and run the snap package, a tool called SNAPD, which is built into all Ubuntu 16.04 systems by default. Then you need to create the Snap tool Snapcraft, which can be installed with a simple command:

The code is as follows:
$ sudo apt-get install Snapcraft

The environment is ready to snap when it's installed.

Snap uses a specific YAML format for file Snapcraft.yaml, which defines how the application is packaged and the dependencies it needs. With a simple application to demonstrate, the following YAML file is a practical example of how to snap a Moon-buggy game, which is provided in the Ubuntu source.

The code is as follows:

Name:moon-buggy
version:1.0.51.11

Summary:drive a car across the moon
Description: |

A simple command-line game where your drive a buggy on the moon

Apps
Play
Command:usr/games/moon-buggy
Parts
Moon-buggy:
Plugin:nil
Stage-packages: [Moon-buggy]
Snap
–usr/games/moon-buggy


The code above shows several new concepts. The first part is about how to get the information that your application can find in the store, setting the package's metadata name, version number, summary, and description. The Apps section implements the play command, pointing to the location of the Moon-buggy executable file. The parts section tells Snapcraft the Plug-ins needed to build the application and the dependent packages. All we need in this simple example is the Moon-buggy application itself from the Ubuntu source, Snapcraft is responsible for the rest of the work.

Running Snapcraft in your Snapcraft.yaml directory creates MOON-BUGGY1.0.51.11AMD64.SNAP packages that you can install using the following command:

The code is as follows:

$ snap Install Moon-buggy_1.0.51.11_amd64.snap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.