#!/bin/sh # $Id: rpm-verify-prelink,v 1.1 2008/11/19 07:36:58 friedman Exp $ # Files which have been prelinked will not have the same md5 checksum as # they had in the original rpm whence they came. The `prelink' command # provides a verification option which will print the original checksum of # the file if it was prelinked, otherwise it just returns the md5 of the # file's current contents. We can compare this value to the md5 of the # file in the rpm database to see if a file has been corrupted, taking into # account possible prelinking. verify() { md5_file=`prelink --verify --md5 "$1" | cut -f1 -d' '` md5_rpm=`rpm -qf --dump "$1" | awk '$1 == file { print $4 }' file="$1"` case $md5_file in $md5_rpm ) return 0 ;; esac echo $md5_file $md5_rpm $file return 1 } main() { case $# in 0 ) while read file; do verify "$file"; done ;; * ) for file in "$@"; do verify "$file"; done ;; esac } main "$@" # eof