我正在尝试在 Azure 管道上的 ubuntu 容器作业上构建 Debian 包。这是我的设置:池:“AWSLinux”容器:映像:ubuntu:20.04但看起来 ubuntu:20.04 docker 映像确实……
我正在尝试在 Azure 管道上的 ubuntu 容器作业上构建 Debian 包。
这是我的设置:
pool: 'AWSLinux'
container:
image: ubuntu:20.04
但看起来 ubuntu:20.04 docker 镜像没有安装一些必需的工具。(SUDO,SVN,dpkg-architecture)
------Update and install packages------
/__w/_temp/40c7e2e3-ed1a-4d0f-a8da-5f7bf062cb90.sh: line 6: sudo: command not found
/__w/_temp/40c7e2e3-ed1a-4d0f-a8da-5f7bf062cb90.sh: line 7: sudo: command not found
/__w/_temp/40c7e2e3-ed1a-4d0f-a8da-5f7bf062cb90.sh: line 8: sudo: command not found
------Initialize build environment------
/__w/_temp/40c7e2e3-ed1a-4d0f-a8da-5f7bf062cb90.sh: line 11: sudo: command not found
------Build DEBIAN------
/__w/16/DEBIAN/scripts/build.includes: line 78: dpkg-architecture: command not found
../../../scripts/build_template.includes: line 118: svnversion: command not found
但是在 Ubuntu vmImage 上构建时我没有遇到如下所示的缺少工具的问题:
pool:
vmImage: ubuntu-20.04
所以我的计划是将 Ubuntu Docker 镜像拉到与 vmImage:ubuntu 等效的某个地方,然后推送到我的私人 Harbor 注册表以在容器规范中引用它:
container:
image: registry:ubuntu2004
endpoint: private_harbor_connection
问题是哪里可以找到这个相当于 vmImage: ubuntu 的 Ubuntu Docker 镜像?有没有更好的解决方案?谢谢。
/////////////////////////////////////////////////////////// //////////////////////////////////
这是更新后的 yaml 文件:
trigger:
- master
pool: 'AWSLinux'
container:
image: ubuntu:20.04
options: "--name sample -v /usr/bin/docker:/tmp/docker:ro"
steps:
- checkout: self
lfs: true
path: HVD
clean: true
- script: |
/tmp/docker exec -t -u root sample mv /etc/sudoers /etc/sudoers.bak
/tmp/docker exec -t -u root sample apt-get -qq update
/tmp/docker exec -t -u root sample apt-get -qq install sudo
/tmp/docker exec -t -u root sample apt-get -qq install subversion
/tmp/docker exec -t -u root sample apt-get -qq install dpkg-dev
/tmp/docker exec -t -u root sample mv /etc/sudoers.bak /etc/sudoers
- script: |
cd HVD/Sources/Proprietary/hvd-client/
echo ------Update and install packages------
sudo apt update -y
sudo apt upgrade -y
sudo apt install -y build-essential devscripts equivs git git-lfs
echo ------Initialize build environment------
sudo ./init-dev-hvd
echo ------Build HVD------
./build.tp
echo ------Build finshed------
但是第二个脚本在运行“更新和安装包”部分时卡在以下屏幕输出。
Setting up tzdata (2024a-0ubuntu0.20.04) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.
1. Africa 4. Australia 7. Atlantic 10. Pacific 13. Etc
2. America 5. Arctic 8. Europe 11. SystemV
3. Antarctica 6. Asia 9. Indian 12. US
Geographic area:
##[error]The operation was canceled.
/////////////////////////////////////////////////////////// ///////////////////
这是 6 月 5 日更新的 yaml。
trigger:
- master
pool: 'AWSLinux'
container:
image: ubuntu:20.04
options: "--name sample -v /usr/bin/docker:/tmp/docker:ro"
steps:
- checkout: self
lfs: true
path: HVD
clean: true
- script: |
/tmp/docker exec -t -u root sample mv /etc/sudoers /etc/sudoers.bak
/tmp/docker exec -t -u root sample apt-get -qq update
/tmp/docker exec -t -u root sample apt-get -qq install sudo
/tmp/docker exec -t -u root sample apt-get -qq install subversion
/tmp/docker exec -t -u root sample apt-get -qq install dpkg-dev
/tmp/docker exec -t -u root sample mv /etc/sudoers.bak /etc/sudoers
- script: |
cd HVD/Sources/Proprietary/hvd-client/
echo ------Update and install packages------
sudo apt update -y
sudo apt upgrade -y
sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential devscripts equivs git git-lfs
echo ------Initialize build environment------
sudo ./init-dev-hvd
echo ------Build HVD------
./build.tp
echo ------Build finshed------
脚本在步骤:\'./build.tp\' 失败,并出现以下错误:
------Build HVD------
No packages directory, rebuilding...
I: Cleaning hvd-client
dh clean
All build files have been removed.
I: Checking external version for hvd-client
I: This is not an external
I: Copying hvd-client
I: Checking source requirements for hvd-client
I: Checking build requirements for hvd-client
dpkg-checkbuilddeps: error: Unmet build dependencies: lbzip2 cmake qt5-default libssl-dev libpcsclite-dev libpng-dev libpulse-dev libxrandr-dev libxkbfile-dev libxcursor-dev libxt-dev chrpath python3-pip python3-venv libpython3-dev libxcb-xinerama0 libfreetype6-dev libxft-dev libqt5x11extras5-dev libxinerama-dev libudev-dev upx wmctrl libxmu-headers libxmu-dev libglib2.0-dev freerdp2-dev liblz4-tool cython3 clang-tidy-11 libuvc-dev libcups2-dev qtmultimedia5-dev qtpositioning5-dev libxext-dev libxcomposite-dev libxdamage-dev libxfixes-dev libxtst-dev libavcodec-dev libavutil-dev libicu-dev libgbm-dev libdrm-dev libjson-c-dev libopencv-dev libcurl4-openssl-dev
在哪里可以找到与 vmImage 等效的 Ubuntu Docker 映像:ubuntu
恐怕目前没有与最新的 ubuntu VmImage 具有相同配置的 docker 映像。
以下是与 Docker Hub 上 Microsoft 托管代理相关的公共映像: Azure Pipelines Agent 。但它们已经过时了。
看起来 ubuntu:20.04 docker 镜像没有安装一些必需的工具。(SUDO、SVN、dpkg-architecture)
为了解决这个问题,您可以使用 apt-get install
命令来安装所需的工具。
但是由于此映像以非root身份运行,因此您无法直接运行命令来安装工具。
这将导致以下权限错误:
您需要按照以下 YAML 脚本来安装它们:
pool:
vmImage: ubuntu-20.04
container:
image: ubuntu:20.04
options: "--name sample -v /usr/bin/docker:/tmp/docker:ro"
steps:
- script: |
/tmp/docker exec -t -u root sample mv /etc/sudoers /etc/sudoers.bak
/tmp/docker exec -t -u root sample apt-get -qq update
/tmp/docker exec -t -u root sample apt-get -qq install sudo
/tmp/docker exec -t -u root sample apt-get -qq install subversion
/tmp/docker exec -t -u root sample apt-get -qq install dpkg-dev
/tmp/docker exec -t -u root sample mv /etc/sudoers.bak /etc/sudoers
- next tasks:
然后就可以使用容器作业中的工具了。
有关更多详细信息,您可以参考此票: 无法在常见的容器发行版上获取根权限
更新:
请选择您居住的地理区域。后续配置问题将通过显示城市列表(代表城市所在的时区)来缩小选择范围。
为了解决这个问题,您需要 DEBIAN_FRONTEND=noninteractive
在 apt install 命令之前添加。
您可以尝试使用以下 yaml 示例:
trigger:
- master
pool: 'AWSLinux'
container:
image: ubuntu:20.04
options: "--name sample -v /usr/bin/docker:/tmp/docker:ro"
steps:
- checkout: self
lfs: true
path: HVD
clean: true
- script: |
/tmp/docker exec -t -u root sample mv /etc/sudoers /etc/sudoers.bak
/tmp/docker exec -t -u root sample apt-get -qq update
/tmp/docker exec -t -u root sample apt-get -qq install sudo
/tmp/docker exec -t -u root sample apt-get -qq install subversion
/tmp/docker exec -t -u root sample apt-get -qq install dpkg-dev
/tmp/docker exec -t -u root sample mv /etc/sudoers.bak /etc/sudoers
- script: |
cd HVD/Sources/Proprietary/hvd-client/
echo ------Update and install packages------
sudo apt update -y
sudo apt upgrade -y
sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential devscripts equivs git git-lfs
echo ------Initialize build environment------
sudo ./init-dev-hvd
echo ------Build HVD------
./build.tp
echo ------Build finshed------