You cann use gnome2.eclass. They have pkg_{preinst,postinst,postrm} which does all that.