#!/bin/sh # $Summary: Print change logs for package files or installed packages$ # $Version: 1.2 (2003-08-11)$ # For speed purposes, we don't verify signatures or checksums NOSIG="--nodigest --nosignature" # Command to make queries QUERY=rpmquery # Command to list versions of the same package starting from the # most recently installed and going backwards QLAST="$QUERY --last" # Command to obtain the changelog QLOG="$QUERY --changelog" # How many lines to retrieve at most LEN="-180" # Iterate over all the command line arguments (for f in $*; do # Does the name correspond to an existing file? if [ ! -e "$f" ] ; then # It doesn't exist, so we just look up installed packages # Get the list of packages installed with this name. If none is # installed, we replace the error text "package X is not installed" # with an empty string n=`$QLAST $f|sed 's/^package.*installed$//'|cut -f1 -d" "` # Check if there's a list of packages or an empty string for this name if [ "x$n" != "x" ]; then # There is a string: output it preceded by "***" echo \*\*\* $n # Get only the first item in the list; get its changelog $QLOG ${n/ */} 2>/dev/null|head $LEN 2>/dev/null else # Output an error message echo \*\*\* package $f is not installed # We continue rather than stop at the first error fi else # This is a file name. Skip it if it doesn't terminate with rpm if [ "${f:$((-3))}" == 'rpm' ] ; then # Obtain package name, without epoch, version, release or architecture n=`$QUERY $NOSIG -p $f --qf %{NAME} 2>/dev/null` # Obtain package name with version and release v=`$QUERY $NOSIG -p $f --qf %{NAME}-%{VERSION}-%{RELEASE} 2>/dev/null` # Get the list of packages installed with this name. If none is # installed, we replace the error text "package X is not installed" # with an empty string n=`$QLAST $n|sed 's/^package.*installed$//'|cut -f1 -d" "` # Check if there's a list of packages or an empty string for this name if [ "x$n" != "x" ]; then # There is a list: print it after the file's package name and version echo \*\*\* $v '<' $n else # An empty string, meaning that no version of this package is # currently installed. Just print the file's package name and version echo \*\*\* $v fi # Get the RPM file's changelog; truncate it if necessary $QLOG -p $NOSIG $f 2>/dev/null|head $LEN 2>/dev/null| sed 's/^(none)$//' # Output an empty line echo fi fi # We pipe all of the above's output to less, telling it to look (and # thus highlight) for lines beginning with three asterisks. done) | less '-p^\*\*\*.*' 2>/dev/null