[devscripts] 01/01: manpage-alert: refine diversion handling

Osamu Aoki osamu at moszumanska.debian.org
Sat Mar 12 06:38:21 UTC 2016


This is an automated email from the git hooks/post-receive script.

osamu pushed a commit to branch master
in repository devscripts.

commit daafa8b3b890af91706dc248c7a0d1b8a95b9de9
Author: Osamu Aoki <osamu at debian.org>
Date:   Sat Mar 12 15:29:24 2016 +0900

    manpage-alert: refine diversion handling
    
    After reading Raphael Hertzog's bug report for the dpkg at
      https://bugs.debian.org/433290#28
    I realize this needs a bit more polishing.
    
    The "dpkg-quesry -S" output with symlink (possibly generated
    by the postinst script), and diversion is complicated.
    
    I see why François had a comment as:
        fix diversions, see dpkg-query manpage.
---
 scripts/manpage-alert.sh | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/scripts/manpage-alert.sh b/scripts/manpage-alert.sh
index 70ddb48..a0c3d48 100755
--- a/scripts/manpage-alert.sh
+++ b/scripts/manpage-alert.sh
@@ -50,17 +50,28 @@ EOF
 showpackage() {
     F1="$1"
     P1="$(LANG=C dpkg-query -S "$F1" 2> /dev/null || true )"
-    P1="$(echo "$P1" | sed -e 's/diversion by \(.+\) to:/\1/')"
+    Q1=""; R1=""; Q2=""; R2=""
+    if [ -n "$P1" ]; then
+        Q1="$(echo "$P1" | grep -v "^diversion by" || true)"
+        R1="$(echo "$P1" | sed -ne 's/^diversion by \(.*\) to:.*$/\1/p'): $F1"
+    fi
     # symlink may be created by postinst script for alternatives etc.,
-    if [ -z "$P1" ] && [ -L "$F1" ]; then
+    if [ -z "$Q1" ] && [ -L "$F1" ]; then
         F2=$(readlink -f "$F1")
         P2="$(LANG=C dpkg-query -S "$F2" 2> /dev/null || true )"
-        P2="$(echo "$P2" | sed -e 's/diversion by \(.+\) to:/\1/')"
+        if [ -n "$P2" ]; then
+            Q2="$(echo "$P2" | grep -v "^diversion by" || true)"
+            R2="$(echo "$P2" | sed -ne 's/^diversion by \(.*\) to:.*$/\1/p'): $F2"
+        fi
     fi
-    if [ -n "$P1" ]; then
-        echo "$P1"
-    elif [ -n "$P2" ]; then
-        echo "unknown_package: $F1 -> $P2"
+    if [ -n "$Q1" ]; then
+        echo "$Q1"
+    elif [ -n "$R1" ]; then
+        echo "$R1 (diversion)"
+    elif [ -n "$Q2" ]; then
+        echo "unknown_package: $F1 -> $Q2"
+    elif [ -n "$R2" ]; then
+        echo "unknown_package: $F1 -> $R2 (diversion)"
     else
         echo "unknown_package: $F1"
     fi

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list