2017-04-27 136 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',但要小心。 –