Jim*_*ght 6 python packaging deb
我有大量我们维护的源代码,生成许多不同的 Ubuntu 软件包。所有这些软件包都需要构建在Ubuntu 8.04 (Hardy Heron) 以后的 Ubuntu LTS 版本之上。(是的,我知道这些都是旧的且不受支持。这些用于受空间限制的系统,因此不可能更新到新版本。但我仍然必须维护它们上的软件,同时更新新版本。)
我正在尝试在Ubuntu 14.04 (Trusty Tahr)上启动并运行整个代码库。令我沮丧的是,我发现 Python 代码的打包已经完全改变了。从 Trusty 开始,python-support 和 python-central 已经消失,你必须使用 dh_python2。
我的问题是如何制作工作debian/control文件。构建依赖:对于Ubuntu 12.04 (Precise Pangolin) 及之前的版本,需要包含python-central,而对于 14.04 及更高版本,则必须包含dh_python2。我发现控制文件中没有条件文本的规定。我尝试找到解决此问题的方法,但到目前为止没有任何效果。
如何才能做到这一点?
我已经启动并运行了一个广泛的 buildbot 系统,可以在许多 Ubuntu 版本、CentOS 版本和一些 OS X 版本上进行编译。分成不同版本的分支包会打破这一点。因此,我正在寻找一种适用于单个源树的解决方案。我试图尽早找到一个可以在 dpkg-buildpackage 中使用的钩子来设置每个版本的内容,但我还没有找到解决方案。
最简单的方法是在现场使用替代包Build-Dependsfe 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-packageUbuntu<version>版本,而您不需要real-package.
例如,为了向后移植apache2Ubuntu 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
Run Code Online (Sandbox Code Playgroud)
并且d/control有
Build-Depends: [...], dh-systemd (>= 1.5) | base-files (<< 7.2ubuntu5~)
Run Code Online (Sandbox Code Playgroud)
这是我想出的脚本,允许代码在任何版本上构建。就我而言,我创建了一个 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
Run Code Online (Sandbox Code Playgroud)