使用 yaourt 和 >makepkg-4.2.0 从 AUR 为 Arch Linux 在 Docker 中自动构建和安装软件包

Automatic building and installing Packages from AUR for Arch Linux inside Docker with yaourt and >makepkg-4.2.0

我在 Docker-Container 中使用 Docker 和 Arch Linux。 介绍 makepkg-4.2.0 我的 yaourt 安装命令被破坏,如下所述:https://github.com/archlinuxfr/yaourt/issues/67

问题是,yaourt 应该 运行 作为非根用户。但是由于 yaourt 还希望在每个案例中安装包,因此在构建它之后,需要 root 用户或具有安装包权限的用户。

所以我的问题是如何解决这个问题?我想在 Docker 中安装来自 AUR 的软件包,因为还没有官方软件包存在。

直到现在我一直在使用 Arch Linux、pacman 和 yaourt。

所以命令,

RUN yaourt -S --noconfirm aur/taskd

安装 taskd,在 makepkg-4.2.0 之前工作:

使用新的 makepkg 版本构建 Docker 失败并出现来自 yaourt 的以下错误:

makepkg: invalid option '--asroot'

如果我将用户更改为非 root 用户并尝试安装软件包,我会在自动构建中收到命令提示符,要求输入用于实际安装软件包的 Root 密码。

Password: su: Authentication information cannot be recovered
Password: su: Authentication information cannot be recovered
Password: su: Authentication information cannot be recovered
The command [/bin/sh -c yaourt -S --noconfirm aur/taskd] returned a non-zero code: 1

在不污染分布在两个 Docker 文件中的许多离题行的情况下,Docker 文件的有趣部分如下所示:

FROM kaot/arch_linux_base:latest
MAINTAINER Kaot
RUN useradd --no-create-home --shell=/bin/false yaourt && usermod -L yaourt
RUN yaourt -S --noconfirm aur/taskd
ENTRYPOINT ["/controlcenter/controlcenter.sh"]
CMD ["cc:start"]

如果找到一个让 yaourt 只下载如何构建包的信息的解决方案,则调用 makepkg 本身,两者都使用非根用户,然后使用根用户和 pacman 安装构建包。 Dockerfile 的部分如下所示

RUN mkdir -p /tmp/Package/ && chown yaourt /tmp/Package
USER yaourt
RUN cd /tmp/Package && pwd && ls -al && yaourt --getpkgbuild aur/taskd && cd taskd && makepkg --pkg taskd 
USER root
RUN pacman -U --noconfirm /tmp/Package/taskd/taskd-1.1.0-1-x86_64.pkg.tar.xz

有了一些变量,可以实现进一步的增强,但原则上这是可行的。