Ubuntu 릴리스에 따라 다른 'debian/control' 파일을 어떻게 생성합니까?

Ubuntu 릴리스에 따라 다른 'debian/control' 파일을 어떻게 생성합니까?

저는 우리가 관리하는 많은 양의 소스 코드를 보유하고 있으며 다양한 Ubuntu 패키지를 제작하고 있습니다. 이러한 패키지는 모두 Ubuntu LTS 릴리스를 기반으로 빌드해야 합니다.우분투 8.04(하디 헤론) 앞으로. (예, 이 제품은 오래되었고 지원되지 않는다는 것을 알고 있습니다. 공간 제약이 있는 시스템용이므로 새 릴리스로 업데이트하는 것은 불가능합니다. 하지만 새 릴리스를 위해 업데이트하는 동안 여전히 해당 소프트웨어를 유지 관리해야 합니다.)

전체 코드 기반을 구축하고 실행하려고 합니다.우분투 14.04(신뢰할 수 있는 타르). 나는 Python 코드의 패키징이 완전히 변경되었다는 사실에 실망스럽게도 많은 것을 발견했습니다. Trusty부터 python-support와 python-central은 사라졌고dh_python2는 당신이 사용해야하는 것입니다.

내 문제는 작업 파일을 만드는 방법입니다 debian/control. 빌드에 따라 다름: 최대 버전우분투 12.04(Precise Pangolin)은 를 포함해야 python-central하지만 14.04 이상 버전의 경우 를 포함해야 합니다 dh_python2. 제어 파일에서 조건부 텍스트에 대한 조항을 찾지 못했습니다. 이 문제를 해결할 방법을 찾으려고 노력했지만 지금까지는 아무것도 작동하지 않습니다.

어떻게 할 수 있습니까?

저는 수많은 Ubuntu 버전, CentOS 버전 및 일부 OS X 버전에서 컴파일되는 광범위한 빌드봇 시스템을 실행하고 있습니다. 다른 버전에 대해 분기된 패키지로 분할하면 문제가 발생할 수 있습니다. 그래서 단일 소스 트리에서 작동하는 솔루션을 찾고 있습니다. dpkg-buildpackage에서 버전별로 설정하는 데 사용할 수 있는 후크를 초기에 찾으려고 노력하고 있지만 아직 해결책을 찾지 못했습니다.

답변1

가장 쉬운 방법은 현장에서 대체 패키지 Build-Dependsfe 를 사용하는 것입니다 Build-Depends: dh-python | python-central, [...]. 여기에는 몇 가지 단점이 있습니다. 종속성 해결 프로그램을 만족하는 첫 번째 종속성이 선택됩니다. 버전이 지정된 Build-Depends(일부 이전 버전의 패키지가 불완전하다는 것을 알고 있는 경우 fe)를 사용할 수도 있습니다 Build-Depends: dh-python (>= <correct_version) | python-central.

이전(또는 이후 릴리스)에 존재하지 않는 패키지에 의존해야 하는 경우 더 복잡한 방법은 base-files (<< <version>) | real-package단순히 종속성으로 추가하고 다음 릴리스의 버전과 일치하도록 real-package조정하는 것 입니다. 이전 시스템에는 패키지 가 <version>필요하지만 새 시스템에는 필요하지 않은 경우 .base-file (>= <version>) | real-package<version>real-package

예를 들어 apache2Ubuntu 12.04의 백포팅을 libnghttp2-dev위해 base-files (<< 7.2~) | libnghttp2-dev.

d/rulesMySQL-5.6 백포트에서 스니펫을 추가하겠습니다 .

DPKG_VENDOR          ?= $(shell dpkg-vendor --query Vendor | tr [A-Z] [a-z])
DEB_DISTRIBUTION     = $(shell dpkg-parsechangelog | sed -ne 's/^Distribution: //p')

ENABLE_SYSTEMD = yes

ifeq (ubuntu,$(DPKG_VENDOR))
  ifeq ($(DEB_DISTRIBUTION),$(filter $(DEB_DISTRIBUTION),precise))
    $(warning Disabling systemd on $(DPKG_VENDOR) $(DEB_DISTRIBUTION))
    ENABLE_SYSTEMD = no
  endif
