Hi,

The patch I sent on 4 October could not have been applied: Gmail sent it as
HTML, and the text part the BTS keeps lost every tab and leading space.
Here it is again as three attached patches with DEP-3 headers, against
1:3.2.4~rc1-3.5, one fix each and reworked after Richard Lewis's review of
my patch for #1111306. They apply in order with patch -p1, and to the
debian branch on Savannah. Linux/3 and Linux/4 are symlinks to Linux/2, not
copies as I said before, so only one file changes.

0001 drops prelink. Where it was installed the check ran "prelink -y --md5
-c", which prelink rejects, as this bug's report said in 2008 and Francois
Gouget confirmed in 2017, so nothing was checked on those systems. prelink
left Debian after buster.

0002 reports missing package files. md5sum -c now says "FILE: FAILED open
or read" for one, which nothing matched, and the .list lookup put literal
quotes around the name, so a deleted file was never reported. md5sum's
verdicts are read as "STATUS FILE", the order Benjamin S. pointed out in
2009, and only the failures reach the loop, which used to run echo and sed
for every file checked: the check takes about a second instead of ten.

0003 makes the /usr/share exclusion work. "[doc|help|...]" is a bracket
expression and matches a single character, so nothing was skipped; it is an
alternation now, plus fonts, which the 2018 change named but left out of
its list. If 0002 goes in without 0003, systems whose dpkg path-exclude
drops /usr/share/doc (Ubuntu's container images do) get those files
reported as missing.

Tested with each release's own tiger package in fresh sid, trixie,
bookworm, bullseye and Ubuntu 24.04 containers, with /usr/bin/xargs
modified, /usr/bin/sdiff deleted and a file under /usr/share/doc changed.
Before, xargs and the doc file were reported and sdiff was not; after,
xargs (lin005f) and sdiff (lin006f) are reported and the doc file is
skipped.

Andrei Trimbitas
Description: deb_checkmd5sums: drop prelink
 Where /usr/sbin/prelink was installed the check ran it as
 "prelink -y --md5 -c", but prelink takes neither md5sum's output nor -c,
 as this bug's report said in 2008 and Francois Gouget confirmed in 2017,
 so on those systems nothing was checked. The problem prelink was brought
 in for (#445531) is gone, and prelink left Debian after buster; md5sum
 -c is used everywhere now.
Author: Andrei Trimbitas <[email protected]>
Bug-Debian: https://bugs.debian.org/505906
Bug: https://savannah.nongnu.org/bugs/?52087
Forwarded: no
Last-Update: 2026-10-29
---
diff --git a/systems/Linux/2/deb_checkmd5sums b/systems/Linux/2/deb_checkmd5sums
index 15572f6..c9cad8e 100755
--- a/systems/Linux/2/deb_checkmd5sums
+++ b/systems/Linux/2/deb_checkmd5sums
@@ -116,15 +116,6 @@ echo "# Checking md5sums of installed files"
 
 haveallcmds MD5SUM CAT CUT SED GREP EGREP BASENAME || exit 1
 
-# Prelink
-PRELINK=/usr/sbin/prelink
-if [ -x "$PRELINK" ] ; then
-    MD5SUM="$PRELINK -y --md5"
-    MD5SUM_CALL="$MD5SUM"
-else
-    MD5SUM_CALL="$MD5SUM -c"
-fi
-
 DIVERSIONS="/var/lib/dpkg/diversions"
 
 if [ -d /var/lib/dpkg/info ] 
@@ -150,7 +141,7 @@ while read md5file; do
 	$GREP -v " dev/" |
 	$GREP -v " lib/udev/devices/" |
 	$SED -e "s/^\(.*\)  \(.*\)/\1  \/\2/" |
-	$MD5SUM_CALL -c 2>&1 | $SED -e "s/^.*md5sum: MD5 check failed for '\(.*\)'/DIFF \1/; s/^.*md5sum: can't open \(.*\)/ERR \1/" | {
+	$MD5SUM -c 2>&1 | $SED -e "s/^.*md5sum: MD5 check failed for '\(.*\)'/DIFF \1/; s/^.*md5sum: can't open \(.*\)/ERR \1/" | {
 		while read file err
 		do
 			package=`$BASENAME "$md5file" ".md5sums"`
Description: deb_checkmd5sums: report missing package files
 md5sum -c says "FILE: FAILED open or read" for a file that is missing.
 The check matched only older wordings, and its lookup in the package's
 .list put literal quotes around the name, so a deleted package file was
 never reported. md5sum's verdicts are now read as "STATUS FILE", the
 order Benjamin S. pointed out in 2009, which also keeps names with a
 blank in them whole, and a file is reported as missing only when it
 does not exist.
 .
 Only the failures reach the loop now; it used to run echo and sed for
 every file md5sum checked, and the check takes about a second instead
 of ten in a fresh container.
 .
 Where dpkg's path-exclude leaves files out (Ubuntu's container images
 drop most of /usr/share/doc), this patch alone reports them as missing;
 the next one skips /usr/share/doc again.
Author: Andrei Trimbitas <[email protected]>
Bug-Debian: https://bugs.debian.org/505906
Forwarded: no
Last-Update: 2026-10-29
---
diff --git a/systems/Linux/2/deb_checkmd5sums b/systems/Linux/2/deb_checkmd5sums
index c9cad8e..b27902e 100755
--- a/systems/Linux/2/deb_checkmd5sums
+++ b/systems/Linux/2/deb_checkmd5sums
@@ -141,11 +141,18 @@ while read md5file; do
 	$GREP -v " dev/" |
 	$GREP -v " lib/udev/devices/" |
 	$SED -e "s/^\(.*\)  \(.*\)/\1  \/\2/" |
-	$MD5SUM -c 2>&1 | $SED -e "s/^.*md5sum: MD5 check failed for '\(.*\)'/DIFF \1/; s/^.*md5sum: can't open \(.*\)/ERR \1/" | {
-		while read file err
+	$MD5SUM -c 2>&1 |
+	# "FILE: FAILED" is a changed file and "FILE: FAILED open or read" a
+	# missing one; older md5sums said so in the other two ways
+	$SED -n -e "s/^\(.*\): FAILED open or read$/ERR \1/p" \
+	    -e "s/^\(.*\): FAILED$/DIFF \1/p" \
+	    -e "s/^.*md5sum: MD5 check failed for '\(.*\)'/DIFF \1/p" \
+	    -e "s/^.*md5sum: can't open \(.*\)/ERR \1/p" | {
+		while IFS= read -r line
 		do
+			err=${line%% *}
+			file=${line#* }
 			package=`$BASENAME "$md5file" ".md5sums"`
-                        file=`echo $file | sed -e "s/:$//"`
 #                        echo "DEBUG: Checking file $file of $package ($err)" >&2
 			case $err in
 			DIFF|FAILED)
@@ -160,7 +167,7 @@ while read md5file; do
 				;;
 			ERR)
 # Check if this package 
- 				if $GREP -sqxF \"$file\" /var/lib/dpkg/info/$package.list ; then
+				if [ ! -e "$file" ] && $GREP -sqxF "$file" /var/lib/dpkg/info/$package.list ; then
 
 					message FAIL lin006f "" "Cannot check file \"$file\" provided by \"$package\" since it does not exist"
 				fi
Description: deb_checkmd5sums: skip the /usr/share directories it means to
 "usr/share/[doc|help|man|...]/" is a bracket expression, which matches
 a single character, so no directory was skipped and documentation, man
 pages and locales were all hashed. The 2018 change that listed them
 used braces, and a fix the same day turned them into brackets; an
 alternation is what both meant. fonts, which that change's description
 named but its list left out, is added.
Author: Andrei Trimbitas <[email protected]>
Bug-Debian: https://bugs.debian.org/505906
Forwarded: no
Last-Update: 2026-10-29
---
diff --git a/systems/Linux/2/deb_checkmd5sums b/systems/Linux/2/deb_checkmd5sums
index b27902e..220ea40 100755
--- a/systems/Linux/2/deb_checkmd5sums
+++ b/systems/Linux/2/deb_checkmd5sums
@@ -137,7 +137,7 @@ while read md5file; do
 # { ls -d /usr/share/* |while read dir; do [ -d "$dir" ] && { echo -n "$dir:" ; find "$dir" -type f  | wc -l  ; } ; done ; } | awk -F : '{print $2" "$1;}' | sort -n |less
 #
 	$CAT "$md5file" |
-	$EGREP -v "usr/share/[doc|help|man|icons|pixmaps|i18n|locale|mime|games]/" |
+	$EGREP -v "usr/share/(doc|help|man|icons|pixmaps|fonts|i18n|locale|mime|games)/" |
 	$GREP -v " dev/" |
 	$GREP -v " lib/udev/devices/" |
 	$SED -e "s/^\(.*\)  \(.*\)/\1  \/\2/" |

Reply via email to