python script to .deb ubuntu package to install a daemon
Asked Answered
S

2

5

I have a python script which runs a daemon-like service, now I created the python package. I created a .deb package from there but I want the script to be run with upstart, but I can't mange to write the files in the /etc/init ubuntu folder automatically when .deb package is installed so that my daemon doesn't have to be started manually on reboot. I don't know if I explained this well, but I don't know how to explain it better...

what I have: python_script.py ->runs a python-daemon

python_script.tar.gz -> python package

what I need:

python.deb -> which install the python script and sets up the upstart for my python scrip so that it runs as a service/daemon

Simonasimonds answered 27/6, 2013 at 12:5 Comment(0)
N
6

You should look for the debian packaging doc for python, other that can be useful is the stdeb tool, a Python to Debian source package conversion utility.

For running it as a daemon you need to create a init.d script (you can see how to here, and here a more complete example), you can add the init.d script in the package and then call "update-rc.d myscript defaults" from the postinst script of the python.deb and call "update-rc.d -f myscript remove" from the prerm script.

Needlework answered 27/6, 2013 at 12:43 Comment(4)
well I know hoe to create the package, my problem is that normally packages don't istall stuff in upstart, my problem is "how to create a custom install to set a python script as an upstarted daemon"...Simonasimonds
nice! we are getting closer! in which part of the script should I move the init.d file in the package to etc/init.d? How? How should I edit the postinst script to run "update-rc.d myscript defaults"? How should I compile the package with a custom postinst? as long as dpkg-buildpackage -us -uc overwrites the postinst??Simonasimonds
I can change the .deb manually even if it gives md5 checksum error... but anyhow the real problem is that when I try to move the file from the package bash doesn't find the file! I tried to find the working directory with $PWD and DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" but nothing !!Simonasimonds
I almost got there with the files and everything, the only problem is that when I change manually the deb package the installer shows this warning : Error bad quality package. how can compile my custom deb without running in this troubleSimonasimonds
E
3

If you are using Ubuntu standard way to create deb package all you need to do is to place package-name.upstart in debian folder.

dh_installinit is a debhelper program that is responsible for installing upstart job files or init scripts with associated defaults files into package build directories, and in the former case providing compatibility handling for non-upstart systems.

See dh_installinit.

I find building a Debian package from Bazaar branch to be the easiest way to create deb package.

See Packaging New Software as well.

I used such approach to create Gearman Job Server set of packages. Placing gearman-job-server.upstart was sufficient.

Expansion answered 28/6, 2013 at 21:26 Comment(1)
I managed to change all the files I needed to setup the init and everything by hand, but now even if I rebuilt the md5checksum file using the command sudo find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums I get this warning when installing the package 'shack': The package is of bad quality; Lintian check results for /../dist/deb_dist/shack-0.1.1-new.deb: E: python-shack: control-file-has-bad-permissions md5sums 0664 != 0644 E: python-shack: wrong-file-owner-uid-or-gid debian/ 1000/1000Simonasimonds

© 2022 - 2024 — McMap. All rights reserved.