python - Installing dependencies of debian/control file -
i in process of porting ruby file used in our build system python. file looks depends lines in debian/control file in our repository, checks every dependency, , apt-get installs isn't installed. trying reproduce functionality.
as part of porting python, looked @ deb_pkg_tools module. pip installed , created simple script, install-dep2.py.
#!/usr/bin/python import deb_pkg_tools controldict = deb_pkg_tools.control.load_control_file('debian/control') however, when run script, following error:
$ build/bin/install-dep2.py traceback (most recent call last): file "build/bin/install-dep2.py", line 4, in <module> controldict = deb_pkg_tools.control.load_control_file('debian/control') attributeerror: 'module' object has no attribute 'control' the debian/control file exists:
$ ls -l debian/control -rw-rw-r-- 1 stephen stephen 2532 jul 13 14:28 debian/control how can process debian/control file? don't need use deb_pkg_tools if there better way.
the problem have not python thinks debian/control not exist, rather seems deb_pkg_tools.control not exist.
i use python-debian package debian parse control file if you. here code parse control file dependencies. should work packages multiple binary packages.
import deb822 paragraph in deb822.deb822.iter_paragraphs(open('debian/control')): item in paragraph.items(): if item[0] == 'depends': print item[1] each item in above example tuple pairs "key" "value", item[0] gives "key" , item[1] gives "value".
obviously above sample prints out dependencies in control file, dependencies aren't in format suitable directly plug apt-get install. also, parsing control file, got stuff ${python:depends} in addition actual package names, have consider. here example of output got above example:
joseph@crunchbang:~$ python test.py bittornado, ${python:depends}, python-psutil, python-qt4, python-qt4reactor, python-twisted, xdg-utils, ${misc:depends}, ${shlibs:depends} i found this bug report , python-debian source code quite useful resources when answering question.
Comments
Post a Comment