--- /usr/bin/pacman-optimize	2005-10-03 21:44:05.000000000 -0700
+++ /usr/bin/pacman-optimize.old	2005-10-03 15:50:44.000000000 -0700
@@ -77,7 +77,8 @@
 
 # step 1: sum the old db
 echo "==> md5sum'ing the old database..."
-find $dbroot -type f | sort | xargs md5sum > /tmp/pacsums.old
+tar --same-order -c $dbroot 2>/dev/null | md5sum >/root/pacsums.old
+
 # step 1: copy the entire db directory to a new one
 echo "==> copying $dbroot..."
 cp -a $dbroot $dbroot.new || die_r "error copying $dbroot"
@@ -86,8 +87,7 @@
 echo "==> md5sum'ing the new database..."
 mv $dbroot $dbroot.bak || die_r "error renaming $dbroot"
 mv $dbroot.new $dbroot || die_r "error renaming $dbroot.new"
-
-find $dbroot -type f | sort | xargs md5sum > /tmp/pacsums.new
+tar --same-order -c $dbroot 2>/dev/null | md5sum >/root/pacsums.new
 
 # step 3: compare sums
 echo "==> checking integrity..."