endif

[...]
%:
ifeq (yes,$(ENABLE_SYSTEMD))
        dh $@ --parallel --with systemd
else
        dh $@ --parallel
endif

그리고d/control

Build-Depends: [...], dh-systemd (>= 1.5) | base-files (<< 7.2ubuntu5~)

답변2

다음은 모든 릴리스에서 코드를 빌드할 수 있도록 제가 생각해낸 스크립트입니다. 제 경우에는 control.pre_trusty와 control.post_precise 파일을 생성했고, rule.pre_trusty와 rule.post_precise를 생성했습니다.

#! /bin/bash
#
# Do magic to allow building on different Ubuntu releases. This script is
# called by buildbot on the different systems prior to dpkg-buildpackage. Do
# what is needed to accomodate different build step requirements as
# Ubuntu changes.
# "pre" and "post" are not inclusive. For example, *.pre_precise files
# apply to hardy and lucid, but not precise or anything after.

RELEASE=$(lsb_release --release --short | tr -d '.')
export LANG=C   # so "cp" doesn't use fancy quoting, which messes up web page

#######################################################################
### we need to run this from the debian directory
#######################################################################
if [ -d debian ] ; then cd debian ; fi
if [ -d "*/debian" ] ; then cd */debian ; fi

#######################################################################
### copy files that apply to previous releases
#######################################################################
cp_pre_lucid ()
{
    for i in *.pre_lucid ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .pre_lucid) ; fi
    done
}

cp_pre_precise ()
{
    for i in *.pre_precise ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .pre_precise) ; fi
    done
}

cp_pre_trusty ()
{
    for i in *.pre_trusty ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .pre_trusty) ; fi
    done
}

cp_pre_xenial ()
{
    for i in *.pre_xenial ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .pre_xenial) ; fi
    done
}

#######################################################################
### copy files that apply to subsequent releases
#######################################################################
cp_post_hardy ()
{
    for i in *.post_hardy ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .post_hardy) ; fi
    done
}

cp_post_lucid ()
{
    for i in *.post_lucid ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .post_lucid) ; fi
    done
}

cp_post_precise ()
{
    for i in *.post_precise ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .post_precise) ; fi
    done
}

cp_post_trusty ()
{
    for i in *.post_trusty ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .post_trusty) ; fi
    done
}

#######################################################################
### process files for each release
#######################################################################
if [ "$RELEASE" -eq 804 ] ; then
    echo "Setup for Hardy 08.04"
    for i in *.hardy ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .hardy) ; fi
    done
    cp_pre_lucid
    cp_pre_precise
    cp_pre_trusty
    cp_pre_xenial

elif [ "$RELEASE" -eq 1004 ] ; then
    echo "Setup for Lucid 10.04"
    cp_post_hardy
    for i in *.lucid ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .lucid) ; fi
    done
    cp_pre_precise
    cp_pre_trusty
    cp_pre_xenial

elif [ "$RELEASE" -eq 1204 ] ; then
    echo "Setup for Precise 12.04"
    cp_post_hardy
    cp_post_lucid
    for i in *.precise ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .precise) ; fi
    done
    cp_pre_trusty
    cp_pre_xenial

elif [ "$RELEASE" -eq 1404 ] ; then
    echo "Setup for Trusty 14.04"
    cp_post_hardy
    cp_post_lucid
    cp_post_precise
    for i in *.trusty ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .trusty) ; fi
    done
    cp_pre_xenial

elif [ "$RELEASE" -eq 1604 ] ; then
    cp_post_hardy
    cp_post_lucid
    cp_post_precise
    cp_post_trusty
    echo "Setup for Xenial 16.04"
    for i in *.xenial ; do
        if [ -f $i ] ; then cp -v -p $i $(basename $i .xenial) ; fi
    done

else
    echo "ERROR: unknown Ubuntu LTS release number '$RELEASE'"
    exit 1
fi

관련 정보