
我有大量我們維護的原始程式碼,產生許多不同的 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
。我發現控製文件中沒有條件文字的規定。我嘗試找到解決此問題的方法,但到目前為止沒有任何效果。
如何才能做到這一點?
我已經啟動並運行了一個廣泛的 buildbot 系統,可以在許多 Ubuntu 版本、CentOS 版本和一些 OS X 版本上進行編譯。分成不同版本的分支包會打破這一點。因此,我正在尋找一種適用於單一來源樹的解決方案。我試圖儘早找到一個可以在 dpkg-buildpackage 中使用的鉤子來設定每個版本的內容,但我還沒有找到解決方案。
答案1
最簡單的方法是在現場使用替代包Build-Depends
fe Build-Depends: dh-python | python-central, [...]
。這有幾個怪癖,將選擇滿足依賴項求解器的第一個依賴項。您也可以使用版本化的 Build-Depends(如果您知道某些早期版本的軟體包不完整,則可以使用),即Build-Depends: dh-python (>= <correct_version) | python-central
.
如果您需要依賴早期(或更高版本)中不存在的套件,則更複雜的方法是添加base-files (<< <version>) | real-package
為依賴項,而不是僅僅real-package
調整它<version>
以匹配下一個版本中的版本。如果您在舊系統上需要一個軟體包,但在新系統上不需要,您可以使用base-file (>= <version>) | real-package
Ubuntu<version>
版本,而您不需要real-package
.
例如,為了向後移植apache2
Ubuntu 12.04,我已更改libnghttp2-dev
為base-files (<< 7.2~) | libnghttp2-dev
.
我將新增d/rules
MySQL-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 文件,以及一個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