什么是 Arch 用户仓库（AUR）以及如何使用？
AUR
如果你一直在使用 [Arch Linux](https://www.archlinux.org/) 或其他基于 Arch 的发行版，如 Manjaro，那么可能会遇到 AUR。你尝试安装新软件，有人建议从 AUR 中安装它。这让你感到困惑。


什么是 AUR？为什么使用它？如何使用 AUR？我将在本文中回答这些问题。


### 什么是 AUR？


![](/data/attachment/album/202004/13/202409mu6h0u7u62og52gh.png)


AUR 表示<ruby> Arch 用户仓库 <rt>  Arch User Repository </rt></ruby>。它是针对基于 Arch 的 Linux 发行版用户的社区驱动的仓库。它包含名为 [PKGBUILD](https://wiki.archlinux.org/index.php/PKGBUILD) 的包描述，它可让你使用 [makepkg](https://wiki.archlinux.org/index.php/Makepkg) 从源代码编译软件包，然后通过 [pacman](https://wiki.archlinux.org/index.php/Pacman#Additional_commands)（Arch Linux 中的软件包管理器）安装。


创建 AUR 的目的是组织和共享社区中的新软件包，并帮助加速将流行的软件包纳入[社区仓库](https://wiki.archlinux.org/index.php/Community_repository)。


进入官方仓库的大量新软件包都从 AUR 开始。在 AUR 中，用户可以贡献自己的软件包构建（PKGBUILD 和相关文件）。


AUR 社区可以对 AUR 中的软件包进行投票。如果一个软件包变得足够流行（假设它具有兼容的许可证和良好的打包技术），那么可以将其加入 `pacman` 直接访问的社区仓库中。



> 
> 简而言之，AUR 是开发人员在 Arch 仓库中正式包含新软件之前向 Arch Linux 用户提供新软件的一种方式。
> 
> 
> 


### 你应该使用 AUR 吗？有什么风险？


使用 AUR 就像过马路一样。如果你谨慎操作，应该就没问题。


如果你刚接触 Linux，建议你在建立有关 Arch/Manjaro 和 Linux 的基础知识之前不要使用 AUR。


的确，任何人都可以将软件包上传到 AUR，但[受信任用户](https://wiki.archlinux.org/index.php/Trusted_Users)（TU）负责监视上传的内容。尽管 TU 对上传的软件包执行质量控制，但不能保证 AUR 中的软件包格式正确或没有恶意。


在实践中，AUR 似乎很安全，但理论上讲它可以造成一定程度的损害，但前提是你不小心。从 AUR 构建软件包时，聪明的 Arch 用户**总是**检查 `PKGBUILD` 和 `*.install` 文件。


此外，TU（受信任用户）还会删除 AUR 中包含在 core/extra/community 中的软件包，因此它们之间不应存在命名冲突。AUR 通常会包含软件包的开发版本（cvs/svn/git 等），但它们的名称会被修改，例如 foo-git。


对于 AUR 软件包，`pacman` 会处理依赖关系并检测文件冲突，因此，除非你默认使用 `–force` 选项，否则你不必担心用另一个包中的文件会覆盖另一个包的文件。如果这么做了，你可能会遇到比文件冲突更严重的问题。


### 如何使用 AUR？


使用 AUR 的最简单方法是通过 AUR 助手。 [AUR 助手](https://itsfoss.com/best-aur-helpers/) 是一个命令行工具（有些还有 GUI），可让你搜索在 AUR 上发布的软件包并安装。


#### 在 Arch Linux 上安装 AUR 助手


假设你要使用 [Yay AUR 助手](https://github.com/Jguer/yay)。确保在 Linux 上安装了 git。然后克隆仓库，进入目录并构建软件包。


依次使用以下命令：



```
sudo pacman -S git
sudo git clone https://aur.archlinux.org/yay-git.git
cd yay
makepkg -si
```

安装后，你可以使用 `yay` 命令来安装软件包：



```
yay -S package_name
```

并非必须使用 AUR 助手来从 AUR 安装软件包。从以下文章解如何在没有 AUR 助手的情况下使用 AUR。


#### 不使用 AUR 助手安装 AUR 软件包


如果你不想使用 AUR 助手，那么也可以自行从 AUR 安装软件包。


在 [AUR 页面](https://aur.archlinux.org/)上找到要安装的软件包后，建议确认“许可证”、“流行程度”、“最新更新”、“依赖项”等，作为额外的质量控制步骤。



```
git clone [package URL]
cd [package name]
makepkg -si
```

例如。假设你要安装 [telegram 桌面包](https://aur.archlinux.org/packages/telegram-desktop-git)：



```
git clone https://aur.archlinux.org/telegram-desktop-git.git
cd telegram-desktop-git
makepkg -si
```

#### 在 Manjaro Linux 中启用 AUR 支持


它默认情况下未启用 AUR，你必须通过 `pamac` 启用它。我的笔记本电脑运行 [Manjaro](https://manjaro.org/) Cinnamon，但是所有 Manjaro 变种的步骤都相同。


打开 Pamac（显示为 “Add/Remove Software”）：


![](/data/attachment/album/202004/13/202757a8kak498x4lk4831.png)


进入 Pamac 后，请进入如下所示的<ruby> 首选项 <rt>  preferences </rt></ruby>。


![](/data/attachment/album/202004/13/202829u9j7v8mg7g2m02nd.png)


在首选项对话框中，进入 “AUR” 选项卡，启用 AUR 支持，启用检查更新，并关闭对话框。


![](/data/attachment/album/202004/13/202852ni77vilrwzdwwype.png)


现在，你可以搜索软件包，并且可以通过软件包描述下的标签来识别属于 AUR 的软件包。


![](/data/attachment/album/202004/13/202922iu6ww7t8hsyzzasd.png)


希望本文对你有用，并关注社交媒体上即将出现的与 Arch 相关的主题。




---


via: <https://itsfoss.com/aur-arch-linux/>


作者：[Dimitrios Savvopoulos](https://itsfoss.com/author/dimitrios/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

If you have been using [Arch Linux](https://www.archlinux.org/) or other [distributions based on Arch](https://itsfoss.com/arch-based-linux-distros/) such as Manjaro, you might have come across the term AUR. You try to install new software and someone suggests installing it from AUR. This leaves you confused.

What is this AUR? Why is it used? How to use AUR? I’ll answer these questions in this article.

![what is aur](https://itsfoss.com/content/images/wordpress/2022/12/what-is-aur.webp)

## What is AUR?

AUR stands for Arch User Repository. It is a community-driven repository for Arch-based Linux distribution users. It contains package descriptions named [PKGBUILDs](https://wiki.archlinux.org/index.php/PKGBUILD) that allow you to compile a package from source with [makepkg](https://wiki.archlinux.org/index.php/Makepkg) and install it via [pacman](https://wiki.archlinux.org/index.php/Pacman#Additional_commands), the package manager in Arch Linux.

The AUR was created to organize and share new packages from the community and to help accelerate popular packages’ inclusion into the [community repository](https://wiki.archlinux.org/index.php/Community_repository).

Many new packages that enter the official repositories start in the AUR. In the AUR, users are able to contribute their own package builds (PKGBUILD and related files).

The AUR community can vote for packages in the AUR. If a package becomes popular enough — provided it has a compatible license and good packaging technique — it may be entered into the community repository directly accessible by pacman.

## Should you use AUR? What’s the risk involved?

Using the AUR is like crossing the street. If you proceed with caution you should be fine.

If you are new to Linux it is advised not to use the AUR until you build a foundation knowledge about Arch/Manjaro and Linux in general.

It is true that anyone can upload packages to the AUR but the [Trusted Users](https://wiki.archlinux.org/index.php/Trusted_Users) (TUs) are charged with keeping an eye on what gets uploaded. Although TUs perform quality control on the uploaded packages, there is no guarantee that packages in the AUR are well-formed or not malicious.

In practice, the AUR seems to be quite safe but in theory, it can do some damage, but only if you are not careful. A smart Arch user **always** inspects PKGBUILDs and *.install files when building packages from the AUR.

Additionally, TUs (Trusted Users) also remove packages in the AUR that are included in core/extra/community so there should be no naming conflicts between them. The AUR will often contain developmental versions of packages (cvs/svn/git/etc) but they will have modified names such as foo-git.

As for the AUR packages, pacman handles dependency resolution and detects file conflicts. You never have to worry about overwriting files in one package with files from another unless you use the `--force`

option by default. If you do that, you probably have more serious problems than file conflicts.

## How to use AUR?

The simplest way to use AUR is through an AUR helper. An [AUR helper](https://itsfoss.com/best-aur-helpers/) is a command line tool (some have GUI as well) that lets you search for packages published on the AUR and install them.

### Installing an AUR helper on Arch Linux

Let’s say you want to use [Yay AUR helper](https://github.com/Jguer/yay). Make sure that you have git installed on Linux. And then clone the repository, go to the directory and build the package.

Use these commands one by one for that:

```
sudo pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
```


Once installed, you can use the yay command like this to install a package:

`yay -S package_name`


It’s not that you must use AUR helper for installing packages from AUR. The next section shows how to use AUR without an AUR helper.

### Installing AUR packages without AUR helpers

If you don’t want to use AUR helper, you can still install packages from AUR. You have to build them with a few commands.

As soon as you find the package you want to install on [AUR page](https://aur.archlinux.org/) it is advised to confirm “Licence”, “Popularity”, “Last Updated”, “Dependencies” and so on as an extra quality control step.

```
git clone [package URL]
cd [package name]
makepkg -si
```


For example. let’s say you want to install [telegram desktop package](https://aur.archlinux.org/packages/telegram-desktop-git):

```
git clone https://aur.archlinux.org/telegram-desktop-git.git
cd telegram-desktop-git
makepkg -si
```


## Enabling AUR support in Manjaro Linux

AUR isn’t enabled by default and you have to enable it through pamac. My laptop runs [Manjaro](https://manjaro.org/) Cinnamon but the steps are the same for all Manjaro flavors.

Open Pamac (listed as Add/Remove Software):

![open add remove software pamac from system menu](https://itsfoss.com/content/images/wordpress/2022/12/open-add-remove-software-pamac-from-system-menu.png)

Once you are in pamac go to preferences like shown below.

![preferences inside pamac](https://itsfoss.com/content/images/wordpress/2022/12/preferences-inside-pamac.png)

In the preferences dialog box go to the AUR tab, enable the AUR support, enable check for updates and close the dialog box.

![enable aur support in manjaro](https://itsfoss.com/content/images/wordpress/2022/12/enable-aur-support-in-manjaro.png)

You can now search for packages and those which belong to AUR can be identified by the tag under the package descriptions.

![aur packages in pamac](https://itsfoss.com/content/images/wordpress/2022/12/aur-packages-in-pamac.png)

AUR is one of the many [reasons why people love Arch Linux](https://itsfoss.com/why-arch-linux/) and you can see why it is so popular.

I hope you find this article useful and keep an eye on social media for upcoming Arch-related topics.