Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

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 http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html

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.

#!/bin/sh

case "$1" in
    remove|purge)
    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
    fi
    rm /etc/apt/sources.list.d/mythbuntu-repos.list 2>/dev/null || true
    ;;
esac
share|improve this answer
    
I'm going to test it tomorrow... please wait 10 hours... :P –  espectalll123 Jun 29 '12 at 22:05
    
Tested! Thanks! :) –  espectalll123 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

 
discard

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.