You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitLab CI中dpkg-buildpackage报错:debhelper版本不满足如何解决?

GitLab CI构建Deb包报错:debhelper版本不兼容问题解决

问题现象

执行dpkg-buildpackage -us -uc时触发依赖检查失败,报错如下:

$ dpkg-buildpackage -us -uc
dpkg-buildpackage: source package gentoo
dpkg-buildpackage: source version 0.9.12-1
dpkg-buildpackage: source changed by root <root@localhost>
dpkg-buildpackage: warning: debian/rules is not executable; fixing that
 dpkg-source --before-build edge_release_management
dpkg-buildpackage: host architecture amd64
dpkg-checkbuilddeps: Unmet build dependencies: debhelper (>= 10)
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)

相关配置文件

control文件

Source: gentoo
Section: unknown
Priority: optional
Maintainer: root <root@localhost>
Build-Depends: debhelper (>=10)
Standards-Version: 4.0.0
Homepage: <insert the upstream URL, if relevant>

Package: gentoo
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: <insert up to 60 chars description>

changelog文件

gentoo (0.9.12-1) unstable; urgency=medium
  * Initial release. (Closes: #nnnn)  <nnnn is the bug number of your ITP>
 -- root <root@localhost>  Mon, 22 Mar 2010 00:37:31 +0100

gitlab-ci.yml文件

# Is performed before the scripts in the stages step
before_script:  
  - source /etc/profile
  - echo "Hello, $GITLAB_USER_LOGIN!"
  - echo "Hello, $GITLAB_USER_PASSWORD"
#  - sudo rm /var/cache/apt/archives/lock
#  - sudo rm /var/lib/dpkg/lock
#  - sudo su
#  - sudo -S su < $password_secret

# Defines stages which are to be executed
stages:  
  - build

# Stage "build"
run-build:  
  stage: build
  script:
#    - apt-get install --force-yes libncurses5-dev libglib2.0-dev libgeoip-dev libtokyocabinet-dev zlib1g-dev libncursesw5-dev libbz2-dev
#    - autoreconf -fvi
#    - mkdir debian
    - ls
    - mkdir -p debian/usr/local/bin/
    - cp COPYING debian/copyright
    - cp ermbuild debian/usr/local/bin/ermbuild
#    - cp changelog debian
#    - cd ..
    - ls
#    - cd debian
    - pwd
    - ls
    - echo $EDITOR
#    - export EDITOR="/usr/bin/vim"
    - echo $EDITOR
#    - dch --create
#    - dpkg-depcheck -d ./configure #to check which all dependent packages are required 
    - dpkg-buildpackage -us -uc
    - mkdir build
    - mv ../ermbuild.deb build/

  # This stage is only executed for new tags
  only:
    - tags

  # The files which are to be made available in GitLab
  artifacts:
    paths:
      - build/*

Dockerfile(原版本)

FROM dockette/wheezy
ADD  setup.sh /opt/  
RUN  /bin/bash /opt/setup.sh

原因分析

通过apt-cache policy debhelper确认,当前Docker容器基于Debian Wheezy系统,官方源提供的debhelper最高版本为9.20120909,而control文件中指定构建依赖debhelper (>=10),版本要求不匹配,导致构建依赖检查失败。

解决方法

方案1:降低debhelper版本要求

修改control文件中的Build-Depends字段,将版本要求调整为容器支持的范围:

Build-Depends: debhelper (>=9)

容器中的9.2版本满足>=9的要求,可通过依赖检查。

方案2:升级Docker基础镜像

更换为支持debhelper 10及以上版本的系统镜像,比如Debian Stretch、Ubuntu 16.04及以上版本。

示例Dockerfile(Debian Stretch):

FROM debian:stretch
ADD setup.sh /opt/  
RUN /bin/bash /opt/setup.sh

示例Dockerfile(Ubuntu 20.04):

FROM ubuntu:20.04
ADD setup.sh /opt/  
RUN /bin/bash /opt/setup.sh

同时需要在setup.sh或gitlab-ci的构建脚本中添加依赖安装步骤:

apt update && apt install -y debhelper

额外优化

针对构建过程中debian/rules is not executable的警告,可在gitlab-ci的script步骤中添加权限设置:

- chmod +x debian/rules

内容的提问来源于stack exchange,提问作者Thor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 05:01:09