From 47f8e2071d597e66ae9729fa7b6f5320793a7557 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Sun, 27 Jun 2010 13:52:52 +0200
Subject: [PATCH] invoke `pycentral pkgremove foo` in preinst if upgrading from
 python-central based package

---
 autoscripts/preinst-pycentral-clean | 6 ++++++
 debian/changelog                    | 8 ++++++++
 dh_python2                          | 1 +
 3 files changed, 15 insertions(+)
 create mode 100644 autoscripts/preinst-pycentral-clean

diff --git a/autoscripts/preinst-pycentral-clean b/autoscripts/preinst-pycentral-clean
new file mode 100644
index 0000000..a89a521
--- /dev/null
+++ b/autoscripts/preinst-pycentral-clean
@@ -0,0 +1,6 @@
+# make sure python-central files are removed before new package is installed
+if [ -f /var/lib/pycentral/#PACKAGE#.pkgremove ] || [ -f /var/lib/pycentral/pkgremove ]
+then
+	pycentral pkgremove #PACKAGE#
+	rm -f /var/lib/pycentral/#PACKAGE#.pkgremove
+fi
diff --git a/debian/changelog b/debian/changelog
index a05ce73..090f982 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+python-defaults (2.6.5-6) UNRELEASED; urgency=low
+
+  * dh_python2:
+    - invoke `pycentral pkgremove foo` in preinst if upgrading from
+      python-central based package
+
+ -- Piotr Ożarowski <piotr@debian.org>  Sun, 27 Jun 2010 13:20:01 +0200
+
 python-defaults (2.6.5-5) unstable; urgency=medium
 
   * Use Python's compileall module instead of pycompile to byte-compile
diff --git a/dh_python2 b/dh_python2
index 94befa9..310de4d 100755
--- a/dh_python2
+++ b/dh_python2
@@ -564,6 +564,7 @@ def main():
 
         pyclean_added = False  # invoke pyclean only once in maintainer script
         if stats['compile']:
+            dh.autoscript(package, 'preinst', 'preinst-pycentral-clean', '')
             dh.autoscript(package, 'postinst', 'postinst-pycompile', '')
             dh.autoscript(package, 'prerm', 'prerm-pyclean', '')
             pyclean_added = True
-- 
GitLab