With regard to your first question:
XYZ package installs some python scripts which on execution creates .pyc
file.Now On uninstallation I want to remove all the files.What would be the
postrm script to cleanly remove package?
In general a suitable postrm script is (I believe) generated automatically by debhelper and friends. See the man page for dh_python
.
In particular, this man page says
If some modules need to be byte-compiled at install time, appropriate
postinst and prerm scripts will be generated. If already byte-compiled
modules are found, they are removed.
With regard to your second question,
Also XYZ is configured using debconf file which on package
installation prompts user to accepts EULA. How do I exit if user says
no to the EULA?
I don't know the answer offhand, but take a look at the debconf templates for some of the proprietary software included in Debian. Sun Java is an example that has (had?) a EULA which was bought up by debconf.
ADDENDUM:
Since the OP appears unconvinced, here is a verbatim copy of the prerm script for a package called python-corrmodel
. I wrote the software and also the Debian packaging. However, I didn't write the postinst and prerm scripts, and in fact had not looked at them till this moment. Notice that the prerm script calls the pyclean
utility, which is part of Python. The help says:
pyclean - removes .pyc and .pyo files
Notice also that the script says the code was generated by dh_python2
.
One final note: I recommend using dh
, which is relatively new compared to old school debhelper, but is growing rapidly in popularity. Basically, dh
by default invokes all the debhelper rules in default mode in some specific order. If you want to customize the behavior of a particular debhelper command, you can override it. Here is a description of dh overrides by Joey Hess, the author of debhelper. The big advantage is that your rules file is much less cluttered, and you can be sure all the commands are called in the right order.
Here is the prerm script.
#!/bin/sh
set -e
# Automatically added by dh_python2:
if which pyclean >/dev/null 2>&1; then
pyclean -p python-corrmodel
else
dpkg -L python-corrmodel | grep \.py$ | while read file
do
rm -f "${file}"[co] >/dev/null
done
fi
# End automatically added section
ADDENDUM 2:
Since I advertised dh
, I'll add my rules file below. This is not the complete rules file, but this line contains the main logic. This basically has debhelper
hand off the build to a setup.py
script, which then does the heavy lifting.
%:
dh $@ --with python2 --buildsystem=python_distutils --install-layout=deb