Merge pull request #12052 from wwhio/master

翻译完成
This commit is contained in:
Xingyu.Wang 2019-01-19 00:24:53 +08:00 committed by GitHub
commit 26c409f234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 308 additions and 314 deletions

View File

@ -1,314 +0,0 @@
Translating by wwhio
A Beginners Guide To Flatpak
======
![](https://www.ostechnix.com/wp-content/uploads/2016/06/flatpak-720x340.jpg)
A while, we have written about [**Ubuntus Snaps**][1]. Snaps are introduced by Canonical for Ubuntu operating system, and later it was adopted by other Linux distributions such as Arch, Gentoo, and Fedora etc. A snap is a single binary package bundled with all required libraries and dependencies, and you can install it on any Linux distribution, regardless of its version and architecture. Similar to Snaps, there is also another tool called **Flatpak**. As you may already know, packaging distributed applications for different Linux distributions are quite time consuming and difficult process. Each distributed application has different set of libraries and dependencies for various Linux distributions. But, Flatpak, the new framework for desktop applications that completely reduces this burden. Now, you can build a single Flatpak app and install it on various operating systems. How cool, isnt it?
Also, the users dont have to worry about the libraries and dependencies, everything is bundled within the app itself. Most importantly, Flaptpak apps are sandboxed and isolated from the rest of the host operating system, and other applications. Another notable feature is we can install multiple versions of the same application at the same time in the same system. For example, you can install VLC player version 2.1, 2.2, and 2.3 on the same system. So, the developers can test different versions of same application at a time.
In this tutorial, we will see how to install Flatpak in GNU/Linux.
### Install Flatpak
Flatpak is available for many popular Linux distributions such as Arch Linux, Debian, Fedora, Gentoo, Red Hat, Linux Mint, openSUSE, Solus, Mageia and Ubuntu distributions.
To install Flatpak on Arch Linux, run:
```
$ sudo pacman -S flatpak
```
Flatpak is available in the default repositories of Debian Stretch and newer. To install it, run:
```
$ sudo apt install flatpak
```
On Fedora, Flatpak is installed by default. All you have to do is enable enable Flathub as described in the next section.
Just in case, it is not installed for any reason, run:
```
$ sudo dnf install flatpak
```
On RHEL 7, run:
```
$ sudo yum install flatpak
```
On Linux Mint 18.3, flatpak is installed by default. So, no setup required.
On openSUSE Tumbleweed, Flatpak can also be installed using Zypper:
```
$ sudo zypper install flatpak
```
On Ubuntu, add the following repository and install Flatpak as shown below.
```
$ sudo add-apt-repository ppa:alexlarsson/flatpak
$ sudo apt update
$ sudo apt install flatpak
```
The Flatpak plugin for the Software app makes it possible to install apps without needing the command line. To install this plugin, run:
```
$ sudo apt install gnome-software-plugin-flatpak
```
For other Linux distributions, refer the official installation [**link**][2].
### Getting Started With Flatpak
There are many popular applications such as Gimp, Kdenlive, Steam, Spotify, Visual studio code etc., available as flatpaks.
Let us now see the basic usage of flatpak command.
First of all, we need to add remote repositories.
#### Adding Remote Repositories**
**Enable Flathub Repository:**
**Flathub** is nothing but a central repository where all flatpak applications available to users. To enable it, just run:
```
$ sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
```
Flathub is enough to install most popular apps. Just in case you wanted to try some GNOME apps, add the GNOME repository.
**Enable GNOME Repository:**
The GNOME repository contains all GNOME core applications. GNOME flatpak repository itself is available as two versions, **stable** and **nightly**.
To add GNOME stable repository, run the following commands:
```
$ wget https://sdk.gnome.org/keys/gnome-sdk.gpg
$ sudo flatpak remote-add --gpg-import=gnome-sdk.gpg --if-not-exists gnome-apps https://sdk.gnome.org/repo-apps/
```
Applications in this repository require the **3.20 version of the org.gnome.Platform runtime**.
To install the stable runtimes, run:
```
$ sudo flatpak remote-add --gpg-import=gnome-sdk.gpg gnome https://sdk.gnome.org/repo/
```
To add the GNOME nightly apps repository, run:
```
$ wget https://sdk.gnome.org/nightly/keys/nightly.gpg
$ sudo flatpak remote-add --gpg-import=nightly.gpg --if-not-exists gnome-nightly-apps https://sdk.gnome.org/nightly/repo-apps/
```
Applications in this repository require the **nightly version of the org.gnome.Platform runtime**.
To install the nightly runtimes, run:
```
$ sudo flatpak remote-add --gpg-import=nightly.gpg gnome-nightly https://sdk.gnome.org/nightly/repo/
```
#### Listing Remotes
To list all configured remote repositories, run:
```
$ flatpak remotes
Name Options
flathub system
gnome system
gnome-apps system
gnome-nightly system
gnome-nightly-apps system
```
As you can see, the above command lists the remotes that you have added in your system. It also lists whether the remote has been added per-user or system-wide.
#### Removing Remotes
To remove a remote, for example flathub, simply do;
```
$ sudo flatpak remote-delete flathub
```
Here **flathub** is remote name.
#### Installing Flatpak Applications
In this section, we will see how to install flatpak apps. To install a flatpak application
To install an application, simply do:
```
$ sudo flatpak install flathub com.spotify.Client
```
All the apps in the GNOME stable repository uses the version name of “stable”.
To install any Stable GNOME applications, for example **Evince** , run:
```
$ sudo flatpak install gnome-apps org.gnome.Evince stable
```
All the apps in the GNOME nightly repository uses the version name of “master”.
For example, to install gedit, run:
```
$ sudo flatpak install gnome-nightly-apps org.gnome.gedit master
```
If you dont want to install apps system-wide, you also can install flatpak apps per-user like below.
```
$ flatpak install --user <name-of-app>
```
All installed apps will be stored in **$HOME/.var/app/** location.
```
$ ls $HOME/.var/app/
com.spotify.Client
```
#### Running Flatpak Applications
You can launch the installed applications at any time from the application launcher. From command line, you can run it, for example Spotify, using command:
```
$ flatpak run com.spotify.Client
```
#### Listing Applications
To view the installed applications and runtimes, run:
```
$ flatpak list
```
To view only the applications, not run times, use this command instead.
```
$ flatpak list --app
```
You can also view the list of available applications and runtimes from all remotes using command:
```
$ flatpak remote-ls
```
To list only applications not runtimes, run:
```
$ flatpak remote-ls --app
```
To list applications and runtimes from a specific repository, for example **gnome-apps** , run:
```
$ flatpak remote-ls gnome-apps
```
To list only the applications from a remote repository, run:
```
$ flatpak remote-ls flathub --app
```
#### Updating Applications
To update all your flatpak applications, run:
```
$ flatpak update
```
To update a specific application, we do:
```
$ flatpak update com.spotify.Client
```
#### Getting Details Of Applications
To display the details of a installed application, run:
```
$ flatpak info io.github.mmstick.FontFinder
```
Sample output:
```
Ref: app/io.github.mmstick.FontFinder/x86_64/stable
ID: io.github.mmstick.FontFinder
Arch: x86_64
Branch: stable
Origin: flathub
Date: 2018-04-11 15:10:31 +0000
Subject: Workaround appstream issues (391ef7f5)
Commit: 07164e84148c9fc8b0a2a263c8a468a5355b89061b43e32d95008fc5dc4988f4
Parent: dbff9150fce9fdfbc53d27e82965010805f16491ec7aa1aa76bf24ec1882d683
Location: /var/lib/flatpak/app/io.github.mmstick.FontFinder/x86_64/stable/07164e84148c9fc8b0a2a263c8a468a5355b89061b43e32d95008fc5dc4988f4
Installed size: 2.5 MB
Runtime: org.gnome.Platform/x86_64/3.28
```
#### Removing Applications
To remove a flatpak application, run:
```
$ sudo flatpak uninstall com.spotify.Client
```
For details, refer flatpak help section.
```
$ flatpak --help
```
And, thats all for now. Hope you had basic idea about Flatpak.
If you find this guide useful, please share it on your social, professional networks and support OSTechNix.
More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/flatpak-new-framework-desktop-applications-linux/
作者:[SK][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.ostechnix.com/author/sk/
[1]:http://www.ostechnix.com/introduction-ubuntus-snap-packages/
[2]:https://flatpak.org/setup/

View File

@ -0,0 +1,308 @@
Flatpak 新手指南
======
![](https://www.ostechnix.com/wp-content/uploads/2016/06/flatpak-720x340.jpg)
不久前,我们介绍 Ubuntu 推出的 [**Snaps**][1]。Snaps 是由 Canonical 公司为 Ubuntu 开发的,并随后移植到其他的 Linux 发行版,如 Arch、Gentoo、Fedora 等等。由于一个 snap 包中含有软件的二进制文件和其所需的所有依赖和库,所以可以在无视软件版本、在任意 Linux 发行版上安装软件。和 Snaps 类似,还有一个名为 **Flatpak** 的工具。也许你已经知道,为不同的 Linux 发行版打包并分发应用时已经多么费时又复杂的工作,因为不同的 Linux 发行版的库不同库的版本也不同。现在Flatpak 作为分发桌面应用的新框架可以让开发者完全摆脱这些负担。开发者只需构建一个 Flatpak app 就可以在多种发行版上安装使用。这真是又酷又棒!
用户也完全不用担心库和依赖的问题了,所有的东西都和 app 打包在了一起。更重要的是 Flatpak app 们都自带沙箱而且与宿主操作系统的其他部分隔离。对了Flatpak 还有一个很棒的特性,它允许用户在同一个系统中安装同一应用的多个版本,例如 VLC 播放器的 2.1 版、2.2 版、2.3 版。这使开发者测试同一个软件的多个版本变得更加方便。
在本文中,我们将指导你如何在 GNU/Linux 中安装 Flatpak。
### 安装 Flatpak
Flatpak 可以在大多数的主流 Linux 发行版上安装使用,如 Arch Linux、Debian、Fedora、Gentoo、Red Hat、Linux Mint、openSUSE、Solus、Mageia 还有 Ubuntu。
在 Arch Linux 上,使用这一条命令来安装 Flatpak
```
$ sudo pacman -S flatpak
```
对于 Debian 用户Flatpak 被收录进 Stretch 或更新版本的默认软件源中。要安装 Flatpak直接执行:
```
$ sudo apt install flatpak
```
对于 Fedora 用户Flatpak 是发行版默认安装的软件。你可以直接跳过这一步。
如果因为任何原因没有安装的话,可以执行:
```
$ sudo dnf install flatpak
```
对于 RHEL 7 用户,安装 Flatpak 的命令为:
```
$ sudo yum install flatpak
```
如果你在使用 Linux Mint 18.3,那么 Flatpat 也随系统默认安装,所以跳过这一步。
在 openSUSE Tumbleweed 中,使用 Zypper 包管理来安装 Flatpak
```
$ sudo zypper install flatpak
```
而 Ubuntu 需要添加下面的软件源再安装 Flatpak命令如下
```
$ sudo add-apt-repository ppa:alexlarsson/flatpak
$ sudo apt update
$ sudo apt install flatpak
```
Gnome 提供了一个 Flatpak 插件,安装它就可以使用图形界面来安装 Flatpak app 了。插件的安装命令为:
```
$ sudo apt install gnome-software-plugin-flatpak
```
如果你是用发行版没有在上述的说明里,请你参考官方[**安装指南**][2]。
### 开始使用 Flatpak
有不少流行应用都支持 Flatpak 安装,如 Gimp、Kdenlive、Steam、Spotify、Visual Sudio Code 等。
下面让我来一起学习 flatpak 的基本操作命令。
首先,我们需要添加远程仓库。
#### 添加软件仓库
**添加 Flathub 仓库:**
**Flathub** 是一个包含了几乎所有 flatpak 应用的仓库。运行这条命令来启用它:
```
$ sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
```
对于流行应用来说Flathub 已经可以满足需求。如果你想试试 GNOME 应用的话,可以添加 GNOME 的仓库。
**添加 GNOME 仓库:**
GNOME 仓库包括了所有的 GNOME 核心应用,它提供了两种版本:<ruby>**稳定版**<rt>stable</rt></ruby><strong><ruby>**每日构建版**<rt>nightly</rt></ruby></strong>
使用下面的命令来添加 GNOME 稳定版仓库:
```
$ wget https://sdk.gnome.org/keys/gnome-sdk.gpg
$ sudo flatpak remote-add --gpg-import=gnome-sdk.gpg --if-not-exists gnome-apps https://sdk.gnome.org/repo-apps/
```
需要注意的是GNOME 稳定版仓库中的应用需要 **3.20 版本的 org.gnome.Platform 运行时环境**
安装稳定版运行时环境,请执行:
```
$ sudo flatpak remote-add --gpg-import=gnome-sdk.gpg gnome https://sdk.gnome.org/repo/
```
如果想使用每日构建版的 GNOME 仓库,使用如下的命令:
```
$ wget https://sdk.gnome.org/nightly/keys/nightly.gpg
$ sudo flatpak remote-add --gpg-import=nightly.gpg --if-not-exists gnome-nightly-apps https://sdk.gnome.org/nightly/repo-apps/
```
同样,每日构建版的 GNOME 仓库也需要 **org.gnome.Platform 运行时环境的每日构建版本**
执行下面的命令安装每日构建版的运行时环境:
```
$ sudo flatpak remote-add --gpg-import=nightly.gpg gnome-nightly https://sdk.gnome.org/nightly/repo/
```
#### 查看软件仓库
要查看已经添加的软件仓库,执行下面的命令:
```
$ flatpak remotes
Name Options
flathub system
gnome system
gnome-apps system
gnome-nightly system
gnome-nightly-apps system
```
如你所见,上述命令会列出你添加到系统中的软件仓库。此外,执行结果还表明了软件仓库的配置是<ruby>用户级<rt>per-user</rt></ruby>还是<ruby>系统级<rt>system-wide</rt></ruby>
#### 删除软件仓库
要删除软件仓库,例如 flathub用这条命令
```
$ sudo flatpak remote-delete flathub
```
这里的 **flathub** 是软件仓库的名字。
#### 安装 Flatpak 应用
这一节,我们将学习如何安装 flatpak 应用。
要安装一个应用,只要一条命令就能完成:
```
$ sudo flatpak install flathub com.spotify.Client
```
所有的稳定版 GNOME 软件仓库中的应用都使用“stable”作为版本名。
例如,想从稳定版 GNOME 软件仓库中安装稳定版 **Evince**,就执行:
```
$ sudo flatpak install gnome-apps org.gnome.Evince stable
```
所有的每日构建版 GNOME 仓库中的应用都使用“master”作为版本名。
例如,要从每日构建版 GNOME 软件仓库中安装 gedit 的每次构建版本,就执行:
```
$ sudo flatpak install gnome-nightly-apps org.gnome.gedit master
```
如果不希望应用安装在<ruby>系统级<rt>system-wide</rt></ruby>,而只安装在<ruby>用户级<rt>per-user</rt></ruby>,那么你可以这样安装软件:
```
$ flatpak install --user <name-of-app>
```
所有的应用都会被存储在 **$HOME/.var/app/** 目录下.
```
$ ls $HOME/.var/app/
com.spotify.Client
```
#### 执行 Flatpak 应用
你可以直接使用<ruby>应用启动器<rt>application launcher</rt></ruby>来运行已安装的 Flatpak 应用。如果你想从命令行启动的话,以 Spotify 为例,执行下面的命令:
```
$ flatpak run com.spotify.Client
```
#### 列出已安装的 Flatpak 应用
要查看已安装的应用程序和运行时环境,执行:
```
$ flatpak list
```
想只查看已安装的应用,那就用这条命令:
```
$ flatpak list --app
```
如果想查询已添加的软件仓库中的可安装程序和可安装的运行时环境,使用命令:
```
$ flatpak remote-ls
```
只列出可安装的应用程序的命令是:
```
$ flatpak remote-ls --app
```
查询指定远程仓库中的所有可安装的应用程序和运行时环境,这里以 **gnome-apps** 为例,执行命令:
```
$ flatpak remote-ls gnome-apps
```
只列出可安装的应用程序,这里以 **flathub** 为例:
```
$ flatpak remote-ls flathub --app
```
#### 更新应用程序
更新所有的 Flatpak 应用程序,执行:
```
$ flatpak update
```
更新指定的 Flatpak 应用程序,执行:
```
$ flatpak update com.spotify.Client
```
#### 获取应用详情
执行下面的命令来查看已安装应用程序的详细信息:
```
$ flatpak info io.github.mmstick.FontFinder
```
输出样例:
```
Ref: app/io.github.mmstick.FontFinder/x86_64/stable
ID: io.github.mmstick.FontFinder
Arch: x86_64
Branch: stable
Origin: flathub
Date: 2018-04-11 15:10:31 +0000
Subject: Workaround appstream issues (391ef7f5)
Commit: 07164e84148c9fc8b0a2a263c8a468a5355b89061b43e32d95008fc5dc4988f4
Parent: dbff9150fce9fdfbc53d27e82965010805f16491ec7aa1aa76bf24ec1882d683
Location: /var/lib/flatpak/app/io.github.mmstick.FontFinder/x86_64/stable/07164e84148c9fc8b0a2a263c8a468a5355b89061b43e32d95008fc5dc4988f4
Installed size: 2.5 MB
Runtime: org.gnome.Platform/x86_64/3.28
```
#### 删除应用程序
要删除一个 Flatpak 应用程序,这里以 spotify 为例,执行:
```
$ sudo flatpak uninstall com.spotify.Client
```
如果你需要更多信息,可以参考 Flatpak 的帮助。
```
$ flatpak --help
```
到此,希望你对 Flatpak 有了一些基础了解。
如果你觉得这篇指南有些帮助,请在你的社交媒体上分享它来支持 OSTechNix。
稍后还有更多精彩内容,尽情期待~
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/flatpak-new-framework-desktop-applications-linux/
作者:[SK][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[wwhio](https://github.com/wwhio)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.ostechnix.com/author/sk/
[1]:http://www.ostechnix.com/introduction-ubuntus-snap-packages/
[2]:https://flatpak.org/setup/