2017-04-27 106 views
2

我需要将docker与gitlab-ci配合使用,以便在每次提交时自动构建和测试archlinux软件包。如何使用gitlab-ci构建docker内的archlinux pkgbuild

.gitlab-ci.yml

image: pritunl/archlinux 

before_script: 
    - pacman -Su pkgbuild-introspection --noconfirm 

stages: 
    - build 

makepkg: 
    script: 
    - makepkg --clean --rmdeps --syncdeps --noarchive --noconfirm --noprogressbar --asdeps 
    stage: build 

一切都很好,但是当CI呼叫makepkg命令我得到这个错误:

==> ERROR: Running makepkg as root is not allowed as it can cause permanent, catastrophic damage to your system. 

==> ERROR: An unknown error has occurred. Exiting... 

我该如何解决呢?

回答

2

AFAIK,没有办法以root身份运行makepkg。如果以root用户身份运行,makepkg可以将文件放置在系统的任何位置,而不仅仅是位于该软件包的制造地点的$pkgdir。这通过使用fakeroot来停止,当以root运行时,该功能被禁用。

A fake root is simply a subdirectory within the build directory that functions and behaves as the system's root directory. In conjunction with the fakeroot program, makepkg creates a fake root directory, and installs the compiled binaries and associated files into it, with root as owner.

我建议你扩展pritunl/archlinux图像,并添加一个简单的用户,只为makepkg操作。

+0

或者无需创建新图像,可以从'.gitlab-ci.yml'文件创建一个新用户,并将其用于'makepkg'命令。 – Jawad

+0

但makepkg需要增加privelagions作为另一个用户然后运行时。我如何解决它? – CryptoManiac

+2

类似的东西,是hacky的伎俩,但它获得root权限用户'echo'your_user ALL =(ALL)ALL'>>/etc/sudoers',但要小心。 –