web-dev-qa-db-ja.com

Ubuntuリリースに基づいて異なるdebian / controlファイルを作成する方法は?

私が管理している多くのソースコードがあり、多くの異なるUbuntuパッケージを作成しています。これらのパッケージはすべて、08.04以降のUbuntu LTSリリースでビルドする必要があります。 (はい、これらは古く、サポートされていないことを知っています。これらはスペースに制限されたシステム用であるため、新しいリリースに更新することはできません。 Trustyでコードベース全体を起動して実行します。 Pythonコードのパッケージが完全に変更されたことにがっかりしました。 Trustyの時点で、python-supportとpython-centralはなくなり、 dh_python2は使用する必要があります です。

私の問題は、動作するdebian/controlファイルを作成する方法です。 Build-Depends:12.04以前のバージョンではpython-centralを含める必要がありますが、14.04以降ではdh_python2を含める必要があります。制御ファイルに条件付きテキストの条項がありません。私はこれを回避する方法を見つけようとしましたが、今のところ何も機能しません。

これをどのように行うことができますか?

編集:

私は、多数のUbuntuバージョン、CentOSバージョン、およびいくつかのOSXバージョンでコンパイルする、広範なビルドボットシステムを稼働しています。異なるバージョンの分岐パッケージに分割すると、それが壊れます。そこで、単一のソースツリーで機能するソリューションを探しています。バージョンごとに設定するためにdpkg-buildpackageで使用できるフックを早期に見つけようとしていますが、まだ解決策が見つかりません。

3
Jim Wright

最も簡単な方法は、Build-Dependsフィールドで代替パッケージを使用することです。 Build-Depends: dh-python | python-central, [...]。これにはいくつかの癖があり、依存関係ソルバーを満たす最初の依存関係が選択されます。バージョン管理されたBuild-Dependsを使用することもできます(たとえば、以前のバージョンのパッケージが不完全であることがわかっている場合)。つまり、Build-Depends: dh-python (>= <correct_version) | python-centralです。

以前の(またはそれ以降のリリース)に存在しないパッケージに依存する必要がある場合のより複雑な方法は、real-packageの代わりにbase-files (<< <version>) | real-packageを依存関係として追加し、<version>を調整することです。次のリリースのバージョンと一致させるため。新しいシステムではなく、古いシステムでパッケージが必要な場合は、base-file (>= <version>) | real-packageを使用し、<version>を必要としないUbuntuリリースのreal-packageを使用します。

たとえば、Ubuntu 12.04のApache2をバックポートする場合、libnghttp2-devbase-files (<< 7.2~) | libnghttp2-devに変更しました。

MySQL-5.6バックポートからd/rulesスニペットを追加します。

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
oerdnj

これは、どのリリースでもコードをビルドできるようにするために考案したスクリプトです。私の場合、control.pre_trustyとcontrol.post_preciseファイル、rules.pre_trustyとrules.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
0
Jim Wright