[Rpm-maint] Patch for check-files

Archie Cobbs archie at dellroad.org
Thu Apr 11 20:13:16 UTC 2013


Hi,

Here's a little patch does a couple of things for the check-files script:

   - Eliminates the use of one of the two temporary files
   - Ensures the other temporary file gets cleaned up in all termination
   scenarios
   - Performs the difference check more efficiently

Looks like strangers aren't allowed to file bugs with patches so I'm
sending it here.

Thanks,
-Archie

-- 
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20130411/f32c3ff1/attachment.html>
-------------- next part --------------
diff -ur rpm-4.10.2.orig/scripts/check-files rpm-4.10.2/scripts/check-files
--- rpm-4.10.2.orig/scripts/check-files	2012-08-08 00:47:54.000000000 -0500
+++ rpm-4.10.2/scripts/check-files	2013-04-11 15:06:06.000000000 -0500
@@ -6,24 +6,25 @@
 #
 # filon at pld.org.pl
 
-RPM_BUILD_ROOT=$1
+# Get build root
+RPM_BUILD_ROOT="${1}"
 
-if [ ! -d "$RPM_BUILD_ROOT" ] ; then
+# Handle the case where ${RPM_BUILD_ROOT} is undefined, not a directory, etc.
+if [ ! -d "${RPM_BUILD_ROOT}" ] ; then
 	cat > /dev/null
+	echo "Error: \`${RPM_BUILD_ROOT}' is not a directory" 1>&2
 	exit 1
 fi
 
-[ "$TMPDIR" ] || TMPDIR=/tmp
-FILES_DISK=`mktemp $TMPDIR/rpmXXXXXX`
-FILES_RPM=`mktemp $TMPDIR/rpmXXXXXX`
-
-find "$RPM_BUILD_ROOT" -type f -o -type l | LC_ALL=C sort > $FILES_DISK
-LC_ALL=C sort > $FILES_RPM
-
-diff -d "$FILES_DISK" "$FILES_RPM" | grep "^< " | cut -c3- | 
-while read f; do
-	echo $f | sed -e "s#^$RPM_BUILD_ROOT#   #g"
-done
+# Create temporary file listing files in the manifest
+[ -n "$TMPDIR" ] || TMPDIR="/tmp"
+FILES_DISK=`mktemp "${TMPDIR}/rpmXXXXXX"`
+
+# Ensure temporary file is cleaned up when we exit
+trap "rm -f \"${FILES_DISK}\"" 0 2 3 5 10 13 15
+
+# Find non-directory files in the build root and compare to the manifest.
+# TODO: regex chars in last sed(1) expression should be escaped
+find "${RPM_BUILD_ROOT}" -type f -o -type l | LC_ALL=C sort > "${FILES_DISK}"
+LC_ALL=C sort | diff -d "${FILES_DISK}" - | sed -n 's|^< '"${RPM_BUILD_ROOT}"'\(.*\)$|   \1|gp'
 
-rm -f $FILES_DISK
-rm -f $FILES_RPM


More information about the Rpm-maint mailing list