Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I'm trying to package my Python app, Virtuam. My question is simple: how can I set the commands which run when I remove the program using apt-get?

share|improve this question
up vote 2 down vote accepted

You will need to use maintainer scripts to do things during the removal of your app (specifically prerm and postrm).

You may want to take a look at Debian packaging policy

Below is an example prerm script that I had previously used when removing the mythbuntu-repos package, in order to remove the added repository and key information as well.


case "$1" in
    if [ -x /usr/bin/apt-key ]; then
        /usr/bin/apt-key del EEED06D0 2>/dev/null || true
        /usr/bin/apt-key del 1504888C 2>/dev/null || true
    rm /etc/apt/sources.list.d/mythbuntu-repos.list 2>/dev/null || true
share|improve this answer
I'm going to test it tomorrow... please wait 10 hours... :P – espectalll Jun 29 '12 at 22:05
Tested! Thanks! :) – espectalll Jun 30 '12 at 10:33
Note that maintainer scripts are not allowed for applications submitted through the Ubuntu App Developer process – David Planella Jul 8 '12 at 7:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.