CC'ed again with patch :)
diff --git a/debian/changelog b/debian/changelog
index 83a327d..bdf6915 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,13 @@ libmtp (0.3.7-8) unstable; urgency=low
 
   [ Savvas Radevic ]
 
-  * debian/libmtp.postinst.in: Remove broken symlink 
-    /etc/udev/rules.d/libmtp.rules (Closes: #531538)
+  * Check if libmtp5 and libmtp6 (<< 0.2.1-2) are installed. If not, remove
+    /etc/udev/libmtp.rules (Closes: #531538)
+  * debian/libmtp.postinst.in: Remove dangling symlink 
+    /etc/udev/rules.d/libmtp.rules
+  * libmtp-common: Unversioned /lib/udev/rules.d/45-libmtp.rules and 
+    /usr/share/hal/fdi/information/20thirdparty/20-libmtp.fdi
+  * Remove old conffile /lib/udev/rules.d/45-libmtp8.rules
 
  -- Rafael Laboissiere <[email protected]>  Fri, 08 May 2009 07:22:24 +0200
 
diff --git a/debian/control.in b/debian/control.in
index 0ee011d..55b580e 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -71,3 +71,17 @@ Description: Media Transfer Protocol (MTP) library tools
  USB digital audio players and movie files on USB portable media players.
  .
  This package contains tools for communicating with MTP devices.
+
+Package: libmtp-common
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Media Transfer Protocol (MTP) library common files
+ libmtp is a library for communicating with MTP aware devices in POSIX
+ compliant operating systems.  It implements MTP Basic, the subset
+ proposed for standardization.
+ .
+ The Media Transfer Protocol (commonly referred to as MTP) is a devised
+ set of custom extensions to support the transfer of music files on
+ USB digital audio players and movie files on USB portable media players.
+ .
+ This package contains the rules and the hal fdi files.
diff --git a/debian/libmtp.install.in b/debian/libmtp.install.in
index a956186..093956b 100644
--- a/debian/libmtp.install.in
+++ b/debian/libmtp.install.in
@@ -1,3 +1 @@
 usr/lib/*.so.*
-../../20-lib...@[email protected] usr/share/hal/fdi/information/20thirdparty
-../../45-lib...@[email protected] lib/udev/rules.d
diff --git a/debian/libmtp.postinst.in b/debian/libmtp.postinst.in
index e7e57a9..7609580 100644
--- a/debian/libmtp.postinst.in
+++ b/debian/libmtp.postinst.in
@@ -24,7 +24,7 @@ configure)
         rm -f $oldlink
     fi
 
-    # Remove broken link, libmtp5 leftover (bug #531538)
+    # Remove broken link, libmtp5 and early libmtp6 leftover (bug #531538)
     oldlink2=/etc/udev/rules.d/libmtp.rules
     if [ -L $oldlink2 -a ! -f $oldlink2 ] ; then
         rm -f $oldlink2
diff --git a/debian/libmtp.preinst.in b/debian/libmtp.preinst.in
index 252a63c..f675b5a 100644
--- a/debian/libmtp.preinst.in
+++ b/debian/libmtp.preinst.in
@@ -4,6 +4,7 @@
 set -e
 
 package=lib...@soversion@
+PACKAGECOMMON="libmtp-common"
 
 # Remove a no-longer used conffile
 # Taken from http://wiki.debian.org/DpkgConffileHandling
@@ -43,6 +44,7 @@ install|upgrade)
     if dpkg --compare-versions "$2" le 0.3.7-3 ; then
 	rm -f /etc/udev/rules.d/$PACKAGE.rules
 	prep_mv_conffile $PACKAGE /etc/udev/$PACKAGE.rules
+    # Basically rm_conffile without marking it obsolete (I think)
     if [ -e "/etc/udev/rules.d/45-libmtp8.rules" ]; then
 		if [ "`md5sum \"/etc/udev/rules.d/45-libmtp8.rules\" | sed -e \"s/ .*//\"`" = \
 		     "`dpkg-query -W -f='${Conffiles}' $PACKAGE | sed -n -e \"\\\\' /etc/udev/rules.d/45-libmtp8.rules's/.* //p\"`" ]
@@ -50,10 +52,36 @@ install|upgrade)
 			rm -f "/etc/udev/rules.d/45-libmtp8.rules"
 		fi
 	fi
-        rm -f /etc/udev/libmtp.rules
         rm -f /etc/udev/$PACKAGE.rules
     fi
 
+    # Don't compare-versions, useful for later package versions too
+    if [ -e "/etc/udev/libmtp.rules" ]; then
+        # Check if libmtp5 or early libmtp6 (<< 0.2.1-2) are installed (and not purged)
+        removeit="1"
+        listpkgs="`dpkg-query -W -f '${Package} ${Version}\n' 'libmtp*' | grep '^libmtp[0-9]\+\s'`"
+        # Separate by new line
+        IFS=$(printf "\n")
+        for ipkg in $listpkgs; do
+            name="`echo $ipkg | cut -d' ' -f1`"
+            version="`echo $ipkg | cut -d' ' -f2`"
+            if [ "$name" = "libmtp5" -a ! "$version" = "" ]; then
+                removeit="0"
+            fi
+            if [ "$name" = "libmtp6" -a ! "$version" = ""]; then
+                if dpkg --compare-versions "$version" lt-nl "0.2.1-2"; then removeit="0"; fi
+            fi
+        done
+        unset IFS
+        # If not installed, remove the old libmtp.rules
+        [ "$removeit" = "1" ] && rm -f /etc/udev/libmtp.rules
+        # Its symlink, /etc/udev/rules.d/libmtp.rules, is checked in postinst
+    fi
+
+    # Remove /lib/udev/rules.d/libmtp8.rules since it represents the default package
+    # Will be replaced by unversioned /lib/udev/rules.d/45-libmtp.rules
+    rm_conffile $PACKAGE /lib/udev/rules.d/45-libmtp8.rules
+
 esac
 
 #DEBHELPER#
diff --git a/debian/rules b/debian/rules
index 5cc2613..9dba675 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,7 +11,7 @@ SUBSTFILES = debian/libmtp$(SOVERSION).docs	\
 	debian/libmtp$(SOVERSION).install	\
 	debian/libmtp$(SOVERSION).preinst	\
 	debian/libmtp$(SOVERSION).postinst
-UDEVFILES = 45-libmtp$(SOVERSION).rules 20-libmtp$(SOVERSION).fdi
+UDEVFILES = 45-libmtp.rules 20-libmtp.fdi
 
 debdir = $(CURDIR)/debian
 debver = $(shell perl -ne '/([\d.-]+)/;print "$$1"; last' \

Reply via email to