Packaging a software component made using python to a Maemo device could be easier, if CDBS cared about hand-held devices and their limitations.
Knowing that using setup.py was the Right Way of Doing It™ for python applications I tried to push myself into making CDBS work together, but not without a little harassment.
First of all, such scope-limited distributions tend to gather components in customized places as to promote integration between them or just in sake of a plain different organization. This difficulty can be overcome by using pycentral and including the following line at debian/rules file.
|
1 |
export DH_PYCENTRAL=nomove |
Just as the manpage says, this will prevent the build-system from moving the files from the selected install prefix to a central place (like /usr/share/pycentral).
Secondly, because of limited storage capacity and speed-up necessities, usually python components install just their .pyo files. This requirement made me struggle trough CDBS’ python-distutils.mk source code in hope for a simple fix. The answer I’ve found was to overrule the python-install target with the following commands (look here for the diff).
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
define FIXUP_DIST -find $(DEB_DESTDIR) -name '*.py' -exec rm -f {} \; -find $(DEB_DESTDIR) -name '*.pyc' -exec rm -f {} \; -find $(DEB_DESTDIR) -name '*.egg-info' -type d -exec rm -rf {} \; endef ifeq (all, $(cdbs_python_module_arch)) common-install-arch common-install-indep:: python-install-py python-install-py: cd $(DEB_SRCDIR) && $(call cdbs_python_binary,python$(cdbs_python_compile_version)) $(DEB_PYTHON_SETUP_CMD) install --root=$(DEB_DESTDIR) $(DEB_PYTHON_INSTALL_ARGS_ALL) $(call FIXUP_DIST) else common-install-arch common-install-indep:: $(addprefix python-install-, $(cdbs_python_build_versions)) python-install-%: cd $(DEB_SRCDIR) && $(call cdbs_python_binary,python$*) $(DEB_PYTHON_SETUP_CMD) install --root=$(DEB_DESTDIR) $(DEB_PYTHON_INSTALL_ARGS_ALL) $(call FIXUP_DIST) endif # archall detection |
Let’s say it’s inside a file named debian/fixup.mk, then my complete debian/rules file would be like this.
|
1 2 3 4 5 6 7 8 9 |
#!/usr/bin/make -f DEB_PYTHON_SYSTEM=pycentral include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk include debian/fixup.mk export DH_PYCENTRAL=nomove |
And this is the beauty of CDBS, a file which would be several lines long gets resumed to a few lines.
I’m still trying to find a way to make this code available for all my components without installing it to a globally reachable path, but did not find a thing such as a MAKEFILEPATH variable untill now. I guess a package like cdbs-maemo-dev.deb would be an appropriate place for stuff like this, but pushing it there is for another post.