I have a Python project and I want to create two Debian packages out of this code, one for the project itself and the other for some data files.
My debian/control
looks like this:
Source: demopackage
Section: web
Priority: extra
Maintainer: myself <[email protected]>
Build-Depends: debhelper (>= 8.0.0), python (>=2.7), python-setuptools
Standards-Version: 3.9.3
Package: demopackage
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}
Description: A demo package
This is the demo package
#Package: demopackage-test
#Architecture: all
#Depends: ${misc:Depends}, ${python:Depends}
#Description: demo package unit test
# This is the demo package's unit test package :)
and debian/rules
:
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
%:
dh $@ --buildsystem=python_distutils --with=python2
When I have a single package listed in debian/control
, it gets created properly; when I uncomment the second package, I get two more or less empty packages, which is expected because debuild
doesn't know which files belong to which package.
The question is what should I change in order to create one demopackage
"python package" and one demopackage-test
containing only test/unit_test.py
(my data file for the second package) ?
Let me be more clear: the resulting demopackage
should be identical to the one created by debuild
when I only have one package listed in debian/control
(i.e. it contains the code installed in /usr/share/pyshared
, symlinks created in /usr/lib/python2.7/...
etc.) .
demopackage-test
I can handle myself, I'll just add a debian/demopackage-test.install
file, but I don't know what to do about demopackage
.
You can download the package test code here.
You've mostly got the answer- dh_install
is the simple way to specify which files go where.
If you can easily enumerate the files and/or directories that you want to go in demopackage
, then creating a debian/demopackage.install
file will take care of the problem. For many python packages, it ends up sufficient to have a line like
/usr/lib/python2.*/*-packages/whatever
However, if you need more flexibility than dh_install
can provide, you may want to use some explicit shell commands instead, or in addition to dh_install
. For example, to make everything that gets installed to debian/tmp
go in demopackage
except for the one test/unit_test.py file, you might put this stanza in debian/rules
:
override_dh_install:
dh_install
cp -a debian/tmp/* debian/demopackage/
rm debian/demopackage/usr/share/whatever/unit_test.py
You can pretty much do whatever you want to put the right files into the right places, as long as you don't pull in files from outside of the build tree, and all the tools you use along the way are accounted for by the build dependencies.